fix remaining compile error since move to AJ 1.7
diff --git a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/javaelements/AspectJMemberElementInfo.java b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/javaelements/AspectJMemberElementInfo.java
index c2c7b9e..6b33117 100755
--- a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/javaelements/AspectJMemberElementInfo.java
+++ b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/javaelements/AspectJMemberElementInfo.java
@@ -17,6 +17,7 @@
import org.aspectj.asm.IProgramElement.Kind;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.internal.core.Annotation;
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
@@ -30,6 +31,7 @@
protected Accessibility accessibility;
protected List modifiers;
protected ExtraInformation extra;
+ protected ILocalVariable[] arguments;
private char[] name;
private char[] returnType;
@@ -183,6 +185,14 @@
}
}
+ public void setArguments(ILocalVariable[] arguments) {
+ this.arguments = arguments;
+ }
+
+ public ILocalVariable[] getArguments() {
+ return arguments;
+ }
+
/* AJDT 1.7 */
protected IJavaElement[] children;
public IJavaElement[] getChildren() {
diff --git a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJCompilationUnitStructureRequestor.java b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJCompilationUnitStructureRequestor.java
index 201e195..9d57222 100644
--- a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJCompilationUnitStructureRequestor.java
+++ b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJCompilationUnitStructureRequestor.java
@@ -12,7 +12,6 @@
package org.eclipse.ajdt.core.parserbridge;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Stack;
@@ -27,17 +26,13 @@
import org.aspectj.asm.IProgramElement;
import org.aspectj.org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo;
-import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo;
-import org.eclipse.jdt.internal.compiler.ast.LongLiteral;
-import org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue;
-import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser;
import org.aspectj.weaver.patterns.DeclareAnnotation;
import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
import org.aspectj.weaver.patterns.DeclareParents;
import org.aspectj.weaver.patterns.DeclarePrecedence;
+import org.eclipse.ajdt.core.ReflectionUtils;
import org.eclipse.ajdt.core.javaelements.AJCompilationUnitInfo;
import org.eclipse.ajdt.core.javaelements.AdviceElement;
import org.eclipse.ajdt.core.javaelements.AdviceElementInfo;
@@ -52,11 +47,14 @@
import org.eclipse.ajdt.core.javaelements.IntertypeElementInfo;
import org.eclipse.ajdt.core.javaelements.PointcutElement;
import org.eclipse.ajdt.core.javaelements.PointcutElementInfo;
+import org.eclipse.ajdt.internal.core.parserbridge.CompilerASTNodeCompatibilityWrapper;
import org.eclipse.ajdt.internal.core.parserbridge.IAspectSourceElementRequestor;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -69,28 +67,31 @@
import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
import org.eclipse.jdt.internal.compiler.ast.DoubleLiteral;
import org.eclipse.jdt.internal.compiler.ast.Expression;
-import org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral;
+import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.FloatLiteral;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.ast.IntLiteral;
-import org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue;
import org.eclipse.jdt.internal.compiler.ast.JavadocArrayQualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.JavadocArraySingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.JavadocImplicitTypeReference;
import org.eclipse.jdt.internal.compiler.ast.JavadocQualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.LongLiteral;
import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation;
+import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -100,15 +101,10 @@
import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.core.JavaElementInfo;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.LocalVariable;
import org.eclipse.jdt.internal.core.NamedMember;
import org.eclipse.jdt.internal.core.PackageDeclaration;
-import org.eclipse.jdt.internal.core.SourceAnnotationMethodInfo;
-import org.eclipse.jdt.internal.core.SourceConstructorInfo;
-import org.eclipse.jdt.internal.core.SourceConstructorWithChildrenInfo;
-import org.eclipse.jdt.internal.core.SourceMethod;
import org.eclipse.jdt.internal.core.SourceMethodElementInfo;
-import org.eclipse.jdt.internal.core.SourceMethodInfo;
-import org.eclipse.jdt.internal.core.SourceMethodWithChildrenInfo;
/**
* This class can be used as a source requestor for the JDT parser *OR*
@@ -117,331 +113,330 @@
* @author Luzius Meisser
* @author Andrew Eisenberg
*/
- /* AJDT 1.7 lots of changes Do not sync with 1.6 */
public class AJCompilationUnitStructureRequestor extends
- CompilationUnitStructureRequestor implements IAspectSourceElementRequestor {
+ CompilationUnitStructureRequestor implements IAspectSourceElementRequestor {
- private static final char[] VOID = new char[]{'v', 'o','i', 'd'};
-
-
- private Stack<org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[]> typeParameterStack = new Stack<org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[]>();
+ private static final char[] VOID = new char[]{'v', 'o','i', 'd'};
+
+
+ private Stack<org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[]> typeParameterStack = new Stack<org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[]>();
public AJCompilationUnitStructureRequestor(ICompilationUnit unit, AJCompilationUnitInfo unitInfo, Map newElements) {
- super(unit, unitInfo, newElements);
- }
-
- public void setParser(Parser parser){
- CompilerOptions options = new CompilerOptions();
- ProblemReporter probrep = new ProblemReporter(null, options, null);
- org.eclipse.jdt.internal.compiler.parser.Parser otherParser =
- new org.eclipse.jdt.internal.compiler.parser.Parser(probrep, false);
- setJDTParser(otherParser);
- }
-
- private void setJDTParser(org.eclipse.jdt.internal.compiler.parser.Parser parser) {
- this.parser = parser;
- }
-
- public void setSource(char[] source) {
- this.parser.scanner.source = source;
- }
+ super(unit, unitInfo, newElements);
+ }
+
+ public void setParser(Parser parser){
+ CompilerOptions options = new CompilerOptions();
+ ProblemReporter probrep = new ProblemReporter(null, options, null);
+ org.eclipse.jdt.internal.compiler.parser.Parser otherParser =
+ new org.eclipse.jdt.internal.compiler.parser.Parser(probrep, false);
+ setJDTParser(otherParser);
+ }
+
+ private void setJDTParser(org.eclipse.jdt.internal.compiler.parser.Parser parser) {
+ this.parser = parser;
+ }
+
+ public void setSource(char[] source) {
+ this.parser.scanner.source = source;
+ }
- public void exitCompilationUnit(int declarationEnd) {
- super.exitCompilationUnit(declarationEnd);
-
- // not keeping track of annotations
- // and this ensures that itd aware content assist
- // still works when there are large numbers ofannotations
- // see bug 268620
- this.unitInfo.annotationNumber = 0;
-
- }
-
+ public void exitCompilationUnit(int declarationEnd) {
+ super.exitCompilationUnit(declarationEnd);
+
+ // not keeping track of annotations
+ // and this ensures that itd aware content assist
+ // still works when there are large numbers ofannotations
+ // see bug 268620
+ this.unitInfo.annotationNumber = 0;
+
+ }
+
- /**
- * Common processing for AJ method infos and JDT method infos
- */
- /*
+ /**
+ * Common processing for AJ method infos and JDT method infos
+ */
+ /*
* a little kludgy here. super type creates JavaElementInfo on the exitMethod
* this type creates JavaElementInfos on the enterMethod
*/
- public void enterMethod(
- int declarationStart,
- int modifiers,
- char[] returnType,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes,
- boolean isConstructor,
- boolean isAnnotation,
- org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] typeParameters,
- AbstractMethodDeclaration methodDeclaration) {
+ public void enterMethod(
+ int declarationStart,
+ int modifiers,
+ char[] returnType,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes,
+ boolean isConstructor,
+ boolean isAnnotation,
+ org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] typeParameters,
+ AbstractMethodDeclaration methodDeclaration) {
- if (methodDeclaration instanceof AdviceDeclaration){
- enterAdvice(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (AdviceDeclaration)methodDeclaration);
- return;
- }
-
- if (methodDeclaration instanceof PointcutDeclaration){
- enterPointcut(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (PointcutDeclaration)methodDeclaration);
- return;
- }
-
- if (methodDeclaration instanceof DeclareDeclaration){
- enterDeclare(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (DeclareDeclaration)methodDeclaration);
- return;
- }
-
- if (methodDeclaration instanceof InterTypeDeclaration){
- typeParameterStack.push(typeParameters);
- enterInterTypeDeclaration(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (InterTypeDeclaration)methodDeclaration);
- return;
- }
-
- org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi =
- new org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo();
- mi.declarationStart = declarationStart;
- mi.modifiers = modifiers;
- mi.name = name;
- mi.nameSourceStart = nameSourceStart;
- mi.nameSourceEnd = nameSourceEnd;
- mi.parameterNames = parameterNames;
- mi.parameterTypes = parameterTypes;
- mi.exceptionTypes = exceptionTypes;
- mi.returnType = returnType;
- mi.isConstructor = isConstructor;
- mi.isAnnotation = isAnnotation;
- mi.typeParameters = convertToJDTTypeParameters(typeParameters);
- if (methodDeclaration != null) {
- try {
- mi.annotations = convertToJDTAnnotations(methodDeclaration.annotations);
- } catch (NullPointerException e) {
- // ensure that this annotation handling code does not break existing functionality
- // catch and log the exception
- }
- }
- super.enterMethod(mi);
- }
+ if (methodDeclaration instanceof AdviceDeclaration){
+ enterAdvice(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (AdviceDeclaration)methodDeclaration);
+ return;
+ }
+
+ if (methodDeclaration instanceof PointcutDeclaration){
+ enterPointcut(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (PointcutDeclaration)methodDeclaration);
+ return;
+ }
+
+ if (methodDeclaration instanceof DeclareDeclaration){
+ enterDeclare(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (DeclareDeclaration)methodDeclaration);
+ return;
+ }
+
+ if (methodDeclaration instanceof InterTypeDeclaration){
+ typeParameterStack.push(typeParameters);
+ enterInterTypeDeclaration(declarationStart, modifiers, returnType, name, nameSourceStart, nameSourceEnd, parameterTypes, parameterNames, exceptionTypes, (InterTypeDeclaration)methodDeclaration);
+ return;
+ }
+
+ org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi =
+ new org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo();
+ mi.declarationStart = declarationStart;
+ mi.modifiers = modifiers;
+ mi.name = name;
+ mi.nameSourceStart = nameSourceStart;
+ mi.nameSourceEnd = nameSourceEnd;
+ mi.parameterNames = parameterNames;
+ mi.parameterTypes = parameterTypes;
+ mi.exceptionTypes = exceptionTypes;
+ mi.returnType = returnType;
+ mi.isConstructor = isConstructor;
+ mi.isAnnotation = isAnnotation;
+ mi.typeParameters = convertToJDTTypeParameters(typeParameters);
+ if (methodDeclaration != null) {
+ try {
+ mi.annotations = convertToJDTAnnotations(methodDeclaration.annotations);
+ } catch (NullPointerException e) {
+ // ensure that this annotation handling code does not break existing functionality
+ // catch and log the exception
+ }
+ }
+ super.enterMethod(mi);
+ }
@Override
- public void enterMethod(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi) {
- enterMethod(mi.declarationStart,
- mi.modifiers,
- mi.returnType,
- mi.name,
- mi.nameSourceStart,
- mi.nameSourceEnd,
- mi.parameterTypes,
- mi.parameterNames,
- mi.exceptionTypes,
- mi.isConstructor,
- mi.isAnnotation,
- convertToAJTypeParameters(mi.typeParameters),
- null);
- }
-
- public void enterMethod(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi) {
- enterMethod(mi.declarationStart,
- mi.modifiers,
- mi.returnType,
- mi.name,
- mi.nameSourceStart,
- mi.nameSourceEnd,
- mi.parameterTypes,
- mi.parameterNames,
- mi.exceptionTypes,
+ public void enterMethod(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi) {
+ enterMethod(mi.declarationStart,
+ mi.modifiers,
+ mi.returnType,
+ mi.name,
+ mi.nameSourceStart,
+ mi.nameSourceEnd,
+ mi.parameterTypes,
+ mi.parameterNames,
+ mi.exceptionTypes,
mi.isConstructor,
mi.isAnnotation,
- mi.typeParameters,
- null);
- }
-
- public void enterMethod(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi,AbstractMethodDeclaration mdecl) {
- enterMethod(mi.declarationStart,
- mi.modifiers,
- mi.returnType,
- mi.name,
- mi.nameSourceStart,
- mi.nameSourceEnd,
- mi.parameterTypes,
- mi.parameterNames,
- mi.exceptionTypes,
- mi.isConstructor,
- mi.isAnnotation,
- convertToAJTypeParameters(mi.typeParameters),
- mdecl);
- }
-
- public void enterMethod(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi,AbstractMethodDeclaration mdecl) {
- enterMethod(mi.declarationStart,
- mi.modifiers,
- mi.returnType,
- mi.name,
- mi.nameSourceStart,
- mi.nameSourceEnd,
- mi.parameterTypes,
- mi.parameterNames,
- mi.exceptionTypes,
+ convertToAJTypeParameters(mi.typeParameters),
+ null);
+ }
+
+ public void enterMethod(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi) {
+ enterMethod(mi.declarationStart,
+ mi.modifiers,
+ mi.returnType,
+ mi.name,
+ mi.nameSourceStart,
+ mi.nameSourceEnd,
+ mi.parameterTypes,
+ mi.parameterNames,
+ mi.exceptionTypes,
mi.isConstructor,
mi.isAnnotation,
mi.typeParameters,
- mdecl);
- }
- /* default */ static String[] convertTypeNamesToSigsCopy(char[][] typeNames) {
- if (typeNames == null)
- return CharOperation.NO_STRINGS;
- int n = typeNames.length;
- if (n == 0)
- return CharOperation.NO_STRINGS;
- String[] typeSigs = new String[n];
- for (int i = 0; i < n; ++i) {
- typeSigs[i] = Signature.createTypeSignature(typeNames[i], false);
- }
- return typeSigs;
- }
-
- public void enterAdvice(
- int declarationStart,
- int modifiers,
- char[] returnType,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes,
- AdviceDeclaration decl) {
-
- Object parentInfo = this.infoStack.peek();
- JavaElement parentHandle= (JavaElement) this.handleStack.peek();
- AdviceElement handle = null;
+ null);
+ }
+
+ public void enterMethod(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi,AbstractMethodDeclaration mdecl) {
+ enterMethod(mi.declarationStart,
+ mi.modifiers,
+ mi.returnType,
+ mi.name,
+ mi.nameSourceStart,
+ mi.nameSourceEnd,
+ mi.parameterTypes,
+ mi.parameterNames,
+ mi.exceptionTypes,
+ mi.isConstructor,
+ mi.isAnnotation,
+ convertToAJTypeParameters(mi.typeParameters),
+ mdecl);
+ }
+
+ public void enterMethod(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi,AbstractMethodDeclaration mdecl) {
+ enterMethod(mi.declarationStart,
+ mi.modifiers,
+ mi.returnType,
+ mi.name,
+ mi.nameSourceStart,
+ mi.nameSourceEnd,
+ mi.parameterTypes,
+ mi.parameterNames,
+ mi.exceptionTypes,
+ mi.isConstructor,
+ mi.isAnnotation,
+ mi.typeParameters,
+ mdecl);
+ }
+ /* default */ static String[] convertTypeNamesToSigsCopy(char[][] typeNames) {
+ if (typeNames == null)
+ return CharOperation.NO_STRINGS;
+ int n = typeNames.length;
+ if (n == 0)
+ return CharOperation.NO_STRINGS;
+ String[] typeSigs = new String[n];
+ for (int i = 0; i < n; ++i) {
+ typeSigs[i] = Signature.createTypeSignature(typeNames[i], false);
+ }
+ return typeSigs;
+ }
+
+ public void enterAdvice(
+ int declarationStart,
+ int modifiers,
+ char[] returnType,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes,
+ AdviceDeclaration decl) {
+
+ Object parentInfo = this.infoStack.peek();
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ AdviceElement handle = null;
- // translate nulls to empty arrays
- if (parameterTypes == null) {
- parameterTypes= CharOperation.NO_CHAR_CHAR;
- }
- if (parameterNames == null) {
- parameterNames= CharOperation.NO_CHAR_CHAR;
- }
- if (exceptionTypes == null) {
- exceptionTypes= CharOperation.NO_CHAR_CHAR;
- }
-
- String nameString = decl.kind.getName();
- String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
- handle = new AdviceElement(parentHandle, nameString, parameterTypeSigs);
-
- resolveDuplicates(handle);
-
- AdviceElementInfo info = new AdviceElementInfo();
- info.setAJKind(IProgramElement.Kind.ADVICE);
- IProgramElement.ExtraInformation extraInfo = new IProgramElement.ExtraInformation();
- info.setAJExtraInfo(extraInfo);
- extraInfo.setExtraAdviceInformation(decl.kind.getName());
-
- info.setSourceRangeStart(declarationStart);
- int flags = modifiers;
- info.setName(nameString.toCharArray());
- info.setNameSourceStart(nameSourceStart);
- info.setNameSourceEnd(nameSourceEnd);
- info.setFlags(flags);
- info.setArgumentNames(parameterNames);
- //info.setArgumentTypeNames(parameterTypes);
- info.setReturnType(returnType == null ? VOID : returnType);
- info.setExceptionTypeNames(exceptionTypes);
+ // translate nulls to empty arrays
+ if (parameterTypes == null) {
+ parameterTypes= CharOperation.NO_CHAR_CHAR;
+ }
+ if (parameterNames == null) {
+ parameterNames= CharOperation.NO_CHAR_CHAR;
+ }
+ if (exceptionTypes == null) {
+ exceptionTypes= CharOperation.NO_CHAR_CHAR;
+ }
+
+ String nameString = decl.kind.getName();
+ String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
+ handle = new AdviceElement(parentHandle, nameString, parameterTypeSigs);
+
+ resolveDuplicates(handle);
+
+ AdviceElementInfo info = new AdviceElementInfo();
+ info.setAJKind(IProgramElement.Kind.ADVICE);
+ IProgramElement.ExtraInformation extraInfo = new IProgramElement.ExtraInformation();
+ info.setAJExtraInfo(extraInfo);
+ extraInfo.setExtraAdviceInformation(decl.kind.getName());
+
+ info.setSourceRangeStart(declarationStart);
+ int flags = modifiers;
+ info.setName(nameString.toCharArray());
+ info.setNameSourceStart(nameSourceStart);
+ info.setNameSourceEnd(nameSourceEnd);
+ info.setFlags(flags);
+ info.setArgumentNames(parameterNames);
+ //info.setArgumentTypeNames(parameterTypes);
+ info.setReturnType(returnType == null ? VOID : returnType);
+ info.setExceptionTypeNames(exceptionTypes);
- addToChildren(parentInfo, handle);
- this.newElements.put(handle, info);
- this.infoStack.push(info);
- this.handleStack.push(handle);
- }
-
- public void enterInterTypeDeclaration(
- int declarationStart,
- int modifiers,
- char[] returnType,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes,
- InterTypeDeclaration decl) {
-
- nameSourceEnd = nameSourceStart + decl.getDeclaredSelector().length - 1;
+ addToChildren(parentInfo, handle);
+ this.newElements.put(handle, info);
+ this.infoStack.push(info);
+ this.handleStack.push(handle);
+ }
+
+ public void enterInterTypeDeclaration(
+ int declarationStart,
+ int modifiers,
+ char[] returnType,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes,
+ InterTypeDeclaration decl) {
+
+ nameSourceEnd = nameSourceStart + decl.getDeclaredSelector().length - 1;
- Object parentInfo = this.infoStack.peek();
- JavaElement parentHandle= (JavaElement) this.handleStack.peek();
- IntertypeElement handle = null;
+ Object parentInfo = this.infoStack.peek();
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ IntertypeElement handle = null;
- // translate nulls to empty arrays
- if (parameterTypes == null) {
- parameterTypes= CharOperation.NO_CHAR_CHAR;
- }
- if (parameterNames == null) {
- parameterNames= CharOperation.NO_CHAR_CHAR;
- }
- if (exceptionTypes == null) {
- exceptionTypes= CharOperation.NO_CHAR_CHAR;
- }
-
- String nameString = concat(decl.getOnType().getTypeName()) + "." + new String(decl.getDeclaredSelector()); //$NON-NLS-1$
-
- String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
- handle = IntertypeElement.create(IntertypeElement.getJemDelimter(decl), parentHandle, nameString, parameterTypeSigs);
-
- resolveDuplicates(handle);
-
- IntertypeElementInfo info = new IntertypeElementInfo();
-
- if (decl instanceof InterTypeFieldDeclaration)
- info.setAJKind(IProgramElement.Kind.INTER_TYPE_FIELD);
- else if (decl instanceof InterTypeMethodDeclaration)
- info.setAJKind(IProgramElement.Kind.INTER_TYPE_METHOD);
- else if (decl instanceof InterTypeConstructorDeclaration)
- info.setAJKind(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
- else
- info.setAJKind(IProgramElement.Kind.INTER_TYPE_PARENT);
-
- // Fix for 116846 - incorrect icons for itds - use declaredModifiers instead
- info.setAJAccessibility(CompilationUnitTools.getAccessibilityFromModifierCode(decl.declaredModifiers));
- info.setAJModifiers(CompilationUnitTools.getModifiersFromModifierCode(decl.declaredModifiers));
-
- info.setSourceRangeStart(declarationStart);
- int flags = modifiers;
- info.setName(nameString.toCharArray());
- info.setNameSourceStart(nameSourceStart);
- info.setNameSourceEnd(nameSourceEnd);
-
- if (decl.getOnType() != null) {
- info.setTargetTypeStart(decl.getOnType().sourceStart);
- info.setTargetTypeEnd(decl.getOnType().sourceEnd+1);
- }
-
- info.setTargetType(concat(decl.getOnType().getTypeName()).toCharArray());
- info.setFlags(flags);
- info.setDeclaredModifiers(decl.declaredModifiers);
- info.setArgumentNames(parameterNames);
- //info.setArgumentTypeNames(parameterTypes);
- info.setReturnType(returnType == null ? VOID : returnType);
- info.setExceptionTypeNames(exceptionTypes);
- try {
- info.setAnnotations(createJDTAnnotations(decl.annotations, info, handle));
- } catch (Exception e) {
- // ensure that this annotation handling code does not break existing functionality
- // catch and log the exception
- }
-
- addToChildren(parentInfo, handle);
- this.newElements.put(handle, info);
- this.infoStack.push(info);
- this.handleStack.push(handle);
- }
-
+ // translate nulls to empty arrays
+ if (parameterTypes == null) {
+ parameterTypes= CharOperation.NO_CHAR_CHAR;
+ }
+ if (parameterNames == null) {
+ parameterNames= CharOperation.NO_CHAR_CHAR;
+ }
+ if (exceptionTypes == null) {
+ exceptionTypes= CharOperation.NO_CHAR_CHAR;
+ }
+
+ String nameString = concat(decl.getOnType().getTypeName()) + "." + new String(decl.getDeclaredSelector()); //$NON-NLS-1$
+
+ String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
+ handle = IntertypeElement.create(IntertypeElement.getJemDelimter(decl), parentHandle, nameString, parameterTypeSigs);
+
+ resolveDuplicates(handle);
+
+ IntertypeElementInfo info = new IntertypeElementInfo();
+
+ if (decl instanceof InterTypeFieldDeclaration)
+ info.setAJKind(IProgramElement.Kind.INTER_TYPE_FIELD);
+ else if (decl instanceof InterTypeMethodDeclaration)
+ info.setAJKind(IProgramElement.Kind.INTER_TYPE_METHOD);
+ else if (decl instanceof InterTypeConstructorDeclaration)
+ info.setAJKind(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
+ else
+ info.setAJKind(IProgramElement.Kind.INTER_TYPE_PARENT);
+
+ // Fix for 116846 - incorrect icons for itds - use declaredModifiers instead
+ info.setAJAccessibility(CompilationUnitTools.getAccessibilityFromModifierCode(decl.declaredModifiers));
+ info.setAJModifiers(CompilationUnitTools.getModifiersFromModifierCode(decl.declaredModifiers));
+
+ info.setSourceRangeStart(declarationStart);
+ int flags = modifiers;
+ info.setName(nameString.toCharArray());
+ info.setNameSourceStart(nameSourceStart);
+ info.setNameSourceEnd(nameSourceEnd);
+
+ if (decl.getOnType() != null) {
+ info.setTargetTypeStart(decl.getOnType().sourceStart);
+ info.setTargetTypeEnd(decl.getOnType().sourceEnd+1);
+ }
+
+ info.setTargetType(concat(decl.getOnType().getTypeName()).toCharArray());
+ info.setFlags(flags);
+ info.setDeclaredModifiers(decl.declaredModifiers);
+ info.setArgumentNames(parameterNames);
+ //info.setArgumentTypeNames(parameterTypes);
+ info.setReturnType(returnType == null ? VOID : returnType);
+ info.setExceptionTypeNames(exceptionTypes);
+ try {
+ info.setAnnotations(createJDTAnnotations(decl.annotations, info, handle));
+ } catch (Exception e) {
+ // ensure that this annotation handling code does not break existing functionality
+ // catch and log the exception
+ }
+
+ addToChildren(parentInfo, handle);
+ this.newElements.put(handle, info);
+ this.infoStack.push(info);
+ this.handleStack.push(handle);
+ }
+
private IAnnotation[] createJDTAnnotations(
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] ajAnnotations, AnnotatableInfo parentInfo, JavaElement parentHandle) {
@@ -470,193 +465,193 @@
}
public void enterDeclare(
- int declarationStart,
- int modifiers,
- char[] returnType,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes,
- DeclareDeclaration decl) {
-
- nameSourceStart += 8;
- nameSourceEnd = nameSourceStart;
- Object parentInfo = this.infoStack.peek();
- JavaElement parentHandle= (JavaElement) this.handleStack.peek();
- DeclareElement handle = null;
+ int declarationStart,
+ int modifiers,
+ char[] returnType,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes,
+ DeclareDeclaration decl) {
+
+ nameSourceStart += 8;
+ nameSourceEnd = nameSourceStart;
+ Object parentInfo = this.infoStack.peek();
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ DeclareElement handle = null;
- DeclareElementInfo info = new DeclareElementInfo();
-
- if (decl.declareDecl instanceof DeclareErrorOrWarning){
- if (((DeclareErrorOrWarning)decl.declareDecl).isError()){
- info.setAJKind(IProgramElement.Kind.DECLARE_ERROR);
- nameSourceEnd += 4;
- }else{
- info.setAJKind(IProgramElement.Kind.DECLARE_WARNING);
- nameSourceEnd += 6;
- }
- } else if (decl.declareDecl instanceof DeclareParents){
- info.setAJKind(IProgramElement.Kind.DECLARE_PARENTS);
- nameSourceEnd += 6;
- } else if (decl.declareDecl instanceof DeclarePrecedence){
- info.setAJKind(IProgramElement.Kind.DECLARE_PRECEDENCE);
- nameSourceEnd += 9;
- } else if (decl.declareDecl instanceof DeclareAnnotation){
- DeclareAnnotation anno = (DeclareAnnotation)decl.declareDecl;
- if (anno.isDeclareAtConstuctor()) {
- info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR);
- nameSourceEnd += "@constructor".length()-1; //$NON-NLS-1$
- } else if (anno.isDeclareAtField()) {
- info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD);
- nameSourceEnd += "@field".length()-1; //$NON-NLS-1$
- } else if (anno.isDeclareAtMethod()) {
- info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD);
- nameSourceEnd += "@method".length()-1; //$NON-NLS-1$
- } else if (anno.isDeclareAtType()) {
- info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE);
- nameSourceEnd += "@type".length()-1; //$NON-NLS-1$
- }
-
- info.setAnnotationRemover(anno.isRemover());
- } else {
- //assume declare soft
- info.setAJKind(IProgramElement.Kind.DECLARE_SOFT);
- nameSourceEnd += 3;
- }
- String nameString = info.getAJKind().toString();
-
-
- // translate nulls to empty arrays
- if (parameterTypes == null) {
- parameterTypes= CharOperation.NO_CHAR_CHAR;
- }
- if (parameterNames == null) {
- parameterNames= CharOperation.NO_CHAR_CHAR;
- }
- if (exceptionTypes == null) {
- exceptionTypes= CharOperation.NO_CHAR_CHAR;
- }
-
- String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
-
- handle = new DeclareElement(parentHandle, nameString, parameterTypeSigs);
-
- resolveDuplicates(handle);
-
- info.setSourceRangeStart(declarationStart);
- int flags = modifiers;
- info.setName(nameString.toCharArray());
- info.setNameSourceStart(nameSourceStart);
- info.setNameSourceEnd(nameSourceEnd);
- info.setFlags(flags);
- info.setArgumentNames(parameterNames);
- //info.setArgumentTypeNames(parameterTypes);
- info.setReturnType(returnType == null ? VOID : returnType);
- info.setExceptionTypeNames(exceptionTypes);
-
- addToChildren(parentInfo, handle);
- this.newElements.put(handle, info);
- this.infoStack.push(info);
- this.handleStack.push(handle);
- }
-
+ DeclareElementInfo info = new DeclareElementInfo();
+
+ if (decl.declareDecl instanceof DeclareErrorOrWarning){
+ if (((DeclareErrorOrWarning)decl.declareDecl).isError()){
+ info.setAJKind(IProgramElement.Kind.DECLARE_ERROR);
+ nameSourceEnd += 4;
+ }else{
+ info.setAJKind(IProgramElement.Kind.DECLARE_WARNING);
+ nameSourceEnd += 6;
+ }
+ } else if (decl.declareDecl instanceof DeclareParents){
+ info.setAJKind(IProgramElement.Kind.DECLARE_PARENTS);
+ nameSourceEnd += 6;
+ } else if (decl.declareDecl instanceof DeclarePrecedence){
+ info.setAJKind(IProgramElement.Kind.DECLARE_PRECEDENCE);
+ nameSourceEnd += 9;
+ } else if (decl.declareDecl instanceof DeclareAnnotation){
+ DeclareAnnotation anno = (DeclareAnnotation)decl.declareDecl;
+ if (anno.isDeclareAtConstuctor()) {
+ info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR);
+ nameSourceEnd += "@constructor".length()-1; //$NON-NLS-1$
+ } else if (anno.isDeclareAtField()) {
+ info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD);
+ nameSourceEnd += "@field".length()-1; //$NON-NLS-1$
+ } else if (anno.isDeclareAtMethod()) {
+ info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD);
+ nameSourceEnd += "@method".length()-1; //$NON-NLS-1$
+ } else if (anno.isDeclareAtType()) {
+ info.setAJKind(IProgramElement.Kind.DECLARE_ANNOTATION_AT_TYPE);
+ nameSourceEnd += "@type".length()-1; //$NON-NLS-1$
+ }
+
+ info.setAnnotationRemover(anno.isRemover());
+ } else {
+ //assume declare soft
+ info.setAJKind(IProgramElement.Kind.DECLARE_SOFT);
+ nameSourceEnd += 3;
+ }
+ String nameString = info.getAJKind().toString();
+
+
+ // translate nulls to empty arrays
+ if (parameterTypes == null) {
+ parameterTypes= CharOperation.NO_CHAR_CHAR;
+ }
+ if (parameterNames == null) {
+ parameterNames= CharOperation.NO_CHAR_CHAR;
+ }
+ if (exceptionTypes == null) {
+ exceptionTypes= CharOperation.NO_CHAR_CHAR;
+ }
+
+ String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
+
+ handle = new DeclareElement(parentHandle, nameString, parameterTypeSigs);
+
+ resolveDuplicates(handle);
+
+ info.setSourceRangeStart(declarationStart);
+ int flags = modifiers;
+ info.setName(nameString.toCharArray());
+ info.setNameSourceStart(nameSourceStart);
+ info.setNameSourceEnd(nameSourceEnd);
+ info.setFlags(flags);
+ info.setArgumentNames(parameterNames);
+ //info.setArgumentTypeNames(parameterTypes);
+ info.setReturnType(returnType == null ? VOID : returnType);
+ info.setExceptionTypeNames(exceptionTypes);
+
+ addToChildren(parentInfo, handle);
+ this.newElements.put(handle, info);
+ this.infoStack.push(info);
+ this.handleStack.push(handle);
+ }
+
public void enterPointcut(
- int declarationStart,
- int modifiers,
- char[] returnType,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] parameterTypes,
- char[][] parameterNames,
- char[][] exceptionTypes,
- PointcutDeclaration decl) {
+ int declarationStart,
+ int modifiers,
+ char[] returnType,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes,
+ PointcutDeclaration decl) {
- Object parentInfo = this.infoStack.peek();
- JavaElement parentHandle= (JavaElement) this.handleStack.peek();
- PointcutElement handle = null;
+ Object parentInfo = this.infoStack.peek();
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ PointcutElement handle = null;
- // translate nulls to empty arrays
- if (parameterTypes == null) {
- parameterTypes= CharOperation.NO_CHAR_CHAR;
- }
- if (parameterNames == null) {
- parameterNames= CharOperation.NO_CHAR_CHAR;
- }
- if (exceptionTypes == null) {
- exceptionTypes= CharOperation.NO_CHAR_CHAR;
- }
-
- String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
- handle = new PointcutElement(parentHandle, new String(name), parameterTypeSigs);
+ // translate nulls to empty arrays
+ if (parameterTypes == null) {
+ parameterTypes= CharOperation.NO_CHAR_CHAR;
+ }
+ if (parameterNames == null) {
+ parameterNames= CharOperation.NO_CHAR_CHAR;
+ }
+ if (exceptionTypes == null) {
+ exceptionTypes= CharOperation.NO_CHAR_CHAR;
+ }
+
+ String[] parameterTypeSigs = convertTypeNamesToSigsCopy(parameterTypes);
+ handle = new PointcutElement(parentHandle, new String(name), parameterTypeSigs);
- resolveDuplicates(handle);
-
- PointcutElementInfo info = new PointcutElementInfo();
-
- info.setAJKind(IProgramElement.Kind.POINTCUT);
- info.setAJAccessibility(CompilationUnitTools.getAccessibilityFromModifierCode(decl.modifiers));
- info.setAJModifiers(CompilationUnitTools.getModifiersFromModifierCode(decl.modifiers));
-
- info.setSourceRangeStart(declarationStart);
- info.setSourceRangeEnd(decl.sourceEnd+1);
- int flags = modifiers;
- info.setName(name);
- info.setNameSourceStart(nameSourceStart);
- info.setNameSourceEnd(nameSourceEnd);
- info.setFlags(flags);
- info.setArgumentNames(parameterNames);
- //info.setArgumentTypeNames(parameterTypes);
- info.setReturnType(returnType == null ? VOID : returnType);
- info.setExceptionTypeNames(exceptionTypes);
+ resolveDuplicates(handle);
+
+ PointcutElementInfo info = new PointcutElementInfo();
+
+ info.setAJKind(IProgramElement.Kind.POINTCUT);
+ info.setAJAccessibility(CompilationUnitTools.getAccessibilityFromModifierCode(decl.modifiers));
+ info.setAJModifiers(CompilationUnitTools.getModifiersFromModifierCode(decl.modifiers));
+
+ info.setSourceRangeStart(declarationStart);
+ info.setSourceRangeEnd(decl.sourceEnd+1);
+ int flags = modifiers;
+ info.setName(name);
+ info.setNameSourceStart(nameSourceStart);
+ info.setNameSourceEnd(nameSourceEnd);
+ info.setFlags(flags);
+ info.setArgumentNames(parameterNames);
+ //info.setArgumentTypeNames(parameterTypes);
+ info.setReturnType(returnType == null ? VOID : returnType);
+ info.setExceptionTypeNames(exceptionTypes);
- addToChildren(parentInfo, handle);
- this.newElements.put(handle, info);
- this.infoStack.push(info);
- this.handleStack.push(handle);
- }
+ addToChildren(parentInfo, handle);
+ this.newElements.put(handle, info);
+ this.infoStack.push(info);
+ this.handleStack.push(handle);
+ }
- public void acceptProblem(CategorizedProblem problem) {
- if ((problem.getID() & IProblem.Syntax) != 0){
- this.hasSyntaxErrors = true;
- }
- }
+ public void acceptProblem(CategorizedProblem problem) {
+ if ((problem.getID() & IProblem.Syntax) != 0){
+ this.hasSyntaxErrors = true;
+ }
+ }
- private void addToChildren(Object parentInfo, JavaElement handle) {
- ArrayList childrenList = (ArrayList) this.children.get(parentInfo);
- if (childrenList == null)
- this.children.put(parentInfo, childrenList = new ArrayList());
- childrenList.add(handle);
- }
-
- public void enterConstructor(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo methodInfo) {
- org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi =
- new org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo();
- mi.declarationStart = methodInfo.declarationStart;
- mi.modifiers = methodInfo.modifiers;
- mi.name = methodInfo.name;
- mi.nameSourceStart = methodInfo.nameSourceStart;
- mi.nameSourceEnd = methodInfo.nameSourceEnd;
- mi.parameterNames = methodInfo.parameterNames;
- mi.parameterTypes = methodInfo.parameterTypes;
- mi.exceptionTypes = methodInfo.exceptionTypes;
- mi.isConstructor = true;
- enterConstructor(mi);
+ private void addToChildren(Object parentInfo, JavaElement handle) {
+ ArrayList childrenList = (ArrayList) this.children.get(parentInfo);
+ if (childrenList == null)
+ this.children.put(parentInfo, childrenList = new ArrayList());
+ childrenList.add(handle);
+ }
+
+ public void enterConstructor(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo methodInfo) {
+ org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo mi =
+ new org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo();
+ mi.declarationStart = methodInfo.declarationStart;
+ mi.modifiers = methodInfo.modifiers;
+ mi.name = methodInfo.name;
+ mi.nameSourceStart = methodInfo.nameSourceStart;
+ mi.nameSourceEnd = methodInfo.nameSourceEnd;
+ mi.parameterNames = methodInfo.parameterNames;
+ mi.parameterTypes = methodInfo.parameterTypes;
+ mi.exceptionTypes = methodInfo.exceptionTypes;
+ mi.isConstructor = true;
+ enterConstructor(mi);
}
public void enterField(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.FieldInfo fieldInfo) {
- org.eclipse.jdt.internal.compiler.ISourceElementRequestor.FieldInfo fi =
- new org.eclipse.jdt.internal.compiler.ISourceElementRequestor.FieldInfo();
- fi.declarationStart = fieldInfo.declarationStart;
- fi.modifiers = fieldInfo.modifiers;
- fi.type = fieldInfo.type;
- fi.name = fieldInfo.name;
- fi.nameSourceStart = fieldInfo.nameSourceStart;
- fi.nameSourceEnd = fieldInfo.nameSourceEnd;
- enterField(fi);
+ org.eclipse.jdt.internal.compiler.ISourceElementRequestor.FieldInfo fi =
+ new org.eclipse.jdt.internal.compiler.ISourceElementRequestor.FieldInfo();
+ fi.declarationStart = fieldInfo.declarationStart;
+ fi.modifiers = fieldInfo.modifiers;
+ fi.type = fieldInfo.type;
+ fi.name = fieldInfo.name;
+ fi.nameSourceStart = fieldInfo.nameSourceStart;
+ fi.nameSourceEnd = fieldInfo.nameSourceEnd;
+ enterField(fi);
}
@@ -664,83 +659,83 @@
* Enter Type from AJ side w/ Aspect information
*/
public void enterType(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo,
- boolean isAspect, boolean isPrivilegedAspect) {
- enterType(typeInfo.declarationStart,
- typeInfo.modifiers,
- typeInfo.name,
- typeInfo.nameSourceStart,
- typeInfo.nameSourceEnd,
- typeInfo.superclass,
- typeInfo.superinterfaces,
- convertToJDTTypeParameters(typeInfo.typeParameters),
- isAspect,
- isPrivilegedAspect);
- }
+ boolean isAspect, boolean isPrivilegedAspect) {
+ enterType(typeInfo.declarationStart,
+ typeInfo.modifiers,
+ typeInfo.name,
+ typeInfo.nameSourceStart,
+ typeInfo.nameSourceEnd,
+ typeInfo.superclass,
+ typeInfo.superinterfaces,
+ convertToJDTTypeParameters(typeInfo.typeParameters),
+ isAspect,
+ isPrivilegedAspect);
+ }
/**
* Enter Type from AJ side
*/
- public void enterType(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo) {
- enterType(typeInfo.declarationStart,
- typeInfo.modifiers,
- typeInfo.name,
- typeInfo.nameSourceStart,
- typeInfo.nameSourceEnd,
- typeInfo.superclass,
- typeInfo.superinterfaces,
- convertToJDTTypeParameters(typeInfo.typeParameters),
- false, false);
- }
-
- /**
+ public void enterType(org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo) {
+ enterType(typeInfo.declarationStart,
+ typeInfo.modifiers,
+ typeInfo.name,
+ typeInfo.nameSourceStart,
+ typeInfo.nameSourceEnd,
+ typeInfo.superclass,
+ typeInfo.superinterfaces,
+ convertToJDTTypeParameters(typeInfo.typeParameters),
+ false, false);
+ }
+
+ /**
* XXX This should override something
*/
- public void enterType(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo,
- boolean isAspect, boolean isPrivilegedAspect) {
- enterType(typeInfo.declarationStart,
- typeInfo.modifiers,
- typeInfo.name,
- typeInfo.nameSourceStart,
- typeInfo.nameSourceEnd,
- typeInfo.superclass,
- typeInfo.superinterfaces,
+ public void enterType(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo,
+ boolean isAspect, boolean isPrivilegedAspect) {
+ enterType(typeInfo.declarationStart,
+ typeInfo.modifiers,
+ typeInfo.name,
+ typeInfo.nameSourceStart,
+ typeInfo.nameSourceEnd,
+ typeInfo.superclass,
+ typeInfo.superinterfaces,
typeInfo.typeParameters,
- isAspect,
- isPrivilegedAspect);
- }
+ isAspect,
+ isPrivilegedAspect);
+ }
- /**
- * enter type from JDT side
- */
- @Override
- public void enterType(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo) {
- enterType(typeInfo.declarationStart,
- typeInfo.modifiers,
- typeInfo.name,
- typeInfo.nameSourceStart,
- typeInfo.nameSourceEnd,
- typeInfo.superclass,
- typeInfo.superinterfaces,
+ /**
+ * enter type from JDT side
+ */
+ @Override
+ public void enterType(org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo typeInfo) {
+ enterType(typeInfo.declarationStart,
+ typeInfo.modifiers,
+ typeInfo.name,
+ typeInfo.nameSourceStart,
+ typeInfo.nameSourceEnd,
+ typeInfo.superclass,
+ typeInfo.superinterfaces,
typeInfo.typeParameters,
- false,
- false);
- }
+ false,
+ false);
+ }
- /**
+ /**
* Common processing for both AJ and JDT types
*/
protected void enterType(
- int declarationStart,
- int modifiers,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[] superclass,
- char[][] superinterfaces,
- org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] tpInfo,
- boolean isAspect,
- boolean isPrivilegedAspect) {
-
+ int declarationStart,
+ int modifiers,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[] superclass,
+ char[][] superinterfaces,
+ org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] tpInfo,
+ boolean isAspect,
+ boolean isPrivilegedAspect) {
+
AspectTypeInfo typeInfo =
new AspectTypeInfo();
typeInfo.declarationStart = declarationStart;
@@ -755,14 +750,14 @@
typeInfo.isPrivilegedAspect = isPrivilegedAspect;
if (!isAspect) {
- super.enterType(typeInfo);
- } else {
- JavaElement parentHandle= (JavaElement) this.handleStack.peek();
- Object parentInfo = this.infoStack.peek();
+ super.enterType(typeInfo);
+ } else {
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ Object parentInfo = this.infoStack.peek();
- String nameString= new String(name);
- AspectElement handle = new AspectElement(parentHandle, nameString);
- resolveDuplicates(handle);
+ String nameString= new String(name);
+ AspectElement handle = new AspectElement(parentHandle, nameString);
+ resolveDuplicates(handle);
this.infoStack.push(typeInfo);
this.handleStack.push(handle);
@@ -770,8 +765,8 @@
((org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeInfo) parentInfo).
childrenCategories.put(handle, typeInfo.categories);
}
- addToChildren(parentInfo, handle);
- }
+ addToChildren(parentInfo, handle);
+ }
}
@@ -851,100 +846,177 @@
}
/**
- * XXX This should override something
- */
- public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand, int modifiers) {
+ * XXX This should override something
+ */
+ public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand, int modifiers) {
super.acceptImport(declarationStart, declarationEnd, CharOperation.splitOn('.', name), onDemand, modifiers);
- }
+ }
- /**
- * use {@link #acceptPackage(ImportReference)} instead
- * @deprecated
- */
- public void acceptPackage(int declarationStart, int declarationEnd,
- char[] name) {
-
- // AJDT 1.6 ADE---copied from CompilationUnitStructureProvider.acceptPackage(ImportReference)
- JavaElementInfo parentInfo = (JavaElementInfo) this.infoStack.peek();
- JavaElement parentHandle= (JavaElement) this.handleStack.peek();
- PackageDeclaration handle = null;
-
- if (parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT) {
- handle = createPackageDeclaration(parentHandle, new String(name));
- }
- else {
- Assert.isTrue(false); // Should not happen
- }
- resolveDuplicates(handle);
-
- AJAnnotatableInfo info = new AJAnnotatableInfo() ;
- info.setSourceRangeStart(declarationStart);
- info.setSourceRangeEnd(declarationEnd);
+ public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {
+ super.acceptImport(declarationStart, declarationEnd, tokens, onDemand, modifiers);
+
+ }
- addToChildren(parentInfo, handle);
- this.newElements.put(handle, info);
+ /**
+ * use {@link #acceptPackage(ImportReference)} instead
+ * @deprecated
+ */
+ public void acceptPackage(int declarationStart, int declarationEnd,
+ char[] name) {
+
+ // AJDT 1.6 ADE---copied from CompilationUnitStructureProvider.acceptPackage(ImportReference)
+ JavaElementInfo parentInfo = (JavaElementInfo) this.infoStack.peek();
+ JavaElement parentHandle= (JavaElement) this.handleStack.peek();
+ PackageDeclaration handle = null;
+
+ if (parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT) {
+ handle = createPackageDeclaration(parentHandle, new String(name));
+ }
+ else {
+ Assert.isTrue(false); // Should not happen
+ }
+ resolveDuplicates(handle);
+
+ AJAnnotatableInfo info = new AJAnnotatableInfo() ;
+ info.setSourceRangeStart(declarationStart);
+ info.setSourceRangeEnd(declarationEnd);
- }
+ addToChildren(parentInfo, handle);
+ this.newElements.put(handle, info);
+ }
+
+ public void exitConstructor(int declarationEnd) {
+ // must ensure that we call exitMethod defined in this class so that constructor arguments are
+ // properly initialized
+ this.exitMethod(declarationEnd, (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) null);
+ }
- /* AJDT 1.7 */
- /*
- * a little kludgy here. super type creates JavaElementInfo on the exitMethod
- * this type creates JavaElementInfos on the enterMethod
- */
- public void exitMethod(int declarationEnd, int defaultValueStart,
- int defaultValueEnd) {
- NamedMember handle = (NamedMember) this.handleStack.peek();
- if (! (handle instanceof AspectJMemberElement)) {
- super.exitMethod(declarationEnd, null);
- return;
- }
-
- this.handleStack.pop();
-
- AspectJMemberElementInfo info = (AspectJMemberElementInfo) this.infoStack.pop();
- info.setSourceRangeEnd(declarationEnd);
- info.setChildren(getChildren(info));
- // only ITDs have type parameters
- if (handle instanceof IntertypeElement) {
- org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] typeParameters =
- (org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[])
- this.typeParameterStack.pop();
- if (typeParameters != null) {
- org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] jdtTypeParameters = convertToJDTTypeParameters(typeParameters);
- for (int i = 0, length = jdtTypeParameters.length; i < length; i++) {
- acceptTypeParameter(jdtTypeParameters[i], info);
- }
- }
- }
- }
-
+ /* AJDT 1.7 */
+ /*
+ * a little kludgy here. super type creates JavaElementInfo on the exitMethod
+ * this type creates JavaElementInfos on the enterMethod
+ */
+ public void exitMethod(int declarationEnd, org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression defaultValue) {
+ NamedMember handle = (NamedMember) this.handleStack.peek();
+ if (! (handle instanceof AspectJMemberElement)) {
+ org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo methodInfo = (org.eclipse.jdt.internal.compiler.ISourceElementRequestor.MethodInfo) this.infoStack.peek();
+ // by passing null to the super method, we do not keep track of default annotation values
+ super.exitMethod(declarationEnd, null);
+ if (handle instanceof IMethod && methodInfo.node == null && methodInfo.parameterNames != null && methodInfo.parameterNames.length > 0) {
+ // need to create method parameters since they weren't created in Super
+ ILocalVariable[] methodParameters = createMethodParameters(handle, ((IMethod) handle).getParameterTypes(), methodInfo.parameterNames, methodInfo.declarationStart);
+ ReflectionUtils.setPrivateField(SourceMethodElementInfo.class, "arguments", (SourceMethodElementInfo) newElements.get(handle), methodParameters);
+ }
+ return;
+ }
+
+ this.handleStack.pop();
+
+ AspectJMemberElementInfo info = (AspectJMemberElementInfo) this.infoStack.pop();
+ info.setSourceRangeEnd(declarationEnd);
+ info.setChildren(getChildren(info));
+ // only ITDs have type parameters
+ if (handle instanceof IntertypeElement) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] typeParameters =
+ (org.aspectj.org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[])
+ this.typeParameterStack.pop();
+ if (typeParameters != null) {
+ org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo[] jdtTypeParameters = convertToJDTTypeParameters(typeParameters);
+ for (int i = 0, length = jdtTypeParameters.length; i < length; i++) {
+ acceptTypeParameter(jdtTypeParameters[i], info);
+ }
+ }
+ // JDT requires that the arguments field is set. We can't create the arguments exactly
+ // since we don't have full slocs and we don't have annotations, but we can get pretty close
+ info.setArguments(createMethodParameters(handle, ((AspectJMemberElement) handle).getParameterTypes(), info.getArgumentNames(), info.getDeclarationSourceStart()));
+ }
+ }
+
+ private ILocalVariable[] createMethodParameters(JavaElement handle, String[] parameterTypes, char[][] argumentNames, int reasonableOffset) {
+ if (argumentNames == null) {
+ return null;
+ }
+ if (argumentNames.length == 0) {
+ return new ILocalVariable[0];
+ }
+ LocalVariable[] result = new LocalVariable[argumentNames.length];
+ for(int i = 0; i < argumentNames.length; i++) {
+ // we don't know the slocs, so just make something up that is vaguely reasonable
+ result[i] = new LocalVariable(handle, String.valueOf(
+ argumentNames[i]), reasonableOffset,
+ reasonableOffset+1, reasonableOffset,
+ reasonableOffset+1, parameterTypes[i],
+ new org.eclipse.jdt.internal.compiler.ast.Annotation[0]);
+ }
+
+ return result;
+ }
-
- // copied from super so that children Map is accessible
- private IJavaElement[] getChildren(Object info) {
- ArrayList childrenList = (ArrayList) this.children.get(info);
- if (childrenList != null) {
- return (IJavaElement[]) childrenList.toArray(new IJavaElement[childrenList.size()]);
- }
- return NO_ELEMENTS;
- }
- protected static final JavaElement[] NO_ELEMENTS = new JavaElement[0];
+// private LocalVariable[] acceptMethodParameters(Argument[] arguments, JavaElement methodHandle, char[][] argumentTypeNames) {
+// if (arguments == null) return null;
+// LocalVariable[] result = new LocalVariable[arguments.length];
+// Annotation[][] paramAnnotations = new Annotation[arguments.length][];
+// for(int i = 0; i < arguments.length; i++) {
+// Argument argument = arguments[i];
+// ITDParameterInfo localVarInfo = new ITDParameterInfo();
+// localVarInfo.setSourceRangeStart(argument.declarationSourceStart);
+// localVarInfo.setSourceRangeEnd(argument.declarationSourceStart);
+// localVarInfo.setNameSourceStart(argument.sourceStart);
+// localVarInfo.setNameSourceEnd(argument.sourceEnd);
+//
+// String paramTypeSig = JavaModelManager.getJavaModelManager().intern(Signature.createTypeSignature(argumentTypeNames[i], false));
+// result[i] = new LocalVariable(
+// methodHandle,
+// new String(argument.name),
+// argument.declarationSourceStart,
+// argument.declarationSourceEnd,
+// argument.sourceStart,
+// argument.sourceEnd,
+// paramTypeSig,
+// argument.annotations,
+// argument.modifiers,
+// true);
+// this.newElements.put(result[i], localVarInfo);
+// this.infoStack.push(localVarInfo);
+// this.handleStack.push(result[i]);
+// if (argument.annotations != null) {
+// paramAnnotations[i] = new Annotation[argument.annotations.length];
+// for (int j = 0; j < argument.annotations.length; j++ ) {
+// org.eclipse.jdt.internal.compiler.ast.Annotation annotation = argument.annotations[j];
+// acceptAnnotation(annotation, localVarInfo, result[i]);
+// }
+// }
+// this.infoStack.pop();
+// this.handleStack.pop();
+// }
+// return result;
+// }
+
+ // copied from super so that children Map is accessible
+ private IJavaElement[] getChildren(Object info) {
+ ArrayList<IJavaElement> childrenList = (ArrayList<IJavaElement>) this.children.get(info);
+ if (childrenList != null) {
+ return (IJavaElement[]) childrenList.toArray(new IJavaElement[childrenList.size()]);
+ }
+ return NO_ELEMENTS;
+ }
+ protected static final JavaElement[] NO_ELEMENTS = new JavaElement[0];
/* AJDT 1.7 end */
-
- /**
- * @since 1.6
- */
- public void acceptPackage(
- org.aspectj.org.eclipse.jdt.internal.compiler.ast.ImportReference ir) {
- ImportReference dup = new ImportReference(ir.tokens,ir.sourcePositions,(ir.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand)!=0,ir.modifiers);
- dup.declarationSourceStart = ir.declarationSourceStart;
- dup.declarationSourceEnd = ir.declarationSourceEnd;
- super.acceptPackage(dup);
- }
+
+ /**
+ * @since 1.6
+ */
+ public void acceptPackage(
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ImportReference ir) {
+ ImportReference dup = new ImportReference(ir.tokens,ir.sourcePositions,(ir.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand)!=0,ir.modifiers);
+ dup.declarationSourceStart = ir.declarationSourceStart;
+ dup.declarationSourceEnd = ir.declarationSourceEnd;
+ super.acceptPackage(dup);
+ }
- // unused
+ // unused
private Annotation[] convertToJDTAnnotations(
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] ajAnnotations) {
if (ajAnnotations == null) {
@@ -1034,18 +1106,72 @@
FloatLiteral castedJDT = new FloatLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd);
jdtExpr = castedJDT;
} else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) {
- IntLiteralMinValue castedJDT = new IntLiteralMinValue();
+ // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
+ // ORIG
+// IntLiteralMinValue castedJDT = new IntLiteralMinValue();
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) ajExpr;
+ IntLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTIntLiteralMinValue(castedAJ);
+ } catch (Exception e) {
+ }
jdtExpr = castedJDT;
} else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) {
+ // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
+ // ORIG
+// IntLiteralMinValue castedJDT = new IntLiteralMinValue();
org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) ajExpr;
- IntLiteral castedJDT = new IntLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd);
+ IntLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTIntLiteral(castedAJ);
+ } catch (Exception e) {
+ }
+ jdtExpr = castedJDT;
+ } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) ajExpr;
+ FalseLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTFalseLiteral(castedAJ);
+ } catch (Exception e) {
+ }
+ jdtExpr = castedJDT;
+ } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) ajExpr;
+ NullLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTNullLiteral(castedAJ);
+ } catch (Exception e) {
+ }
+ jdtExpr = castedJDT;
+ } else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) ajExpr;
+ TrueLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTTrueLiteral(castedAJ);
+ } catch (Exception e) {
+ }
jdtExpr = castedJDT;
} else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) {
- LongLiteralMinValue castedJDT = new LongLiteralMinValue();
+ // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
+ // ORIG
+// IntLiteralMinValue castedJDT = new IntLiteralMinValue();
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) ajExpr;
+ LongLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTLongLiteralMinValue(castedAJ);
+ } catch (Exception e) {
+ }
jdtExpr = castedJDT;
} else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) {
+ // ECLIPSE 3.7.1 --- must use reflection since constructors have changed
+ // ORIG
+// IntLiteralMinValue castedJDT = new IntLiteralMinValue();
org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral castedAJ = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) ajExpr;
- LongLiteral castedJDT = new LongLiteral(castedAJ.source(), castedAJ.sourceStart, castedAJ.sourceEnd);
+ LongLiteral castedJDT = null;
+ try {
+ castedJDT = CompilerASTNodeCompatibilityWrapper.createJDTLongLiteral(castedAJ);
+ } catch (Exception e) {
+ }
jdtExpr = castedJDT;
} else if (ajExpr instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) {
// note that here we capture both StringLiteral and ExtendedStringLiteral
@@ -1268,5 +1394,4 @@
}
return ajTypeParams;
}
-
}
\ No newline at end of file
diff --git a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementNotifier.java b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementNotifier.java
index 2b7c424..7d92073 100644
--- a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementNotifier.java
+++ b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementNotifier.java
@@ -61,741 +61,741 @@
*
*/
public class AJSourceElementNotifier {
- /**
- * An ast visitor that visits local type declarations.
- */
- public class LocalDeclarationVisitor extends ASTVisitor {
- ArrayList declaringTypes;
- public void pushDeclaringType(TypeDeclaration declaringType) {
- if (this.declaringTypes == null) {
- this.declaringTypes = new ArrayList();
- }
- this.declaringTypes.add(declaringType);
- }
- public void popDeclaringType() {
- this.declaringTypes.remove(this.declaringTypes.size()-1);
- }
- public TypeDeclaration peekDeclaringType() {
- if (this.declaringTypes == null) return null;
- int size = this.declaringTypes.size();
- if (size == 0) return null;
- return (TypeDeclaration) this.declaringTypes.get(size-1);
- }
- public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
- notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
- return false; // don't visit members as this was done during notifySourceElementRequestor(...)
- }
- public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
- notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
- return false; // don't visit members as this was done during notifySourceElementRequestor(...)
- }
- }
-
- AJCompilationUnitStructureRequestor requestor; // AspectJ change
- boolean reportReferenceInfo;
- char[][] typeNames;
- char[][] superTypeNames;
- int nestedTypeIndex;
- LocalDeclarationVisitor localDeclarationVisitor = null;
-
- HashtableOfObjectToInt sourceEnds;
- Map nodesToCategories;
-
- int initialPosition;
- int eofPosition;
-
+ /**
+ * An ast visitor that visits local type declarations.
+ */
+ public class LocalDeclarationVisitor extends ASTVisitor {
+ ArrayList declaringTypes;
+ public void pushDeclaringType(TypeDeclaration declaringType) {
+ if (this.declaringTypes == null) {
+ this.declaringTypes = new ArrayList();
+ }
+ this.declaringTypes.add(declaringType);
+ }
+ public void popDeclaringType() {
+ this.declaringTypes.remove(this.declaringTypes.size()-1);
+ }
+ public TypeDeclaration peekDeclaringType() {
+ if (this.declaringTypes == null) return null;
+ int size = this.declaringTypes.size();
+ if (size == 0) return null;
+ return (TypeDeclaration) this.declaringTypes.get(size-1);
+ }
+ public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
+ notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
+ return false; // don't visit members as this was done during notifySourceElementRequestor(...)
+ }
+ public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
+ notifySourceElementRequestor(typeDeclaration, true, peekDeclaringType());
+ return false; // don't visit members as this was done during notifySourceElementRequestor(...)
+ }
+ }
+
+ AJCompilationUnitStructureRequestor requestor; // AspectJ change
+ boolean reportReferenceInfo;
+ char[][] typeNames;
+ char[][] superTypeNames;
+ int nestedTypeIndex;
+ LocalDeclarationVisitor localDeclarationVisitor = null;
+
+ HashtableOfObjectToInt sourceEnds;
+ Map nodesToCategories;
+
+ int initialPosition;
+ int eofPosition;
+
public AJSourceElementNotifier(AJCompilationUnitStructureRequestor requestor, boolean reportLocalDeclarations) { // AspectJ Change
- this.requestor = requestor;
- if (reportLocalDeclarations) {
- this.localDeclarationVisitor = new LocalDeclarationVisitor();
- }
- typeNames = new char[4][];
- superTypeNames = new char[4][];
- nestedTypeIndex = 0;
+ this.requestor = requestor;
+ if (reportLocalDeclarations) {
+ this.localDeclarationVisitor = new LocalDeclarationVisitor();
+ }
+ typeNames = new char[4][];
+ superTypeNames = new char[4][];
+ nestedTypeIndex = 0;
}
protected char[][][] getArguments(Argument[] arguments) {
- int argumentLength = arguments.length;
- char[][] argumentTypes = new char[argumentLength][];
- char[][] argumentNames = new char[argumentLength][];
- for (int i = 0; i < argumentLength; i++) {
- argumentTypes[i] = CharOperation.concatWith(arguments[i].type.getParameterizedTypeName(), '.');
- argumentNames[i] = arguments[i].name;
- }
-
- return new char[][][] {argumentTypes, argumentNames};
+ int argumentLength = arguments.length;
+ char[][] argumentTypes = new char[argumentLength][];
+ char[][] argumentNames = new char[argumentLength][];
+ for (int i = 0; i < argumentLength; i++) {
+ argumentTypes[i] = CharOperation.concatWith(arguments[i].type.getParameterizedTypeName(), '.');
+ argumentNames[i] = arguments[i].name;
+ }
+
+ return new char[][][] {argumentTypes, argumentNames};
}
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
- char[][] interfaceNames = null;
- int superInterfacesLength = 0;
- TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
- if (superInterfaces != null) {
- superInterfacesLength = superInterfaces.length;
- interfaceNames = new char[superInterfacesLength][];
- } else {
- if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
- // see PR 3442
- QualifiedAllocationExpression alloc = typeDeclaration.allocation;
- if (alloc != null && alloc.type != null) {
- superInterfaces = new TypeReference[] { alloc.type};
- superInterfacesLength = 1;
- interfaceNames = new char[1][];
- }
- }
- }
- if (superInterfaces != null) {
- for (int i = 0; i < superInterfacesLength; i++) {
- interfaceNames[i] =
- CharOperation.concatWith(superInterfaces[i].getParameterizedTypeName(), '.');
- }
- }
- return interfaceNames;
+ char[][] interfaceNames = null;
+ int superInterfacesLength = 0;
+ TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
+ if (superInterfaces != null) {
+ superInterfacesLength = superInterfaces.length;
+ interfaceNames = new char[superInterfacesLength][];
+ } else {
+ if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
+ // see PR 3442
+ QualifiedAllocationExpression alloc = typeDeclaration.allocation;
+ if (alloc != null && alloc.type != null) {
+ superInterfaces = new TypeReference[] { alloc.type};
+ superInterfacesLength = 1;
+ interfaceNames = new char[1][];
+ }
+ }
+ }
+ if (superInterfaces != null) {
+ for (int i = 0; i < superInterfacesLength; i++) {
+ interfaceNames[i] =
+ CharOperation.concatWith(superInterfaces[i].getParameterizedTypeName(), '.');
+ }
+ }
+ return interfaceNames;
}
protected char[] getSuperclassName(TypeDeclaration typeDeclaration) {
- TypeReference superclass = typeDeclaration.superclass;
- return superclass != null ? CharOperation.concatWith(superclass.getParameterizedTypeName(), '.') : null;
+ TypeReference superclass = typeDeclaration.superclass;
+ return superclass != null ? CharOperation.concatWith(superclass.getParameterizedTypeName(), '.') : null;
}
protected char[][] getThrownExceptions(AbstractMethodDeclaration methodDeclaration) {
- char[][] thrownExceptionTypes = null;
- TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
- if (thrownExceptions != null) {
- int thrownExceptionLength = thrownExceptions.length;
- thrownExceptionTypes = new char[thrownExceptionLength][];
- for (int i = 0; i < thrownExceptionLength; i++) {
- thrownExceptionTypes[i] =
- CharOperation.concatWith(thrownExceptions[i].getParameterizedTypeName(), '.');
- }
- }
- return thrownExceptionTypes;
+ char[][] thrownExceptionTypes = null;
+ TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
+ if (thrownExceptions != null) {
+ int thrownExceptionLength = thrownExceptions.length;
+ thrownExceptionTypes = new char[thrownExceptionLength][];
+ for (int i = 0; i < thrownExceptionLength; i++) {
+ thrownExceptionTypes[i] =
+ CharOperation.concatWith(thrownExceptions[i].getParameterizedTypeName(), '.');
+ }
+ }
+ return thrownExceptionTypes;
}
protected char[][] getTypeParameterBounds(TypeParameter typeParameter) {
- TypeReference firstBound = typeParameter.type;
- TypeReference[] otherBounds = typeParameter.bounds;
- char[][] typeParameterBounds = null;
- if (firstBound != null) {
- if (otherBounds != null) {
- int otherBoundsLength = otherBounds.length;
- char[][] boundNames = new char[otherBoundsLength+1][];
- boundNames[0] = CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.');
- for (int j = 0; j < otherBoundsLength; j++) {
- boundNames[j+1] =
- CharOperation.concatWith(otherBounds[j].getParameterizedTypeName(), '.');
- }
- typeParameterBounds = boundNames;
- } else {
- typeParameterBounds = new char[][] { CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.')};
- }
- } else {
- typeParameterBounds = CharOperation.NO_CHAR_CHAR;
- }
-
- return typeParameterBounds;
+ TypeReference firstBound = typeParameter.type;
+ TypeReference[] otherBounds = typeParameter.bounds;
+ char[][] typeParameterBounds = null;
+ if (firstBound != null) {
+ if (otherBounds != null) {
+ int otherBoundsLength = otherBounds.length;
+ char[][] boundNames = new char[otherBoundsLength+1][];
+ boundNames[0] = CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.');
+ for (int j = 0; j < otherBoundsLength; j++) {
+ boundNames[j+1] =
+ CharOperation.concatWith(otherBounds[j].getParameterizedTypeName(), '.');
+ }
+ typeParameterBounds = boundNames;
+ } else {
+ typeParameterBounds = new char[][] { CharOperation.concatWith(firstBound.getParameterizedTypeName(), '.')};
+ }
+ } else {
+ typeParameterBounds = CharOperation.NO_CHAR_CHAR;
+ }
+
+ return typeParameterBounds;
}
private ISourceElementRequestor.TypeParameterInfo[] getTypeParameterInfos(TypeParameter[] typeParameters) {
- if (typeParameters == null) return null;
- int typeParametersLength = typeParameters.length;
- ISourceElementRequestor.TypeParameterInfo[] result = new ISourceElementRequestor.TypeParameterInfo[typeParametersLength];
- for (int i = 0; i < typeParametersLength; i++) {
- TypeParameter typeParameter = typeParameters[i];
- char[][] typeParameterBounds = this.getTypeParameterBounds(typeParameter);
- ISourceElementRequestor.TypeParameterInfo typeParameterInfo = new ISourceElementRequestor.TypeParameterInfo();
- typeParameterInfo.declarationStart = typeParameter.declarationSourceStart;
- typeParameterInfo.declarationEnd = typeParameter.declarationSourceEnd;
- typeParameterInfo.name = typeParameter.name;
- typeParameterInfo.nameSourceStart = typeParameter.sourceStart;
- typeParameterInfo.nameSourceEnd = typeParameter.sourceEnd;
- typeParameterInfo.bounds = typeParameterBounds;
- result[i] = typeParameterInfo;
- }
- return result;
+ if (typeParameters == null) return null;
+ int typeParametersLength = typeParameters.length;
+ ISourceElementRequestor.TypeParameterInfo[] result = new ISourceElementRequestor.TypeParameterInfo[typeParametersLength];
+ for (int i = 0; i < typeParametersLength; i++) {
+ TypeParameter typeParameter = typeParameters[i];
+ char[][] typeParameterBounds = this.getTypeParameterBounds(typeParameter);
+ ISourceElementRequestor.TypeParameterInfo typeParameterInfo = new ISourceElementRequestor.TypeParameterInfo();
+ typeParameterInfo.declarationStart = typeParameter.declarationSourceStart;
+ typeParameterInfo.declarationEnd = typeParameter.declarationSourceEnd;
+ typeParameterInfo.name = typeParameter.name;
+ typeParameterInfo.nameSourceStart = typeParameter.sourceStart;
+ typeParameterInfo.nameSourceEnd = typeParameter.sourceEnd;
+ typeParameterInfo.bounds = typeParameterBounds;
+ result[i] = typeParameterInfo;
+ }
+ return result;
}
/*
* Checks whether one of the annotations is the @Deprecated annotation
* (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89807)
*/
private boolean hasDeprecatedAnnotation(Annotation[] annotations) {
- if (annotations != null) {
- for (int i = 0, length = annotations.length; i < length; i++) {
- Annotation annotation = annotations[i];
- if (CharOperation.equals(annotation.type.getLastToken(), TypeConstants.JAVA_LANG_DEPRECATED[2])) {
- return true;
- }
- }
- }
- return false;
+ if (annotations != null) {
+ for (int i = 0, length = annotations.length; i < length; i++) {
+ Annotation annotation = annotations[i];
+ if (CharOperation.equals(annotation.type.getLastToken(), TypeConstants.JAVA_LANG_DEPRECATED[2])) {
+ return true;
+ }
+ }
+ }
+ return false;
}
/*
* Update the bodyStart of the corresponding parse node
*/
protected void notifySourceElementRequestor(AbstractMethodDeclaration methodDeclaration) {
- // range check
- boolean isInRange =
- initialPosition <= methodDeclaration.declarationSourceStart
- && eofPosition >= methodDeclaration.declarationSourceEnd;
+ // range check
+ boolean isInRange =
+ initialPosition <= methodDeclaration.declarationSourceStart
+ && eofPosition >= methodDeclaration.declarationSourceEnd;
- if (methodDeclaration.isClinit()) {
- this.visitIfNeeded(methodDeclaration);
- return;
- }
+ if (methodDeclaration.isClinit()) {
+ this.visitIfNeeded(methodDeclaration);
+ return;
+ }
- if (methodDeclaration.isDefaultConstructor()) {
- if (reportReferenceInfo) {
- ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
- ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
- if (constructorCall != null) {
- switch(constructorCall.accessMode) {
- case ExplicitConstructorCall.This :
- requestor.acceptConstructorReference(
- typeNames[nestedTypeIndex-1],
- constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
- constructorCall.sourceStart);
- break;
- case ExplicitConstructorCall.Super :
- case ExplicitConstructorCall.ImplicitSuper :
- requestor.acceptConstructorReference(
- superTypeNames[nestedTypeIndex-1],
- constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
- constructorCall.sourceStart);
- break;
- }
- }
- }
- return;
- }
- char[][] argumentTypes = null;
- char[][] argumentNames = null;
- boolean isVarArgs = false;
- Argument[] arguments = methodDeclaration.arguments;
- if (arguments != null) {
- char[][][] argumentTypesAndNames = this.getArguments(arguments);
- argumentTypes = argumentTypesAndNames[0];
- argumentNames = argumentTypesAndNames[1];
-
- isVarArgs = arguments[arguments.length-1].isVarArgs();
- }
- char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration);
- // by default no selector end position
- int selectorSourceEnd = -1;
- if (methodDeclaration.isConstructor()) {
- selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
- if (isInRange){
- int currentModifiers = methodDeclaration.modifiers;
- if (isVarArgs)
- currentModifiers |= ClassFileConstants.AccVarargs;
-
- // remember deprecation so as to not lose it below
- boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations);
-
- ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
- methodInfo.isConstructor = true;
- methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
- methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
- methodInfo.name = methodDeclaration.selector;
- methodInfo.nameSourceStart = methodDeclaration.sourceStart;
- methodInfo.nameSourceEnd = selectorSourceEnd;
- methodInfo.parameterTypes = argumentTypes;
- methodInfo.parameterNames = argumentNames;
- methodInfo.exceptionTypes = thrownExceptionTypes;
- methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
- methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
- methodInfo.annotations = methodDeclaration.annotations;
- methodInfo.node = methodDeclaration;
- requestor.enterConstructor(methodInfo);
- }
- if (reportReferenceInfo) {
- ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
- ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
- if (constructorCall != null) {
- switch(constructorCall.accessMode) {
- case ExplicitConstructorCall.This :
- requestor.acceptConstructorReference(
- typeNames[nestedTypeIndex-1],
- constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
- constructorCall.sourceStart);
- break;
- case ExplicitConstructorCall.Super :
- case ExplicitConstructorCall.ImplicitSuper :
- requestor.acceptConstructorReference(
- superTypeNames[nestedTypeIndex-1],
- constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
- constructorCall.sourceStart);
- break;
- }
- }
- }
- this.visitIfNeeded(methodDeclaration);
- if (isInRange){
- requestor.exitConstructor(methodDeclaration.declarationSourceEnd);
- }
- return;
- }
- selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
-
- // AspectJ Change Begin
- // recreate source locations for Pointcuts and Advice
- org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration ajmDec = new org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration(new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult(methodDeclaration.compilationResult.fileName, methodDeclaration.compilationResult.unitIndex, methodDeclaration.compilationResult.totalUnitsKnown, 500));
- if (ajmDec instanceof PointcutDeclaration) {
- selectorSourceEnd = methodDeclaration.sourceStart + methodDeclaration.selector.length - 1;
- }
- if (ajmDec instanceof AdviceDeclaration) {
- selectorSourceEnd = methodDeclaration.sourceStart + ((AdviceDeclaration) ajmDec).kind.getName().length() - 1;
- }
- // AspectJ Change End
+ if (methodDeclaration.isDefaultConstructor()) {
+ if (reportReferenceInfo) {
+ ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
+ ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
+ if (constructorCall != null) {
+ switch(constructorCall.accessMode) {
+ case ExplicitConstructorCall.This :
+ requestor.acceptConstructorReference(
+ typeNames[nestedTypeIndex-1],
+ constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
+ constructorCall.sourceStart);
+ break;
+ case ExplicitConstructorCall.Super :
+ case ExplicitConstructorCall.ImplicitSuper :
+ requestor.acceptConstructorReference(
+ superTypeNames[nestedTypeIndex-1],
+ constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
+ constructorCall.sourceStart);
+ break;
+ }
+ }
+ }
+ return;
+ }
+ char[][] argumentTypes = null;
+ char[][] argumentNames = null;
+ boolean isVarArgs = false;
+ Argument[] arguments = methodDeclaration.arguments;
+ if (arguments != null) {
+ char[][][] argumentTypesAndNames = this.getArguments(arguments);
+ argumentTypes = argumentTypesAndNames[0];
+ argumentNames = argumentTypesAndNames[1];
+
+ isVarArgs = arguments[arguments.length-1].isVarArgs();
+ }
+ char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration);
+ // by default no selector end position
+ int selectorSourceEnd = -1;
+ if (methodDeclaration.isConstructor()) {
+ selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
+ if (isInRange){
+ int currentModifiers = methodDeclaration.modifiers;
+ if (isVarArgs)
+ currentModifiers |= ClassFileConstants.AccVarargs;
+
+ // remember deprecation so as to not lose it below
+ boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations);
+
+ ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
+ methodInfo.isConstructor = true;
+ methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
+ methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
+ methodInfo.name = methodDeclaration.selector;
+ methodInfo.nameSourceStart = methodDeclaration.sourceStart;
+ methodInfo.nameSourceEnd = selectorSourceEnd;
+ methodInfo.parameterTypes = argumentTypes;
+ methodInfo.parameterNames = argumentNames;
+ methodInfo.exceptionTypes = thrownExceptionTypes;
+ methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
+ methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
+ methodInfo.annotations = methodDeclaration.annotations;
+ methodInfo.node = methodDeclaration;
+ requestor.enterConstructor(methodInfo);
+ }
+ if (reportReferenceInfo) {
+ ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
+ ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
+ if (constructorCall != null) {
+ switch(constructorCall.accessMode) {
+ case ExplicitConstructorCall.This :
+ requestor.acceptConstructorReference(
+ typeNames[nestedTypeIndex-1],
+ constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
+ constructorCall.sourceStart);
+ break;
+ case ExplicitConstructorCall.Super :
+ case ExplicitConstructorCall.ImplicitSuper :
+ requestor.acceptConstructorReference(
+ superTypeNames[nestedTypeIndex-1],
+ constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
+ constructorCall.sourceStart);
+ break;
+ }
+ }
+ }
+ this.visitIfNeeded(methodDeclaration);
+ if (isInRange){
+ requestor.exitConstructor(methodDeclaration.declarationSourceEnd);
+ }
+ return;
+ }
+ selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
+
+ // AspectJ Change Begin
+ // recreate source locations for Pointcuts and Advice
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration ajmDec = new org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration(new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult(methodDeclaration.compilationResult.fileName, methodDeclaration.compilationResult.unitIndex, methodDeclaration.compilationResult.totalUnitsKnown, 500));
+ if (ajmDec instanceof PointcutDeclaration) {
+ selectorSourceEnd = methodDeclaration.sourceStart + methodDeclaration.selector.length - 1;
+ }
+ if (ajmDec instanceof AdviceDeclaration) {
+ selectorSourceEnd = methodDeclaration.sourceStart + ((AdviceDeclaration) ajmDec).kind.getName().length() - 1;
+ }
+ // AspectJ Change End
- if (isInRange) {
- int currentModifiers = methodDeclaration.modifiers;
- if (isVarArgs)
- currentModifiers |= ClassFileConstants.AccVarargs;
-
- // remember deprecation so as to not lose it below
- boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations);
-
- TypeReference returnType = methodDeclaration instanceof MethodDeclaration
- ? ((MethodDeclaration) methodDeclaration).returnType
- : null;
- ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
- methodInfo.isAnnotation = methodDeclaration instanceof AnnotationMethodDeclaration;
- methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
- methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
- methodInfo.returnType = returnType == null ? null : CharOperation.concatWith(returnType.getParameterizedTypeName(), '.');
- methodInfo.name = methodDeclaration.selector;
- methodInfo.nameSourceStart = methodDeclaration.sourceStart;
- methodInfo.nameSourceEnd = selectorSourceEnd;
- methodInfo.parameterTypes = argumentTypes;
- methodInfo.parameterNames = argumentNames;
- methodInfo.exceptionTypes = thrownExceptionTypes;
- methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
- methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
- methodInfo.annotations = methodDeclaration.annotations;
- methodInfo.node = methodDeclaration;
- requestor.enterMethod(methodInfo);
- }
-
- this.visitIfNeeded(methodDeclaration);
+ if (isInRange) {
+ int currentModifiers = methodDeclaration.modifiers;
+ if (isVarArgs)
+ currentModifiers |= ClassFileConstants.AccVarargs;
+
+ // remember deprecation so as to not lose it below
+ boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations);
+
+ TypeReference returnType = methodDeclaration instanceof MethodDeclaration
+ ? ((MethodDeclaration) methodDeclaration).returnType
+ : null;
+ ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
+ methodInfo.isAnnotation = methodDeclaration instanceof AnnotationMethodDeclaration;
+ methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
+ methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
+ methodInfo.returnType = returnType == null ? null : CharOperation.concatWith(returnType.getParameterizedTypeName(), '.');
+ methodInfo.name = methodDeclaration.selector;
+ methodInfo.nameSourceStart = methodDeclaration.sourceStart;
+ methodInfo.nameSourceEnd = selectorSourceEnd;
+ methodInfo.parameterTypes = argumentTypes;
+ methodInfo.parameterNames = argumentNames;
+ methodInfo.exceptionTypes = thrownExceptionTypes;
+ methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
+ methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
+ methodInfo.annotations = methodDeclaration.annotations;
+ methodInfo.node = methodDeclaration;
+ requestor.enterMethod(methodInfo);
+ }
+
+ this.visitIfNeeded(methodDeclaration);
- if (isInRange) {
- if (methodDeclaration instanceof AnnotationMethodDeclaration) {
- AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration;
- Expression expression = annotationMethodDeclaration.defaultValue;
- if (expression != null) {
- requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression);
- return;
- }
- }
- requestor.exitMethod(methodDeclaration.declarationSourceEnd, null);
- }
+ if (isInRange) {
+ if (methodDeclaration instanceof AnnotationMethodDeclaration) {
+ AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration;
+ Expression expression = annotationMethodDeclaration.defaultValue;
+ if (expression != null) {
+ requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression);
+ return;
+ }
+ }
+ requestor.exitMethod(methodDeclaration.declarationSourceEnd, (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) null);
+ }
}
/*
* Update the bodyStart of the corresponding parse node
*/
public void notifySourceElementRequestor(
- CompilationUnitDeclaration parsedUnit,
- int sourceStart,
- int sourceEnd,
- boolean reportReference,
- HashtableOfObjectToInt sourceEndsMap,
- Map nodesToCategoriesMap) {
-
- this.initialPosition = sourceStart;
- this.eofPosition = sourceEnd;
-
- this.reportReferenceInfo = reportReference;
- this.sourceEnds = sourceEndsMap;
- this.nodesToCategories = nodesToCategoriesMap;
-
- try {
- // range check
- boolean isInRange =
- initialPosition <= parsedUnit.sourceStart
- && eofPosition >= parsedUnit.sourceEnd;
-
- // collect the top level ast nodes
- int length = 0;
- ASTNode[] nodes = null;
- if (isInRange) {
- requestor.enterCompilationUnit();
- }
- ImportReference currentPackage = parsedUnit.currentPackage;
- ImportReference[] imports = parsedUnit.imports;
- TypeDeclaration[] types = parsedUnit.types;
- length =
- (currentPackage == null ? 0 : 1)
- + (imports == null ? 0 : imports.length)
- + (types == null ? 0 : types.length);
- nodes = new ASTNode[length];
- int index = 0;
- if (currentPackage != null) {
- nodes[index++] = currentPackage;
- }
- if (imports != null) {
- for (int i = 0, max = imports.length; i < max; i++) {
- nodes[index++] = imports[i];
- }
- }
- if (types != null) {
- for (int i = 0, max = types.length; i < max; i++) {
- nodes[index++] = types[i];
- }
- }
-
- // notify the nodes in the syntactical order
- if (length > 0) {
- quickSort(nodes, 0, length-1);
- for (int i=0;i<length;i++) {
- ASTNode node = nodes[i];
- if (node instanceof ImportReference) {
- ImportReference importRef = (ImportReference)node;
- if (node == parsedUnit.currentPackage) {
- notifySourceElementRequestor(importRef, true);
- } else {
- notifySourceElementRequestor(importRef, false);
- }
- } else { // instanceof TypeDeclaration
- notifySourceElementRequestor((TypeDeclaration)node, true, null);
- }
- }
- }
-
- if (isInRange) {
- requestor.exitCompilationUnit(parsedUnit.sourceEnd);
- }
- } finally {
- this.reset();
- }
+ CompilationUnitDeclaration parsedUnit,
+ int sourceStart,
+ int sourceEnd,
+ boolean reportReference,
+ HashtableOfObjectToInt sourceEndsMap,
+ Map nodesToCategoriesMap) {
+
+ this.initialPosition = sourceStart;
+ this.eofPosition = sourceEnd;
+
+ this.reportReferenceInfo = reportReference;
+ this.sourceEnds = sourceEndsMap;
+ this.nodesToCategories = nodesToCategoriesMap;
+
+ try {
+ // range check
+ boolean isInRange =
+ initialPosition <= parsedUnit.sourceStart
+ && eofPosition >= parsedUnit.sourceEnd;
+
+ // collect the top level ast nodes
+ int length = 0;
+ ASTNode[] nodes = null;
+ if (isInRange) {
+ requestor.enterCompilationUnit();
+ }
+ ImportReference currentPackage = parsedUnit.currentPackage;
+ ImportReference[] imports = parsedUnit.imports;
+ TypeDeclaration[] types = parsedUnit.types;
+ length =
+ (currentPackage == null ? 0 : 1)
+ + (imports == null ? 0 : imports.length)
+ + (types == null ? 0 : types.length);
+ nodes = new ASTNode[length];
+ int index = 0;
+ if (currentPackage != null) {
+ nodes[index++] = currentPackage;
+ }
+ if (imports != null) {
+ for (int i = 0, max = imports.length; i < max; i++) {
+ nodes[index++] = imports[i];
+ }
+ }
+ if (types != null) {
+ for (int i = 0, max = types.length; i < max; i++) {
+ nodes[index++] = types[i];
+ }
+ }
+
+ // notify the nodes in the syntactical order
+ if (length > 0) {
+ quickSort(nodes, 0, length-1);
+ for (int i=0;i<length;i++) {
+ ASTNode node = nodes[i];
+ if (node instanceof ImportReference) {
+ ImportReference importRef = (ImportReference)node;
+ if (node == parsedUnit.currentPackage) {
+ notifySourceElementRequestor(importRef, true);
+ } else {
+ notifySourceElementRequestor(importRef, false);
+ }
+ } else { // instanceof TypeDeclaration
+ notifySourceElementRequestor((TypeDeclaration)node, true, null);
+ }
+ }
+ }
+
+ if (isInRange) {
+ requestor.exitCompilationUnit(parsedUnit.sourceEnd);
+ }
+ } finally {
+ this.reset();
+ }
}
/*
* Update the bodyStart of the corresponding parse node
*/
protected void notifySourceElementRequestor(FieldDeclaration fieldDeclaration, TypeDeclaration declaringType) {
-
- // range check
- boolean isInRange =
- initialPosition <= fieldDeclaration.declarationSourceStart
- && eofPosition >= fieldDeclaration.declarationSourceEnd;
+
+ // range check
+ boolean isInRange =
+ initialPosition <= fieldDeclaration.declarationSourceStart
+ && eofPosition >= fieldDeclaration.declarationSourceEnd;
- switch(fieldDeclaration.getKind()) {
- case AbstractVariableDeclaration.ENUM_CONSTANT:
- if (this.reportReferenceInfo) {
- // accept constructor reference for enum constant
- if (fieldDeclaration.initialization instanceof AllocationExpression) {
- AllocationExpression alloc = (AllocationExpression) fieldDeclaration.initialization;
- requestor.acceptConstructorReference(
- declaringType.name,
- alloc.arguments == null ? 0 : alloc.arguments.length,
- alloc.sourceStart);
- }
- }
- // fall through next case
- case AbstractVariableDeclaration.FIELD:
- int fieldEndPosition = this.sourceEnds.get(fieldDeclaration);
- if (fieldEndPosition == -1) {
- // use the declaration source end by default
- fieldEndPosition = fieldDeclaration.declarationSourceEnd;
- }
- if (isInRange) {
- int currentModifiers = fieldDeclaration.modifiers;
-
- // remember deprecation so as to not lose it below
- boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(fieldDeclaration.annotations);
-
- char[] typeName = null;
- if (fieldDeclaration.type == null) {
- // enum constant
- typeName = declaringType.name;
- currentModifiers |= ClassFileConstants.AccEnum;
- } else {
- // regular field
- typeName = CharOperation.concatWith(fieldDeclaration.type.getParameterizedTypeName(), '.');
- }
- ISourceElementRequestor.FieldInfo fieldInfo = new ISourceElementRequestor.FieldInfo();
- fieldInfo.declarationStart = fieldDeclaration.declarationSourceStart;
- fieldInfo.name = fieldDeclaration.name;
- fieldInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
- fieldInfo.type = typeName;
- fieldInfo.nameSourceStart = fieldDeclaration.sourceStart;
- fieldInfo.nameSourceEnd = fieldDeclaration.sourceEnd;
- fieldInfo.categories = (char[][]) this.nodesToCategories.get(fieldDeclaration);
- fieldInfo.annotations = fieldDeclaration.annotations;
- fieldInfo.node = fieldDeclaration;
- requestor.enterField(fieldInfo);
- }
- this.visitIfNeeded(fieldDeclaration, declaringType);
- if (isInRange){
- requestor.exitField(
- // filter out initializations that are not a constant (simple check)
- (fieldDeclaration.initialization == null
- || fieldDeclaration.initialization instanceof ArrayInitializer
- || fieldDeclaration.initialization instanceof AllocationExpression
- || fieldDeclaration.initialization instanceof ArrayAllocationExpression
- || fieldDeclaration.initialization instanceof Assignment
- || fieldDeclaration.initialization instanceof ClassLiteralAccess
- || fieldDeclaration.initialization instanceof MessageSend
- || fieldDeclaration.initialization instanceof ArrayReference
- || fieldDeclaration.initialization instanceof ThisReference) ?
- -1 :
- fieldDeclaration.initialization.sourceStart,
- fieldEndPosition,
- fieldDeclaration.declarationSourceEnd);
- }
- break;
- case AbstractVariableDeclaration.INITIALIZER:
- if (isInRange){
- requestor.enterInitializer(
- fieldDeclaration.declarationSourceStart,
- fieldDeclaration.modifiers);
- }
- this.visitIfNeeded((Initializer)fieldDeclaration);
- if (isInRange){
- requestor.exitInitializer(fieldDeclaration.declarationSourceEnd);
- }
- break;
- }
+ switch(fieldDeclaration.getKind()) {
+ case AbstractVariableDeclaration.ENUM_CONSTANT:
+ if (this.reportReferenceInfo) {
+ // accept constructor reference for enum constant
+ if (fieldDeclaration.initialization instanceof AllocationExpression) {
+ AllocationExpression alloc = (AllocationExpression) fieldDeclaration.initialization;
+ requestor.acceptConstructorReference(
+ declaringType.name,
+ alloc.arguments == null ? 0 : alloc.arguments.length,
+ alloc.sourceStart);
+ }
+ }
+ // fall through next case
+ case AbstractVariableDeclaration.FIELD:
+ int fieldEndPosition = this.sourceEnds.get(fieldDeclaration);
+ if (fieldEndPosition == -1) {
+ // use the declaration source end by default
+ fieldEndPosition = fieldDeclaration.declarationSourceEnd;
+ }
+ if (isInRange) {
+ int currentModifiers = fieldDeclaration.modifiers;
+
+ // remember deprecation so as to not lose it below
+ boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(fieldDeclaration.annotations);
+
+ char[] typeName = null;
+ if (fieldDeclaration.type == null) {
+ // enum constant
+ typeName = declaringType.name;
+ currentModifiers |= ClassFileConstants.AccEnum;
+ } else {
+ // regular field
+ typeName = CharOperation.concatWith(fieldDeclaration.type.getParameterizedTypeName(), '.');
+ }
+ ISourceElementRequestor.FieldInfo fieldInfo = new ISourceElementRequestor.FieldInfo();
+ fieldInfo.declarationStart = fieldDeclaration.declarationSourceStart;
+ fieldInfo.name = fieldDeclaration.name;
+ fieldInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
+ fieldInfo.type = typeName;
+ fieldInfo.nameSourceStart = fieldDeclaration.sourceStart;
+ fieldInfo.nameSourceEnd = fieldDeclaration.sourceEnd;
+ fieldInfo.categories = (char[][]) this.nodesToCategories.get(fieldDeclaration);
+ fieldInfo.annotations = fieldDeclaration.annotations;
+ fieldInfo.node = fieldDeclaration;
+ requestor.enterField(fieldInfo);
+ }
+ this.visitIfNeeded(fieldDeclaration, declaringType);
+ if (isInRange){
+ requestor.exitField(
+ // filter out initializations that are not a constant (simple check)
+ (fieldDeclaration.initialization == null
+ || fieldDeclaration.initialization instanceof ArrayInitializer
+ || fieldDeclaration.initialization instanceof AllocationExpression
+ || fieldDeclaration.initialization instanceof ArrayAllocationExpression
+ || fieldDeclaration.initialization instanceof Assignment
+ || fieldDeclaration.initialization instanceof ClassLiteralAccess
+ || fieldDeclaration.initialization instanceof MessageSend
+ || fieldDeclaration.initialization instanceof ArrayReference
+ || fieldDeclaration.initialization instanceof ThisReference) ?
+ -1 :
+ fieldDeclaration.initialization.sourceStart,
+ fieldEndPosition,
+ fieldDeclaration.declarationSourceEnd);
+ }
+ break;
+ case AbstractVariableDeclaration.INITIALIZER:
+ if (isInRange){
+ requestor.enterInitializer(
+ fieldDeclaration.declarationSourceStart,
+ fieldDeclaration.modifiers);
+ }
+ this.visitIfNeeded((Initializer)fieldDeclaration);
+ if (isInRange){
+ requestor.exitInitializer(fieldDeclaration.declarationSourceEnd);
+ }
+ break;
+ }
}
protected void notifySourceElementRequestor(
- ImportReference importReference,
- boolean isPackage) {
- if (isPackage) {
- requestor.acceptPackage(importReference);
- } else {
- requestor.acceptImport(
- importReference.declarationSourceStart,
- importReference.declarationSourceEnd,
- importReference.tokens,
- (importReference.bits & ASTNode.OnDemand) != 0,
- importReference.modifiers);
- }
+ ImportReference importReference,
+ boolean isPackage) {
+ if (isPackage) {
+ requestor.acceptPackage(importReference);
+ } else {
+ requestor.acceptImport(
+ importReference.declarationSourceStart,
+ importReference.declarationSourceEnd,
+ importReference.tokens,
+ (importReference.bits & ASTNode.OnDemand) != 0,
+ importReference.modifiers);
+ }
}
protected void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence, TypeDeclaration declaringType) {
-
- if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
+
+ if (CharOperation.equals(TypeConstants.PACKAGE_INFO_NAME, typeDeclaration.name)) return;
- // AspectJ change begin
- boolean isAspect = false;
- org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration ajtypeDeclaration =
- new org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration(
- new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult(
- typeDeclaration.compilationResult.fileName, typeDeclaration.compilationResult.unitIndex,
- typeDeclaration.compilationResult.totalUnitsKnown, 500));
- if (ajtypeDeclaration instanceof AspectDeclaration) {
- isAspect = true;
- }
- // AspectJ change end
+ // AspectJ change begin
+ boolean isAspect = false;
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration ajtypeDeclaration =
+ new org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration(
+ new org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult(
+ typeDeclaration.compilationResult.fileName, typeDeclaration.compilationResult.unitIndex,
+ typeDeclaration.compilationResult.totalUnitsKnown, 500));
+ if (ajtypeDeclaration instanceof AspectDeclaration) {
+ isAspect = true;
+ }
+ // AspectJ change end
-
- // range check
- boolean isInRange =
- initialPosition <= typeDeclaration.declarationSourceStart
- && eofPosition >= typeDeclaration.declarationSourceEnd;
-
- FieldDeclaration[] fields = typeDeclaration.fields;
- AbstractMethodDeclaration[] methods = typeDeclaration.methods;
- TypeDeclaration[] memberTypes = typeDeclaration.memberTypes;
- int fieldCounter = fields == null ? 0 : fields.length;
- int methodCounter = methods == null ? 0 : methods.length;
- int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
- int fieldIndex = 0;
- int methodIndex = 0;
- int memberTypeIndex = 0;
-
- if (notifyTypePresence){
- char[][] interfaceNames = getInterfaceNames(typeDeclaration);
- int kind = TypeDeclaration.kind(typeDeclaration.modifiers);
- char[] implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_OBJECT;
- if (isInRange) {
- int currentModifiers = typeDeclaration.modifiers;
-
- // remember deprecation so as to not lose it below
- boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(typeDeclaration.annotations);
-
- boolean isEnumInit = typeDeclaration.allocation != null && typeDeclaration.allocation.enumConstant != null;
- char[] superclassName;
- if (isEnumInit) {
- currentModifiers |= ClassFileConstants.AccEnum;
- superclassName = declaringType.name;
- } else {
- superclassName = getSuperclassName(typeDeclaration);
- }
- ISourceElementRequestor.TypeInfo typeInfo = new ISourceElementRequestor.TypeInfo();
- if (typeDeclaration.allocation == null) {
- typeInfo.declarationStart = typeDeclaration.declarationSourceStart;
- } else if (isEnumInit) {
- typeInfo.declarationStart = typeDeclaration.allocation.enumConstant.sourceStart;
- } else {
- typeInfo.declarationStart = typeDeclaration.allocation.sourceStart;
- }
- typeInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
- typeInfo.name = typeDeclaration.name;
- typeInfo.nameSourceStart = isEnumInit ? typeDeclaration.allocation.enumConstant.sourceStart : typeDeclaration.sourceStart;
- typeInfo.nameSourceEnd = sourceEnd(typeDeclaration);
- typeInfo.superclass = superclassName;
- typeInfo.superinterfaces = interfaceNames;
- typeInfo.typeParameters = getTypeParameterInfos(typeDeclaration.typeParameters);
- typeInfo.categories = (char[][]) this.nodesToCategories.get(typeDeclaration);
- typeInfo.secondary = typeDeclaration.isSecondary();
- typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
- typeInfo.annotations = typeDeclaration.annotations;
- typeInfo.node = typeDeclaration;
- requestor.enterType(typeInfo, isAspect, (isAspect ? ((AspectDeclaration) ajtypeDeclaration).isPrivileged : false)); // AspectJ change
- switch (kind) {
- case TypeDeclaration.CLASS_DECL :
- if (superclassName != null)
- implicitSuperclassName = superclassName;
- break;
- case TypeDeclaration.INTERFACE_DECL :
- implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_OBJECT;
- break;
- case TypeDeclaration.ENUM_DECL :
- implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_ENUM;
- break;
- case TypeDeclaration.ANNOTATION_TYPE_DECL :
- implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_ANNOTATION_ANNOTATION;
- break;
- }
- }
- if (this.nestedTypeIndex == this.typeNames.length) {
- // need a resize
- System.arraycopy(this.typeNames, 0, (this.typeNames = new char[this.nestedTypeIndex * 2][]), 0, this.nestedTypeIndex);
- System.arraycopy(this.superTypeNames, 0, (this.superTypeNames = new char[this.nestedTypeIndex * 2][]), 0, this.nestedTypeIndex);
- }
- this.typeNames[this.nestedTypeIndex] = typeDeclaration.name;
- this.superTypeNames[this.nestedTypeIndex++] = implicitSuperclassName;
- }
- while ((fieldIndex < fieldCounter)
- || (memberTypeIndex < memberTypeCounter)
- || (methodIndex < methodCounter)) {
- FieldDeclaration nextFieldDeclaration = null;
- AbstractMethodDeclaration nextMethodDeclaration = null;
- TypeDeclaration nextMemberDeclaration = null;
-
- int position = Integer.MAX_VALUE;
- int nextDeclarationType = -1;
- if (fieldIndex < fieldCounter) {
- nextFieldDeclaration = fields[fieldIndex];
- if (nextFieldDeclaration.declarationSourceStart < position) {
- position = nextFieldDeclaration.declarationSourceStart;
- nextDeclarationType = 0; // FIELD
- }
- }
- if (methodIndex < methodCounter) {
- nextMethodDeclaration = methods[methodIndex];
- if (nextMethodDeclaration.declarationSourceStart < position) {
- position = nextMethodDeclaration.declarationSourceStart;
- nextDeclarationType = 1; // METHOD
- }
- }
- if (memberTypeIndex < memberTypeCounter) {
- nextMemberDeclaration = memberTypes[memberTypeIndex];
- if (nextMemberDeclaration.declarationSourceStart < position) {
- position = nextMemberDeclaration.declarationSourceStart;
- nextDeclarationType = 2; // MEMBER
- }
- }
- switch (nextDeclarationType) {
- case 0 :
- fieldIndex++;
- notifySourceElementRequestor(nextFieldDeclaration, typeDeclaration);
- break;
- case 1 :
- methodIndex++;
- notifySourceElementRequestor(nextMethodDeclaration);
- break;
- case 2 :
- memberTypeIndex++;
- notifySourceElementRequestor(nextMemberDeclaration, true, null);
- }
- }
- if (notifyTypePresence){
- if (isInRange){
- requestor.exitType(typeDeclaration.declarationSourceEnd);
- }
- nestedTypeIndex--;
- }
+
+ // range check
+ boolean isInRange =
+ initialPosition <= typeDeclaration.declarationSourceStart
+ && eofPosition >= typeDeclaration.declarationSourceEnd;
+
+ FieldDeclaration[] fields = typeDeclaration.fields;
+ AbstractMethodDeclaration[] methods = typeDeclaration.methods;
+ TypeDeclaration[] memberTypes = typeDeclaration.memberTypes;
+ int fieldCounter = fields == null ? 0 : fields.length;
+ int methodCounter = methods == null ? 0 : methods.length;
+ int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length;
+ int fieldIndex = 0;
+ int methodIndex = 0;
+ int memberTypeIndex = 0;
+
+ if (notifyTypePresence){
+ char[][] interfaceNames = getInterfaceNames(typeDeclaration);
+ int kind = TypeDeclaration.kind(typeDeclaration.modifiers);
+ char[] implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_OBJECT;
+ if (isInRange) {
+ int currentModifiers = typeDeclaration.modifiers;
+
+ // remember deprecation so as to not lose it below
+ boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(typeDeclaration.annotations);
+
+ boolean isEnumInit = typeDeclaration.allocation != null && typeDeclaration.allocation.enumConstant != null;
+ char[] superclassName;
+ if (isEnumInit) {
+ currentModifiers |= ClassFileConstants.AccEnum;
+ superclassName = declaringType.name;
+ } else {
+ superclassName = getSuperclassName(typeDeclaration);
+ }
+ ISourceElementRequestor.TypeInfo typeInfo = new ISourceElementRequestor.TypeInfo();
+ if (typeDeclaration.allocation == null) {
+ typeInfo.declarationStart = typeDeclaration.declarationSourceStart;
+ } else if (isEnumInit) {
+ typeInfo.declarationStart = typeDeclaration.allocation.enumConstant.sourceStart;
+ } else {
+ typeInfo.declarationStart = typeDeclaration.allocation.sourceStart;
+ }
+ typeInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
+ typeInfo.name = typeDeclaration.name;
+ typeInfo.nameSourceStart = isEnumInit ? typeDeclaration.allocation.enumConstant.sourceStart : typeDeclaration.sourceStart;
+ typeInfo.nameSourceEnd = sourceEnd(typeDeclaration);
+ typeInfo.superclass = superclassName;
+ typeInfo.superinterfaces = interfaceNames;
+ typeInfo.typeParameters = getTypeParameterInfos(typeDeclaration.typeParameters);
+ typeInfo.categories = (char[][]) this.nodesToCategories.get(typeDeclaration);
+ typeInfo.secondary = typeDeclaration.isSecondary();
+ typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
+ typeInfo.annotations = typeDeclaration.annotations;
+ typeInfo.node = typeDeclaration;
+ requestor.enterType(typeInfo, isAspect, (isAspect ? ((AspectDeclaration) ajtypeDeclaration).isPrivileged : false)); // AspectJ change
+ switch (kind) {
+ case TypeDeclaration.CLASS_DECL :
+ if (superclassName != null)
+ implicitSuperclassName = superclassName;
+ break;
+ case TypeDeclaration.INTERFACE_DECL :
+ implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_OBJECT;
+ break;
+ case TypeDeclaration.ENUM_DECL :
+ implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_ENUM;
+ break;
+ case TypeDeclaration.ANNOTATION_TYPE_DECL :
+ implicitSuperclassName = TypeConstants.CharArray_JAVA_LANG_ANNOTATION_ANNOTATION;
+ break;
+ }
+ }
+ if (this.nestedTypeIndex == this.typeNames.length) {
+ // need a resize
+ System.arraycopy(this.typeNames, 0, (this.typeNames = new char[this.nestedTypeIndex * 2][]), 0, this.nestedTypeIndex);
+ System.arraycopy(this.superTypeNames, 0, (this.superTypeNames = new char[this.nestedTypeIndex * 2][]), 0, this.nestedTypeIndex);
+ }
+ this.typeNames[this.nestedTypeIndex] = typeDeclaration.name;
+ this.superTypeNames[this.nestedTypeIndex++] = implicitSuperclassName;
+ }
+ while ((fieldIndex < fieldCounter)
+ || (memberTypeIndex < memberTypeCounter)
+ || (methodIndex < methodCounter)) {
+ FieldDeclaration nextFieldDeclaration = null;
+ AbstractMethodDeclaration nextMethodDeclaration = null;
+ TypeDeclaration nextMemberDeclaration = null;
+
+ int position = Integer.MAX_VALUE;
+ int nextDeclarationType = -1;
+ if (fieldIndex < fieldCounter) {
+ nextFieldDeclaration = fields[fieldIndex];
+ if (nextFieldDeclaration.declarationSourceStart < position) {
+ position = nextFieldDeclaration.declarationSourceStart;
+ nextDeclarationType = 0; // FIELD
+ }
+ }
+ if (methodIndex < methodCounter) {
+ nextMethodDeclaration = methods[methodIndex];
+ if (nextMethodDeclaration.declarationSourceStart < position) {
+ position = nextMethodDeclaration.declarationSourceStart;
+ nextDeclarationType = 1; // METHOD
+ }
+ }
+ if (memberTypeIndex < memberTypeCounter) {
+ nextMemberDeclaration = memberTypes[memberTypeIndex];
+ if (nextMemberDeclaration.declarationSourceStart < position) {
+ position = nextMemberDeclaration.declarationSourceStart;
+ nextDeclarationType = 2; // MEMBER
+ }
+ }
+ switch (nextDeclarationType) {
+ case 0 :
+ fieldIndex++;
+ notifySourceElementRequestor(nextFieldDeclaration, typeDeclaration);
+ break;
+ case 1 :
+ methodIndex++;
+ notifySourceElementRequestor(nextMethodDeclaration);
+ break;
+ case 2 :
+ memberTypeIndex++;
+ notifySourceElementRequestor(nextMemberDeclaration, true, null);
+ }
+ }
+ if (notifyTypePresence){
+ if (isInRange){
+ requestor.exitType(typeDeclaration.declarationSourceEnd);
+ }
+ nestedTypeIndex--;
+ }
}
/*
* Sort the given ast nodes by their positions.
*/
private static void quickSort(ASTNode[] sortedCollection, int left, int right) {
- int original_left = left;
- int original_right = right;
- ASTNode mid = sortedCollection[left + (right - left) / 2];
- do {
- while (sortedCollection[left].sourceStart < mid.sourceStart) {
- left++;
- }
- while (mid.sourceStart < sortedCollection[right].sourceStart) {
- right--;
- }
- if (left <= right) {
- ASTNode tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(sortedCollection, original_left, right);
- }
- if (left < original_right) {
- quickSort(sortedCollection, left, original_right);
- }
+ int original_left = left;
+ int original_right = right;
+ ASTNode mid = sortedCollection[left + (right - left) / 2];
+ do {
+ while (sortedCollection[left].sourceStart < mid.sourceStart) {
+ left++;
+ }
+ while (mid.sourceStart < sortedCollection[right].sourceStart) {
+ right--;
+ }
+ if (left <= right) {
+ ASTNode tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSort(sortedCollection, original_left, right);
+ }
+ if (left < original_right) {
+ quickSort(sortedCollection, left, original_right);
+ }
}
private void reset() {
- typeNames = new char[4][];
- superTypeNames = new char[4][];
- nestedTypeIndex = 0;
-
- this.sourceEnds = null;
+ typeNames = new char[4][];
+ superTypeNames = new char[4][];
+ nestedTypeIndex = 0;
+
+ this.sourceEnds = null;
}
private int sourceEnd(TypeDeclaration typeDeclaration) {
- if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
- QualifiedAllocationExpression allocation = typeDeclaration.allocation;
- if (allocation.enumConstant != null) // case of enum constant body
- return allocation.enumConstant.sourceEnd;
- return allocation.type.sourceEnd;
- } else {
- return typeDeclaration.sourceEnd;
- }
+ if ((typeDeclaration.bits & ASTNode.IsAnonymousType) != 0) {
+ QualifiedAllocationExpression allocation = typeDeclaration.allocation;
+ if (allocation.enumConstant != null) // case of enum constant body
+ return allocation.enumConstant.sourceEnd;
+ return allocation.type.sourceEnd;
+ } else {
+ return typeDeclaration.sourceEnd;
+ }
}
private void visitIfNeeded(AbstractMethodDeclaration method) {
- if (this.localDeclarationVisitor != null
- && (method.bits & ASTNode.HasLocalType) != 0) {
- if (method instanceof ConstructorDeclaration) {
- ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) method;
- if (constructorDeclaration.constructorCall != null) {
- constructorDeclaration.constructorCall.traverse(this.localDeclarationVisitor, method.scope);
- }
- }
- if (method.statements != null) {
- int statementsLength = method.statements.length;
- for (int i = 0; i < statementsLength; i++)
- method.statements[i].traverse(this.localDeclarationVisitor, method.scope);
- }
- }
+ if (this.localDeclarationVisitor != null
+ && (method.bits & ASTNode.HasLocalType) != 0) {
+ if (method instanceof ConstructorDeclaration) {
+ ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) method;
+ if (constructorDeclaration.constructorCall != null) {
+ constructorDeclaration.constructorCall.traverse(this.localDeclarationVisitor, method.scope);
+ }
+ }
+ if (method.statements != null) {
+ int statementsLength = method.statements.length;
+ for (int i = 0; i < statementsLength; i++)
+ method.statements[i].traverse(this.localDeclarationVisitor, method.scope);
+ }
+ }
}
private void visitIfNeeded(FieldDeclaration field, TypeDeclaration declaringType) {
- if (this.localDeclarationVisitor != null
- && (field.bits & ASTNode.HasLocalType) != 0) {
- if (field.initialization != null) {
- try {
- this.localDeclarationVisitor.pushDeclaringType(declaringType);
- field.initialization.traverse(this.localDeclarationVisitor, (MethodScope) null);
- } finally {
- this.localDeclarationVisitor.popDeclaringType();
- }
- }
- }
+ if (this.localDeclarationVisitor != null
+ && (field.bits & ASTNode.HasLocalType) != 0) {
+ if (field.initialization != null) {
+ try {
+ this.localDeclarationVisitor.pushDeclaringType(declaringType);
+ field.initialization.traverse(this.localDeclarationVisitor, (MethodScope) null);
+ } finally {
+ this.localDeclarationVisitor.popDeclaringType();
+ }
+ }
+ }
}
private void visitIfNeeded(Initializer initializer) {
- if (this.localDeclarationVisitor != null
- && (initializer.bits & ASTNode.HasLocalType) != 0) {
- if (initializer.block != null) {
- initializer.block.traverse(this.localDeclarationVisitor, null);
- }
- }
+ if (this.localDeclarationVisitor != null
+ && (initializer.bits & ASTNode.HasLocalType) != 0) {
+ if (initializer.block != null) {
+ initializer.block.traverse(this.localDeclarationVisitor, null);
+ }
+ }
}
}
diff --git a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementParser.java b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementParser.java
index 93d9da6..df48370 100644
--- a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementParser.java
+++ b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/parserbridge/AJSourceElementParser.java
@@ -783,6 +783,7 @@
System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
+ impt.trailingStarPosition = this.intStack[this.intPtr--];
if (this.currentToken == TokenNameSEMICOLON){
impt.declarationSourceEnd = this.scanner.currentPosition - 1;
} else {
@@ -1264,7 +1265,7 @@
methodInfo.parameterNames = argumentNames;
methodInfo.exceptionTypes = thrownExceptionTypes;
methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
- methodInfo.annotationPositions = collectAnnotationPositions(methodDeclaration.annotations);
+ methodInfo.annotations = methodDeclaration.annotations;
methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
requestor.enterConstructor(methodInfo);
}
@@ -1337,7 +1338,7 @@
methodInfo.parameterNames = argumentNames;
methodInfo.exceptionTypes = thrownExceptionTypes;
methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
- methodInfo.annotationPositions = collectAnnotationPositions(methodDeclaration.annotations);
+ methodInfo.annotations = methodDeclaration.annotations;
methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
requestor.enterMethod(methodInfo,methodDeclaration);
}
@@ -1349,11 +1350,11 @@
AnnotationMethodDeclaration annotationMethodDeclaration = (AnnotationMethodDeclaration) methodDeclaration;
Expression expression = annotationMethodDeclaration.defaultValue;
if (expression != null) {
- requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression.sourceStart, expression.sourceEnd);
+ requestor.exitMethod(methodDeclaration.declarationSourceEnd, expression);
return;
}
}
- requestor.exitMethod(methodDeclaration.declarationSourceEnd, -1, -1);
+ requestor.exitMethod(methodDeclaration.declarationSourceEnd, null);
}
}
@@ -1406,7 +1407,7 @@
fieldInfo.type = typeName;
fieldInfo.nameSourceStart = fieldDeclaration.sourceStart;
fieldInfo.nameSourceEnd = fieldDeclaration.sourceEnd;
- fieldInfo.annotationPositions = collectAnnotationPositions(fieldDeclaration.annotations);
+ fieldInfo.annotations = fieldDeclaration.annotations;
fieldInfo.categories = (char[][]) this.nodesToCategories.get(fieldDeclaration);
requestor.enterField(fieldInfo);
}
@@ -1449,11 +1450,14 @@
// AJDT 1.6 changed to new method
requestor.acceptPackage(importReference);
} else {
- requestor.acceptImport(
+ boolean onDemand = (importReference.bits & ASTNode.OnDemand) != 0;
+ requestor.acceptImport(
importReference.declarationSourceStart,
importReference.declarationSourceEnd,
+ importReference.sourceStart,
+ onDemand ? importReference.trailingStarPosition : importReference.sourceEnd,
importReference.tokens,
- (importReference.bits & ASTNode.OnDemand) != 0,
+ onDemand,
importReference.modifiers);
}
}
@@ -1533,7 +1537,7 @@
typeInfo.superclass = superclassName;
typeInfo.superinterfaces = interfaceNames;
typeInfo.typeParameters = getTypeParameterInfos(typeDeclaration.typeParameters);
- typeInfo.annotationPositions = collectAnnotationPositions(typeDeclaration.annotations);
+ typeInfo.annotations = typeDeclaration.annotations;
typeInfo.categories = (char[][]) this.nodesToCategories.get(typeDeclaration);
typeInfo.secondary = typeDeclaration.isSecondary();
typeInfo.anonymousMember = typeDeclaration.allocation != null && typeDeclaration.allocation.enclosingInstance != null;
diff --git a/org.eclipse.ajdt.core/src/org/eclipse/ajdt/internal/core/parserbridge/CompilerASTNodeCompatibilityWrapper.java b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/internal/core/parserbridge/CompilerASTNodeCompatibilityWrapper.java
new file mode 100644
index 0000000..c793296
--- /dev/null
+++ b/org.eclipse.ajdt.core/src/org/eclipse/ajdt/internal/core/parserbridge/CompilerASTNodeCompatibilityWrapper.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2012 VMware Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Eisenberg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ajdt.internal.core.parserbridge;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.ajdt.internal.core.ras.NoFFDC;
+import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
+import org.eclipse.jdt.internal.compiler.ast.IntLiteral;
+import org.eclipse.jdt.internal.compiler.ast.LongLiteral;
+import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
+import org.eclipse.jdt.internal.compiler.ast.NumberLiteral;
+import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
+
+/**
+ * Changes to the constructors of several compiler AST nodes has occurred between 3.7.0 and 3.7.1.
+ * We need to use reflection to create these objects so that AJDT can be compatible with both older and newer
+ * versions of JDT.
+ * @author Andrew Eisenberg
+ * @created Sep 23, 2011
+ */
+public class CompilerASTNodeCompatibilityWrapper implements NoFFDC {
+
+ public static TrueLiteral createJDTTrueLiteral(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return new TrueLiteral(ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd);
+ }
+
+ public static FalseLiteral createJDTFalseLiteral(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return new FalseLiteral(ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd);
+ }
+
+ public static NullLiteral createJDTNullLiteral(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return new NullLiteral(ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd);
+ }
+
+ public static IntLiteral createJDTIntLiteral(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return (IntLiteral) buildLiteral(ajdtLiteral.source(), ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd, true);
+ }
+
+ public static IntLiteral createJDTIntLiteralMinValue(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return (IntLiteral) buildLiteral(ajdtLiteral.source(), ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd, true);
+ }
+
+ public static LongLiteral createJDTLongLiteral(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return (LongLiteral) buildLiteral(ajdtLiteral.source(), ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd, false);
+ }
+
+ public static LongLiteral createJDTLongLiteralMinValue(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue ajdtLiteral) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
+ return (LongLiteral) buildLiteral(ajdtLiteral.source(), ajdtLiteral.sourceStart, ajdtLiteral.sourceEnd, false);
+ }
+
+ private static NumberLiteral buildLiteral(char[] source, int sourceStart, int sourceEnd, boolean isInt) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, SecurityException, NoSuchMethodException {
+ // first try to get the buildXXXLiteral method. if it doesn't exist, then assume
+ // that we are on 3.7.
+ Method buildXXXLiteralMethod = getXXXLiteralMethod(isInt);
+ if (buildXXXLiteralMethod != null) {
+ return (NumberLiteral) buildXXXLiteralMethod.invoke(null, source, sourceStart, sourceEnd);
+ } else {
+ Constructor<? extends NumberLiteral> constructXXXLiteral = getXXXConstructor(isInt);
+ if (constructXXXLiteral == null) {
+ // shouldn't get here
+ return null;
+ }
+ return constructXXXLiteral.newInstance(source, sourceStart, sourceEnd);
+ }
+ }
+
+ private static Constructor<? extends NumberLiteral> getXXXConstructor(boolean isInt) throws ClassNotFoundException, SecurityException, NoSuchMethodException {
+ if (isInt) {
+ if (intLiteralConstructorChecked) {
+ return intLiteralConstructorCached;
+ } else {
+ intLiteralConstructorChecked = true;
+ }
+ } else {
+ if (longLiteralConstructorChecked) {
+ return longLiteralConstructorCached;
+ } else {
+ longLiteralConstructorChecked = true;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ Class<? extends NumberLiteral> clazz = (Class<? extends NumberLiteral>) Class.forName("org.eclipse.jdt.internal.compiler.ast." + (isInt ? "Int" : "Long") + "Literal");
+ Constructor<? extends NumberLiteral> cons = clazz.getConstructor(char[].class, int.class, int.class);
+ if (isInt) {
+ intLiteralConstructorCached = cons;
+ } else {
+ longLiteralConstructorCached = cons;
+ }
+ return cons;
+ }
+
+ private static Method getXXXLiteralMethod(boolean isInt) throws ClassNotFoundException {
+ if (isInt) {
+ if (buildIntLiteralChecked) {
+ return buildIntLiteralCached;
+ } else {
+ buildIntLiteralChecked = true;
+ }
+ } else {
+ if (buildLongLiteralChecked) {
+ return buildLongLiteralCached;
+ } else {
+ buildLongLiteralChecked = true;
+ }
+ }
+ @SuppressWarnings("unchecked")
+ Class<? extends NumberLiteral> clazz = (Class<? extends NumberLiteral>) Class.forName("org.eclipse.jdt.internal.compiler.ast." + (isInt ? "Int" : "Long") + "Literal");
+ Method buildXXXMethod;
+ try {
+ buildXXXMethod = clazz.getMethod("build" + (isInt ? "Int" : "Long") + "Literal", char[].class, int.class, int.class);
+ if (isInt) {
+ buildIntLiteralCached = buildXXXMethod;
+ } else {
+ buildLongLiteralCached = buildXXXMethod;
+ }
+ } catch (SecurityException e) {
+ buildXXXMethod = null;
+ } catch (NoSuchMethodException e) {
+ buildXXXMethod = null;
+ }
+ return buildXXXMethod;
+ }
+
+ private static boolean buildLongLiteralChecked = false;
+ private static boolean buildIntLiteralChecked = false;
+
+ private static Method buildLongLiteralCached = null;
+ private static Method buildIntLiteralCached = null;
+
+ private static boolean longLiteralConstructorChecked = false;
+ private static boolean intLiteralConstructorChecked = false;
+
+ private static Constructor<? extends NumberLiteral> longLiteralConstructorCached = null;
+ private static Constructor<? extends NumberLiteral> intLiteralConstructorCached = null;
+
+}
\ No newline at end of file