org_aspectj_tools_ajc_ASTVisitorTest_java
org.aspectj.org.eclipse.jdt.core.dom.AjASTConverter
//public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration methodDeclaration) { public ASTNode convert(boolean isInterface, org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration methodDeclaration) { checkCanceled(); if (methodDeclaration instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) { return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) methodDeclaration); } MethodDeclaration methodDecl = new MethodDeclaration(this.ast); boolean isConstructor = methodDeclaration.isConstructor(); methodDecl.setConstructor(isConstructor);  // //////////////// ajh02: added. ugh, polymorphism! Where are you! if (methodDeclaration instanceof DeclareDeclaration) { return convert((DeclareDeclaration) methodDeclaration); } else if (methodDeclaration instanceof InterTypeFieldDeclaration) { return convert((InterTypeFieldDeclaration) methodDeclaration); } else if (methodDeclaration instanceof InterTypeMethodDeclaration) { methodDecl = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration(this.ast); ((org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration) methodDecl) .setOnType(((InterTypeMethodDeclaration) methodDeclaration).getOnType().toString()); } else if (methodDeclaration instanceof InterTypeConstructorDeclaration) { methodDecl = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration(this.ast); ((org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration) methodDecl) .setOnType(((InterTypeConstructorDeclaration) methodDeclaration).getOnType().toString()); methodDecl.setConstructor(true); } else if (methodDeclaration instanceof PointcutDeclaration) { return convert((PointcutDeclaration) methodDeclaration); } else if (methodDeclaration instanceof AdviceDeclaration) { return convert((AdviceDeclaration) methodDeclaration); } // ///////////////////////  // set modifiers after checking whether we're an itd, otherwise // the modifiers are not set on the correct object. setModifiers(methodDecl, methodDeclaration); final SimpleName methodName = new SimpleName(this.ast); // AspectJ Extension - for ITD's use the declaredSelector if (methodDeclaration instanceof InterTypeDeclaration) { InterTypeDeclaration itd = (InterTypeDeclaration) methodDeclaration; methodName.internalSetIdentifier(new String(itd.getDeclaredSelector())); } else { methodName.internalSetIdentifier(new String(methodDeclaration.selector)); } // AspectJ Extension end int start = methodDeclaration.sourceStart; int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd); methodName.setSourceRange(start, end - start + 1); methodDecl.setName(methodName); org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions; int methodHeaderEnd = methodDeclaration.sourceEnd; int thrownExceptionsLength = thrownExceptions == null ? 0 : thrownExceptions.length; if (thrownExceptionsLength > 0) { Name thrownException; int i = 0; do { thrownException = convert(thrownExceptions[i++]); methodDecl.thrownExceptions().add(thrownException); } while (i < thrownExceptionsLength); methodHeaderEnd = thrownException.getStartPosition() + thrownException.getLength(); } org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = methodDeclaration.arguments; int parametersLength = parameters == null ? 0 : parameters.length; if (parametersLength > 0) { SingleVariableDeclaration parameter; int i = 0; do { parameter = convert(parameters[i++]); methodDecl.parameters().add(parameter); } while (i < parametersLength); if (thrownExceptionsLength == 0) { methodHeaderEnd = parameter.getStartPosition() + parameter.getLength(); } } org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall explicitConstructorCall = null; if (isConstructor) { if (isInterface) { // interface cannot have a constructor methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); } org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration constructorDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration) methodDeclaration; explicitConstructorCall = constructorDeclaration.constructorCall; switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : // set the return type to VOID PrimitiveType returnType = new PrimitiveType(this.ast); returnType.setPrimitiveTypeCode(PrimitiveType.VOID); returnType.setSourceRange(methodDeclaration.sourceStart, 0); methodDecl.internalSetReturnType(returnType); break; default : methodDecl.setReturnType2(null); } } else if (methodDeclaration instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) { org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration method = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) methodDeclaration; org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = method.returnType; if (typeReference != null) { Type returnType = convertType(typeReference); // get the positions of the right parenthesis int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition(end, method.bodyEnd); int extraDimensions = retrieveExtraDimension(rightParenthesisPosition, method.bodyEnd); methodDecl.setExtraDimensions(extraDimensions); setTypeForMethodDeclaration(methodDecl, returnType, extraDimensions); } else { // no return type for a method that is not a constructor methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : break; default : methodDecl.setReturnType2(null); } } } int declarationSourceStart = methodDeclaration.declarationSourceStart; int bodyEnd = methodDeclaration.bodyEnd; methodDecl.setSourceRange(declarationSourceStart, bodyEnd - declarationSourceStart + 1); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; int closingPosition = retrieveRightBraceOrSemiColonPosition(rightBraceOrSemiColonPositionStart, declarationSourceEnd); if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1);  org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = methodDeclaration.statements;  start = retrieveStartBlockPosition(methodHeaderEnd, methodDeclaration.bodyStart); if (start == -1) start = methodDeclaration.bodyStart; // use recovery position for body start end = retrieveRightBrace(methodDeclaration.bodyEnd, declarationSourceEnd); Block block = null; if (start != -1 && end != -1) { /*  * start or end can be equal to -1 if we have an interface's method.  */ block = new Block(this.ast); block.setSourceRange(start, closingPosition - start + 1); methodDecl.setBody(block); } if (block != null && (statements != null || explicitConstructorCall != null)) { if (explicitConstructorCall != null && explicitConstructorCall.accessMode != org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.ImplicitSuper) { block.statements().add(convert(explicitConstructorCall)); } int statementsLength = statements == null ? 0 : statements.length; for (int i = 0; i < statementsLength; i++) { if (statements[i] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { checkAndAddMultipleLocalDeclaration(statements, i, block.statements()); } else { final Statement statement = convert(statements[i]); if (statement != null) { block.statements().add(statement); } } } } if (block != null && (Modifier.isAbstract(methodDecl.getModifiers()) || Modifier.isNative(methodDecl.getModifiers()) || isInterface)) { methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); } } else { // syntax error in this method declaration methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract()) { start = retrieveStartBlockPosition(methodHeaderEnd, bodyEnd); if (start == -1) start = methodDeclaration.bodyStart; // use recovery position for body start end = methodDeclaration.bodyEnd; // try to get the best end position CategorizedProblem[] problems = methodDeclaration.compilationResult().problems; if (problems != null) { for (int i = 0, max = methodDeclaration.compilationResult().problemCount; i < max; i++) { CategorizedProblem currentProblem = problems[i]; if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) { end = currentProblem.getSourceEnd(); break; } } } int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, end - startPosition + 1); if (start != -1 && end != -1) { /*  * start or end can be equal to -1 if we have an interface's method.  */ Block block = new Block(this.ast); block.setSourceRange(start, end - start + 1); methodDecl.setBody(block); } } }  org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = methodDeclaration.typeParameters(); if (typeParameters != null) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); break; default : for (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter : typeParameters) { methodDecl.typeParameters().add(convert(typeParameter)); } } }  // The javadoc comment is now got from list store in compilation unit declaration convert(methodDeclaration.javadoc, methodDecl); if (this.resolveBindings) { recordNodes(methodDecl, methodDeclaration); recordNodes(methodName, methodDeclaration); methodDecl.resolveBinding(); } return methodDecl;

 -> java.util.List.add(java.lang.Object): boolean -> java.util.ArrayList.size(): int -> java.lang.Object.getClass(): java.lang.Class -> java.lang.Class.isAssignableFrom(java.lang.Class): boolean -> java.util.ArrayList.add(int,java.lang.Object): void -> java.lang.System.arraycopy(java.lang.Object,int,java.lang.Object,int,int): void -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.lang.Object.getClass(): java.lang.Class -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.util.Arrays.equals(char[],char[]): boolean -> java.lang.Object.getClass(): java.lang.Class -> java.lang.Object.getClass(): java.lang.Class -> java.lang.Class.isAssignableFrom(java.lang.Class): boolean -> java.util.List.add(java.lang.Object): boolean -> java.util.List.get(int): java.lang.Object -> java.util.List.add(java.lang.Object): boolean -> java.util.List.remove(int): java.lang.Object -> java.util.List.size(): int -> java.util.ArrayList.addAll(java.util.Collection): boolean -> java.util.Collections.unmodifiableList(java.util.List): java.util.List -> java.lang.Object.getClass(): java.lang.Class -> java.util.List.add(java.lang.Object): boolean -> java.util.ArrayList.size(): int -> java.lang.Object.getClass(): java.lang.Class -> java.lang.Class.isAssignableFrom(java.lang.Class): boolean -> java.util.ArrayList.add(int,java.lang.Object): void -> java.util.List.iterator(): java.util.Iterator -> java.util.Iterator.hasNext(): boolean -> java.util.ArrayList.size(): int -> java.util.Iterator.next(): java.lang.Object -> java.util.ArrayList.get(int): java.lang.Object -> java.util.Iterator.hasNext(): boolean -> java.util.ArrayList.size(): int -> java.util.List.iterator(): java.util.Iterator -> java.util.Iterator.hasNext(): boolean -> java.util.ArrayList.size(): int -> java.util.Iterator.next(): java.lang.Object -> java.util.ArrayList.get(int): java.lang.Object -> java.util.Iterator.hasNext(): boolean -> java.util.ArrayList.size(): int