Java Code Examples for org.eclipse.jdt.core.dom.AbstractTypeDeclaration#bodyDeclarations()
The following examples show how to use
org.eclipse.jdt.core.dom.AbstractTypeDeclaration#bodyDeclarations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalleeAnalyzerVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * @see HierarchicalASTVisitor#visit(org.eclipse.jdt.core.dom.AbstractTypeDeclaration) */ @Override public boolean visit(AbstractTypeDeclaration node) { progressMonitorWorked(1); if (!isFurtherTraversalNecessary(node)) { return false; } if (isNodeWithinMethod(node)) { List<BodyDeclaration> bodyDeclarations= node.bodyDeclarations(); for (Iterator<BodyDeclaration> iter= bodyDeclarations.iterator(); iter.hasNext(); ) { BodyDeclaration bodyDeclaration= iter.next(); if (bodyDeclaration instanceof MethodDeclaration) { MethodDeclaration child= (MethodDeclaration) bodyDeclaration; if (child.isConstructor()) { addMethodCall(child.resolveBinding(), child.getName()); } } } return false; } return true; }
Example 2
Source File: ExtractFieldRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private int computeInsertIndexForNewConstructor(AbstractTypeDeclaration declaration) { List<BodyDeclaration> declarations = declaration.bodyDeclarations(); if (declarations.isEmpty()) { return 0; } int index = findFirstMethodIndex(declaration); if (index == -1) { return declarations.size(); } else { return index; } }
Example 3
Source File: UMLModelASTReader.java From RefactoringMiner with MIT License | 5 votes |
private void processBodyDeclarations(CompilationUnit cu, AbstractTypeDeclaration abstractTypeDeclaration, String packageName, String sourceFile, List<String> importedTypes, UMLClass umlClass) { List<BodyDeclaration> bodyDeclarations = abstractTypeDeclaration.bodyDeclarations(); for(BodyDeclaration bodyDeclaration : bodyDeclarations) { if(bodyDeclaration instanceof FieldDeclaration) { FieldDeclaration fieldDeclaration = (FieldDeclaration)bodyDeclaration; List<UMLAttribute> attributes = processFieldDeclaration(cu, fieldDeclaration, umlClass.isInterface(), sourceFile); for(UMLAttribute attribute : attributes) { attribute.setClassName(umlClass.getName()); umlClass.addAttribute(attribute); } } else if(bodyDeclaration instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration)bodyDeclaration; UMLOperation operation = processMethodDeclaration(cu, methodDeclaration, packageName, umlClass.isInterface(), sourceFile); operation.setClassName(umlClass.getName()); umlClass.addOperation(operation); } else if(bodyDeclaration instanceof TypeDeclaration) { TypeDeclaration typeDeclaration = (TypeDeclaration)bodyDeclaration; processTypeDeclaration(cu, typeDeclaration, umlClass.getName(), sourceFile, importedTypes); } else if(bodyDeclaration instanceof EnumDeclaration) { EnumDeclaration enumDeclaration = (EnumDeclaration)bodyDeclaration; processEnumDeclaration(cu, enumDeclaration, umlClass.getName(), sourceFile, importedTypes); } } }
Example 4
Source File: PromoteTempToFieldRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private int computeInsertIndexForNewConstructor(AbstractTypeDeclaration declaration) { List<BodyDeclaration> declarations= declaration.bodyDeclarations(); if (declarations.isEmpty()) return 0; int index= findFirstMethodIndex(declaration); if (index == -1) return declarations.size(); else return index; }