本文整理匯總了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());
}
}