当前位置: 首页>>代码示例>>Java>>正文


Java ASTFragmentFactory类代码示例

本文整理汇总了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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:InlineConstantRefactoring.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:ConstantChecks.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:ExtractConstantRefactoring.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ExtractConstantRefactoring.java

示例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()};
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:ExtractTempRefactoring.java

示例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()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:ExtractConstantRefactoring.java

示例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()};
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:ExtractTempRefactoring.java

示例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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:InlineConstantRefactoring.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:ConstantChecks.java

示例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()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ExtractConstantRefactoring.java

示例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()));
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:ExtractTempRefactoring.java

示例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()));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:ExtractTempRefactoring.java


注:本文中的org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。