本文整理汇总了Java中org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory类的典型用法代码示例。如果您正苦于以下问题:Java ASTFragmentFactory类的具体用法?Java ASTFragmentFactory怎么用?Java ASTFragmentFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ASTFragmentFactory类属于org.eclipse.jdt.internal.corext.dom.fragments包,在下文中一共展示了ASTFragmentFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkInitializer
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private RefactoringStatus checkInitializer() {
Expression initializer = getInitializer();
if (initializer == null)
return RefactoringStatus.createStatus(
RefactoringStatus.FATAL,
RefactoringCoreMessages.InlineConstantRefactoring_blank_finals,
null,
Corext.getPluginId(),
RefactoringStatusCodes.CANNOT_INLINE_BLANK_FINAL,
null);
fInitializerAllStaticFinal =
ConstantChecks.isStaticFinalConstant(
(IExpressionFragment) ASTFragmentFactory.createFragmentForFullSubtree(initializer));
fInitializerChecked = true;
return new RefactoringStatus();
}
示例2: visit
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
@Override
public boolean visit(MethodInvocation node) {
if (node.getExpression() == null) {
visitName(node.getName());
} else {
fResult &=
new LoadTimeConstantChecker(
(IExpressionFragment)
ASTFragmentFactory.createFragmentForFullSubtree(node.getExpression()))
.check();
}
return false;
}
示例3: depends
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private static boolean depends(IExpressionFragment selected, BodyDeclaration bd) {
/* We currently consider selected to depend on bd only if db includes a declaration
* of a static field on which selected depends.
*
* A more accurate strategy might be to also check if bd contains (or is) a
* static initializer containing code which changes the value of a static field on
* which selected depends. However, if a static is written to multiple times within
* during class initialization, it is difficult to predict which value should be used.
* This would depend on which value is used by expressions instances for which the new
* constant will be substituted, and there may be many of these; in each, the
* static field in question may have taken on a different value (if some of these uses
* occur within static initializers).
*/
if (bd instanceof FieldDeclaration) {
FieldDeclaration fieldDecl = (FieldDeclaration) bd;
for (Iterator<VariableDeclarationFragment> fragments = fieldDecl.fragments().iterator();
fragments.hasNext(); ) {
VariableDeclarationFragment fragment = fragments.next();
SimpleName staticFieldName = fragment.getName();
if (selected.getSubFragmentsMatching(
ASTFragmentFactory.createFragmentForFullSubtree(staticFieldName))
.length
!= 0) return true;
}
}
return false;
}
示例4: initializeSelectedExpression
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private void initializeSelectedExpression(CompilationUnitRewrite cuRewrite) throws JavaModelException {
IASTFragment fragment= ASTFragmentFactory.createFragmentForSourceRange(
new SourceRange(fSelectionStart, fSelectionLength), cuRewrite.getRoot(), cuRewrite.getCu());
if (! (fragment instanceof IExpressionFragment))
return;
//TODO: doesn't handle selection of partial Expressions
Expression expression= ((IExpressionFragment) fragment).getAssociatedExpression();
if (fragment.getStartPosition() != expression.getStartPosition()
|| fragment.getLength() != expression.getLength())
return;
if (Checks.isInsideJavadoc(expression))
return;
//TODO: exclude invalid selections
if (Checks.isEnumCase(expression.getParent()))
return;
fSelectedExpression= expression;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:IntroduceParameterRefactoring.java
示例5: depends
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private static boolean depends(IExpressionFragment selected, BodyDeclaration bd) {
/* We currently consider selected to depend on bd only if db includes a declaration
* of a static field on which selected depends.
*
* A more accurate strategy might be to also check if bd contains (or is) a
* static initializer containing code which changes the value of a static field on
* which selected depends. However, if a static is written to multiple times within
* during class initialization, it is difficult to predict which value should be used.
* This would depend on which value is used by expressions instances for which the new
* constant will be substituted, and there may be many of these; in each, the
* static field in question may have taken on a different value (if some of these uses
* occur within static initializers).
*/
if(bd instanceof FieldDeclaration) {
FieldDeclaration fieldDecl = (FieldDeclaration) bd;
for(Iterator<VariableDeclarationFragment> fragments = fieldDecl.fragments().iterator(); fragments.hasNext();) {
VariableDeclarationFragment fragment = fragments.next();
SimpleName staticFieldName = fragment.getName();
if(selected.getSubFragmentsMatching(ASTFragmentFactory.createFragmentForFullSubtree(staticFieldName)).length != 0)
return true;
}
}
return false;
}
示例6: getMatchingFragments
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private IASTFragment[] getMatchingFragments() throws JavaModelException {
if (fReplaceAllOccurrences) {
IASTFragment[] allMatches =
ASTFragmentFactory.createFragmentForFullSubtree(getEnclosingBodyNode())
.getSubFragmentsMatching(getSelectedExpression());
return allMatches;
} else return new IASTFragment[] {getSelectedExpression()};
}
示例7: getFragmentsToReplace
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private IASTFragment[] getFragmentsToReplace() throws JavaModelException {
List<IASTFragment> toReplace = new ArrayList<IASTFragment>();
if (fReplaceAllOccurrences) {
Iterator<ASTNode> replacementScope = getReplacementScope();
while (replacementScope.hasNext()) {
ASTNode scope = replacementScope.next();
IASTFragment[] allMatches =
ASTFragmentFactory.createFragmentForFullSubtree(scope)
.getSubFragmentsMatching(getSelectedExpression());
IASTFragment[] replaceableMatches = retainOnlyReplacableMatches(allMatches);
for (int i = 0; i < replaceableMatches.length; i++) toReplace.add(replaceableMatches[i]);
}
} else if (canReplace(getSelectedExpression())) toReplace.add(getSelectedExpression());
return toReplace.toArray(new IASTFragment[toReplace.size()]);
}
示例8: getMatchingFragments
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private IASTFragment[] getMatchingFragments() throws JavaModelException {
if (fReplaceAllOccurrences) {
IASTFragment[] allMatches= ASTFragmentFactory.createFragmentForFullSubtree(getEnclosingBodyNode()).getSubFragmentsMatching(getSelectedExpression());
return allMatches;
} else
return new IASTFragment[] { getSelectedExpression()};
}
示例9: checkInitializer
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private RefactoringStatus checkInitializer() {
Expression initializer= getInitializer();
if (initializer == null)
return RefactoringStatus.createStatus(RefactoringStatus.FATAL, RefactoringCoreMessages.InlineConstantRefactoring_blank_finals, null, Corext.getPluginId(), RefactoringStatusCodes.CANNOT_INLINE_BLANK_FINAL, null);
fInitializerAllStaticFinal= ConstantChecks.isStaticFinalConstant((IExpressionFragment) ASTFragmentFactory.createFragmentForFullSubtree(initializer));
fInitializerChecked= true;
return new RefactoringStatus();
}
示例10: visit
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
@Override
public boolean visit(MethodInvocation node) {
if(node.getExpression() == null) {
visitName(node.getName());
} else {
fResult&= new LoadTimeConstantChecker((IExpressionFragment) ASTFragmentFactory.createFragmentForFullSubtree(node.getExpression())).check();
}
return false;
}
示例11: getFragmentsToReplace
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private IASTFragment[] getFragmentsToReplace() throws JavaModelException {
List<IASTFragment> toReplace = new ArrayList<IASTFragment>();
if (fReplaceAllOccurrences) {
Iterator<ASTNode> replacementScope = getReplacementScope();
while(replacementScope.hasNext()) {
ASTNode scope= replacementScope.next();
IASTFragment[] allMatches= ASTFragmentFactory.createFragmentForFullSubtree(scope).getSubFragmentsMatching(getSelectedExpression());
IASTFragment[] replaceableMatches = retainOnlyReplacableMatches(allMatches);
for(int i = 0; i < replaceableMatches.length; i++)
toReplace.add(replaceableMatches[i]);
}
} else if (canReplace(getSelectedExpression()))
toReplace.add(getSelectedExpression());
return toReplace.toArray(new IASTFragment[toReplace.size()]);
}
示例12: shouldReplaceSelectedExpressionWithTempDeclaration
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private boolean shouldReplaceSelectedExpressionWithTempDeclaration() throws JavaModelException {
IExpressionFragment selectedFragment = getSelectedExpression();
return selectedFragment.getAssociatedNode().getParent() instanceof ExpressionStatement
&& selectedFragment.matches(
ASTFragmentFactory.createFragmentForFullSubtree(selectedFragment.getAssociatedNode()));
}
示例13: shouldReplaceSelectedExpressionWithTempDeclaration
import org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory; //导入依赖的package包/类
private boolean shouldReplaceSelectedExpressionWithTempDeclaration() throws JavaModelException {
IExpressionFragment selectedFragment= getSelectedExpression();
return selectedFragment.getAssociatedNode().getParent() instanceof ExpressionStatement
&& selectedFragment.matches(ASTFragmentFactory.createFragmentForFullSubtree(selectedFragment.getAssociatedNode()));
}