本文整理汇总了Java中org.eclipse.jdt.core.dom.TypeDeclaration.getMethods方法的典型用法代码示例。如果您正苦于以下问题:Java TypeDeclaration.getMethods方法的具体用法?Java TypeDeclaration.getMethods怎么用?Java TypeDeclaration.getMethods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.TypeDeclaration
的用法示例。
在下文中一共展示了TypeDeclaration.getMethods方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInterfaceMethodModifiers
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
private int getInterfaceMethodModifiers(ASTNode targetTypeDecl, boolean createAbstractMethod) {
// for interface and annotation members copy the modifiers from an existing member
if (targetTypeDecl instanceof TypeDeclaration) {
TypeDeclaration type= (TypeDeclaration) targetTypeDecl;
MethodDeclaration[] methodDecls= type.getMethods();
if (methodDecls.length > 0) {
if (createAbstractMethod) {
for (MethodDeclaration methodDeclaration : methodDecls) {
IMethodBinding methodBinding= methodDeclaration.resolveBinding();
if (methodBinding != null && JdtFlags.isAbstract(methodBinding)) {
return methodDeclaration.getModifiers();
}
}
}
return methodDecls[0].getModifiers() & Modifier.PUBLIC;
}
List<BodyDeclaration> bodyDecls= type.bodyDeclarations();
if (bodyDecls.size() > 0) {
return bodyDecls.get(0).getModifiers() & Modifier.PUBLIC;
}
}
return 0;
}
示例2: annotateMethods
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
/**
* @param rewrite
* @param declaration
*/
private void annotateMethods(ASTRewrite rewrite, TypeDeclaration declaration) {
MethodDeclaration[] methods = declaration.getMethods();
for (int i = 0; i < methods.length; i++) {
MethodDeclaration methodDeclaration = methods[i];
annotateMethodReturnType(rewrite, methodDeclaration);
annotateMethodParameters(rewrite, methodDeclaration);
DefaultingVisitor visitor = new DefaultingVisitor();
visitor.rewrite = rewrite;
Block body = methodDeclaration.getBody();
if (body != null) {
body.accept(visitor);
}
}
}
示例3: populateMethodDeclarations
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的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);
}
}
示例4: hasConstructor
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public static boolean hasConstructor(TypeDeclaration typeDecl, Map<ast.Type, TypeDeclaration> types,
QualifiedClassName cThis) {
boolean hasConstr = false;
if (!hasFieldInitializers(typeDecl))
hasConstr = true;
else {
for (MethodDeclaration md : typeDecl.getMethods()) {
if (md.isConstructor())
hasConstr = true;
}
}
Type superclassType = typeDecl.getSuperclassType();
if (superclassType == null)
return hasConstr;
if (superclassType.resolveBinding().getQualifiedName().equals(Utils.JAVA_LANG_OBJECT))
return hasConstr;
TypeDeclaration superTypeDecl = types.get(new QualifiedClassName(superclassType.resolveBinding(), cThis)
.getType());
if (superTypeDecl != null) {
hasConstr = hasConstr && hasConstructor(superTypeDecl, types, cThis);
}
return hasConstr;
}
示例5: mBody
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
/**
* returns all method declarations in a type, and its supertype recursively.
* call MethodDeclaration.getBody() to get the body of the method. TODO:
* actual/formal substitution
* */
public static Set<MethodDeclaration> mBody(TypeDeclaration typeDecl, TypeHierarchy hierarchy,
Map<ast.Type, TypeDeclaration> types, QualifiedClassName cThis) {
Set<MethodDeclaration> returnSet = new HashSet<MethodDeclaration>();
for (MethodDeclaration md : typeDecl.getMethods()) {
returnSet.add(md);
}
Type superclassType = typeDecl.getSuperclassType();
if (superclassType == null)
return returnSet;
if (superclassType.resolveBinding().getQualifiedName().equals(Utils.JAVA_LANG_OBJECT))
return returnSet;
TypeDeclaration superTypeDecl = types.get(new QualifiedClassName(superclassType.resolveBinding(), cThis)
.getType());
if (superTypeDecl != null) {
Set<MethodDeclaration> auxSet = mBody(superTypeDecl, hierarchy, types, cThis);
returnSet.addAll(auxSet);
// TODO: here you don't want to add OverrideMethod
// TODO: find a way to uniquely identify methods: define mtype.
}
return returnSet;
}
示例6: populateMethodDeclarations
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的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);
}
}
示例7: visitInterface
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
private boolean visitInterface(TypeDeclaration node) {
InterfaceInfo interfaceInfo = new InterfaceInfo();
interfaceInfo.name = node.getName().getFullyQualifiedName();
interfaceInfo.fullName = NameResolver.getFullName(node);
interfaceInfo.visibility = getVisibility(node);
List<Type> superInterfaceList = node.superInterfaceTypes();
for (Type superInterface : superInterfaceList)
interfaceInfo.superInterfaceTypeList.add(NameResolver.getFullName(superInterface));
if (node.getJavadoc() != null)
interfaceInfo.comment = sourceContent.substring(node.getJavadoc().getStartPosition(), node.getJavadoc().getStartPosition() + node.getJavadoc().getLength());
interfaceInfo.content = sourceContent.substring(node.getStartPosition(), node.getStartPosition() + node.getLength());
elementInfoPool.interfaceInfoMap.put(interfaceInfo.fullName, interfaceInfo);
MethodDeclaration[] methodDeclarations = node.getMethods();
for (MethodDeclaration methodDeclaration : methodDeclarations) {
MethodInfo methodInfo = createMethodInfo(methodDeclaration, interfaceInfo.fullName);
elementInfoPool.methodInfoMap.put(methodInfo.hashName(), methodInfo);
}
FieldDeclaration[] fieldDeclarations = node.getFields();
for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
List<FieldInfo> fieldInfos = createFieldInfos(fieldDeclaration, interfaceInfo.fullName);
for (FieldInfo fieldInfo : fieldInfos)
elementInfoPool.fieldInfoMap.put(fieldInfo.hashName(), fieldInfo);
}
return true;
}
示例8: visitClass
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
private boolean visitClass(TypeDeclaration node) {
ClassInfo classInfo = new ClassInfo();
classInfo.name = node.getName().getFullyQualifiedName();
classInfo.fullName = NameResolver.getFullName(node);
classInfo.visibility = getVisibility(node);
classInfo.isAbstract = isAbstract(node);
classInfo.isFinal = isFinal(node);
classInfo.superClassType = node.getSuperclassType() == null ? "java.lang.Object" : NameResolver.getFullName(node.getSuperclassType());
List<Type> superInterfaceList = node.superInterfaceTypes();
for (Type superInterface : superInterfaceList)
classInfo.superInterfaceTypeList.add(NameResolver.getFullName(superInterface));
if (node.getJavadoc() != null)
classInfo.comment = sourceContent.substring(node.getJavadoc().getStartPosition(), node.getJavadoc().getStartPosition() + node.getJavadoc().getLength());
classInfo.content = sourceContent.substring(node.getStartPosition(), node.getStartPosition() + node.getLength());
elementInfoPool.classInfoMap.put(classInfo.fullName, classInfo);
MethodDeclaration[] methodDeclarations = node.getMethods();
for (MethodDeclaration methodDeclaration : methodDeclarations) {
MethodInfo methodInfo = createMethodInfo(methodDeclaration, classInfo.fullName);
elementInfoPool.methodInfoMap.put(methodInfo.hashName(), methodInfo);
}
FieldDeclaration[] fieldDeclarations = node.getFields();
for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
List<FieldInfo> fieldInfos = createFieldInfos(fieldDeclaration, classInfo.fullName);
for (FieldInfo fieldInfo : fieldInfos)
elementInfoPool.fieldInfoMap.put(fieldInfo.hashName(), fieldInfo);
}
return true;
}
示例9: isTypeLooksLikeABuilder
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
private boolean isTypeLooksLikeABuilder(TypeDeclaration nestedType) {
if (nestedType.getTypes().length > 0) {
return false;
}
if (nestedType.getMethods().length < 2) {
return false;
}
if (getNumberOfEmptyPrivateConstructors(nestedType) != 1) {
return false;
}
return true;
}
示例10: newTypeParameter
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public static TypeParameter newTypeParameter(AST ast, String content) {
StringBuffer buffer= new StringBuffer(TYPEPARAM_HEADER);
buffer.append(content);
buffer.append(TYPEPARAM_FOOTER);
ASTParser p= ASTParser.newParser(ast.apiLevel());
p.setSource(buffer.toString().toCharArray());
CompilationUnit root= (CompilationUnit) p.createAST(null);
List<AbstractTypeDeclaration> list= root.types();
TypeDeclaration typeDecl= (TypeDeclaration) list.get(0);
MethodDeclaration methodDecl= typeDecl.getMethods()[0];
TypeParameter tp= (TypeParameter) methodDecl.typeParameters().get(0);
ASTNode result= ASTNode.copySubtree(ast, tp);
result.accept(new PositionClearer());
return (TypeParameter) result;
}
示例11: newType
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public static Type newType(AST ast, String content) {
StringBuffer buffer= new StringBuffer(TYPE_HEADER);
buffer.append(content);
buffer.append(TYPE_FOOTER);
ASTParser p= ASTParser.newParser(ast.apiLevel());
p.setSource(buffer.toString().toCharArray());
CompilationUnit root= (CompilationUnit) p.createAST(null);
List<AbstractTypeDeclaration> list= root.types();
TypeDeclaration typeDecl= (TypeDeclaration) list.get(0);
MethodDeclaration methodDecl= typeDecl.getMethods()[0];
ASTNode type= methodDecl.getReturnType2();
ASTNode result= ASTNode.copySubtree(ast, type);
result.accept(new PositionClearer());
return (Type)result;
}
示例12: traverseMethod
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
private void traverseMethod(TypeDeclaration declaration) throws IOException {
MethodDeclaration[] methods = declaration.getMethods();
for (int i = 0; i < methods.length; i++) {
MethodDeclaration methodDeclaration = methods[i];
traverseMethodReturn(methodDeclaration);
traverseMethodParams(methodDeclaration);
}
}
示例13: getMethodDeclaration
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
/**
* @param methodKey
* @param typeDecl
* @return formal parameters of method given as a binding key
*/
public static MethodDeclaration getMethodDeclaration(IMethodBinding mb, TypeDeclaration typeDecl) {
MethodDeclaration[] methods = typeDecl.getMethods();
for (MethodDeclaration md : methods) {
if (md.resolveBinding().getKey().equals(mb.getKey())) {
return md;
}
}
return null;
}
示例14: visitLocals
import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
private void visitLocals(TypeDeclaration declaration) {
MethodDeclaration[] methods = declaration.getMethods();
for (MethodDeclaration methodDeclaration : methods) {
methodDeclaration.accept(new HeuristicOwnedLocalsVisitor());
}
}