本文整理汇总了Java中org.eclipse.jdt.core.dom.BodyDeclaration.accept方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.accept方法的具体用法?Java BodyDeclaration.accept怎么用?Java BodyDeclaration.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.BodyDeclaration
的用法示例。
在下文中一共展示了BodyDeclaration.accept方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static ITypeBinding[] perform(BodyDeclaration enclosingNode, Selection selection) {
ExceptionAnalyzer analyzer = new ExceptionAnalyzer(selection);
enclosingNode.accept(analyzer);
List<ITypeBinding> exceptions = analyzer.getCurrentExceptions();
if (enclosingNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
List<Type> thrownExceptions = ((MethodDeclaration) enclosingNode).thrownExceptionTypes();
for (Iterator<Type> thrown = thrownExceptions.iterator(); thrown.hasNext(); ) {
ITypeBinding thrownException = thrown.next().resolveBinding();
if (thrownException != null) {
for (Iterator<ITypeBinding> excep = exceptions.iterator(); excep.hasNext(); ) {
ITypeBinding exception = excep.next();
if (exception.isAssignmentCompatible(thrownException)) excep.remove();
}
}
}
}
Collections.sort(exceptions, new ExceptionComparator());
return exceptions.toArray(new ITypeBinding[exceptions.size()]);
}
示例2: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static RefactoringStatus perform(BodyDeclaration declaration, Selection selection) {
LocalTypeAnalyzer analyzer = new LocalTypeAnalyzer(selection);
declaration.accept(analyzer);
RefactoringStatus result = new RefactoringStatus();
analyzer.check(result);
return result;
}
示例3: addLocalDeclarations
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
private boolean addLocalDeclarations(
ASTNode node, int offset, int flags, IBindingRequestor requestor) {
if (hasFlag(VARIABLES, flags) || hasFlag(TYPES, flags)) {
BodyDeclaration declaration = ASTResolving.findParentBodyDeclaration(node);
if (declaration instanceof MethodDeclaration
|| declaration instanceof Initializer
|| declaration instanceof FieldDeclaration) {
ScopeAnalyzerVisitor visitor = new ScopeAnalyzerVisitor(offset, flags, requestor);
declaration.accept(visitor);
return visitor.fBreak;
}
}
return false;
}
示例4: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static RefactoringStatus perform(BodyDeclaration declaration, Selection selection) {
LocalTypeAnalyzer analyzer = new LocalTypeAnalyzer(selection);
declaration.accept(analyzer);
RefactoringStatus result = new RefactoringStatus();
analyzer.check(result);
return result;
}
示例5: getLocallyDeclaredNames
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
/**
* @param scope not a TypeDeclaration
* @return Set containing Strings representing simple names
*/
private Set<String> getLocallyDeclaredNames(BodyDeclaration scope) {
Assert.isTrue(!(scope instanceof AbstractTypeDeclaration));
final Set<String> result = new HashSet<String>();
if (scope instanceof FieldDeclaration) return result;
scope.accept(
new HierarchicalASTVisitor() {
@Override
public boolean visit(AbstractTypeDeclaration node) {
Assert.isTrue(node.getParent() instanceof TypeDeclarationStatement);
result.add(node.getName().getIdentifier());
return false;
}
@Override
public boolean visit(AnonymousClassDeclaration anonDecl) {
return false;
}
@Override
public boolean visit(VariableDeclaration varDecl) {
result.add(varDecl.getName().getIdentifier());
return false;
}
});
return result;
}
示例6: doPerform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
private static int doPerform(BodyDeclaration node) {
LocalVariableIndex counter = new LocalVariableIndex();
node.accept(counter);
return counter.fTopIndex;
}
示例7: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static Scope perform(BodyDeclaration node, IBinding ignore) {
CodeScopeBuilder collector = new CodeScopeBuilder(node, ignore);
node.accept(collector);
return collector.fScope;
}
示例8: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public FlowInfo perform(BodyDeclaration node) {
Assert.isTrue(!(node instanceof AbstractTypeDeclaration));
node.accept(this);
return getFlowInfo(node);
}
示例9: addMissingReturnTypeProposals
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static void addMissingReturnTypeProposals(IInvocationContext context, IProblemLocation problem, Collection<CUCorrectionProposal> proposals) {
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
ASTNode selectedNode= problem.getCoveringNode(astRoot);
if (selectedNode == null) {
return;
}
BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode);
if (decl instanceof MethodDeclaration) {
MethodDeclaration methodDeclaration= (MethodDeclaration) decl;
ReturnStatementCollector eval= new ReturnStatementCollector();
decl.accept(eval);
AST ast= astRoot.getAST();
ITypeBinding typeBinding= eval.getTypeBinding(decl.getAST());
typeBinding= Bindings.normalizeTypeBinding(typeBinding);
if (typeBinding == null) {
typeBinding= ast.resolveWellKnownType("void"); //$NON-NLS-1$
}
if (typeBinding.isWildcardType()) {
typeBinding= ASTResolving.normalizeWildcardType(typeBinding, true, ast);
}
ASTRewrite rewrite= ASTRewrite.create(ast);
String label= Messages.format(CorrectionMessages.ReturnTypeSubProcessor_missingreturntype_description, BindingLabelProvider.getBindingLabel(typeBinding, BindingLabelProvider.DEFAULT_TEXTFLAGS));
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, IProposalRelevance.MISSING_RETURN_TYPE);
ImportRewrite imports= proposal.createImportRewrite(astRoot);
ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(decl, imports);
Type type= imports.addImport(typeBinding, ast, importRewriteContext, TypeLocation.RETURN_TYPE);
rewrite.set(methodDeclaration, MethodDeclaration.RETURN_TYPE2_PROPERTY, type, null);
rewrite.set(methodDeclaration, MethodDeclaration.CONSTRUCTOR_PROPERTY, Boolean.FALSE, null);
Javadoc javadoc= methodDeclaration.getJavadoc();
if (javadoc != null && typeBinding != null) {
TagElement newTag= ast.newTagElement();
newTag.setTagName(TagElement.TAG_RETURN);
TextElement commentStart= ast.newTextElement();
newTag.fragments().add(commentStart);
JavadocTagsSubProcessor.insertTag(rewrite.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY), newTag, null);
proposal.addLinkedPosition(rewrite.track(commentStart), false, "comment_start"); //$NON-NLS-1$
}
String key= "return_type"; //$NON-NLS-1$
proposal.addLinkedPosition(rewrite.track(type), true, key);
if (typeBinding != null) {
ITypeBinding[] bindings= ASTResolving.getRelaxingTypes(ast, typeBinding);
for (int i= 0; i < bindings.length; i++) {
proposal.addLinkedPositionProposal(key, bindings[i]);
}
}
proposals.add(proposal);
// change to constructor
ASTNode parentType= ASTResolving.findParentType(decl);
if (parentType instanceof AbstractTypeDeclaration) {
boolean isInterface= parentType instanceof TypeDeclaration && ((TypeDeclaration) parentType).isInterface();
if (!isInterface) {
String constructorName= ((AbstractTypeDeclaration) parentType).getName().getIdentifier();
ASTNode nameNode= methodDeclaration.getName();
label= Messages.format(CorrectionMessages.ReturnTypeSubProcessor_wrongconstructorname_description, BasicElementLabels.getJavaElementName(constructorName));
proposals.add(new ReplaceCorrectionProposal(label, cu, nameNode.getStartPosition(), nameNode.getLength(), constructorName, IProposalRelevance.CHANGE_TO_CONSTRUCTOR));
}
}
}
}
示例10: doPerform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
private static int doPerform(BodyDeclaration node) {
LocalVariableIndex counter = new LocalVariableIndex();
node.accept(counter);
return counter.fTopIndex;
}
示例11: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static Scope perform(BodyDeclaration node, IBinding ignore) {
CodeScopeBuilder collector = new CodeScopeBuilder(node, ignore);
node.accept(collector);
return collector.fScope;
}
示例12: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public FlowInfo perform(BodyDeclaration node) {
Assert.isTrue(!(node instanceof AbstractTypeDeclaration));
node.accept(this);
return getFlowInfo(node);
}
示例13: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static VariableDeclaration[] perform(BodyDeclaration parent, Selection selection) {
LocalDeclarationAnalyzer analyzer = new LocalDeclarationAnalyzer(selection);
parent.accept(analyzer);
return analyzer.fAffectedLocals.toArray(
new VariableDeclaration[analyzer.fAffectedLocals.size()]);
}