本文整理汇总了Java中org.eclipse.jdt.core.dom.MethodDeclaration.accept方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration.accept方法的具体用法?Java MethodDeclaration.accept怎么用?Java MethodDeclaration.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.accept方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration node) {
boolean instanceMember = !node.isConstructor() && !Modifier.isStatic(node.getModifiers());
if(((TypeDeclaration) node.getParent()).isPackageMemberTypeDeclaration()) {
AssignmentVisitor v = new AssignmentVisitor();
node.accept(v);
if(instanceMember) {
MethodInfo m = new MethodInfo(
node.getName().getIdentifier(),
VisibilityInfo.from(node),
node.getReturnType2().resolveBinding().isParameterizedType() ? Object.class.toString() : node.getReturnType2().resolveBinding().getQualifiedName(),
v.params,
v.containsFieldAssignments);
info.addMethod(m);
}
}
return false;
}
示例2: populateMethodDeclarations
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
private void populateMethodDeclarations(TypeDeclaration declaration){
TypeDeclaration[] nestedTypes = declaration.getTypes();
for (int i = 0; i < nestedTypes.length; i++) {
TypeDeclaration nestedType = nestedTypes[i];
populateMethodDeclarations(nestedType);
}
FieldDeclaration[] fields = declaration.getFields();
for (FieldDeclaration fieldDeclaration : fields) {
fieldDeclaration.accept(new HeuristicOwnedVisitor());
}
MethodDeclaration[] methods = declaration.getMethods();
for (MethodDeclaration methodDeclaration : methods) {
methodDeclaration.accept(new HeuristicOwnedVisitor());
methodDeclaration.accept(new HeuristicOwnedLocalsVisitor());
this.methodDecls.add(methodDeclaration);
}
}
示例3: countStatements
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
public int countStatements(MethodDeclaration methodDeclaration) {
counter = 0;
methodDeclaration.accept(this);
return counter;
}
示例4: parse
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static MethodBean parse(MethodDeclaration pMethodNode, Collection<InstanceVariableBean> pClassInstanceVariableBeans) {
// Instantiate the bean
MethodBean methodBean = new MethodBean();
// Set the name
methodBean.setName(pMethodNode.getName().toString());
methodBean.setParameters(pMethodNode.parameters());
methodBean.setReturnType(pMethodNode.getReturnType2());
// Set the textual content
methodBean.setTextContent(pMethodNode.toString());
if ((pMethodNode.toString().contains("static "))) {
methodBean.setStatic(true);
} else {
methodBean.setStatic(false);
}
// Get the names in the method
Collection<String> names = new HashSet<>();
pMethodNode.accept(new NameVisitor(names));
// Verify the correspondence between names and instance variables
Collection<InstanceVariableBean> usedInstanceVariableBeans = getUsedInstanceVariable(names, pClassInstanceVariableBeans);
// Set the used instance variables
methodBean.setUsedInstanceVariables(usedInstanceVariableBeans);
// Get the invocation names
Collection<String> invocations = new HashSet<>();
pMethodNode.accept(new InvocationVisitor(invocations));
// Get the invocation beans from the invocation names
Collection<MethodBean> invocationBeans = new ArrayList<>();
for (String invocation : invocations) {
invocationBeans.add(InvocationParser.parse(invocation));
}
// Set the invocations
methodBean.setMethodCalls(invocationBeans);
// Return the bean
return methodBean;
}
示例5: visitLocals
import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
private void visitLocals(TypeDeclaration declaration) {
MethodDeclaration[] methods = declaration.getMethods();
for (MethodDeclaration methodDeclaration : methods) {
methodDeclaration.accept(new HeuristicOwnedLocalsVisitor());
}
}