• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NodeFinder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.core.dom.NodeFinder的典型用法代码示例。如果您正苦于以下问题:Java NodeFinder类的具体用法?Java NodeFinder怎么用?Java NodeFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NodeFinder类属于org.eclipse.jdt.core.dom包,在下文中一共展示了NodeFinder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addEdits

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
@Override
protected void addEdits(IDocument doc, TextEdit root) throws CoreException {
	super.addEdits(doc, root);

	// build a full AST
	CompilationUnit unit = SharedASTProvider.getInstance().getAST(getCompilationUnit(), null);

	ASTNode name= NodeFinder.perform(unit, fOffset, fLength);
	if (name instanceof SimpleName) {

		SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name);
		if (names != null) {
			for (int i= 0; i < names.length; i++) {
				SimpleName curr= names[i];
				root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName));
			}
			return;
		}
	}
	root.addChild(new ReplaceEdit(fOffset, fLength, fNewName));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:RenameNodeCorrectionProposal.java


示例2: initAST

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private void initAST(IProgressMonitor pm) {
  if (fCompilationUnitNode == null) {
    fCompilationUnitNode = RefactoringASTParser.parseWithASTProvider(fCu, true, pm);
  }
  if (fAnonymousInnerClassNode == null) {
    fAnonymousInnerClassNode =
        getAnonymousInnerClass(
            NodeFinder.perform(fCompilationUnitNode, fSelectionStart, fSelectionLength));
  }
  if (fAnonymousInnerClassNode != null) {
    final AbstractTypeDeclaration declaration =
        (AbstractTypeDeclaration)
            ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class);
    if (declaration instanceof TypeDeclaration) {
      final AbstractTypeDeclaration[] nested = ((TypeDeclaration) declaration).getTypes();
      fClassNamesUsed = new HashSet<String>(nested.length);
      for (int index = 0; index < nested.length; index++)
        fClassNamesUsed.add(nested[index].getName().getIdentifier());
    } else fClassNamesUsed = Collections.emptySet();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ConvertAnonymousToNestedRefactoring.java


示例3: findConstantNameNode

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private Name findConstantNameNode() {
  ASTNode node =
      NodeFinder.perform(fSelectionCuRewrite.getRoot(), fSelectionStart, fSelectionLength);
  if (node == null) return null;
  if (node instanceof FieldAccess) node = ((FieldAccess) node).getName();
  if (!(node instanceof Name)) return null;
  Name name = (Name) node;
  IBinding binding = name.resolveBinding();
  if (!(binding instanceof IVariableBinding)) return null;
  IVariableBinding variableBinding = (IVariableBinding) binding;
  if (!variableBinding.isField() || variableBinding.isEnumConstant()) return null;
  int modifiers = binding.getModifiers();
  if (!(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers))) return null;

  return name;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:InlineConstantRefactoring.java


示例4: getTargetNode

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
/**
 * Finds and returns the <code>ASTNode</code> for the given source text selection, if it is an
 * entire constructor call or the class name portion of a constructor call or constructor
 * declaration, or null otherwise.
 *
 * @param unit The compilation unit in which the selection was made
 * @param offset The textual offset of the start of the selection
 * @param length The length of the selection in characters
 * @return ClassInstanceCreation or MethodDeclaration
 */
private ASTNode getTargetNode(ICompilationUnit unit, int offset, int length) {
  ASTNode node = ASTNodes.getNormalizedNode(NodeFinder.perform(fCU, offset, length));
  if (node.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) return node;
  if (node.getNodeType() == ASTNode.METHOD_DECLARATION
      && ((MethodDeclaration) node).isConstructor()) return node;
  // we have some sub node. Make sure its the right child of the parent
  StructuralPropertyDescriptor location = node.getLocationInParent();
  ASTNode parent = node.getParent();
  if (location == ClassInstanceCreation.TYPE_PROPERTY) {
    return parent;
  } else if (location == MethodDeclaration.NAME_PROPERTY
      && ((MethodDeclaration) parent).isConstructor()) {
    return parent;
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:IntroduceFactoryRefactoring.java


示例5: checkInitialConditions

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
  if (fVisibility < 0)
    fVisibility = (fField.getFlags() & (Flags.AccPublic | Flags.AccProtected | Flags.AccPrivate));
  RefactoringStatus result = new RefactoringStatus();
  result.merge(Checks.checkAvailability(fField));
  if (result.hasFatalError()) return result;
  fRoot =
      new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
          .parse(fField.getCompilationUnit(), true, pm);
  ISourceRange sourceRange = fField.getNameRange();
  ASTNode node = NodeFinder.perform(fRoot, sourceRange.getOffset(), sourceRange.getLength());
  if (node == null) {
    return mappingErrorFound(result, node);
  }
  fFieldDeclaration =
      (VariableDeclarationFragment) ASTNodes.getParent(node, VariableDeclarationFragment.class);
  if (fFieldDeclaration == null) {
    return mappingErrorFound(result, node);
  }
  if (fFieldDeclaration.resolveBinding() == null) {
    if (!processCompilerError(result, node))
      result.addFatalError(RefactoringCoreMessages.SelfEncapsulateField_type_not_resolveable);
    return result;
  }
  computeUsedNames();
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:SelfEncapsulateFieldRefactoring.java


示例6: addEdits

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
@Override
protected void addEdits(IDocument doc, TextEdit root) throws CoreException {
  super.addEdits(doc, root);

  // build a full AST
  CompilationUnit unit =
      SharedASTProvider.getAST(getCompilationUnit(), SharedASTProvider.WAIT_YES, null);

  ASTNode name = NodeFinder.perform(unit, fOffset, fLength);
  if (name instanceof SimpleName) {

    SimpleName[] names = LinkedNodeFinder.findByProblems(unit, (SimpleName) name);
    if (names != null) {
      for (int i = 0; i < names.length; i++) {
        SimpleName curr = names[i];
        root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName));
      }
      return;
    }
  }
  root.addChild(new ReplaceEdit(fOffset, fLength, fNewName));
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:RenameNodeCorrectionProposal.java


示例7: checkInitialConditions

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
	try {
		pm.beginTask(RefactoringCoreMessages.MoveMembersRefactoring_checking, 1);
		RefactoringStatus result= new RefactoringStatus();
		result.merge(checkDeclaringType());
		pm.worked(1);
		if (result.hasFatalError())
			return result;

		fSource= new CompilationUnitRewrite(fMembersToMove[0].getCompilationUnit());
		fSourceBinding= (ITypeBinding)((SimpleName)NodeFinder.perform(fSource.getRoot(), fMembersToMove[0].getDeclaringType().getNameRange())).resolveBinding();
		fMemberBindings= getMemberBindings();
		if (fSourceBinding == null || hasUnresolvedMemberBinding()) {
			result.addFatalError(Messages.format(
				RefactoringCoreMessages.MoveMembersRefactoring_compile_errors,
				BasicElementLabels.getFileName(fSource.getCu())));
		}
		fMemberDeclarations= getASTMembers(result);
		return result;
	} finally {
		pm.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:MoveStaticMembersProcessor.java


示例8: getASTMembers

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private BodyDeclaration[] getASTMembers(RefactoringStatus status) throws JavaModelException {
	BodyDeclaration[] result= new BodyDeclaration[fMembersToMove.length];
	for (int i= 0; i < fMembersToMove.length; i++) {
		IMember member= fMembersToMove[i];
		ASTNode node= NodeFinder.perform(fSource.getRoot(), member.getNameRange());
		result[i]= (BodyDeclaration)ASTNodes.getParent(node, BodyDeclaration.class);

		//Fix for bug 42383: exclude multiple VariableDeclarationFragments ("int a=1, b=2")
		//ReferenceAnalyzer#visit(FieldDeclaration node) depends on fragments().size() != 1 !
		if (result[i] instanceof FieldDeclaration
				&& ((FieldDeclaration) result[i]).fragments().size() != 1) {
			status.addFatalError(RefactoringCoreMessages.MoveMembersRefactoring_multi_var_fields);
			return result;
		}

	}

	//Sorting members is important for field declarations referring to previous fields.
	Arrays.sort(result, new Comparator<BodyDeclaration>() {
		public int compare(BodyDeclaration o1, BodyDeclaration o2) {
			return o1.getStartPosition() - o2.getStartPosition();
		}
	});
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:MoveStaticMembersProcessor.java


示例9: createExceptionInfoList

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private RefactoringStatus createExceptionInfoList() {
	if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
		fExceptionInfos= new ArrayList<ExceptionInfo>(0);
		try {
			ASTNode nameNode= NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
			if (nameNode == null || !(nameNode instanceof Name) || !(nameNode.getParent() instanceof MethodDeclaration))
				return null;
			MethodDeclaration methodDeclaration= (MethodDeclaration) nameNode.getParent();
			List<Type> exceptions= methodDeclaration.thrownExceptionTypes();
			List<ExceptionInfo> result= new ArrayList<ExceptionInfo>(exceptions.size());
			for (int i= 0; i < exceptions.size(); i++) {
				Type type= exceptions.get(i);
				ITypeBinding typeBinding= type.resolveBinding();
				if (typeBinding == null)
					return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
				IJavaElement element= typeBinding.getJavaElement();
				result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
			}
			fExceptionInfos= result;
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ChangeSignatureProcessor.java


示例10: getHoverRegion

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
	if (!(getEditor() instanceof JavaEditor))
		return null;

	ITypeRoot je= getEditorInputJavaElement();
	if (je == null)
		return null;

	// Never wait for an AST in UI thread.
	CompilationUnit ast= SharedASTProvider.getAST(je, SharedASTProvider.WAIT_NO, null);
	if (ast == null)
		return null;

	ASTNode node= NodeFinder.perform(ast, offset, 1);
	if (node instanceof StringLiteral) {
		StringLiteral stringLiteral= (StringLiteral)node;
		return new Region(stringLiteral.getStartPosition(), stringLiteral.getLength());
	} else if (node instanceof SimpleName) {
		SimpleName simpleName= (SimpleName)node;
		return new Region(simpleName.getStartPosition(), simpleName.getLength());
	}

	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:NLSStringHover.java


示例11: addEdits

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
@Override
protected void addEdits(IDocument doc, TextEdit root) throws CoreException {
	super.addEdits(doc, root);

	// build a full AST
	CompilationUnit unit= SharedASTProvider.getAST(getCompilationUnit(), SharedASTProvider.WAIT_YES, null);

	ASTNode name= NodeFinder.perform(unit, fOffset, fLength);
	if (name instanceof SimpleName) {

		SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name);
		if (names != null) {
			for (int i= 0; i < names.length; i++) {
				SimpleName curr= names[i];
				root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName));
			}
			return;
		}
	}
	root.addChild(new ReplaceEdit(fOffset, fLength, fNewName));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:RenameNodeCorrectionProposal.java


示例12: getTargetNode

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
/**
 * Finds and returns the <code>ASTNode</code> for the given source text
 * selection, if it is an entire constructor call or the class name portion
 * of a constructor call or constructor declaration, or null otherwise.
 * @param unit The compilation unit in which the selection was made
 * @param offset The textual offset of the start of the selection
 * @param length The length of the selection in characters
 * @return ClassInstanceCreation or MethodDeclaration
 */
private ASTNode getTargetNode(ICompilationUnit unit, int offset, int length) {
	ASTNode node= ASTNodes.getNormalizedNode(NodeFinder.perform(fCU, offset, length));
	if (node.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION)
		return node;
	if (node.getNodeType() == ASTNode.METHOD_DECLARATION && ((MethodDeclaration)node).isConstructor())
		return node;
	// we have some sub node. Make sure its the right child of the parent
	StructuralPropertyDescriptor location= node.getLocationInParent();
	ASTNode parent= node.getParent();
	if (location == ClassInstanceCreation.TYPE_PROPERTY) {
		return parent;
	} else if (location == MethodDeclaration.NAME_PROPERTY && ((MethodDeclaration)parent).isConstructor()) {
		return parent;
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:IntroduceFactoryRefactoring.java


示例13: initDomAST

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private void initDomAST() {
		if (isReadOnly())
			return;
		
		ASTParser parser= ASTParser.newParser(AST.JLS4);
		parser.setSource(getCompilationUnit());
		parser.setResolveBindings(true);
		org.eclipse.jdt.core.dom.ASTNode domAst = parser.createAST(new NullProgressMonitor());
		
//		org.eclipse.jdt.core.dom.AST ast = domAst.getAST();
		
		NodeFinder nf = new NodeFinder(domAst, getCompletionOffset(), 1);
		org.eclipse.jdt.core.dom.ASTNode cv = nf.getCoveringNode();
		
		bodyDeclaration = ASTResolving.findParentBodyDeclaration(cv);
		parentDeclaration = ASTResolving.findParentType(cv);
		domInitialized = true;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:JavaStatementPostfixContext.java


示例14: getConstantValueFromActiveEditor

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
/**
 * Returns the constant value for a field that is referenced by the currently active type.
 * This method does may not run in the main UI thread.
 * <p>
 * XXX: This method was part of the JavadocHover#getConstantValue(IField field, IRegion hoverRegion)
 * 		method (lines 299-314).
 * </p>
 * @param activeType the type that is currently active
 * @param field the field that is being referenced (usually not declared in <code>activeType</code>)
 * @param selection the region in <code>activeType</code> that contains the field reference
 * @param monitor a progress monitor
 *
 * @return the constant value for the given field or <code>null</code> if none
 * @since 3.4
 */
private static Object getConstantValueFromActiveEditor(ITypeRoot activeType, IField field, ITextSelection selection, IProgressMonitor monitor) {
	Object constantValue= null;

	CompilationUnit unit= SharedASTProvider.getAST(activeType, SharedASTProvider.WAIT_ACTIVE_ONLY, monitor);
	if (unit == null)
		return null;

	ASTNode node= NodeFinder.perform(unit, selection.getOffset(), selection.getLength());
	if (node != null && node.getNodeType() == ASTNode.SIMPLE_NAME) {
		IBinding binding= ((SimpleName)node).resolveBinding();
		if (binding != null && binding.getKind() == IBinding.VARIABLE) {
			IVariableBinding variableBinding= (IVariableBinding)binding;
			if (field.equals(variableBinding.getJavaElement())) {
				constantValue= variableBinding.getConstantValue();
			}
		}
	}
	return constantValue;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:35,代码来源:JavadocView.java


示例15: generateSetterMethod

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
/**
 * Generates a new setter method for the specified field
 * 
 * @param field the field
 * @param astRewrite the AST rewrite to use
 * @param rewrite the list rewrite to use
 * @throws CoreException if an error occurs
 * @throws OperationCanceledException if the operation has been cancelled
 */
private void generateSetterMethod(final IField field, ASTRewrite astRewrite, final ListRewrite rewrite) throws CoreException, OperationCanceledException {
	final IType type= field.getDeclaringType();
	final String name= GetterSetterUtil.getSetterName(field, null);
	final IMethod existing= JavaModelUtil.findMethod(name, new String[] { field.getTypeSignature()}, false, type);
	if (existing == null || !querySkipExistingMethods(existing)) {
		IJavaElement sibling= null;
		if (existing != null) {
			sibling= StubUtility.findNextSibling(existing);
			removeExistingAccessor(existing, rewrite);
		} else
			sibling= fInsert;
		ASTNode insertion= StubUtility2.getNodeToInsertBefore(rewrite, sibling);
		addNewAccessor(type, field, GetterSetterUtil.getSetterStub(field, name, fSettings.createComments, fVisibility | (field.getFlags() & Flags.AccStatic)), rewrite, insertion);
		if (Flags.isFinal(field.getFlags())) {
			ASTNode fieldDecl= ASTNodes.getParent(NodeFinder.perform(fASTRoot, field.getNameRange()), FieldDeclaration.class);
			if (fieldDecl != null) {
				ModifierRewrite.create(astRewrite, fieldDecl).setModifiers(0, Modifier.FINAL, null);
			}
		}

	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:AddGetterSetterOperation.java


示例16: findInHierarchyWithAST

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private int findInHierarchyWithAST(CompilationUnit astRoot, IMethod method) throws JavaModelException {
	ASTNode node= NodeFinder.perform(astRoot, method.getNameRange());
	if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration) {
		IMethodBinding binding= ((MethodDeclaration) node.getParent()).resolveBinding();
		if (binding != null) {
			IMethodBinding defining= Bindings.findOverriddenMethod(binding, true);
			if (defining != null) {
				if (JdtFlags.isAbstract(defining)) {
					return JavaElementImageDescriptor.IMPLEMENTS;
				} else {
					return JavaElementImageDescriptor.OVERRIDES;
				}
			}
			return 0;
		}
	}
	return -1;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:OverrideIndicatorLabelDecorator.java


示例17: initDomAST

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private void initDomAST() {
		if (isReadOnly())
			return;
		
		ASTParser parser= ASTParser.newParser(AST.JLS8);
		parser.setSource(getCompilationUnit());
		parser.setResolveBindings(true);
		org.eclipse.jdt.core.dom.ASTNode domAst = parser.createAST(new NullProgressMonitor());
		
//		org.eclipse.jdt.core.dom.AST ast = domAst.getAST();
		
		NodeFinder nf = new NodeFinder(domAst, getCompletionOffset(), 1);
		org.eclipse.jdt.core.dom.ASTNode cv = nf.getCoveringNode();
		
		bodyDeclaration = ASTResolving.findParentBodyDeclaration(cv);
		parentDeclaration = ASTResolving.findParentType(cv);
		domInitialized = true;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:JavaStatementPostfixContext.java


示例18: createParameterObject

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private List<ResourceChange> createParameterObject(ParameterObjectFactory pof, IPackageFragmentRoot packageRoot) throws CoreException {
	FieldUpdate fieldUpdate= new FieldUpdate();
	if (fDescriptor.isCreateTopLevel())
		return pof.createTopLevelParameterObject(packageRoot, fieldUpdate);
	else {
		CompilationUnit root= fBaseCURewrite.getRoot();
		TypeDeclaration typeDecl= (TypeDeclaration) NodeFinder.perform(root, fDescriptor.getType().getSourceRange());
		ASTRewrite rewrite= fBaseCURewrite.getASTRewrite();
		ListRewrite listRewrite= rewrite.getListRewrite(typeDecl, TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
		TypeDeclaration paramClass= pof.createClassDeclaration(typeDecl.getName().getFullyQualifiedName(), fBaseCURewrite, fieldUpdate);
		paramClass.modifiers().add(rewrite.getAST().newModifier(ModifierKeyword.PUBLIC_KEYWORD));
		paramClass.modifiers().add(rewrite.getAST().newModifier(ModifierKeyword.STATIC_KEYWORD));
		listRewrite.insertFirst(paramClass, fBaseCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractClassRefactoring_group_insert_parameter));
		return new ArrayList<ResourceChange>(); //Change will be generated later for fBaseCURewrite
	}

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:18,代码来源:ExtractClassRefactoring.java


示例19: createExceptionInfoList

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private RefactoringStatus createExceptionInfoList() {
	if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
		fExceptionInfos= new ArrayList<ExceptionInfo>(0);
		try {
			ASTNode nameNode= NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
			if (nameNode == null || !(nameNode instanceof Name) || !(nameNode.getParent() instanceof MethodDeclaration))
				return null;
			MethodDeclaration methodDeclaration= (MethodDeclaration) nameNode.getParent();
			List<Name> exceptions= methodDeclaration.thrownExceptions();
			List<ExceptionInfo> result= new ArrayList<ExceptionInfo>(exceptions.size());
			for (int i= 0; i < exceptions.size(); i++) {
				Name name= exceptions.get(i);
				ITypeBinding typeBinding= name.resolveTypeBinding();
				if (typeBinding == null)
					return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
				IJavaElement element= typeBinding.getJavaElement();
				result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
			}
			fExceptionInfos= result;
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:ChangeSignatureProcessor.java


示例20: initAST

import org.eclipse.jdt.core.dom.NodeFinder; //导入依赖的package包/类
private void initAST(IProgressMonitor pm) {
   	if (fCompilationUnitNode == null) {
   		fCompilationUnitNode= RefactoringASTParser.parseWithASTProvider(fCu, true, pm);
   	}
   	if (fAnonymousInnerClassNode == null) {
   		fAnonymousInnerClassNode= getAnonymousInnerClass(NodeFinder.perform(fCompilationUnitNode, fSelectionStart, fSelectionLength));
   	}
	if (fAnonymousInnerClassNode != null) {
		final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class);
		if (declaration instanceof TypeDeclaration) {
			final AbstractTypeDeclaration[] nested= ((TypeDeclaration) declaration).getTypes();
			fClassNamesUsed= new HashSet<String>(nested.length);
			for (int index= 0; index < nested.length; index++)
				fClassNamesUsed.add(nested[index].getName().getIdentifier());
		} else
			fClassNamesUsed= Collections.emptySet();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:ConvertAnonymousToNestedRefactoring.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FilePickerActivity类代码示例发布时间:2022-05-22
下一篇:
Java ProgramRunnerUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap