aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-09-23 15:49:53 +0000
committeraclement <aclement>2005-09-23 15:49:53 +0000
commitd0ae646468f33d52522cc324e5d7db112c0fd534 (patch)
treecd3006e1597b8a33c6d84dbf2c303cfb8028b9ba
parent61cddce63a77f4e35c7ae75313b503019197ad83 (diff)
downloadaspectj-d0ae646468f33d52522cc324e5d7db112c0fd534.tar.gz
aspectj-d0ae646468f33d52522cc324e5d7db112c0fd534.zip
ast support !
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AdviceDeclaration.java327
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterAdviceDeclaration.java63
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterReturningAdviceDeclaration.java148
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterThrowingAdviceDeclaration.java147
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java4356
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTMatcher.java252
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTVisitor.java166
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java1640
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java148
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AndPointcut.java123
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java258
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java145
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/BeforeAdviceDeclaration.java63
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/CflowPointcut.java102
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareDeclaration.java150
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java64
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeFieldDeclaration.java64
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java91
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/NotPointcut.java97
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/OrPointcut.java124
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerCflow.java107
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerObject.java107
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerTypeWithin.java69
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java323
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDesignator.java33
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/ReferencePointcut.java107
27 files changed, 9276 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
index 750f6997d..fa68d4640 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
@@ -95,6 +95,8 @@ public class DeclarationFactory implements IDeclarationFactory {
AspectDeclaration aspect = (AspectDeclaration) aspectDecl;
PseudoTokens tok = (PseudoTokens) pseudoTokens;
aspect.perClause = tok.parsePerClause(parser);
+ // For the ast support: currently the below line is not finished! The start is set incorrectly
+ ((AspectDeclaration)aspectDecl).perClause.setLocation(null,1,parser.getCurrentTokenStart()+1);
}
/* (non-Javadoc)
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AdviceDeclaration.java
new file mode 100644
index 000000000..4691827f9
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AdviceDeclaration.java
@@ -0,0 +1,327 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AdviceDeclaration DOM AST node.
+ * Source code forked from MethodDeclaration.
+ * An abstract AdviceDeclaration is just like a MethodDeclaration,
+ * but without a name or return type.
+ * @author ajh02
+ */
+
+public abstract class AdviceDeclaration extends BodyDeclaration {
+
+ /**
+ * The "javadoc" structural property of this node type.
+ * @since 3.0
+ */
+ public static final ChildPropertyDescriptor JAVADOC_PROPERTY =
+ internalJavadocPropertyFactory(AdviceDeclaration.class);
+
+ /**
+ * The "parameters" structural property of this node type).
+ * @since 3.0
+ */
+ public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY =
+ new ChildListPropertyDescriptor(AdviceDeclaration.class, "parameters", SingleVariableDeclaration.class, CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor POINTCUT_PROPERTY =
+ new ChildPropertyDescriptor(AdviceDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ /**
+ * The "thrownExceptions" structural property of this node type).
+ * @since 3.0
+ */
+ public static final ChildListPropertyDescriptor THROWN_EXCEPTIONS_PROPERTY =
+ new ChildListPropertyDescriptor(AdviceDeclaration.class, "thrownExceptions", Name.class, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ /**
+ * The "body" structural property of this node type.
+ * @since 3.0
+ */
+ public static final ChildPropertyDescriptor BODY_PROPERTY =
+ new ChildPropertyDescriptor(AdviceDeclaration.class, "body", Block.class, OPTIONAL, CYCLE_RISK); //$NON-NLS-1$
+
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ * @since 3.0
+ */
+ protected static List PROPERTY_DESCRIPTORS_2_0;
+
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ * @since 3.1
+ */
+ protected static List PROPERTY_DESCRIPTORS_3_0;
+
+ static {
+ List propertyList = new ArrayList(5);
+ createPropertyList(AdviceDeclaration.class, propertyList);
+ addProperty(JAVADOC_PROPERTY, propertyList);
+ addProperty(PARAMETERS_PROPERTY, propertyList);
+ addProperty(THROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(POINTCUT_PROPERTY, propertyList);
+ addProperty(BODY_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
+
+ propertyList = new ArrayList(5);
+ createPropertyList(AdviceDeclaration.class, propertyList);
+ addProperty(JAVADOC_PROPERTY, propertyList);
+ addProperty(PARAMETERS_PROPERTY, propertyList);
+ addProperty(THROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(POINTCUT_PROPERTY, propertyList);
+ addProperty(BODY_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
+ }
+
+ /**
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the AST.JLS* constants
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ * @since 3.0
+ */
+ public static List propertyDescriptors(int apiLevel) {
+ if (apiLevel == AST.JLS2_INTERNAL) {
+ return PROPERTY_DESCRIPTORS_2_0;
+ } else {
+ return PROPERTY_DESCRIPTORS_3_0;
+ }
+ }
+
+ /**
+ * The parameter declarations
+ * (element type: <code>SingleVariableDeclaration</code>).
+ * Defaults to an empty list.
+ */
+ protected ASTNode.NodeList parameters =
+ new ASTNode.NodeList(PARAMETERS_PROPERTY);
+
+ private PointcutDesignator pointcut;
+
+ /**
+ * The list of thrown exception names (element type: <code>Name</code>).
+ * Defaults to an empty list.
+ */
+ protected ASTNode.NodeList thrownExceptions =
+ new ASTNode.NodeList(THROWN_EXCEPTIONS_PROPERTY);
+
+ /**
+ * The method body, or <code>null</code> if none.
+ * Defaults to none.
+ */
+ private Block optionalBody = null;
+
+ /**
+ * Creates a new AST node for a method declaration owned
+ * by the given AST. By default, the declaration is for a method of an
+ * unspecified, but legal, name; no modifiers; no javadoc; no type
+ * parameters; void return type; no parameters; no array dimensions after
+ * the parameters; no thrown exceptions; and no body (as opposed to an
+ * empty body).
+ * <p>
+ * N.B. This constructor is package-private; all subclasses must be
+ * declared in the same package; clients are unable to declare
+ * additional subclasses.
+ * </p>
+ *
+ * @param ast the AST that is to own this node
+ */
+ AdviceDeclaration(AST ast) {
+ super(ast);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ * @since 3.0
+ */
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == JAVADOC_PROPERTY) {
+ if (get) {
+ return getJavadoc();
+ } else {
+ setJavadoc((Javadoc) child);
+ return null;
+ }
+ }
+ if (property == POINTCUT_PROPERTY) {
+ if (get) {
+ return getPointcut();
+ } else {
+ setPointcut((PointcutDesignator) child);
+ return null;
+ }
+ }
+ if (property == BODY_PROPERTY) {
+ if (get) {
+ return getBody();
+ } else {
+ setBody((Block) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ List internalGetChildListProperty(ChildListPropertyDescriptor property) {
+ if (property == PARAMETERS_PROPERTY) {
+ return parameters();
+ }
+ if (property == THROWN_EXCEPTIONS_PROPERTY) {
+ return thrownExceptions();
+ }
+ // allow default implementation to flag the error
+ return super.internalGetChildListProperty(property);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on BodyDeclaration.
+ */
+ final ChildPropertyDescriptor internalJavadocProperty() {
+ return JAVADOC_PROPERTY;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final int getNodeType0() {
+ return METHOD_DECLARATION; // ajh02: should add one like ADVICE_DECLARATION or something
+ }
+
+ public PointcutDesignator getPointcut(){
+ return pointcut;
+ }
+ public void setPointcut(PointcutDesignator pointcut) {
+ if (pointcut == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.pointcut;
+ preReplaceChild(oldChild, pointcut, POINTCUT_PROPERTY);
+ this.pointcut = pointcut;
+ postReplaceChild(oldChild, pointcut, POINTCUT_PROPERTY);
+ }
+
+
+ /**
+ * Returns the live ordered list of method parameter declarations for this
+ * method declaration.
+ *
+ * @return the live list of method parameter declarations
+ * (element type: <code>SingleVariableDeclaration</code>)
+ */
+ public List parameters() {
+ return this.parameters;
+ }
+
+ /**
+ * Returns the live ordered list of thrown exception names in this method
+ * declaration.
+ *
+ * @return the live list of exception names
+ * (element type: <code>Name</code>)
+ */
+ public List thrownExceptions() {
+ return this.thrownExceptions;
+ }
+
+ /**
+ * Returns the body of this method declaration, or <code>null</code> if
+ * this method has <b>no</b> body.
+ * <p>
+ * Note that there is a subtle difference between having no body and having
+ * an empty body ("{}").
+ * </p>
+ *
+ * @return the method body, or <code>null</code> if this method has no
+ * body
+ */
+ public Block getBody() {
+ return this.optionalBody;
+ }
+
+ /**
+ * Sets or clears the body of this method declaration.
+ * <p>
+ * Note that there is a subtle difference between having no body
+ * (as in <code>"void foo();"</code>) and having an empty body (as in
+ * "void foo() {}"). Abstract methods, and methods declared in interfaces,
+ * have no body. Non-abstract methods, and all constructors, have a body.
+ * </p>
+ *
+ * @param body the block node, or <code>null</code> if
+ * there is none
+ * @exception IllegalArgumentException if:
+ * <ul>
+ * <li>the node belongs to a different AST</li>
+ * <li>the node already has a parent</li>
+ * <li>a cycle in would be created</li>
+ * </ul>
+ */
+ public void setBody(Block body) {
+ // a MethodDeclaration may occur in a Block - must check cycles
+ ASTNode oldChild = this.optionalBody;
+ preReplaceChild(oldChild, body, BODY_PROPERTY);
+ this.optionalBody = body;
+ postReplaceChild(oldChild, body, BODY_PROPERTY);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ int memSize() {
+ return super.memSize() + 0; // ajh02: stub. I don't know what this is meant to do
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ int treeSize() {
+ return
+ memSize()
+ + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize())
+ + (this.modifiers == null ? 0 : this.modifiers.listSize())
+ + this.parameters.listSize()
+ + this.thrownExceptions.listSize()
+ + (this.pointcut == null ? 0 : getPointcut().treeSize())
+ + (this.optionalBody == null ? 0 : getBody().treeSize());
+ }
+
+ final SimplePropertyDescriptor internalModifiersProperty() {
+ return internalModifiersPropertyFactory(AdviceDeclaration.class); // ajh02: stub method. I don't know what this does
+ }
+ final ChildListPropertyDescriptor internalModifiers2Property() {
+ return internalModifiers2PropertyFactory(AdviceDeclaration.class);// ajh02: stub method. I don't know what this does
+ }
+
+}
+
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterAdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterAdviceDeclaration.java
new file mode 100644
index 000000000..9a128d6df
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterAdviceDeclaration.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+/**
+ * AfterAdviceDeclaration DOM AST node.
+ * @author ajh02
+ */
+
+public class AfterAdviceDeclaration extends AdviceDeclaration {
+
+ AfterAdviceDeclaration(AST ast) {
+ super(ast);
+ }
+
+ ASTNode clone0(AST target) {
+ AfterAdviceDeclaration result = new AfterAdviceDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ result.parameters().addAll(
+ ASTNode.copySubtrees(target, parameters()));
+ result.thrownExceptions().addAll(
+ ASTNode.copySubtrees(target, thrownExceptions()));
+ result.setPointcut(getPointcut());
+ result.setBody(
+ (Block) ASTNode.copySubtree(target, getBody()));
+ return result;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ acceptChildren(visitor, this.parameters);
+ acceptChild(visitor, getPointcut());
+ acceptChildren(visitor, this.thrownExceptions);
+ acceptChild(visitor, getBody());
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterReturningAdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterReturningAdviceDeclaration.java
new file mode 100644
index 000000000..508e80d82
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterReturningAdviceDeclaration.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AfterReturningAdviceDeclaration DOM AST node.
+ * has:
+ * everything an AfterAdviceDeclaration has,
+ * an optional returning property
+ *
+ * It inherits property descriptors from AdviceDeclaration,
+ * but needs to add one for its returning property,
+ * but I can't mix descripters from two different classes in a property list,
+ * so I have to redefine them all here and use
+ * a 'returning' prefix to distinguish them from the ones defined in AdviceDeclaration.
+ * There has to be a better way, but this works.
+ * @author ajh02
+ *
+ */
+
+public class AfterReturningAdviceDeclaration extends AfterAdviceDeclaration {
+
+ public static final ChildPropertyDescriptor returningJAVADOC_PROPERTY =
+ internalJavadocPropertyFactory(AfterReturningAdviceDeclaration.class);
+
+ public static final ChildListPropertyDescriptor returningPARAMETERS_PROPERTY =
+ new ChildListPropertyDescriptor(AfterReturningAdviceDeclaration.class, "parameters", SingleVariableDeclaration.class, CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor returningPOINTCUT_PROPERTY =
+ new ChildPropertyDescriptor(AfterReturningAdviceDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildListPropertyDescriptor returningTHROWN_EXCEPTIONS_PROPERTY =
+ new ChildListPropertyDescriptor(AfterReturningAdviceDeclaration.class, "thrownExceptions", Name.class, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor returningBODY_PROPERTY =
+ new ChildPropertyDescriptor(AfterReturningAdviceDeclaration.class, "body", Block.class, OPTIONAL, CYCLE_RISK); //$NON-NLS-1$
+
+ protected static List returningPROPERTY_DESCRIPTORS_2_0;
+
+ protected static List returningPROPERTY_DESCRIPTORS_3_0;
+
+ public static final ChildPropertyDescriptor returningRETURNING_PROPERTY =
+ new ChildPropertyDescriptor(AfterReturningAdviceDeclaration.class, "returning", SingleVariableDeclaration.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static List propertyDescriptors(int apiLevel) {
+ if (apiLevel == AST.JLS2_INTERNAL) {
+ return returningPROPERTY_DESCRIPTORS_2_0;
+ } else {
+ return returningPROPERTY_DESCRIPTORS_3_0;
+ }
+ }
+
+ static {
+ List propertyList = new ArrayList(6);
+ createPropertyList(AfterReturningAdviceDeclaration.class, propertyList);
+ addProperty(returningJAVADOC_PROPERTY, propertyList);
+ addProperty(returningPARAMETERS_PROPERTY, propertyList);
+ addProperty(returningTHROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(returningPOINTCUT_PROPERTY, propertyList);
+ addProperty(returningRETURNING_PROPERTY, propertyList);
+ addProperty(returningBODY_PROPERTY, propertyList);
+ returningPROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
+
+ propertyList = new ArrayList(6);
+ createPropertyList(AfterReturningAdviceDeclaration.class, propertyList);
+ addProperty(returningJAVADOC_PROPERTY, propertyList);
+ addProperty(returningPARAMETERS_PROPERTY, propertyList);
+ addProperty(returningTHROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(returningPOINTCUT_PROPERTY, propertyList);
+ addProperty(returningRETURNING_PROPERTY, propertyList);
+ addProperty(returningBODY_PROPERTY, propertyList);
+ returningPROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
+ }
+
+ private SingleVariableDeclaration returning = null;
+
+ AfterReturningAdviceDeclaration(AST ast) {
+ super(ast);
+ }
+
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == returningRETURNING_PROPERTY) {
+ if (get) {
+ return getReturning();
+ } else {
+ setReturning((SingleVariableDeclaration) child);
+ return null;
+ }
+ }
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ public SingleVariableDeclaration getReturning() {
+ return returning;
+ }
+
+ public void setReturning(SingleVariableDeclaration returning) {
+ this.returning = returning;
+ }
+
+ ASTNode clone0(AST target) {
+ AfterReturningAdviceDeclaration result = new AfterReturningAdviceDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ result.parameters().addAll(
+ ASTNode.copySubtrees(target, parameters()));
+ result.setPointcut(getPointcut());
+ result.setReturning(returning);
+ result.thrownExceptions().addAll(
+ ASTNode.copySubtrees(target, thrownExceptions()));
+ result.setBody(
+ (Block) ASTNode.copySubtree(target, getBody()));
+ return result;
+ }
+
+ int treeSize() {
+ return
+ super.treeSize()
+ + (this.returning == null ? 0 : this.returning.treeSize());
+ }
+
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ acceptChildren(visitor, this.parameters);
+ acceptChild(visitor, getPointcut());
+ acceptChild(visitor, getReturning());
+ acceptChildren(visitor, this.thrownExceptions);
+ acceptChild(visitor, getBody());
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterThrowingAdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterThrowingAdviceDeclaration.java
new file mode 100644
index 000000000..9d62d92b9
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AfterThrowingAdviceDeclaration.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AfterThrowingAdviceDeclaration DOM AST node.
+ * has:
+ * everything an AfterAdviceDeclaration has,
+ * an optional throwing property
+ *
+ * It inherits property descriptors from AdviceDeclaration,
+ * but needs to add one for its throwing property,
+ * but I can't mix descripters from two different classes in a property list,
+ * so I have to redefine them all here and use
+ * a 'throwing' prefix to distinguish them from the ones defined in AdviceDeclaration.
+ * There has to be a better way, but this works.
+ * @author ajh02
+ *
+ */
+public class AfterThrowingAdviceDeclaration extends AfterAdviceDeclaration {
+
+ public static final ChildPropertyDescriptor throwingJAVADOC_PROPERTY =
+ internalJavadocPropertyFactory(AfterThrowingAdviceDeclaration.class);
+
+ public static final ChildListPropertyDescriptor throwingPARAMETERS_PROPERTY =
+ new ChildListPropertyDescriptor(AfterThrowingAdviceDeclaration.class, "parameters", SingleVariableDeclaration.class, CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor throwingPOINTCUT_PROPERTY =
+ new ChildPropertyDescriptor(AfterThrowingAdviceDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildListPropertyDescriptor throwingTHROWN_EXCEPTIONS_PROPERTY =
+ new ChildListPropertyDescriptor(AfterThrowingAdviceDeclaration.class, "thrownExceptions", Name.class, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor throwingBODY_PROPERTY =
+ new ChildPropertyDescriptor(AfterThrowingAdviceDeclaration.class, "body", Block.class, OPTIONAL, CYCLE_RISK); //$NON-NLS-1$
+
+ protected static List throwingPROPERTY_DESCRIPTORS_2_0;
+
+ protected static List throwingPROPERTY_DESCRIPTORS_3_0;
+
+ public static final ChildPropertyDescriptor throwingTHROWING_PROPERTY =
+ new ChildPropertyDescriptor(AfterThrowingAdviceDeclaration.class, "throwing", SingleVariableDeclaration.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static List propertyDescriptors(int apiLevel) {
+ if (apiLevel == AST.JLS2_INTERNAL) {
+ return throwingPROPERTY_DESCRIPTORS_2_0;
+ } else {
+ return throwingPROPERTY_DESCRIPTORS_3_0;
+ }
+ }
+
+ static {
+ List propertyList = new ArrayList(6);
+ createPropertyList(AfterThrowingAdviceDeclaration.class, propertyList);
+ addProperty(throwingJAVADOC_PROPERTY, propertyList);
+ addProperty(throwingPARAMETERS_PROPERTY, propertyList);
+ addProperty(throwingTHROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(throwingPOINTCUT_PROPERTY, propertyList);
+ addProperty(throwingTHROWING_PROPERTY, propertyList);
+ addProperty(throwingBODY_PROPERTY, propertyList);
+ throwingPROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
+
+ propertyList = new ArrayList(6);
+ createPropertyList(AfterThrowingAdviceDeclaration.class, propertyList);
+ addProperty(throwingJAVADOC_PROPERTY, propertyList);
+ addProperty(throwingPARAMETERS_PROPERTY, propertyList);
+ addProperty(throwingTHROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(throwingPOINTCUT_PROPERTY, propertyList);
+ addProperty(throwingTHROWING_PROPERTY, propertyList);
+ addProperty(throwingBODY_PROPERTY, propertyList);
+ throwingPROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
+ }
+
+ private SingleVariableDeclaration throwing = null;
+
+ AfterThrowingAdviceDeclaration(AST ast) {
+ super(ast);
+ }
+
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == throwingTHROWING_PROPERTY) {
+ if (get) {
+ return getThrowing();
+ } else {
+ setThrowing((SingleVariableDeclaration) child);
+ return null;
+ }
+ }
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ public SingleVariableDeclaration getThrowing() {
+ return throwing;
+ }
+
+ public void setThrowing(SingleVariableDeclaration throwing) {
+ this.throwing = throwing;
+ }
+
+ ASTNode clone0(AST target) {
+ AfterThrowingAdviceDeclaration result = new AfterThrowingAdviceDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ result.parameters().addAll(
+ ASTNode.copySubtrees(target, parameters()));
+ result.setPointcut(getPointcut());
+ result.setThrowing(throwing);
+ result.thrownExceptions().addAll(
+ ASTNode.copySubtrees(target, thrownExceptions()));
+ result.setBody(
+ (Block) ASTNode.copySubtree(target, getBody()));
+ return result;
+ }
+
+ int treeSize() {
+ return
+ super.treeSize()
+ + (this.throwing == null ? 0 : this.throwing.treeSize());
+ }
+
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ acceptChildren(visitor, this.parameters);
+ acceptChild(visitor, getPointcut());
+ acceptChild(visitor, getThrowing());
+ acceptChildren(visitor, this.thrownExceptions);
+ acceptChild(visitor, getBody());
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
new file mode 100644
index 000000000..e98d2f73f
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
@@ -0,0 +1,4356 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeConstructorDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
+import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
+import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
+import org.aspectj.org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.aspectj.org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocArgumentExpression;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocFieldReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Wildcard;
+import org.aspectj.org.eclipse.jdt.internal.compiler.env.IConstants;
+import org.aspectj.org.eclipse.jdt.internal.compiler.env.IGenericType;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.aspectj.org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+import org.aspectj.weaver.AdviceKind;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Internal class for converting internal compiler ASTs into public ASTs.
+ */
+public class AjASTConverter extends ASTConverter {
+
+
+ public AjASTConverter(Map options, boolean resolveBindings, IProgressMonitor monitor) {
+ super(options,resolveBindings,monitor);
+ }
+
+
+
+ public ASTNode convert(AdviceDeclaration adviceDeclaration){
+ // ajh02: method added
+ org.aspectj.org.eclipse.jdt.core.dom.AdviceDeclaration adviceDecl = null;
+ if (adviceDeclaration.kind.equals(AdviceKind.Before)){
+ adviceDecl = new org.aspectj.org.eclipse.jdt.core.dom.BeforeAdviceDeclaration(this.ast);
+ } else if (adviceDeclaration.kind.equals(AdviceKind.After)){
+ adviceDecl = new org.aspectj.org.eclipse.jdt.core.dom.AfterAdviceDeclaration(this.ast);
+ } else if (adviceDeclaration.kind.equals(AdviceKind.AfterThrowing)){
+ adviceDecl = new AfterThrowingAdviceDeclaration(this.ast);
+ SingleVariableDeclaration throwing = convert(adviceDeclaration.extraArgument);
+ ((AfterThrowingAdviceDeclaration)adviceDecl).setThrowing(throwing);
+ } else if (adviceDeclaration.kind.equals(AdviceKind.AfterReturning)){
+ adviceDecl = new AfterReturningAdviceDeclaration(this.ast);
+ SingleVariableDeclaration returning = convert(adviceDeclaration.extraArgument);
+ ((AfterReturningAdviceDeclaration)adviceDecl).setReturning(returning);
+ } else if (adviceDeclaration.kind.equals(AdviceKind.Around)){
+ adviceDecl = new AroundAdviceDeclaration(this.ast);
+ // set the returnType
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = adviceDeclaration.returnType;
+ if (typeReference != null) {
+ Type returnType = convertType(typeReference);
+ // get the positions of the right parenthesis
+ setTypeForAroundAdviceDeclaration((AroundAdviceDeclaration)adviceDecl, returnType);
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = adviceDeclaration.typeParameters();
+ if (typeParameters != null) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ adviceDecl.setFlags(adviceDecl.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ for (int i = 0, max = typeParameters.length; i < max; i++) {
+ ((AroundAdviceDeclaration)adviceDecl).typeParameters().add(convert(typeParameters[i]));
+ }
+ }
+ }
+ }
+// set its javadoc, parameters, throws, pointcut and body
+ org.aspectj.weaver.patterns.Pointcut pointcut = adviceDeclaration.pointcutDesignator.getPointcut();
+ adviceDecl.setPointcut(convert(pointcut));
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = adviceDeclaration.thrownExceptions;
+ if (thrownExceptions != null) {
+ int thrownExceptionsLength = thrownExceptions.length;
+ for (int i = 0; i < thrownExceptionsLength; i++) {
+ adviceDecl.thrownExceptions().add(convert(thrownExceptions[i]));
+ }
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = adviceDeclaration.arguments;
+ if (parameters != null) {
+ int parametersLength = parameters.length;
+ for (int i = 0; i < parametersLength; i++) {
+ adviceDecl.parameters().add(convert(parameters[i]));
+ }
+ }
+ int start = adviceDeclaration.sourceStart;
+ int end = retrieveIdentifierEndPosition(start, adviceDeclaration.sourceEnd);
+
+ int declarationSourceStart = adviceDeclaration.declarationSourceStart;
+ int declarationSourceEnd = adviceDeclaration.bodyEnd;
+ adviceDecl.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
+ int closingPosition = retrieveRightBraceOrSemiColonPosition(adviceDeclaration.bodyEnd + 1, adviceDeclaration.declarationSourceEnd);
+ if (closingPosition != -1) {
+ int startPosition = adviceDecl.getStartPosition();
+ adviceDecl.setSourceRange(startPosition, closingPosition - startPosition + 1);
+
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = adviceDeclaration.statements;
+
+ start = retrieveStartBlockPosition(adviceDeclaration.sourceStart, declarationSourceEnd);
+ end = retrieveEndBlockPosition(adviceDeclaration.sourceStart, adviceDeclaration.declarationSourceEnd);
+ Block block = null;
+ if (start != -1 && end != -1) {
+ /*
+ * start or end can be equal to -1 if we have an interface's method.
+ */
+ block = new Block(this.ast);
+ block.setSourceRange(start, end - start + 1);
+ adviceDecl.setBody(block);
+ }
+ if (block != null && statements != null) {
+ int statementsLength = statements == null ? 0 : statements.length;
+ for (int i = 0; i < statementsLength; i++) {
+ if (statements[i] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
+ checkAndAddMultipleLocalDeclaration(statements, i, block.statements());
+ } else {
+ block.statements().add(convert(statements[i]));
+ }
+ }
+ }
+ if (block != null) {
+ adviceDecl.setFlags(adviceDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ } else {
+ // syntax error in this advice declaration
+ start = retrieveStartBlockPosition(adviceDeclaration.sourceStart, declarationSourceEnd);
+ end = adviceDeclaration.bodyEnd;
+ // try to get the best end position
+ IProblem[] problems = adviceDeclaration.compilationResult().problems;
+ if (problems != null) {
+ for (int i = 0, max = adviceDeclaration.compilationResult().problemCount; i < max; i++) {
+ IProblem currentProblem = problems[i];
+ if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) {
+ end = currentProblem.getSourceEnd();
+ break;
+ }
+ }
+ }
+ int startPosition = adviceDecl.getStartPosition();
+ adviceDecl.setSourceRange(startPosition, end - startPosition + 1);
+ if (start != -1 && end != -1) {
+ /*
+ * start or end can be equal to -1 if we have an interface's method.
+ */
+ Block block = new Block(this.ast);
+ block.setSourceRange(start, end - start + 1);
+ adviceDecl.setBody(block);
+ }
+ }
+
+ // The javadoc comment is now got from list store in compilation unit declaration
+ if (this.resolveBindings) {
+ recordNodes(adviceDecl, adviceDeclaration);
+ //if (adviceDecl.resolveBinding() != null) {
+ //// ajh02: what is resolveBinding()?
+ // convert(adviceDeclaration.javadoc, adviceDecl);
+ //}
+ } else {
+ convert(adviceDeclaration.javadoc, adviceDecl);
+ }
+ return adviceDecl;
+ }
+
+ public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration methodDeclaration) {
+ checkCanceled();
+ if (methodDeclaration instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) methodDeclaration);
+ }
+ MethodDeclaration methodDecl = new MethodDeclaration(this.ast);
+ setModifiers(methodDecl, methodDeclaration);
+ boolean isConstructor = methodDeclaration.isConstructor();
+ methodDecl.setConstructor(isConstructor);
+
+ ////////////////// ajh02: added. ugh, polymorphism! Where are you!
+ if (methodDeclaration instanceof DeclareDeclaration){
+ return convert((DeclareDeclaration)methodDeclaration);
+ } else if (methodDeclaration instanceof InterTypeFieldDeclaration){
+ return convert((InterTypeFieldDeclaration) methodDeclaration);
+ } else if (methodDeclaration instanceof InterTypeMethodDeclaration){
+ methodDecl = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration(this.ast);
+ } else if (methodDeclaration instanceof InterTypeConstructorDeclaration){
+ methodDecl = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration(this.ast);
+ methodDecl.setConstructor(true);
+ } else if (methodDeclaration instanceof PointcutDeclaration){
+ return convert((PointcutDeclaration) methodDeclaration);
+ } else if (methodDeclaration instanceof AdviceDeclaration){
+ return convert((AdviceDeclaration)methodDeclaration);
+ }
+ /////////////////////////
+
+ final SimpleName methodName = new SimpleName(this.ast);
+ methodName.internalSetIdentifier(new String(methodDeclaration.selector));
+ int start = methodDeclaration.sourceStart;
+ int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
+ methodName.setSourceRange(start, end - start + 1);
+ methodDecl.setName(methodName);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
+ if (thrownExceptions != null) {
+ int thrownExceptionsLength = thrownExceptions.length;
+ for (int i = 0; i < thrownExceptionsLength; i++) {
+ methodDecl.thrownExceptions().add(convert(thrownExceptions[i]));
+ }
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = methodDeclaration.arguments;
+ if (parameters != null) {
+ int parametersLength = parameters.length;
+ for (int i = 0; i < parametersLength; i++) {
+ methodDecl.parameters().add(convert(parameters[i]));
+ }
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall explicitConstructorCall = null;
+ if (isConstructor) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration constructorDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration) methodDeclaration;
+ explicitConstructorCall = constructorDeclaration.constructorCall;
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ // set the return type to VOID
+ PrimitiveType returnType = new PrimitiveType(this.ast);
+ returnType.setPrimitiveTypeCode(PrimitiveType.VOID);
+ returnType.setSourceRange(methodDeclaration.sourceStart, 0);
+ methodDecl.internalSetReturnType(returnType);
+ break;
+ case AST.JLS3 :
+ methodDecl.setReturnType2(null);
+ }
+ } else if (methodDeclaration instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration method = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) methodDeclaration;
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = method.returnType;
+ if (typeReference != null) {
+ Type returnType = convertType(typeReference);
+ // get the positions of the right parenthesis
+ int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition(end, method.bodyEnd);
+ int extraDimensions = retrieveExtraDimension(rightParenthesisPosition, method.bodyEnd);
+ methodDecl.setExtraDimensions(extraDimensions);
+ setTypeForMethodDeclaration(methodDecl, returnType, extraDimensions);
+ }
+ }
+ int declarationSourceStart = methodDeclaration.declarationSourceStart;
+ int declarationSourceEnd = methodDeclaration.bodyEnd;
+ methodDecl.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
+ int closingPosition = retrieveRightBraceOrSemiColonPosition(methodDeclaration.bodyEnd + 1, methodDeclaration.declarationSourceEnd);
+ if (closingPosition != -1) {
+ int startPosition = methodDecl.getStartPosition();
+ methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1);
+
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = methodDeclaration.statements;
+
+ start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd);
+ end = retrieveEndBlockPosition(methodDeclaration.sourceStart, methodDeclaration.declarationSourceEnd);
+ Block block = null;
+ if (start != -1 && end != -1) {
+ /*
+ * start or end can be equal to -1 if we have an interface's method.
+ */
+ block = new Block(this.ast);
+ block.setSourceRange(start, end - start + 1);
+ methodDecl.setBody(block);
+ }
+ if (block != null && (statements != null || explicitConstructorCall != null)) {
+ if (explicitConstructorCall != null && explicitConstructorCall.accessMode != org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.ImplicitSuper) {
+ block.statements().add(convert(explicitConstructorCall));
+ }
+ int statementsLength = statements == null ? 0 : statements.length;
+ for (int i = 0; i < statementsLength; i++) {
+ if (statements[i] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
+ checkAndAddMultipleLocalDeclaration(statements, i, block.statements());
+ } else {
+ block.statements().add(convert(statements[i]));
+ }
+ }
+ }
+ if (block != null && (Modifier.isAbstract(methodDecl.getModifiers()) || Modifier.isNative(methodDecl.getModifiers()))) {
+ methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ } else {
+ // syntax error in this method declaration
+ if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract()) {
+ start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd);
+ end = methodDeclaration.bodyEnd;
+ // try to get the best end position
+ IProblem[] problems = methodDeclaration.compilationResult().problems;
+ if (problems != null) {
+ for (int i = 0, max = methodDeclaration.compilationResult().problemCount; i < max; i++) {
+ IProblem currentProblem = problems[i];
+ if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) {
+ end = currentProblem.getSourceEnd();
+ break;
+ }
+ }
+ }
+ int startPosition = methodDecl.getStartPosition();
+ methodDecl.setSourceRange(startPosition, end - startPosition + 1);
+ if (start != -1 && end != -1) {
+ /*
+ * start or end can be equal to -1 if we have an interface's method.
+ */
+ Block block = new Block(this.ast);
+ block.setSourceRange(start, end - start + 1);
+ methodDecl.setBody(block);
+ }
+ }
+ }
+
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = methodDeclaration.typeParameters();
+ if (typeParameters != null) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ for (int i = 0, max = typeParameters.length; i < max; i++) {
+ methodDecl.typeParameters().add(convert(typeParameters[i]));
+ }
+ }
+ }
+
+ // The javadoc comment is now got from list store in compilation unit declaration
+ if (this.resolveBindings) {
+ recordNodes(methodDecl, methodDeclaration);
+ recordNodes(methodName, methodDeclaration);
+ if (methodDecl.resolveBinding() != null) {
+ convert(methodDeclaration.javadoc, methodDecl);
+ }
+ } else {
+ convert(methodDeclaration.javadoc, methodDecl);
+ }
+ return methodDecl;
+ }
+
+
+ public ASTNode convert(DeclareDeclaration declareDecl) {
+ // ajh02: method added
+ checkCanceled(); // ajh02: is this line needed?
+ final org.aspectj.org.eclipse.jdt.core.dom.DeclareDeclaration declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareDeclaration(this.ast,declareDecl.declareDecl);
+ return declareDeclaration;
+ }
+ public ASTNode convert(InterTypeFieldDeclaration fieldDecl) {
+ // ajh02: method added
+ checkCanceled(); // ajh02: is this line needed?
+ VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(fieldDecl);
+ final org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration fieldDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration(this.ast);
+ fieldDeclaration.fragments().add(variableDeclarationFragment);
+ IVariableBinding binding = null;
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, fieldDecl);
+ binding = variableDeclarationFragment.resolveBinding();
+ }
+ fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStart, fieldDecl.declarationSourceEnd - fieldDecl.declarationSourceStart + 1);
+ Type type = convertType(fieldDecl.returnType);
+ setTypeForField(fieldDeclaration, type, variableDeclarationFragment.getExtraDimensions());
+ setModifiers(fieldDeclaration, fieldDecl);
+ if (!(this.resolveBindings && binding == null)) {
+ convert(fieldDecl.javadoc, fieldDeclaration);
+ }
+ return fieldDeclaration;
+ }
+ public ASTNode convert(PointcutDeclaration pointcutDeclaration) {
+ // ajh02: method added
+ checkCanceled();
+ org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration pointcutDecl = new org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration(this.ast);
+ setModifiers(pointcutDecl, pointcutDeclaration);
+ final SimpleName pointcutName = new SimpleName(this.ast);
+ pointcutName.internalSetIdentifier(new String(pointcutDeclaration.selector));
+ int start = pointcutDeclaration.sourceStart;
+ int end = retrieveIdentifierEndPosition(start, pointcutDeclaration.sourceEnd);
+ pointcutName.setSourceRange(start, end - start + 1);
+ pointcutDecl.setSourceRange(pointcutDeclaration.declarationSourceStart, (pointcutDeclaration.bodyEnd - pointcutDeclaration.declarationSourceStart + 1));
+ pointcutDecl.setName(pointcutName);
+ if (pointcutDeclaration.pointcutDesignator != null){
+ pointcutDecl.setDesignator((org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator)convert(pointcutDeclaration.pointcutDesignator.getPointcut()));
+ } else {
+ pointcutDecl.setDesignator(new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast,pointcutDeclaration.toString()));
+ }
+// The javadoc comment is now got from list store in compilation unit declaration
+ if (this.resolveBindings) {
+ recordNodes(pointcutDecl, pointcutDeclaration);
+ recordNodes(pointcutName, pointcutDeclaration);
+ } else {
+ convert(pointcutDeclaration.javadoc, pointcutDecl);
+ }
+ return pointcutDecl;
+ }
+ public org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator convert(org.aspectj.weaver.patterns.Pointcut pointcut){
+ // ajh02: this could do with being seperate methods
+ // rather than a huge if.elseif..elseif.. thing
+ org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator pointcutDesi = null;
+ if (pointcut instanceof org.aspectj.weaver.patterns.ReferencePointcut){
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.ReferencePointcut(this.ast);
+ final SimpleName pointcutName = new SimpleName(this.ast);
+ int start = pointcut.getStart();
+ int end = retrieveIdentifierEndPosition(start, pointcut.getEnd());
+ pointcutName.setSourceRange(start, end - start + 1);
+ pointcutName.internalSetIdentifier(((org.aspectj.weaver.patterns.ReferencePointcut)pointcut).name);
+ ((org.aspectj.org.eclipse.jdt.core.dom.ReferencePointcut)pointcutDesi).setName(pointcutName);
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.NotPointcut) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.NotPointcut(this.ast);
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.NotPointcut)pointcut).getNegatedPointcut());
+ ((org.aspectj.org.eclipse.jdt.core.dom.NotPointcut)pointcutDesi).setBody(body);
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.PerObject) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.PerObject(this.ast);
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.PerObject)pointcut).getEntry());
+ ((org.aspectj.org.eclipse.jdt.core.dom.PerObject)pointcutDesi).setBody(body);
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.PerCflow) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.PerCflow(this.ast);
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.PerCflow)pointcut).getEntry());
+ ((org.aspectj.org.eclipse.jdt.core.dom.PerCflow)pointcutDesi).setBody(body);
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.PerTypeWithin) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.PerTypeWithin(this.ast);
+ // should set its type pattern here
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.CflowPointcut) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut(this.ast);
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator body = convert(((org.aspectj.weaver.patterns.CflowPointcut)pointcut).getEntry());
+ ((org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut)pointcutDesi).setBody(body);
+ ((org.aspectj.org.eclipse.jdt.core.dom.CflowPointcut)pointcutDesi).setIsCflowBelow(((org.aspectj.weaver.patterns.CflowPointcut)pointcut).isCflowBelow());
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.AndPointcut) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.AndPointcut(this.ast);
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator left = convert(((org.aspectj.weaver.patterns.AndPointcut)pointcut).getLeft());
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator right = convert(((org.aspectj.weaver.patterns.AndPointcut)pointcut).getRight());
+ ((org.aspectj.org.eclipse.jdt.core.dom.AndPointcut)pointcutDesi).setLeft(left);
+ ((org.aspectj.org.eclipse.jdt.core.dom.AndPointcut)pointcutDesi).setRight(right);
+ } else if (pointcut instanceof org.aspectj.weaver.patterns.OrPointcut) {
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.OrPointcut(this.ast);
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator left = convert(((org.aspectj.weaver.patterns.OrPointcut)pointcut).getLeft());
+ final org.aspectj.org.eclipse.jdt.core.dom.PointcutDesignator right = convert(((org.aspectj.weaver.patterns.OrPointcut)pointcut).getRight());
+ ((org.aspectj.org.eclipse.jdt.core.dom.OrPointcut)pointcutDesi).setLeft(left);
+ ((org.aspectj.org.eclipse.jdt.core.dom.OrPointcut)pointcutDesi).setRight(right);
+ } else {
+ // ajh02: default stub until I make all the concrete PointcutDesignator types
+ pointcutDesi = new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast,pointcut.toString());
+ }
+ pointcutDesi.setSourceRange(pointcut.getStart(),(pointcut.getEnd() - pointcut.getStart() + 1));
+ return pointcutDesi;
+ }
+
+ public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
+ checkCanceled();
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ return null;
+ }
+ AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration2 = new AnnotationTypeMemberDeclaration(this.ast);
+ setModifiers(annotationTypeMemberDeclaration2, annotationTypeMemberDeclaration);
+ final SimpleName methodName = new SimpleName(this.ast);
+ methodName.internalSetIdentifier(new String(annotationTypeMemberDeclaration.selector));
+ int start = annotationTypeMemberDeclaration.sourceStart;
+ int end = retrieveIdentifierEndPosition(start, annotationTypeMemberDeclaration.sourceEnd);
+ methodName.setSourceRange(start, end - start + 1);
+ annotationTypeMemberDeclaration2.setName(methodName);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = annotationTypeMemberDeclaration.returnType;
+ if (typeReference != null) {
+ Type returnType = convertType(typeReference);
+ setTypeForMethodDeclaration(annotationTypeMemberDeclaration2, returnType, 0);
+ }
+ int declarationSourceStart = annotationTypeMemberDeclaration.declarationSourceStart;
+ int declarationSourceEnd = annotationTypeMemberDeclaration.bodyEnd;
+ annotationTypeMemberDeclaration2.setSourceRange(declarationSourceStart, declarationSourceEnd - declarationSourceStart + 1);
+ // The javadoc comment is now got from list store in compilation unit declaration
+ convert(annotationTypeMemberDeclaration.javadoc, annotationTypeMemberDeclaration2);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression memberValue = annotationTypeMemberDeclaration.defaultValue;
+ if (memberValue != null) {
+ annotationTypeMemberDeclaration2.setDefault(convert(memberValue));
+ }
+ if (this.resolveBindings) {
+ recordNodes(annotationTypeMemberDeclaration2, annotationTypeMemberDeclaration);
+ recordNodes(methodName, annotationTypeMemberDeclaration);
+ annotationTypeMemberDeclaration2.resolveBinding();
+ }
+ return annotationTypeMemberDeclaration2;
+ }
+
+ public SingleVariableDeclaration convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument argument) {
+ SingleVariableDeclaration variableDecl = new SingleVariableDeclaration(this.ast);
+ setModifiers(variableDecl, argument);
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(argument.name));
+ int start = argument.sourceStart;
+ int nameEnd = argument.sourceEnd;
+ name.setSourceRange(start, nameEnd - start + 1);
+ variableDecl.setName(name);
+ final int typeSourceEnd = argument.type.sourceEnd;
+ final int extraDimensions = retrieveExtraDimension(nameEnd + 1, typeSourceEnd);
+ variableDecl.setExtraDimensions(extraDimensions);
+ final boolean isVarArgs = argument.isVarArgs();
+ if (isVarArgs && extraDimensions == 0) {
+ // remove the ellipsis from the type source end
+ argument.type.sourceEnd = retrieveEllipsisStartPosition(argument.type.sourceStart, typeSourceEnd);
+ }
+ Type type = convertType(argument.type);
+ int typeEnd = type.getStartPosition() + type.getLength() - 1;
+ int rightEnd = Math.max(typeEnd, argument.declarationSourceEnd);
+ /*
+ * There is extra work to do to set the proper type positions
+ * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284
+ */
+ if (isVarArgs) {
+ setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions + 1);
+ if (extraDimensions != 0) {
+ variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ } else {
+ setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions);
+ }
+ variableDecl.setSourceRange(argument.declarationSourceStart, rightEnd - argument.declarationSourceStart + 1);
+
+ if (isVarArgs) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ variableDecl.setVarargs(true);
+ }
+ }
+ if (this.resolveBindings) {
+ recordNodes(name, argument);
+ recordNodes(variableDecl, argument);
+ variableDecl.resolveBinding();
+ }
+ return variableDecl;
+ }
+
+
+ public Annotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation) {
+ if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) annotation);
+ } else if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation) annotation);
+ } else {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation) annotation);
+ }
+ }
+
+ public ArrayCreation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression expression) {
+ ArrayCreation arrayCreation = new ArrayCreation(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(arrayCreation, expression);
+ }
+ arrayCreation.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] dimensions = expression.dimensions;
+
+ int dimensionsLength = dimensions.length;
+ for (int i = 0; i < dimensionsLength; i++) {
+ if (dimensions[i] != null) {
+ Expression dimension = convert(dimensions[i]);
+ if (this.resolveBindings) {
+ recordNodes(dimension, dimensions[i]);
+ }
+ arrayCreation.dimensions().add(dimension);
+ }
+ }
+ Type type = convertType(expression.type);
+ if (this.resolveBindings) {
+ recordNodes(type, expression.type);
+ }
+ ArrayType arrayType = null;
+ if (type.isArrayType()) {
+ arrayType = (ArrayType) type;
+ } else {
+ arrayType = this.ast.newArrayType(type, dimensionsLength);
+ if (this.resolveBindings) {
+ completeRecord(arrayType, expression);
+ }
+ int start = type.getStartPosition();
+ int end = type.getStartPosition() + type.getLength();
+ int previousSearchStart = end;
+ ArrayType componentType = (ArrayType) type.getParent();
+ for (int i = 0; i < dimensionsLength; i++) {
+ previousSearchStart = retrieveRightBracketPosition(previousSearchStart + 1, this.compilationUnitSourceLength);
+ componentType.setSourceRange(start, previousSearchStart - start + 1);
+ componentType = (ArrayType) componentType.getParent();
+ }
+ }
+ arrayCreation.setType(arrayType);
+ if (this.resolveBindings) {
+ recordNodes(arrayType, expression);
+ }
+ if (expression.initializer != null) {
+ arrayCreation.setInitializer(convert(expression.initializer));
+ }
+ return arrayCreation;
+ }
+
+ public ArrayInitializer convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer expression) {
+ ArrayInitializer arrayInitializer = new ArrayInitializer(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(arrayInitializer, expression);
+ }
+ arrayInitializer.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] expressions = expression.expressions;
+ if (expressions != null) {
+ int length = expressions.length;
+ for (int i = 0; i < length; i++) {
+ Expression expr = convert(expressions[i]);
+ if (this.resolveBindings) {
+ recordNodes(expr, expressions[i]);
+ }
+ arrayInitializer.expressions().add(expr);
+ }
+ }
+ return arrayInitializer;
+ }
+
+ public ArrayAccess convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference reference) {
+ ArrayAccess arrayAccess = new ArrayAccess(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(arrayAccess, reference);
+ }
+ arrayAccess.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1);
+ arrayAccess.setArray(convert(reference.receiver));
+ arrayAccess.setIndex(convert(reference.position));
+ return arrayAccess;
+ }
+
+ public AssertStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement statement) {
+ AssertStatement assertStatement = new AssertStatement(this.ast);
+ int end = statement.assertExpression.sourceEnd + 1;
+ assertStatement.setExpression(convert(statement.assertExpression));
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression exceptionArgument = statement.exceptionArgument;
+ if (exceptionArgument != null) {
+ end = exceptionArgument.sourceEnd + 1;
+ assertStatement.setMessage(convert(exceptionArgument));
+ }
+ int start = statement.sourceStart;
+ int sourceEnd = retrieveEndingSemiColonPosition(end, this.compilationUnitSourceLength);
+ assertStatement.setSourceRange(start, sourceEnd - start + 1);
+ return assertStatement;
+ }
+
+ public Assignment convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment expression) {
+ Assignment assignment = new Assignment(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(assignment, expression);
+ }
+ Expression lhs = convert(expression.lhs);
+ assignment.setLeftHandSide(lhs);
+ assignment.setOperator(Assignment.Operator.ASSIGN);
+ assignment.setRightHandSide(convert(expression.expression));
+ int start = lhs.getStartPosition();
+ assignment.setSourceRange(start, expression.sourceEnd - start + 1);
+ return assignment;
+ }
+
+ /*
+ * Internal use only
+ * Used to convert class body declarations
+ */
+ public TypeDeclaration convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode[] nodes) {
+ final TypeDeclaration typeDecl = TypeDeclaration.getTypeDeclaration(this.ast);
+ typeDecl.setInterface(false);
+ int nodesLength = nodes.length;
+ for (int i = 0; i < nodesLength; i++) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodes[i];
+ if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer) node;
+ Initializer initializer = new Initializer(this.ast);
+ initializer.setBody(convert(oldInitializer.block));
+ setModifiers(initializer, oldInitializer);
+ initializer.setSourceRange(oldInitializer.declarationSourceStart, oldInitializer.sourceEnd - oldInitializer.declarationSourceStart + 1);
+// setJavaDocComment(initializer);
+// initializer.setJavadoc(convert(oldInitializer.javadoc));
+ convert(oldInitializer.javadoc, initializer);
+ typeDecl.bodyDeclarations().add(initializer);
+ } else if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node;
+ if (i > 0
+ && (nodes[i - 1] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)
+ && ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration)nodes[i - 1]).declarationSourceStart == fieldDeclaration.declarationSourceStart) {
+ // we have a multiple field declaration
+ // We retrieve the existing fieldDeclaration to add the new VariableDeclarationFragment
+ FieldDeclaration currentFieldDeclaration = (FieldDeclaration) typeDecl.bodyDeclarations().get(typeDecl.bodyDeclarations().size() - 1);
+ currentFieldDeclaration.fragments().add(convertToVariableDeclarationFragment(fieldDeclaration));
+ } else {
+ // we can create a new FieldDeclaration
+ typeDecl.bodyDeclarations().add(convertToFieldDeclaration(fieldDeclaration));
+ }
+ } else if(node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration) {
+ AbstractMethodDeclaration nextMethodDeclaration = (AbstractMethodDeclaration) node;
+ if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
+ typeDecl.bodyDeclarations().add(convert(nextMethodDeclaration));
+ }
+ } else if(node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node;
+ ASTNode nextMemberDeclarationNode = convert(nextMemberDeclaration);
+ if (nextMemberDeclarationNode == null) {
+ typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
+ } else {
+ typeDecl.bodyDeclarations().add(nextMemberDeclarationNode);
+ }
+ }
+ }
+ return typeDecl;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression expression) {
+ InfixExpression infixExpression = new InfixExpression(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(infixExpression, expression);
+ }
+
+ int expressionOperatorID = (expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
+ switch (expressionOperatorID) {
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL :
+ infixExpression.setOperator(InfixExpression.Operator.EQUALS);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL :
+ infixExpression.setOperator(InfixExpression.Operator.LESS_EQUALS);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL :
+ infixExpression.setOperator(InfixExpression.Operator.GREATER_EQUALS);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL :
+ infixExpression.setOperator(InfixExpression.Operator.NOT_EQUALS);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT :
+ infixExpression.setOperator(InfixExpression.Operator.LEFT_SHIFT);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT :
+ infixExpression.setOperator(InfixExpression.Operator.RIGHT_SHIFT_SIGNED);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT :
+ infixExpression.setOperator(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR :
+ infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND :
+ infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
+ infixExpression.setOperator(InfixExpression.Operator.PLUS);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
+ infixExpression.setOperator(InfixExpression.Operator.MINUS);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER :
+ infixExpression.setOperator(InfixExpression.Operator.REMAINDER);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR :
+ infixExpression.setOperator(InfixExpression.Operator.XOR);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND :
+ infixExpression.setOperator(InfixExpression.Operator.AND);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY :
+ infixExpression.setOperator(InfixExpression.Operator.TIMES);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR :
+ infixExpression.setOperator(InfixExpression.Operator.OR);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE :
+ infixExpression.setOperator(InfixExpression.Operator.DIVIDE);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER :
+ infixExpression.setOperator(InfixExpression.Operator.GREATER);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS :
+ infixExpression.setOperator(InfixExpression.Operator.LESS);
+ }
+
+ if (expression.left instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression
+ && ((expression.left.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) {
+ // create an extended string literal equivalent => use the extended operands list
+ infixExpression.extendedOperands().add(convert(expression.right));
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left;
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null;
+ do {
+ rightOperand = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) leftOperand).right;
+ if ((((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID
+ && ((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))
+ || ((rightOperand instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression
+ && ((rightOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT) != expressionOperatorID)
+ && ((rightOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0))) {
+ List extendedOperands = infixExpression.extendedOperands();
+ InfixExpression temp = new InfixExpression(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(temp, expression);
+ }
+ temp.setOperator(getOperatorFor(expressionOperatorID));
+ Expression leftSide = convert(leftOperand);
+ temp.setLeftOperand(leftSide);
+ temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength());
+ int size = extendedOperands.size();
+ for (int i = 0; i < size - 1; i++) {
+ Expression expr = temp;
+ temp = new InfixExpression(this.ast);
+
+ if (this.resolveBindings) {
+ this.recordNodes(temp, expression);
+ }
+ temp.setLeftOperand(expr);
+ temp.setOperator(getOperatorFor(expressionOperatorID));
+ temp.setSourceRange(expr.getStartPosition(), expr.getLength());
+ }
+ infixExpression = temp;
+ for (int i = 0; i < size; i++) {
+ Expression extendedOperand = (Expression) extendedOperands.remove(size - 1 - i);
+ temp.setRightOperand(extendedOperand);
+ int startPosition = temp.getLeftOperand().getStartPosition();
+ temp.setSourceRange(startPosition, extendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition);
+ if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) {
+ temp = (InfixExpression) temp.getLeftOperand();
+ }
+ }
+ int startPosition = infixExpression.getLeftOperand().getStartPosition();
+ infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ if (this.resolveBindings) {
+ this.recordNodes(infixExpression, expression);
+ }
+ return infixExpression;
+ }
+ infixExpression.extendedOperands().add(0, convert(rightOperand));
+ leftOperand = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) leftOperand).left;
+ } while (leftOperand instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression && ((leftOperand.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0));
+ Expression leftExpression = convert(leftOperand);
+ infixExpression.setLeftOperand(leftExpression);
+ infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0));
+ int startPosition = leftExpression.getStartPosition();
+ infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ return infixExpression;
+ } else if (expression.left instanceof StringLiteralConcatenation
+ && ((expression.left.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) == 0)) {
+ StringLiteralConcatenation literal = (StringLiteralConcatenation) expression.left;
+ final org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] stringLiterals = literal.literals;
+ infixExpression.setLeftOperand(convert(stringLiterals[0]));
+ infixExpression.setRightOperand(convert(stringLiterals[1]));
+ for (int i = 2; i < literal.counter; i++) {
+ infixExpression.extendedOperands().add(convert(stringLiterals[i]));
+ }
+ infixExpression.extendedOperands().add(convert(expression.right));
+ int startPosition = literal.sourceStart;
+ infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ return infixExpression;
+ }
+ Expression leftExpression = convert(expression.left);
+ infixExpression.setLeftOperand(leftExpression);
+ infixExpression.setRightOperand(convert(expression.right));
+ int startPosition = leftExpression.getStartPosition();
+ infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ return infixExpression;
+ }
+
+ public Block convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Block statement) {
+ Block block = new Block(this.ast);
+ if (statement.sourceEnd > 0) {
+ block.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = statement.statements;
+ if (statements != null) {
+ int statementsLength = statements.length;
+ for (int i = 0; i < statementsLength; i++) {
+ if (statements[i] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
+ checkAndAddMultipleLocalDeclaration(statements, i, block.statements());
+ } else {
+ block.statements().add(convert(statements[i]));
+ }
+ }
+ }
+ return block;
+ }
+
+ public BreakStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.BreakStatement statement) {
+ BreakStatement breakStatement = new BreakStatement(this.ast);
+ breakStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ if (statement.label != null) {
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(statement.label));
+ retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name);
+ breakStatement.setLabel(name);
+ }
+ retrieveSemiColonPosition(breakStatement);
+ return breakStatement;
+ }
+
+
+ public SwitchCase convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CaseStatement statement) {
+ SwitchCase switchCase = new SwitchCase(this.ast);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression constantExpression = statement.constantExpression;
+ if (constantExpression == null) {
+ switchCase.setExpression(null);
+ } else {
+ switchCase.setExpression(convert(constantExpression));
+ }
+ switchCase.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ retrieveColonPosition(switchCase);
+ return switchCase;
+ }
+
+ public CastExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression expression) {
+ CastExpression castExpression = new CastExpression(this.ast);
+ castExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression type = expression.type;
+ trimWhiteSpacesAndComments(type);
+ if (type instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference ) {
+ castExpression.setType(convertType((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference)type));
+ } else if (type instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) {
+ castExpression.setType(convertToType((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference)type));
+ }
+ castExpression.setExpression(convert(expression.expression));
+ if (this.resolveBindings) {
+ recordNodes(castExpression, expression);
+ }
+ return castExpression;
+ }
+
+ public CharacterLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral expression) {
+ int length = expression.sourceEnd - expression.sourceStart + 1;
+ int sourceStart = expression.sourceStart;
+ CharacterLiteral literal = new CharacterLiteral(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.internalSetEscapedValue(new String(this.compilationUnitSource, sourceStart, length));
+ literal.setSourceRange(sourceStart, length);
+ removeLeadingAndTrailingCommentsFromLiteral(literal);
+ return literal;
+ }
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess expression) {
+ TypeLiteral typeLiteral = new TypeLiteral(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(typeLiteral, expression);
+ }
+ typeLiteral.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ typeLiteral.setType(convertType(expression.type));
+ return typeLiteral;
+ }
+
+ public CompilationUnit convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration unit, char[] source) {
+ this.compilationUnitSource = source;
+ this.compilationUnitSourceLength = source.length;
+ this.scanner.setSource(source, unit.compilationResult);
+ CompilationUnit compilationUnit = new CompilationUnit(this.ast);
+
+ // Parse comments
+ int[][] comments = unit.comments;
+ if (comments != null) {
+ buildCommentsTable(compilationUnit, comments);
+ }
+
+ // handle the package declaration immediately
+ // There is no node corresponding to the package declaration
+ if (this.resolveBindings) {
+ recordNodes(compilationUnit, unit);
+ }
+ if (unit.currentPackage != null) {
+ PackageDeclaration packageDeclaration = convertPackage(unit);
+ compilationUnit.setPackage(packageDeclaration);
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ImportReference[] imports = unit.imports;
+ if (imports != null) {
+ int importLength = imports.length;
+ for (int i = 0; i < importLength; i++) {
+ compilationUnit.imports().add(convertImport(imports[i]));
+ }
+ }
+
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = unit.types;
+ if (types != null) {
+ int typesLength = types.length;
+ for (int i = 0; i < typesLength; i++) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration declaration = types[i];
+ if (CharOperation.equals(declaration.name, TypeConstants.PACKAGE_INFO_NAME)) {
+ continue;
+ }
+ ASTNode type = convert(declaration);
+ if (type == null) {
+ compilationUnit.setFlags(compilationUnit.getFlags() | ASTNode.MALFORMED);
+ } else {
+ compilationUnit.types().add(type);
+ }
+ }
+ }
+ compilationUnit.setSourceRange(unit.sourceStart, unit.sourceEnd - unit.sourceStart + 1);
+
+ int problemLength = unit.compilationResult.problemCount;
+ if (problemLength != 0) {
+ IProblem[] resizedProblems = null;
+ final IProblem[] problems = unit.compilationResult.getProblems();
+ final int realProblemLength=problems.length;
+ if (realProblemLength == problemLength) {
+ resizedProblems = problems;
+ } else {
+ System.arraycopy(problems, 0, (resizedProblems = new IProblem[realProblemLength]), 0, realProblemLength);
+ }
+ ASTSyntaxErrorPropagator syntaxErrorPropagator = new ASTSyntaxErrorPropagator(resizedProblems);
+ compilationUnit.accept(syntaxErrorPropagator);
+ compilationUnit.setProblems(resizedProblems);
+ }
+ if (this.resolveBindings) {
+ lookupForScopes();
+ }
+ compilationUnit.initCommentMapper(this.scanner);
+ return compilationUnit;
+ }
+
+ public Assignment convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment expression) {
+ Assignment assignment = new Assignment(this.ast);
+ Expression lhs = convert(expression.lhs);
+ assignment.setLeftHandSide(lhs);
+ int start = lhs.getStartPosition();
+ assignment.setSourceRange(start, expression.sourceEnd - start + 1);
+ switch (expression.operator) {
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
+ assignment.setOperator(Assignment.Operator.PLUS_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
+ assignment.setOperator(Assignment.Operator.MINUS_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY :
+ assignment.setOperator(Assignment.Operator.TIMES_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE :
+ assignment.setOperator(Assignment.Operator.DIVIDE_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND :
+ assignment.setOperator(Assignment.Operator.BIT_AND_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR :
+ assignment.setOperator(Assignment.Operator.BIT_OR_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR :
+ assignment.setOperator(Assignment.Operator.BIT_XOR_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER :
+ assignment.setOperator(Assignment.Operator.REMAINDER_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT :
+ assignment.setOperator(Assignment.Operator.LEFT_SHIFT_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT :
+ assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT :
+ assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN);
+ break;
+ }
+ assignment.setRightHandSide(convert(expression.expression));
+ if (this.resolveBindings) {
+ recordNodes(assignment, expression);
+ }
+ return assignment;
+ }
+
+ public ConditionalExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression expression) {
+ ConditionalExpression conditionalExpression = new ConditionalExpression(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(conditionalExpression, expression);
+ }
+ conditionalExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ conditionalExpression.setExpression(convert(expression.condition));
+ conditionalExpression.setThenExpression(convert(expression.valueIfTrue));
+ conditionalExpression.setElseExpression(convert(expression.valueIfFalse));
+ return conditionalExpression;
+ }
+
+ public Statement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall statement) {
+ Statement newStatement;
+ int sourceStart = statement.sourceStart;
+ if (statement.isSuperAccess() || statement.isSuper()) {
+ SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation(this.ast);
+ if (statement.qualification != null) {
+ superConstructorInvocation.setExpression(convert(statement.qualification));
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments;
+ if (arguments != null) {
+ int length = arguments.length;
+ for (int i = 0; i < length; i++) {
+ superConstructorInvocation.arguments().add(convert(arguments[i]));
+ }
+ }
+ if (statement.typeArguments != null) {
+ if (sourceStart > statement.typeArgumentsSourceStart) {
+ sourceStart = statement.typeArgumentsSourceStart;
+ }
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ superConstructorInvocation.setFlags(superConstructorInvocation.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ for (int i = 0, max = statement.typeArguments.length; i < max; i++) {
+ superConstructorInvocation.typeArguments().add(convertType(statement.typeArguments[i]));
+ }
+ break;
+ }
+ }
+ newStatement = superConstructorInvocation;
+ } else {
+ ConstructorInvocation constructorInvocation = new ConstructorInvocation(this.ast);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments;
+ if (arguments != null) {
+ int length = arguments.length;
+ for (int i = 0; i < length; i++) {
+ constructorInvocation.arguments().add(convert(arguments[i]));
+ }
+ }
+ if (statement.typeArguments != null) {
+ if (sourceStart > statement.typeArgumentsSourceStart) {
+ sourceStart = statement.typeArgumentsSourceStart;
+ }
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ for (int i = 0, max = statement.typeArguments.length; i < max; i++) {
+ constructorInvocation.typeArguments().add(convertType(statement.typeArguments[i]));
+ }
+ break;
+ }
+ }
+ if (statement.qualification != null) {
+ // this is an error
+ constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED);
+ }
+ newStatement = constructorInvocation;
+ }
+ newStatement.setSourceRange(sourceStart, statement.sourceEnd - sourceStart + 1);
+ retrieveSemiColonPosition(newStatement);
+ if (this.resolveBindings) {
+ recordNodes(newStatement, statement);
+ }
+ return newStatement;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) {
+ if ((expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) != 0) {
+ return convertToParenthesizedExpression(expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression) expression);
+ }
+ // switch between all types of expression
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompoundAssignment) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Assignment) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CharLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteralMinValue) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LongLiteral) expression);
+ }
+ if (expression instanceof StringLiteralConcatenation) {
+ return convert((StringLiteralConcatenation) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AND_AND_Expression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.EqualExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.EqualExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BinaryExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.UnaryExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.UnaryExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference) expression);
+ }
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression);
+ }
+ return null;
+ }
+
+ public StringLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral expression) {
+ expression.computeConstant();
+ StringLiteral literal = new StringLiteral(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setLiteralValue(expression.constant.stringValue());
+ literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return literal;
+ }
+
+ public BooleanLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FalseLiteral expression) {
+ final BooleanLiteral literal = new BooleanLiteral(this.ast);
+ literal.setBooleanValue(false);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return literal;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference reference) {
+ if (reference.receiver.isSuper()) {
+ final SuperFieldAccess superFieldAccess = new SuperFieldAccess(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(superFieldAccess, reference);
+ }
+ if (reference.receiver instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) {
+ Name qualifier = convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) reference.receiver);
+ superFieldAccess.setQualifier(qualifier);
+ if (this.resolveBindings) {
+ recordNodes(qualifier, reference.receiver);
+ }
+ }
+ final SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(reference.token));
+ int sourceStart = (int)(reference.nameSourcePosition>>>32);
+ int length = (int)(reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1;
+ simpleName.setSourceRange(sourceStart, length);
+ superFieldAccess.setName(simpleName);
+ if (this.resolveBindings) {
+ recordNodes(simpleName, reference);
+ }
+ superFieldAccess.setSourceRange(reference.receiver.sourceStart, reference.sourceEnd - reference.receiver.sourceStart + 1);
+ return superFieldAccess;
+ } else {
+ final FieldAccess fieldAccess = new FieldAccess(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(fieldAccess, reference);
+ }
+ Expression receiver = convert(reference.receiver);
+ fieldAccess.setExpression(receiver);
+ final SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(reference.token));
+ int sourceStart = (int)(reference.nameSourcePosition>>>32);
+ int length = (int)(reference.nameSourcePosition & 0xFFFFFFFF) - sourceStart + 1;
+ simpleName.setSourceRange(sourceStart, length);
+ fieldAccess.setName(simpleName);
+ if (this.resolveBindings) {
+ recordNodes(simpleName, reference);
+ }
+ fieldAccess.setSourceRange(receiver.getStartPosition(), reference.sourceEnd - receiver.getStartPosition() + 1);
+ return fieldAccess;
+ }
+ }
+
+ public NumberLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FloatLiteral expression) {
+ int length = expression.sourceEnd - expression.sourceStart + 1;
+ int sourceStart = expression.sourceStart;
+ NumberLiteral literal = new NumberLiteral(this.ast);
+ literal.internalSetToken(new String(this.compilationUnitSource, sourceStart, length));
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setSourceRange(sourceStart, length);
+ removeLeadingAndTrailingCommentsFromLiteral(literal);
+ return literal;
+ }
+
+ public Statement convert(ForeachStatement statement) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ return createFakeEmptyStatement(statement);
+ case AST.JLS3 :
+ EnhancedForStatement enhancedForStatement = new EnhancedForStatement(this.ast);
+ enhancedForStatement.setParameter(convertToSingleVariableDeclaration(statement.elementVariable));
+ enhancedForStatement.setExpression(convert(statement.collection));
+ enhancedForStatement.setBody(convert(statement.action));
+ int start = statement.sourceStart;
+ int end = statement.sourceEnd;
+ enhancedForStatement.setSourceRange(start, end - start + 1);
+ return enhancedForStatement;
+ default:
+ return createFakeEmptyStatement(statement);
+ }
+ }
+
+ public ForStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ForStatement statement) {
+ ForStatement forStatement = new ForStatement(this.ast);
+ forStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] initializations = statement.initializations;
+ if (initializations != null) {
+ // we know that we have at least one initialization
+ if (initializations[0] instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
+ VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) initializations[0]);
+ int initializationsLength = initializations.length;
+ for (int i = 1; i < initializationsLength; i++) {
+ variableDeclarationExpression.fragments().add(convertToVariableDeclarationFragment((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)initializations[i]));
+ }
+ if (initializationsLength != 1) {
+ int start = variableDeclarationExpression.getStartPosition();
+ int end = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) initializations[initializationsLength - 1]).declarationSourceEnd;
+ variableDeclarationExpression.setSourceRange(start, end - start + 1);
+ }
+ forStatement.initializers().add(variableDeclarationExpression);
+ } else {
+ int initializationsLength = initializations.length;
+ for (int i = 0; i < initializationsLength; i++) {
+ Expression initializer = convertToExpression(initializations[i]);
+ if (initializer != null) {
+ forStatement.initializers().add(initializer);
+ } else {
+ forStatement.setFlags(forStatement.getFlags() | ASTNode.MALFORMED);
+ }
+ }
+ }
+ }
+ if (statement.condition != null) {
+ forStatement.setExpression(convert(statement.condition));
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] increments = statement.increments;
+ if (increments != null) {
+ int incrementsLength = increments.length;
+ for (int i = 0; i < incrementsLength; i++) {
+ forStatement.updaters().add(convertToExpression(increments[i]));
+ }
+ }
+ forStatement.setBody(convert(statement.action));
+ return forStatement;
+ }
+
+ public IfStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IfStatement statement) {
+ IfStatement ifStatement = new IfStatement(this.ast);
+ ifStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ ifStatement.setExpression(convert(statement.condition));
+ ifStatement.setThenStatement(convert(statement.thenStatement));
+ if (statement.elseStatement != null) {
+ ifStatement.setElseStatement(convert(statement.elseStatement));
+ }
+ return ifStatement;
+ }
+
+ public InstanceofExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression expression) {
+ InstanceofExpression instanceOfExpression = new InstanceofExpression(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(instanceOfExpression, expression);
+ }
+ Expression leftExpression = convert(expression.expression);
+ instanceOfExpression.setLeftOperand(leftExpression);
+ instanceOfExpression.setRightOperand(convertType(expression.type));
+ int startPosition = leftExpression.getStartPosition();
+ instanceOfExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ return instanceOfExpression;
+ }
+
+ public NumberLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral expression) {
+ int length = expression.sourceEnd - expression.sourceStart + 1;
+ int sourceStart = expression.sourceStart;
+ final NumberLiteral literal = new NumberLiteral(this.ast);
+ literal.internalSetToken(new String(this.compilationUnitSource, sourceStart, length));
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setSourceRange(sourceStart, length);
+ removeLeadingAndTrailingCommentsFromLiteral(literal);
+ return literal;
+ }
+
+ public NumberLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteralMinValue expression) {
+ int length = expression.sourceEnd - expression.sourceStart + 1;
+ int sourceStart = expression.sourceStart;
+ NumberLiteral literal = new NumberLiteral(this.ast);
+ literal.internalSetToken(new String(this.compilationUnitSource, sourceStart, length));
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setSourceRange(sourceStart, length);
+ removeLeadingAndTrailingCommentsFromLiteral(literal);
+ return literal;
+ }
+
+ public void convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) {
+ if (bodyDeclaration.getJavadoc() == null) {
+ if (javadoc != null) {
+ if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) {
+ this.commentMapper = new DefaultCommentMapper(this.commentsTable);
+ }
+ Comment comment = this.commentMapper.getComment(javadoc.sourceStart);
+ if (comment != null && comment.isDocComment() && comment.getParent() == null) {
+ Javadoc docComment = (Javadoc) comment;
+ if (this.resolveBindings) {
+ recordNodes(docComment, javadoc);
+ // resolve member and method references binding
+ Iterator tags = docComment.tags().listIterator();
+ while (tags.hasNext()) {
+ recordNodes(javadoc, (TagElement) tags.next());
+ }
+ }
+ bodyDeclaration.setJavadoc(docComment);
+ }
+ }
+ }
+ }
+
+ public void convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, PackageDeclaration packageDeclaration) {
+ if (ast.apiLevel == AST.JLS3 && packageDeclaration.getJavadoc() == null) {
+ if (javadoc != null) {
+ if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) {
+ this.commentMapper = new DefaultCommentMapper(this.commentsTable);
+ }
+ Comment comment = this.commentMapper.getComment(javadoc.sourceStart);
+ if (comment != null && comment.isDocComment() && comment.getParent() == null) {
+ Javadoc docComment = (Javadoc) comment;
+ if (this.resolveBindings) {
+ recordNodes(docComment, javadoc);
+ // resolve member and method references binding
+ Iterator tags = docComment.tags().listIterator();
+ while (tags.hasNext()) {
+ recordNodes(javadoc, (TagElement) tags.next());
+ }
+ }
+ packageDeclaration.setJavadoc(docComment);
+ }
+ }
+ }
+ }
+
+ public LabeledStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LabeledStatement statement) {
+ LabeledStatement labeledStatement = new LabeledStatement(this.ast);
+ labeledStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement body = statement.statement;
+ labeledStatement.setBody(convert(body));
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(statement.label));
+ retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name);
+ labeledStatement.setLabel(name);
+ return labeledStatement;
+ }
+
+
+
+ public InfixExpression convert(StringLiteralConcatenation expression) {
+ expression.computeConstant();
+ final InfixExpression infixExpression = new InfixExpression(this.ast);
+ infixExpression.setOperator(InfixExpression.Operator.PLUS);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] stringLiterals = expression.literals;
+ infixExpression.setLeftOperand(convert(stringLiterals[0]));
+ infixExpression.setRightOperand(convert(stringLiterals[1]));
+ for (int i = 2; i < expression.counter; i++) {
+ infixExpression.extendedOperands().add(convert(stringLiterals[i]));
+ }
+ if (this.resolveBindings) {
+ this.recordNodes(infixExpression, expression);
+ }
+ infixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return infixExpression;
+ }
+
+ public NormalAnnotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation annotation) {
+ final NormalAnnotation normalAnnotation = new NormalAnnotation(this.ast);
+ setTypeNameForAnnotation(annotation, normalAnnotation);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.MemberValuePair[] memberValuePairs = annotation.memberValuePairs;
+ if (memberValuePairs != null) {
+ for (int i = 0, max = memberValuePairs.length; i < max; i++) {
+ normalAnnotation.values().add(convert(memberValuePairs[i]));
+ }
+ }
+ int start = annotation.sourceStart;
+ int end = annotation.declarationSourceEnd;
+ normalAnnotation.setSourceRange(start, end - start + 1);
+ if (this.resolveBindings) {
+ recordNodes(normalAnnotation, annotation);
+ }
+ return normalAnnotation;
+ }
+
+ public NullLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NullLiteral expression) {
+ final NullLiteral literal = new NullLiteral(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return literal;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.OR_OR_Expression expression) {
+ final InfixExpression infixExpression = new InfixExpression(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(infixExpression, expression);
+ }
+ Expression leftExpression = convert(expression.left);
+ infixExpression.setLeftOperand(leftExpression);
+ infixExpression.setRightOperand(convert(expression.right));
+ infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
+ int sourceStart = leftExpression.getStartPosition();
+ infixExpression.setSourceRange(sourceStart, expression.sourceEnd - sourceStart + 1);
+ return infixExpression;
+ }
+
+ public PostfixExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.PostfixExpression expression) {
+ final PostfixExpression postfixExpression = new PostfixExpression(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(postfixExpression, expression);
+ }
+ postfixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ postfixExpression.setOperand(convert(expression.lhs));
+ switch (expression.operator) {
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
+ postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
+ postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT);
+ break;
+ }
+ return postfixExpression;
+ }
+
+ public PrefixExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.PrefixExpression expression) {
+ final PrefixExpression prefixExpression = new PrefixExpression(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(prefixExpression, expression);
+ }
+ prefixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ prefixExpression.setOperand(convert(expression.lhs));
+ switch (expression.operator) {
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
+ prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);
+ break;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
+ prefixExpression.setOperator(PrefixExpression.Operator.DECREMENT);
+ break;
+ }
+ return prefixExpression;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression allocation) {
+ final ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation(this.ast);
+ if (allocation.enclosingInstance != null) {
+ classInstanceCreation.setExpression(convert(allocation.enclosingInstance));
+ }
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ classInstanceCreation.internalSetName(convert(allocation.type));
+ break;
+ case AST.JLS3 :
+ classInstanceCreation.setType(convertType(allocation.type));
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = allocation.arguments;
+ if (arguments != null) {
+ int length = arguments.length;
+ for (int i = 0; i < length; i++) {
+ Expression argument = convert(arguments[i]);
+ if (this.resolveBindings) {
+ recordNodes(argument, arguments[i]);
+ }
+ classInstanceCreation.arguments().add(argument);
+ }
+ }
+ if (allocation.typeArguments != null) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ classInstanceCreation.setFlags(classInstanceCreation.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ for (int i = 0, max = allocation.typeArguments.length; i < max; i++) {
+ classInstanceCreation.typeArguments().add(convertType(allocation.typeArguments[i]));
+ }
+ }
+ }
+ if (allocation.anonymousType != null) {
+ int declarationSourceStart = allocation.sourceStart;
+ classInstanceCreation.setSourceRange(declarationSourceStart, allocation.anonymousType.bodyEnd - declarationSourceStart + 1);
+ final AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration(this.ast);
+ int start = retrieveStartBlockPosition(allocation.anonymousType.sourceEnd, allocation.anonymousType.bodyEnd);
+ anonymousClassDeclaration.setSourceRange(start, allocation.anonymousType.bodyEnd - start + 1);
+ classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
+ buildBodyDeclarations(allocation.anonymousType, anonymousClassDeclaration);
+ if (this.resolveBindings) {
+ recordNodes(classInstanceCreation, allocation.anonymousType);
+ recordNodes(anonymousClassDeclaration, allocation.anonymousType);
+ anonymousClassDeclaration.resolveBinding();
+ }
+ return classInstanceCreation;
+ } else {
+ final int start = allocation.sourceStart;
+ classInstanceCreation.setSourceRange(start, allocation.sourceEnd - start + 1);
+ if (this.resolveBindings) {
+ recordNodes(classInstanceCreation, allocation);
+ }
+ removeTrailingCommentFromExpressionEndingWithAParen(classInstanceCreation);
+ return classInstanceCreation;
+ }
+ }
+
+ public Name convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference nameReference) {
+ return setQualifiedNameNameAndSourceRanges(nameReference.tokens, nameReference.sourcePositions, nameReference);
+ }
+
+ public Name convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference reference) {
+ return convert(reference.qualification);
+ }
+
+ public ThisExpression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference reference) {
+ final ThisExpression thisExpression = new ThisExpression(this.ast);
+ thisExpression.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1);
+ thisExpression.setQualifier(convert(reference.qualification));
+ if (this.resolveBindings) {
+ recordNodes(thisExpression, reference);
+ recordPendingThisExpressionScopeResolution(thisExpression);
+ }
+ return thisExpression;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Reference reference) {
+ if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference) reference);
+ }
+ if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThisReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThisReference) reference);
+ }
+ if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayReference) reference);
+ }
+ if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldReference) reference);
+ }
+ return null; // cannot be reached
+ }
+
+ public ReturnStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement statement) {
+ final ReturnStatement returnStatement = new ReturnStatement(this.ast);
+ returnStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ if (statement.expression != null) {
+ returnStatement.setExpression(convert(statement.expression));
+ }
+ retrieveSemiColonPosition(returnStatement);
+ return returnStatement;
+ }
+
+ public SingleMemberAnnotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation annotation) {
+ final SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation(this.ast);
+ setTypeNameForAnnotation(annotation, singleMemberAnnotation);
+ singleMemberAnnotation.setValue(convert(annotation.memberValue));
+ int start = annotation.sourceStart;
+ int end = annotation.declarationSourceEnd;
+ singleMemberAnnotation.setSourceRange(start, end - start + 1);
+ if (this.resolveBindings) {
+ recordNodes(singleMemberAnnotation, annotation);
+ }
+ return singleMemberAnnotation;
+ }
+
+ public SimpleName convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference nameReference) {
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(nameReference.token));
+ if (this.resolveBindings) {
+ recordNodes(name, nameReference);
+ }
+ name.setSourceRange(nameReference.sourceStart, nameReference.sourceEnd - nameReference.sourceStart + 1);
+ return name;
+ }
+
+ public Statement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement statement) {
+ if (statement instanceof ForeachStatement) {
+ return convert((ForeachStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) {
+ return convertToVariableDeclarationStatement((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration)statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.AssertStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Block) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Block) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.BreakStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.BreakStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ContinueStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ContinueStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.CaseStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.CaseStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.DoStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.EmptyStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.EmptyStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ForStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ForStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.IfStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.IfStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.LabeledStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.LabeledStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThrowStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThrowStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TryStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TryStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
+ ASTNode result = convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) statement);
+ if (result == null) {
+ return createFakeEmptyStatement(statement);
+ }
+ switch(result.getNodeType()) {
+ case ASTNode.ENUM_DECLARATION:
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ return createFakeEmptyStatement(statement);
+ case AST.JLS3 :
+ final TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast);
+ typeDeclarationStatement.setDeclaration((EnumDeclaration) result);
+ AbstractTypeDeclaration typeDecl = typeDeclarationStatement.getDeclaration();
+ typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength());
+ return typeDeclarationStatement;
+ }
+ break;
+ case ASTNode.ANNOTATION_TYPE_DECLARATION :
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ return createFakeEmptyStatement(statement);
+ case AST.JLS3 :
+ TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast);
+ typeDeclarationStatement.setDeclaration((AnnotationTypeDeclaration) result);
+ AbstractTypeDeclaration typeDecl = typeDeclarationStatement.getDeclaration();
+ typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength());
+ return typeDeclarationStatement;
+ }
+ break;
+ default:
+ TypeDeclaration typeDeclaration = (TypeDeclaration) result;
+ if (typeDeclaration == null) {
+ return createFakeEmptyStatement(statement);
+ } else {
+ TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement(this.ast);
+ typeDeclarationStatement.setDeclaration(typeDeclaration);
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ TypeDeclaration typeDecl = typeDeclarationStatement.internalGetTypeDeclaration();
+ typeDeclarationStatement.setSourceRange(typeDecl.getStartPosition(), typeDecl.getLength());
+ break;
+ case AST.JLS3 :
+ AbstractTypeDeclaration typeDeclAST3 = typeDeclarationStatement.getDeclaration();
+ typeDeclarationStatement.setSourceRange(typeDeclAST3.getStartPosition(), typeDeclAST3.getLength());
+ break;
+ }
+ return typeDeclarationStatement;
+ }
+ }
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.WhileStatement) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.WhileStatement) statement);
+ }
+ if (statement instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) {
+ final Expression expr = convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) statement);
+ final ExpressionStatement stmt = new ExpressionStatement(this.ast);
+ stmt.setExpression(expr);
+ stmt.setSourceRange(expr.getStartPosition(), expr.getLength());
+ retrieveSemiColonPosition(stmt);
+ return stmt;
+ }
+ return createFakeEmptyStatement(statement);
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral expression) {
+ if (expression instanceof StringLiteralConcatenation) {
+ return convert((StringLiteralConcatenation) expression);
+ }
+ int length = expression.sourceEnd - expression.sourceStart + 1;
+ int sourceStart = expression.sourceStart;
+ StringLiteral literal = new StringLiteral(this.ast);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.internalSetEscapedValue(new String(this.compilationUnitSource, sourceStart, length));
+ literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return literal;
+ }
+
+ public SwitchStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchStatement statement) {
+ SwitchStatement switchStatement = new SwitchStatement(this.ast);
+ switchStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ switchStatement.setExpression(convert(statement.expression));
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement[] statements = statement.statements;
+ if (statements != null) {
+ int statementsLength = statements.length;
+ for (int i = 0; i < statementsLength; i++) {
+ switchStatement.statements().add(convert(statements[i]));
+ }
+ }
+ return switchStatement;
+ }
+
+ public SynchronizedStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement statement) {
+ SynchronizedStatement synchronizedStatement = new SynchronizedStatement(this.ast);
+ synchronizedStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ synchronizedStatement.setBody(convert(statement.block));
+ synchronizedStatement.setExpression(convert(statement.expression));
+ return synchronizedStatement;
+ }
+
+ public Expression convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThisReference reference) {
+ if (reference.isImplicitThis()) {
+ // There is no source associated with an implicit this
+ return null;
+ } else if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) reference);
+ } else if (reference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference) {
+ return convert((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference) reference);
+ } else {
+ ThisExpression thisExpression = new ThisExpression(this.ast);
+ thisExpression.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1);
+ if (this.resolveBindings) {
+ recordNodes(thisExpression, reference);
+ recordPendingThisExpressionScopeResolution(thisExpression);
+ }
+ return thisExpression;
+ }
+ }
+
+ public ThrowStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThrowStatement statement) {
+ final ThrowStatement throwStatement = new ThrowStatement(this.ast);
+ throwStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ throwStatement.setExpression(convert(statement.exception));
+ retrieveSemiColonPosition(throwStatement);
+ return throwStatement;
+ }
+
+ public BooleanLiteral convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral expression) {
+ final BooleanLiteral literal = new BooleanLiteral(this.ast);
+ literal.setBooleanValue(true);
+ if (this.resolveBindings) {
+ this.recordNodes(literal, expression);
+ }
+ literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ return literal;
+ }
+
+ public TryStatement convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TryStatement statement) {
+ final TryStatement tryStatement = new TryStatement(this.ast);
+ tryStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+
+ tryStatement.setBody(convert(statement.tryBlock));
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] catchArguments = statement.catchArguments;
+ if (catchArguments != null) {
+ int catchArgumentsLength = catchArguments.length;
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Block[] catchBlocks = statement.catchBlocks;
+ int start = statement.tryBlock.sourceEnd;
+ for (int i = 0; i < catchArgumentsLength; i++) {
+ CatchClause catchClause = new CatchClause(this.ast);
+ int catchClauseSourceStart = retrieveStartingCatchPosition(start, catchArguments[i].sourceStart);
+ catchClause.setSourceRange(catchClauseSourceStart, catchBlocks[i].sourceEnd - catchClauseSourceStart + 1);
+ catchClause.setBody(convert(catchBlocks[i]));
+ catchClause.setException(convert(catchArguments[i]));
+ tryStatement.catchClauses().add(catchClause);
+ start = catchBlocks[i].sourceEnd;
+ }
+ }
+ if (statement.finallyBlock != null) {
+ tryStatement.setFinally(convert(statement.finallyBlock));
+ }
+ return tryStatement;
+ }
+
+ public ASTNode convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
+ switch (typeDeclaration.kind()) {
+ case IGenericType.ENUM_DECL :
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ return null;
+ } else {
+ return convertToEnumDeclaration(typeDeclaration);
+ }
+ case IGenericType.ANNOTATION_TYPE_DECL :
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ return null;
+ } else {
+ return convertToAnnotationDeclaration(typeDeclaration);
+ }
+ }
+
+ checkCanceled();
+ TypeDeclaration typeDecl = TypeDeclaration.getTypeDeclaration(this.ast);
+
+ //////////////// ajh02: added
+ if (typeDeclaration instanceof AspectDeclaration){
+ org.aspectj.weaver.patterns.PerClause perClause = ((AspectDeclaration)typeDeclaration).perClause;
+ if (perClause == null){
+ typeDecl = new org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration(this.ast,null);
+ } else {
+ typeDecl = new org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration(this.ast,convert(perClause));
+ }
+ }
+ ///////////////////////////////
+
+ if (typeDeclaration.modifiersSourceStart != -1) {
+ setModifiers(typeDecl, typeDeclaration);
+ }
+ typeDecl.setInterface(typeDeclaration.kind() == IGenericType.INTERFACE_DECL);
+ final SimpleName typeName = new SimpleName(this.ast);
+ typeName.internalSetIdentifier(new String(typeDeclaration.name));
+ typeName.setSourceRange(typeDeclaration.sourceStart, typeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
+ typeDecl.setName(typeName);
+ typeDecl.setSourceRange(typeDeclaration.declarationSourceStart, typeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
+
+ // need to set the superclass and super interfaces here since we cannot distinguish them at
+ // the type references level.
+ if (typeDeclaration.superclass != null) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ typeDecl.internalSetSuperclass(convert(typeDeclaration.superclass));
+ break;
+ case AST.JLS3 :
+ typeDecl.setSuperclassType(convertType(typeDeclaration.superclass));
+ break;
+ }
+ }
+
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference[] superInterfaces = typeDeclaration.superInterfaces;
+ if (superInterfaces != null) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ for (int index = 0, length = superInterfaces.length; index < length; index++) {
+ typeDecl.internalSuperInterfaces().add(convert(superInterfaces[index]));
+ }
+ break;
+ case AST.JLS3 :
+ for (int index = 0, length = superInterfaces.length; index < length; index++) {
+ typeDecl.superInterfaceTypes().add(convertType(superInterfaces[index]));
+ }
+ }
+ }
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = typeDeclaration.typeParameters;
+ if (typeParameters != null) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
+ break;
+ case AST.JLS3 :
+ for (int index = 0, length = typeParameters.length; index < length; index++) {
+ typeDecl.typeParameters().add(convert(typeParameters[index]));
+ }
+ }
+ }
+ buildBodyDeclarations(typeDeclaration, typeDecl);
+ if (this.resolveBindings) {
+ recordNodes(typeDecl, typeDeclaration);
+ recordNodes(typeName, typeDeclaration);
+ typeDecl.resolveBinding();
+ }
+ return typeDecl;
+ }
+
+ public TypeParameter convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter typeParameter) {
+ final TypeParameter typeParameter2 = new TypeParameter(this.ast);
+ final SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(typeParameter.name));
+ int start = typeParameter.sourceStart;
+ int end = typeParameter.sourceEnd;
+ simpleName.setSourceRange(start, end - start + 1);
+ typeParameter2.setName(simpleName);
+ final TypeReference superType = typeParameter.type;
+ end = typeParameter.declarationSourceEnd;
+ if (superType != null) {
+ Type type = convertType(superType);
+ typeParameter2.typeBounds().add(type);
+ end = type.getStartPosition() + type.getLength() - 1;
+ }
+ TypeReference[] bounds = typeParameter.bounds;
+ if (bounds != null) {
+ Type type = null;
+ for (int index = 0, length = bounds.length; index < length; index++) {
+ type = convertType(bounds[index]);
+ typeParameter2.typeBounds().add(type);
+ end = type.getStartPosition() + type.getLength() - 1;
+ }
+ }
+ start = typeParameter.declarationSourceStart;
+ end = retrieveClosingAngleBracketPosition(end);
+ typeParameter2.setSourceRange(start, end - start + 1);
+ if (this.resolveBindings) {
+ recordName(simpleName, typeParameter);
+ recordNodes(typeParameter2, typeParameter);
+ typeParameter2.resolveBinding();
+ }
+ return typeParameter2;
+ }
+
+ public Name convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference) {
+ char[][] typeName = typeReference.getTypeName();
+ int length = typeName.length;
+ if (length > 1) {
+ // QualifiedName
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference qualifiedTypeReference = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference;
+ final long[] positions = qualifiedTypeReference.sourcePositions;
+ return setQualifiedNameNameAndSourceRanges(typeName, positions, typeReference);
+ } else {
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(typeName[0]));
+ name.setSourceRange(typeReference.sourceStart, typeReference.sourceEnd - typeReference.sourceStart + 1);
+ if (this.resolveBindings) {
+ recordNodes(name, typeReference);
+ }
+ return name;
+ }
+ }
+
+
+
+ protected FieldDeclaration convertToFieldDeclaration(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) {
+ VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(fieldDecl);
+ final FieldDeclaration fieldDeclaration = new FieldDeclaration(this.ast);
+ fieldDeclaration.fragments().add(variableDeclarationFragment);
+ IVariableBinding binding = null;
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, fieldDecl);
+ binding = variableDeclarationFragment.resolveBinding();
+ }
+ fieldDeclaration.setSourceRange(fieldDecl.declarationSourceStart, fieldDecl.declarationEnd - fieldDecl.declarationSourceStart + 1);
+ Type type = convertType(fieldDecl.type);
+ setTypeForField(fieldDeclaration, type, variableDeclarationFragment.getExtraDimensions());
+ setModifiers(fieldDeclaration, fieldDecl);
+ if (!(this.resolveBindings && binding == null)) {
+ convert(fieldDecl.javadoc, fieldDeclaration);
+ }
+ return fieldDeclaration;
+ }
+
+ public ParenthesizedExpression convertToParenthesizedExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) {
+ final ParenthesizedExpression parenthesizedExpression = new ParenthesizedExpression(this.ast);
+ if (this.resolveBindings) {
+ recordNodes(parenthesizedExpression, expression);
+ }
+ parenthesizedExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ adjustSourcePositionsForParent(expression);
+ trimWhiteSpacesAndComments(expression);
+ // decrement the number of parenthesis
+ int numberOfParenthesis = (expression.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) >> org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT;
+ expression.bits &= ~org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK;
+ expression.bits |= (numberOfParenthesis - 1) << org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedSHIFT;
+ parenthesizedExpression.setExpression(convert(expression));
+ return parenthesizedExpression;
+ }
+
+ public Type convertToType(org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference reference) {
+ Name name = convert(reference);
+ final SimpleType type = new SimpleType(this.ast);
+ type.setName(name);
+ type.setSourceRange(name.getStartPosition(), name.getLength());
+ if (this.resolveBindings) {
+ this.recordNodes(type, reference);
+ }
+ return type;
+ }
+
+ protected VariableDeclarationExpression convertToVariableDeclarationExpression(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
+ final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
+ final VariableDeclarationExpression variableDeclarationExpression = new VariableDeclarationExpression(this.ast);
+ variableDeclarationExpression.fragments().add(variableDeclarationFragment);
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, localDeclaration);
+ }
+ variableDeclarationExpression.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
+ Type type = convertType(localDeclaration.type);
+ setTypeForVariableDeclarationExpression(variableDeclarationExpression, type, variableDeclarationFragment.getExtraDimensions());
+ if (localDeclaration.modifiersSourceStart != -1) {
+ setModifiers(variableDeclarationExpression, localDeclaration);
+ }
+ return variableDeclarationExpression;
+ }
+
+ protected SingleVariableDeclaration convertToSingleVariableDeclaration(LocalDeclaration localDeclaration) {
+ final SingleVariableDeclaration variableDecl = new SingleVariableDeclaration(this.ast);
+ setModifiers(variableDecl, localDeclaration);
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(localDeclaration.name));
+ int start = localDeclaration.sourceStart;
+ int nameEnd = localDeclaration.sourceEnd;
+ name.setSourceRange(start, nameEnd - start + 1);
+ variableDecl.setName(name);
+ final int extraDimensions = retrieveExtraDimension(nameEnd + 1, localDeclaration.type.sourceEnd);
+ variableDecl.setExtraDimensions(extraDimensions);
+ Type type = convertType(localDeclaration.type);
+ int typeEnd = type.getStartPosition() + type.getLength() - 1;
+ int rightEnd = Math.max(typeEnd, localDeclaration.declarationSourceEnd);
+ /*
+ * There is extra work to do to set the proper type positions
+ * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284
+ */
+ setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions);
+ variableDecl.setSourceRange(localDeclaration.declarationSourceStart, rightEnd - localDeclaration.declarationSourceStart + 1);
+ if (this.resolveBindings) {
+ recordNodes(name, localDeclaration);
+ recordNodes(variableDecl, localDeclaration);
+ variableDecl.resolveBinding();
+ }
+ return variableDecl;
+ }
+
+ protected VariableDeclarationFragment convertToVariableDeclarationFragment(InterTypeFieldDeclaration fieldDeclaration) {
+ // ajh02: method added
+ final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast);
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(fieldDeclaration.getDeclaredSelector()));
+ name.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.sourceEnd - fieldDeclaration.sourceStart + 1);
+ variableDeclarationFragment.setName(name);
+ int start = fieldDeclaration.sourceEnd;
+ if (fieldDeclaration.initialization != null) {
+ final Expression expression = convert(fieldDeclaration.initialization);
+ variableDeclarationFragment.setInitializer(expression);
+ start = expression.getStartPosition() + expression.getLength();
+ }
+ int end = retrievePositionBeforeNextCommaOrSemiColon(start, fieldDeclaration.declarationSourceEnd);
+ if (end == -1) {
+ variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.declarationSourceEnd - fieldDeclaration.sourceStart + 1);
+ variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED);
+ } else {
+ variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, end - fieldDeclaration.sourceStart + 1);
+ }
+ variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, fieldDeclaration.declarationSourceEnd ));
+ if (this.resolveBindings) {
+ recordNodes(name, fieldDeclaration);
+ recordNodes(variableDeclarationFragment, fieldDeclaration);
+ variableDeclarationFragment.resolveBinding();
+ }
+ return variableDeclarationFragment;
+ }
+
+ protected VariableDeclarationFragment convertToVariableDeclarationFragment(org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) {
+ final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast);
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(fieldDeclaration.name));
+ name.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.sourceEnd - fieldDeclaration.sourceStart + 1);
+ variableDeclarationFragment.setName(name);
+ int start = fieldDeclaration.sourceEnd;
+ if (fieldDeclaration.initialization != null) {
+ final Expression expression = convert(fieldDeclaration.initialization);
+ variableDeclarationFragment.setInitializer(expression);
+ start = expression.getStartPosition() + expression.getLength();
+ }
+ int end = retrievePositionBeforeNextCommaOrSemiColon(start, fieldDeclaration.declarationSourceEnd);
+ if (end == -1) {
+ variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, fieldDeclaration.declarationSourceEnd - fieldDeclaration.sourceStart + 1);
+ variableDeclarationFragment.setFlags(variableDeclarationFragment.getFlags() | ASTNode.MALFORMED);
+ } else {
+ variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, end - fieldDeclaration.sourceStart + 1);
+ }
+ variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, fieldDeclaration.declarationSourceEnd ));
+ if (this.resolveBindings) {
+ recordNodes(name, fieldDeclaration);
+ recordNodes(variableDeclarationFragment, fieldDeclaration);
+ variableDeclarationFragment.resolveBinding();
+ }
+ return variableDeclarationFragment;
+ }
+
+ protected VariableDeclarationFragment convertToVariableDeclarationFragment(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
+ final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment(this.ast);
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(localDeclaration.name));
+ name.setSourceRange(localDeclaration.sourceStart, localDeclaration.sourceEnd - localDeclaration.sourceStart + 1);
+ variableDeclarationFragment.setName(name);
+ int start = localDeclaration.sourceEnd;
+ if (localDeclaration.initialization != null) {
+ final Expression expression = convert(localDeclaration.initialization);
+ variableDeclarationFragment.setInitializer(expression);
+ start = expression.getStartPosition() + expression.getLength();
+ }
+ int end = retrievePositionBeforeNextCommaOrSemiColon(start, localDeclaration.declarationSourceEnd);
+ if (end == -1) {
+ if (localDeclaration.initialization != null) {
+ variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, localDeclaration.initialization.sourceEnd - localDeclaration.sourceStart + 1);
+ } else {
+ variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, localDeclaration.sourceEnd - localDeclaration.sourceStart + 1);
+ }
+ } else {
+ variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, end - localDeclaration.sourceStart + 1);
+ }
+ variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, this.compilationUnitSourceLength));
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, localDeclaration);
+ recordNodes(name, localDeclaration);
+ variableDeclarationFragment.resolveBinding();
+ }
+ return variableDeclarationFragment;
+ }
+
+ protected VariableDeclarationStatement convertToVariableDeclarationStatement(org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
+ final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
+ final VariableDeclarationStatement variableDeclarationStatement = new VariableDeclarationStatement(this.ast);
+ variableDeclarationStatement.fragments().add(variableDeclarationFragment);
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, localDeclaration);
+ }
+ variableDeclarationStatement.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
+ Type type = convertType(localDeclaration.type);
+ setTypeForVariableDeclarationStatement(variableDeclarationStatement, type, variableDeclarationFragment.getExtraDimensions());
+ if (localDeclaration.modifiersSourceStart != -1) {
+ setModifiers(variableDeclarationStatement, localDeclaration);
+ }
+ return variableDeclarationStatement;
+ }
+
+ public Type convertType(TypeReference typeReference) {
+ if (typeReference instanceof Wildcard) {
+ final Wildcard wildcard = (Wildcard) typeReference;
+ final WildcardType wildcardType = new WildcardType(this.ast);
+ if (wildcard.bound != null) {
+ final Type bound = convertType(wildcard.bound);
+ wildcardType.setBound(bound, wildcard.kind == Wildcard.EXTENDS);
+ int start = wildcard.sourceStart;
+ wildcardType.setSourceRange(start, bound.getStartPosition() + bound.getLength() - start);
+ } else {
+ final int start = wildcard.sourceStart;
+ final int end = wildcard.sourceEnd;
+ wildcardType.setSourceRange(start, end - start + 1);
+ }
+ if (this.resolveBindings) {
+ recordNodes(wildcardType, typeReference);
+ }
+ return wildcardType;
+ }
+ Type type = null;
+ int sourceStart = -1;
+ int length = 0;
+ int dimensions = typeReference.dimensions();
+ if (typeReference instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) {
+ // this is either an ArrayTypeReference or a SingleTypeReference
+ char[] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference) typeReference).getTypeName()[0];
+ sourceStart = typeReference.sourceStart;
+ length = typeReference.sourceEnd - typeReference.sourceStart + 1;
+ // need to find out if this is an array type of primitive types or not
+ if (isPrimitiveType(name)) {
+ int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
+ if (end == -1) {
+ end = sourceStart + length - 1;
+ }
+ final PrimitiveType primitiveType = new PrimitiveType(this.ast);
+ primitiveType.setPrimitiveTypeCode(getPrimitiveTypeCode(name));
+ primitiveType.setSourceRange(sourceStart, end - sourceStart + 1);
+ type = primitiveType;
+ } else if (typeReference instanceof ParameterizedSingleTypeReference) {
+ ParameterizedSingleTypeReference parameterizedSingleTypeReference = (ParameterizedSingleTypeReference) typeReference;
+ final SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(name));
+ int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
+ if (end == -1) {
+ end = sourceStart + length - 1;
+ }
+ simpleName.setSourceRange(sourceStart, end - sourceStart + 1);
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ SimpleType simpleType = new SimpleType(this.ast);
+ simpleType.setName(simpleName);
+ simpleType.setFlags(simpleType.getFlags() | ASTNode.MALFORMED);
+ simpleType.setSourceRange(sourceStart, end - sourceStart + 1);
+ type = simpleType;
+ if (this.resolveBindings) {
+ this.recordNodes(simpleName, typeReference);
+ }
+ break;
+ case AST.JLS3 :
+ simpleType = new SimpleType(this.ast);
+ simpleType.setName(simpleName);
+ simpleType.setSourceRange(simpleName.getStartPosition(), simpleName.getLength());
+ final ParameterizedType parameterizedType = new ParameterizedType(this.ast);
+ parameterizedType.setType(simpleType);
+ type = parameterizedType;
+ TypeReference[] typeArguments = parameterizedSingleTypeReference.typeArguments;
+ if (typeArguments != null) {
+ Type type2 = null;
+ for (int i = 0, max = typeArguments.length; i < max; i++) {
+ type2 = convertType(typeArguments[i]);
+ ((ParameterizedType) type).typeArguments().add(type2);
+ end = type2.getStartPosition() + type2.getLength() - 1;
+ }
+ end = retrieveClosingAngleBracketPosition(end + 1);
+ type.setSourceRange(sourceStart, end - sourceStart + 1);
+ } else {
+ type.setSourceRange(sourceStart, end - sourceStart + 1);
+ }
+ if (this.resolveBindings) {
+ this.recordNodes(simpleName, typeReference);
+ this.recordNodes(simpleType, typeReference);
+ }
+ }
+ } else {
+ final SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(name));
+ // we need to search for the starting position of the first brace in order to set the proper length
+ // PR http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
+ int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
+ if (end == -1) {
+ end = sourceStart + length - 1;
+ }
+ simpleName.setSourceRange(sourceStart, end - sourceStart + 1);
+ final SimpleType simpleType = new SimpleType(this.ast);
+ simpleType.setName(simpleName);
+ type = simpleType;
+ type.setSourceRange(sourceStart, end - sourceStart + 1);
+ type = simpleType;
+ if (this.resolveBindings) {
+ this.recordNodes(simpleName, typeReference);
+ }
+ }
+ if (dimensions != 0) {
+ type = this.ast.newArrayType(type, dimensions);
+ type.setSourceRange(sourceStart, length);
+ ArrayType subarrayType = (ArrayType) type;
+ int index = dimensions - 1;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ int end = retrieveProperRightBracketPosition(index, sourceStart);
+ subarrayType.setSourceRange(sourceStart, end - sourceStart + 1);
+ index--;
+ }
+ if (this.resolveBindings) {
+ // store keys for inner types
+ completeRecord((ArrayType) type, typeReference);
+ }
+ }
+ } else {
+ if (typeReference instanceof ParameterizedQualifiedTypeReference) {
+ ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = (ParameterizedQualifiedTypeReference) typeReference;
+ char[][] tokens = parameterizedQualifiedTypeReference.tokens;
+ TypeReference[][] typeArguments = parameterizedQualifiedTypeReference.typeArguments;
+ long[] positions = parameterizedQualifiedTypeReference.sourcePositions;
+ sourceStart = (int)(positions[0]>>>32);
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL : {
+ char[][] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference).getTypeName();
+ int nameLength = name.length;
+ sourceStart = (int)(positions[0]>>>32);
+ length = (int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1;
+ Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference);
+ final SimpleType simpleType = new SimpleType(this.ast);
+ simpleType.setName(qualifiedName);
+ simpleType.setSourceRange(sourceStart, length);
+ type = simpleType;
+ }
+ break;
+ case AST.JLS3 :
+ if (typeArguments != null) {
+ int numberOfEnclosingType = 0;
+ int startingIndex = 0;
+ int endingIndex = 0;
+ for (int i = 0, max = typeArguments.length; i < max; i++) {
+ if (typeArguments[i] != null) {
+ numberOfEnclosingType++;
+ } else if (numberOfEnclosingType == 0) {
+ endingIndex++;
+ }
+ }
+ Name name = null;
+ if (endingIndex - startingIndex == 0) {
+ final SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(tokens[startingIndex]));
+ recordPendingNameScopeResolution(simpleName);
+ int start = (int)(positions[startingIndex]>>>32);
+ int end = (int) positions[startingIndex];
+ simpleName.setSourceRange(start, end - start + 1);
+ simpleName.index = 1;
+ name = simpleName;
+ if (this.resolveBindings) {
+ recordNodes(simpleName, typeReference);
+ }
+ } else {
+ name = this.setQualifiedNameNameAndSourceRanges(tokens, positions, endingIndex, typeReference);
+ }
+ SimpleType simpleType = new SimpleType(this.ast);
+ simpleType.setName(name);
+ int start = (int)(positions[startingIndex]>>>32);
+ int end = (int) positions[endingIndex];
+ simpleType.setSourceRange(start, end - start + 1);
+ ParameterizedType parameterizedType = new ParameterizedType(this.ast);
+ parameterizedType.setType(simpleType);
+ if (this.resolveBindings) {
+ recordNodes(simpleType, typeReference);
+ recordNodes(parameterizedType, typeReference);
+ }
+ start = simpleType.getStartPosition();
+ end = start + simpleType.getLength() - 1;
+ for (int i = 0, max = typeArguments[endingIndex].length; i < max; i++) {
+ final Type type2 = convertType(typeArguments[endingIndex][i]);
+ parameterizedType.typeArguments().add(type2);
+ end = type2.getStartPosition() + type2.getLength() - 1;
+ }
+ int indexOfEnclosingType = 1;
+ parameterizedType.index = indexOfEnclosingType;
+ end = retrieveClosingAngleBracketPosition(end + 1);
+ length = end + 1;
+ parameterizedType.setSourceRange(start, end - start + 1);
+ startingIndex = endingIndex + 1;
+ Type currentType = parameterizedType;
+ while(startingIndex < typeArguments.length) {
+ SimpleName simpleName = new SimpleName(this.ast);
+ simpleName.internalSetIdentifier(new String(tokens[startingIndex]));
+ simpleName.index = startingIndex + 1;
+ start = (int)(positions[startingIndex]>>>32);
+ end = (int) positions[startingIndex];
+ simpleName.setSourceRange(start, end - start + 1);
+ recordPendingNameScopeResolution(simpleName);
+ QualifiedType qualifiedType = new QualifiedType(this.ast);
+ qualifiedType.setQualifier(currentType);
+ qualifiedType.setName(simpleName);
+ if (this.resolveBindings) {
+ recordNodes(simpleName, typeReference);
+ recordNodes(qualifiedType, typeReference);
+ }
+ start = currentType.getStartPosition();
+ end = simpleName.getStartPosition() + simpleName.getLength() - 1;
+ qualifiedType.setSourceRange(start, end - start + 1);
+ indexOfEnclosingType++;
+ if (typeArguments[startingIndex] != null) {
+ qualifiedType.index = indexOfEnclosingType;
+ ParameterizedType parameterizedType2 = new ParameterizedType(this.ast);
+ parameterizedType2.setType(qualifiedType);
+ parameterizedType2.index = indexOfEnclosingType;
+ if (this.resolveBindings) {
+ recordNodes(parameterizedType2, typeReference);
+ }
+ for (int i = 0, max = typeArguments[startingIndex].length; i < max; i++) {
+ final Type type2 = convertType(typeArguments[startingIndex][i]);
+ parameterizedType2.typeArguments().add(type2);
+ end = type2.getStartPosition() + type2.getLength() - 1;
+ }
+ end = retrieveClosingAngleBracketPosition(end + 1);
+ length = end + 1;
+ parameterizedType2.setSourceRange(start, end - start + 1);
+ currentType = parameterizedType2;
+ } else {
+ currentType = qualifiedType;
+ qualifiedType.index = indexOfEnclosingType;
+ }
+ startingIndex++;
+ }
+ if (this.resolveBindings) {
+ this.recordNodes(currentType, typeReference);
+ }
+ type = currentType;
+ length -= sourceStart;
+ }
+ }
+ } else {
+ char[][] name = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference).getTypeName();
+ int nameLength = name.length;
+ long[] positions = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference).sourcePositions;
+ sourceStart = (int)(positions[0]>>>32);
+ length = (int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1;
+ final Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference);
+ final SimpleType simpleType = new SimpleType(this.ast);
+ simpleType.setName(qualifiedName);
+ type = simpleType;
+ type.setSourceRange(sourceStart, length);
+ }
+
+ if (dimensions != 0) {
+ type = this.ast.newArrayType(type, dimensions);
+ if (this.resolveBindings) {
+ completeRecord((ArrayType) type, typeReference);
+ }
+ int end = retrieveEndOfDimensionsPosition(sourceStart+length, this.compilationUnitSourceLength);
+ if (end != -1) {
+ type.setSourceRange(sourceStart, end - sourceStart + 1);
+ } else {
+ type.setSourceRange(sourceStart, length);
+ }
+ ArrayType subarrayType = (ArrayType) type;
+ int index = dimensions - 1;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ end = retrieveProperRightBracketPosition(index, sourceStart);
+ subarrayType.setSourceRange(sourceStart, end - sourceStart + 1);
+ index--;
+ }
+ }
+ }
+ if (this.resolveBindings) {
+ this.recordNodes(type, typeReference);
+ }
+ return type;
+ }
+
+ protected Comment createComment(int[] positions) {
+ // Create comment node
+ Comment comment = null;
+ int start = positions[0];
+ int end = positions[1];
+ if (positions[1]>0) { // Javadoc comments have positive end position
+ Javadoc docComment = this.docParser.parse(positions);
+ if (docComment == null) return null;
+ comment = docComment;
+ } else {
+ end = -end;
+ if (positions[0]>0) { // Block comment have positive start position
+ comment = new BlockComment(this.ast);
+ } else { // Line comment have negative start and end position
+ start = -start;
+ comment = new LineComment(this.ast);
+ }
+ comment.setSourceRange(start, end - start);
+ }
+ return comment;
+ }
+
+ protected Statement createFakeEmptyStatement(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement statement) {
+ EmptyStatement emptyStatement = new EmptyStatement(this.ast);
+ emptyStatement.setFlags(emptyStatement.getFlags() | ASTNode.MALFORMED);
+ int start = statement.sourceStart;
+ int end = statement.sourceEnd;
+ emptyStatement.setSourceRange(start, end - start + 1);
+ return emptyStatement;
+ }
+ /**
+ * @return a new modifier
+ */
+ private Modifier createModifier(ModifierKeyword keyword) {
+ final Modifier modifier = new Modifier(this.ast);
+ modifier.setKeyword(keyword);
+ int start = this.scanner.getCurrentTokenStartPosition();
+ int end = this.scanner.getCurrentTokenEndPosition();
+ modifier.setSourceRange(start, end - start + 1);
+ return modifier;
+ }
+
+ protected InfixExpression.Operator getOperatorFor(int operatorID) {
+ switch (operatorID) {
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.EQUAL_EQUAL :
+ return InfixExpression.Operator.EQUALS;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS_EQUAL :
+ return InfixExpression.Operator.LESS_EQUALS;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER_EQUAL :
+ return InfixExpression.Operator.GREATER_EQUALS;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.NOT_EQUAL :
+ return InfixExpression.Operator.NOT_EQUALS;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LEFT_SHIFT :
+ return InfixExpression.Operator.LEFT_SHIFT;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.RIGHT_SHIFT :
+ return InfixExpression.Operator.RIGHT_SHIFT_SIGNED;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.UNSIGNED_RIGHT_SHIFT :
+ return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR_OR :
+ return InfixExpression.Operator.CONDITIONAL_OR;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND_AND :
+ return InfixExpression.Operator.CONDITIONAL_AND;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS :
+ return InfixExpression.Operator.PLUS;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS :
+ return InfixExpression.Operator.MINUS;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.REMAINDER :
+ return InfixExpression.Operator.REMAINDER;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.XOR :
+ return InfixExpression.Operator.XOR;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.AND :
+ return InfixExpression.Operator.AND;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.MULTIPLY :
+ return InfixExpression.Operator.TIMES;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.OR :
+ return InfixExpression.Operator.OR;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.DIVIDE :
+ return InfixExpression.Operator.DIVIDE;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.GREATER :
+ return InfixExpression.Operator.GREATER;
+ case org.aspectj.org.eclipse.jdt.internal.compiler.ast.OperatorIds.LESS :
+ return InfixExpression.Operator.LESS;
+ }
+ return null;
+ }
+
+ protected PrimitiveType.Code getPrimitiveTypeCode(char[] name) {
+ switch(name[0]) {
+ case 'i' :
+ if (name.length == 3 && name[1] == 'n' && name[2] == 't') {
+ return PrimitiveType.INT;
+ }
+ break;
+ case 'l' :
+ if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') {
+ return PrimitiveType.LONG;
+ }
+ break;
+ case 'd' :
+ if (name.length == 6
+ && name[1] == 'o'
+ && name[2] == 'u'
+ && name[3] == 'b'
+ && name[4] == 'l'
+ && name[5] == 'e') {
+ return PrimitiveType.DOUBLE;
+ }
+ break;
+ case 'f' :
+ if (name.length == 5
+ && name[1] == 'l'
+ && name[2] == 'o'
+ && name[3] == 'a'
+ && name[4] == 't') {
+ return PrimitiveType.FLOAT;
+ }
+ break;
+ case 'b' :
+ if (name.length == 4
+ && name[1] == 'y'
+ && name[2] == 't'
+ && name[3] == 'e') {
+ return PrimitiveType.BYTE;
+ } else
+ if (name.length == 7
+ && name[1] == 'o'
+ && name[2] == 'o'
+ && name[3] == 'l'
+ && name[4] == 'e'
+ && name[5] == 'a'
+ && name[6] == 'n') {
+ return PrimitiveType.BOOLEAN;
+ }
+ break;
+ case 'c' :
+ if (name.length == 4
+ && name[1] == 'h'
+ && name[2] == 'a'
+ && name[3] == 'r') {
+ return PrimitiveType.CHAR;
+ }
+ break;
+ case 's' :
+ if (name.length == 5
+ && name[1] == 'h'
+ && name[2] == 'o'
+ && name[3] == 'r'
+ && name[4] == 't') {
+ return PrimitiveType.SHORT;
+ }
+ break;
+ case 'v' :
+ if (name.length == 4
+ && name[1] == 'o'
+ && name[2] == 'i'
+ && name[3] == 'd') {
+ return PrimitiveType.VOID;
+ }
+ }
+ return null; // cannot be reached
+ }
+
+ protected boolean isPrimitiveType(char[] name) {
+ switch(name[0]) {
+ case 'i' :
+ if (name.length == 3 && name[1] == 'n' && name[2] == 't') {
+ return true;
+ }
+ return false;
+ case 'l' :
+ if (name.length == 4 && name[1] == 'o' && name[2] == 'n' && name[3] == 'g') {
+ return true;
+ }
+ return false;
+ case 'd' :
+ if (name.length == 6
+ && name[1] == 'o'
+ && name[2] == 'u'
+ && name[3] == 'b'
+ && name[4] == 'l'
+ && name[5] == 'e') {
+ return true;
+ }
+ return false;
+ case 'f' :
+ if (name.length == 5
+ && name[1] == 'l'
+ && name[2] == 'o'
+ && name[3] == 'a'
+ && name[4] == 't') {
+ return true;
+ }
+ return false;
+ case 'b' :
+ if (name.length == 4
+ && name[1] == 'y'
+ && name[2] == 't'
+ && name[3] == 'e') {
+ return true;
+ } else
+ if (name.length == 7
+ && name[1] == 'o'
+ && name[2] == 'o'
+ && name[3] == 'l'
+ && name[4] == 'e'
+ && name[5] == 'a'
+ && name[6] == 'n') {
+ return true;
+ }
+ return false;
+ case 'c' :
+ if (name.length == 4
+ && name[1] == 'h'
+ && name[2] == 'a'
+ && name[3] == 'r') {
+ return true;
+ }
+ return false;
+ case 's' :
+ if (name.length == 5
+ && name[1] == 'h'
+ && name[2] == 'o'
+ && name[3] == 'r'
+ && name[4] == 't') {
+ return true;
+ }
+ return false;
+ case 'v' :
+ if (name.length == 4
+ && name[1] == 'o'
+ && name[2] == 'i'
+ && name[3] == 'd') {
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+
+ private void lookupForScopes() {
+ if (this.pendingNameScopeResolution != null) {
+ for (Iterator iterator = this.pendingNameScopeResolution.iterator(); iterator.hasNext(); ) {
+ Name name = (Name) iterator.next();
+ this.ast.getBindingResolver().recordScope(name, lookupScope(name));
+ }
+ }
+ if (this.pendingThisExpressionScopeResolution != null) {
+ for (Iterator iterator = this.pendingThisExpressionScopeResolution.iterator(); iterator.hasNext(); ) {
+ ThisExpression thisExpression = (ThisExpression) iterator.next();
+ this.ast.getBindingResolver().recordScope(thisExpression, lookupScope(thisExpression));
+ }
+ }
+
+ }
+
+ private BlockScope lookupScope(ASTNode node) {
+ ASTNode currentNode = node;
+ while(currentNode != null
+ &&!(currentNode instanceof MethodDeclaration)
+ && !(currentNode instanceof Initializer)
+ && !(currentNode instanceof FieldDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ if (currentNode == null) {
+ return null;
+ }
+ if (currentNode instanceof Initializer) {
+ Initializer initializer = (Initializer) currentNode;
+ while(!(currentNode instanceof AbstractTypeDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ if (currentNode instanceof TypeDeclaration
+ || currentNode instanceof EnumDeclaration
+ || currentNode instanceof AnnotationTypeDeclaration) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode);
+ if ((initializer.getModifiers() & Modifier.STATIC) != 0) {
+ return typeDecl.staticInitializerScope;
+ } else {
+ return typeDecl.initializerScope;
+ }
+ }
+ } else if (currentNode instanceof FieldDeclaration) {
+ FieldDeclaration fieldDeclaration = (FieldDeclaration) currentNode;
+ while(!(currentNode instanceof AbstractTypeDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ if (currentNode instanceof TypeDeclaration
+ || currentNode instanceof EnumDeclaration
+ || currentNode instanceof AnnotationTypeDeclaration) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode);
+ if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) {
+ return typeDecl.staticInitializerScope;
+ } else {
+ return typeDecl.initializerScope;
+ }
+ }
+ }
+ AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.ast.getBindingResolver().getCorrespondingNode(currentNode);
+ return abstractMethodDeclaration.scope;
+ }
+
+ protected void recordName(Name name, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode) {
+ if (compilerNode != null) {
+ recordNodes(name, compilerNode);
+ if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) compilerNode;
+ if (name.isQualifiedName()) {
+ SimpleName simpleName = null;
+ while (name.isQualifiedName()) {
+ simpleName = ((QualifiedName) name).getName();
+ recordNodes(simpleName, typeRef);
+ name = ((QualifiedName) name).getQualifier();
+ recordNodes(name, typeRef);
+ }
+ }
+ }
+ }
+ }
+
+ protected void recordNodes(ASTNode node, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode oldASTNode) {
+ this.ast.getBindingResolver().store(node, oldASTNode);
+ }
+
+ protected void recordNodes(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, TagElement tagElement) {
+ Iterator fragments = tagElement.fragments().listIterator();
+ while (fragments.hasNext()) {
+ ASTNode node = (ASTNode) fragments.next();
+ if (node.getNodeType() == ASTNode.MEMBER_REF) {
+ MemberRef memberRef = (MemberRef) node;
+ Name name = memberRef.getName();
+ // get compiler node and record nodes
+ int start = name.getStartPosition();
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(start);
+ if (compilerNode!= null) {
+ recordNodes(name, compilerNode);
+ recordNodes(node, compilerNode);
+ }
+ // Replace qualifier to have all nodes recorded
+ if (memberRef.getQualifier() != null) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null;
+ if (compilerNode instanceof JavadocFieldReference) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocFieldReference)compilerNode).receiver;
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) {
+ typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression;
+ }
+ }
+ else if (compilerNode instanceof JavadocMessageSend) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((JavadocMessageSend)compilerNode).receiver;
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) {
+ typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression;
+ }
+ }
+ if (typeRef != null) {
+ recordName(memberRef.getQualifier(), typeRef);
+ }
+ }
+ } else if (node.getNodeType() == ASTNode.METHOD_REF) {
+ MethodRef methodRef = (MethodRef) node;
+ Name name = methodRef.getName();
+ // get compiler node and record nodes
+ int start = name.getStartPosition();
+ // get compiler node and record nodes
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(start);
+ // record nodes
+ if (compilerNode != null) {
+ recordNodes(methodRef, compilerNode);
+ // get type ref
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = null;
+ if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression) {
+ typeRef = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocAllocationExpression)compilerNode).type;
+ if (typeRef != null) recordNodes(name, compilerNode);
+ }
+ else if (compilerNode instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = ((org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocMessageSend)compilerNode).receiver;
+ if (expression instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) {
+ typeRef = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference) expression;
+ }
+ // TODO (frederic) remove following line to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=62650
+ recordNodes(name, compilerNode);
+ }
+ // record name and qualifier
+ if (typeRef != null && methodRef.getQualifier() != null) {
+ recordName(methodRef.getQualifier(), typeRef);
+ }
+ }
+ // Resolve parameters
+ Iterator parameters = methodRef.parameters().listIterator();
+ while (parameters.hasNext()) {
+ MethodRefParameter param = (MethodRefParameter) parameters.next();
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) javadoc.getNodeStartingAt(param.getStartPosition());
+ if (expression != null) {
+ recordNodes(param, expression);
+ if (expression instanceof JavadocArgumentExpression) {
+ JavadocArgumentExpression argExpr = (JavadocArgumentExpression) expression;
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef = argExpr.argument.type;
+ if (this.ast.apiLevel >= AST.JLS3) param.setVarargs(argExpr.argument.isVarArgs());
+ recordNodes(param.getType(), typeRef);
+ if (param.getType().isSimpleType()) {
+ recordName(((SimpleType)param.getType()).getName(), typeRef);
+ } else if (param.getType().isArrayType()) {
+ Type type = ((ArrayType) param.getType()).getElementType();
+ recordNodes(type, typeRef);
+ if (type.isSimpleType()) {
+ recordName(((SimpleType)type).getName(), typeRef);
+ }
+ }
+ }
+ }
+ }
+ } else if (node.getNodeType() == ASTNode.SIMPLE_NAME ||
+ node.getNodeType() == ASTNode.QUALIFIED_NAME) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode compilerNode = javadoc.getNodeStartingAt(node.getStartPosition());
+ recordName((Name) node, compilerNode);
+ } else if (node.getNodeType() == ASTNode.TAG_ELEMENT) {
+ // resolve member and method references binding
+ recordNodes(javadoc, (TagElement) node);
+ }
+ }
+ }
+
+ protected void recordPendingNameScopeResolution(Name name) {
+ if (this.pendingNameScopeResolution == null) {
+ this.pendingNameScopeResolution = new HashSet();
+ }
+ this.pendingNameScopeResolution.add(name);
+ }
+
+ protected void recordPendingThisExpressionScopeResolution(ThisExpression thisExpression) {
+ if (this.pendingThisExpressionScopeResolution == null) {
+ this.pendingThisExpressionScopeResolution = new HashSet();
+ }
+ this.pendingThisExpressionScopeResolution.add(thisExpression);
+ }
+
+ /**
+ * Remove whitespaces and comments before and after the expression.
+ */
+ private void trimWhiteSpacesAndComments(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression expression) {
+ int start = expression.sourceStart;
+ int end = expression.sourceEnd;
+ int token;
+ int trimLeftPosition = expression.sourceStart;
+ int trimRightPosition = expression.sourceEnd;
+ boolean first = true;
+ Scanner removeBlankScanner = this.ast.scanner;
+ try {
+ removeBlankScanner.setSource(this.compilationUnitSource);
+ removeBlankScanner.resetTo(start, end);
+ while (true) {
+ token = removeBlankScanner.getNextToken();
+ switch (token) {
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ if (first) {
+ trimLeftPosition = removeBlankScanner.currentPosition;
+ }
+ break;
+ case TerminalTokens.TokenNameWHITESPACE :
+ if (first) {
+ trimLeftPosition = removeBlankScanner.currentPosition;
+ }
+ break;
+ case TerminalTokens.TokenNameEOF :
+ expression.sourceStart = trimLeftPosition;
+ expression.sourceEnd = trimRightPosition;
+ return;
+ default :
+ /*
+ * if we find something else than a whitespace or a comment,
+ * then we reset the trimRigthPosition to the expression
+ * source end.
+ */
+ trimRightPosition = removeBlankScanner.currentPosition - 1;
+ first = false;
+ }
+ }
+ } catch (InvalidInputException e){
+ // ignore
+ }
+ }
+
+ protected int retrieveEndingSemiColonPosition(int start, int end) {
+ int count = 0;
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameSEMICOLON:
+ if (count == 0) {
+ return this.scanner.currentPosition - 1;
+ }
+ break;
+ case TerminalTokens.TokenNameLBRACE :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACE :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLPAREN :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRPAREN :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLBRACKET :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACKET :
+ count--;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve the ending position for a type declaration when the dimension is right after the type
+ * name.
+ * For example:
+ * int[] i; => return 5, but int i[] => return -1;
+ * @return int the dimension found
+ */
+ protected int retrieveEndOfDimensionsPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ int foundPosition = -1;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameLBRACKET:
+ case TerminalTokens.TokenNameCOMMENT_BLOCK:
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC:
+ case TerminalTokens.TokenNameCOMMENT_LINE:
+ break;
+ case TerminalTokens.TokenNameRBRACKET://166
+ foundPosition = this.scanner.currentPosition - 1;
+ break;
+ default:
+ return foundPosition;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return foundPosition;
+ }
+
+ /**
+ * This method is used to retrieve the position just before the left bracket.
+ * @return int the dimension found, -1 if none
+ */
+ protected int retrieveEndOfElementTypeNamePosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameIdentifier:
+ case TerminalTokens.TokenNamebyte:
+ case TerminalTokens.TokenNamechar:
+ case TerminalTokens.TokenNamedouble:
+ case TerminalTokens.TokenNamefloat:
+ case TerminalTokens.TokenNameint:
+ case TerminalTokens.TokenNamelong:
+ case TerminalTokens.TokenNameshort:
+ case TerminalTokens.TokenNameboolean:
+ return this.scanner.currentPosition - 1;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve the position after the right parenthesis.
+ * @return int the position found
+ */
+ protected int retrieveEndOfRightParenthesisPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameRPAREN:
+ return this.scanner.currentPosition;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve the array dimension declared after the
+ * name of a local or a field declaration.
+ * For example:
+ * int i, j[] = null, k[][] = {{}};
+ * It should return 0 for i, 1 for j and 2 for k.
+ * @return int the dimension found
+ */
+ protected int retrieveExtraDimension(int start, int end) {
+ this.scanner.resetTo(start, end);
+ int dimensions = 0;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameLBRACKET:
+ case TerminalTokens.TokenNameCOMMENT_BLOCK:
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC:
+ case TerminalTokens.TokenNameCOMMENT_LINE:
+ break;
+ case TerminalTokens.TokenNameRBRACKET://166
+ dimensions++;
+ break;
+ default:
+ return dimensions;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return dimensions;
+ }
+
+ protected void retrieveIdentifierAndSetPositions(int start, int end, Name name) {
+ this.scanner.resetTo(start, end);
+ int token;
+ try {
+ while((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ if (token == TerminalTokens.TokenNameIdentifier) {
+ int startName = this.scanner.startPosition;
+ int endName = this.scanner.currentPosition - 1;
+ name.setSourceRange(startName, endName - startName + 1);
+ return;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+
+ /**
+ * This method is used to retrieve the start position of the block.
+ * @return int the dimension found, -1 if none
+ */
+ protected int retrieveIdentifierEndPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameIdentifier://110
+ return this.scanner.getCurrentTokenEndPosition();
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve position before the next comma or semi-colon.
+ * @return int the position found.
+ */
+ protected int retrievePositionBeforeNextCommaOrSemiColon(int start, int end) {
+ this.scanner.resetTo(start, end);
+ int braceCounter = 0;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameLBRACE :
+ braceCounter++;
+ break;
+ case TerminalTokens.TokenNameRBRACE :
+ braceCounter--;
+ break;
+ case TerminalTokens.TokenNameLPAREN :
+ braceCounter++;
+ break;
+ case TerminalTokens.TokenNameRPAREN :
+ braceCounter--;
+ break;
+ case TerminalTokens.TokenNameLBRACKET :
+ braceCounter++;
+ break;
+ case TerminalTokens.TokenNameRBRACKET :
+ braceCounter--;
+ break;
+ case TerminalTokens.TokenNameCOMMA :
+ case TerminalTokens.TokenNameSEMICOLON :
+ if (braceCounter == 0) {
+ return this.scanner.startPosition - 1;
+ }
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ protected int retrieveProperRightBracketPosition(int bracketNumber, int start) {
+ this.scanner.resetTo(start, this.compilationUnitSourceLength);
+ try {
+ int token, count = 0;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameRBRACKET:
+ count++;
+ if (count == bracketNumber) {
+ return this.scanner.currentPosition - 1;
+ }
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve position before the next right brace or semi-colon.
+ * @return int the position found.
+ */
+ protected int retrieveRightBraceOrSemiColonPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameRBRACE :
+ return this.scanner.currentPosition - 1;
+ case TerminalTokens.TokenNameSEMICOLON :
+ return this.scanner.currentPosition - 1;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve position before the next right brace or semi-colon.
+ * @return int the position found.
+ */
+ protected int retrieveRightBrace(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameRBRACE :
+ return this.scanner.currentPosition - 1;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve the position of the right bracket.
+ * @return int the dimension found, -1 if none
+ */
+ protected int retrieveRightBracketPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameRBRACKET:
+ return this.scanner.currentPosition - 1;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /*
+ * This method is used to set the right end position for expression
+ * statement. The actual AST nodes don't include the trailing semicolon.
+ * This method fixes the length of the corresponding node.
+ */
+ protected void retrieveSemiColonPosition(ASTNode node) {
+ int start = node.getStartPosition();
+ int length = node.getLength();
+ int end = start + length;
+ int count = 0;
+ this.scanner.resetTo(end, this.compilationUnitSourceLength);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameSEMICOLON:
+ if (count == 0) {
+ node.setSourceRange(start, this.scanner.currentPosition - start);
+ return;
+ }
+ break;
+ case TerminalTokens.TokenNameLBRACE :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACE :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLPAREN :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRPAREN :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLBRACKET :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACKET :
+ count--;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+
+ /**
+ * This method is used to retrieve the start position of the block.
+ * @return int the dimension found, -1 if none
+ */
+ protected int retrieveStartBlockPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameLBRACE://110
+ return this.scanner.startPosition;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ /**
+ * This method is used to retrieve the starting position of the catch keyword.
+ * @return int the dimension found, -1 if none
+ */
+ protected int retrieveStartingCatchPosition(int start, int end) {
+ this.scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNamecatch://225
+ return this.scanner.startPosition;
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ return -1;
+ }
+
+ public void setAST(AST ast) {
+ this.ast = ast;
+ this.docParser = new DocCommentParser(this.ast, this.scanner, this.insideComments);
+ }
+
+ protected void setModifiers(AnnotationTypeDeclaration typeDecl, org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
+ this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart);
+ this.setModifiers(typeDecl, typeDeclaration.annotations);
+ }
+
+ protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMemberDecl, org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
+ this.scanner.resetTo(annotationTypeMemberDeclaration.declarationSourceStart, annotationTypeMemberDeclaration.sourceStart);
+ this.setModifiers(annotationTypeMemberDecl, annotationTypeMemberDeclaration.annotations);
+ }
+
+ /**
+ * @param bodyDeclaration
+ */
+ protected void setModifiers(BodyDeclaration bodyDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) {
+ try {
+ int token;
+ int indexInAnnotations = 0;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ IExtendedModifier modifier = null;
+ switch(token) {
+ case TerminalTokens.TokenNameabstract:
+ modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamepublic:
+ modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestatic:
+ modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprotected:
+ modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprivate:
+ modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamefinal:
+ modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamenative:
+ modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamesynchronized:
+ modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNametransient:
+ modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamevolatile:
+ modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestrictfp:
+ modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameAT :
+ // we have an annotation
+ if (annotations != null && indexInAnnotations < annotations.length) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
+ modifier = convert(annotation);
+ this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
+ }
+ break;
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ break;
+ default :
+ return;
+ }
+ if (modifier != null) {
+ bodyDeclaration.modifiers().add(modifier);
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+
+
+ protected void setModifiers(EnumDeclaration enumDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2) {
+ this.scanner.resetTo(enumDeclaration2.declarationSourceStart, enumDeclaration2.sourceStart);
+ this.setModifiers(enumDeclaration, enumDeclaration2.annotations);
+ }
+
+ protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ enumConstantDeclaration.internalSetModifiers(fieldDeclaration.modifiers & CompilerModifiers.AccJustFlag);
+ if (fieldDeclaration.annotations != null) {
+ enumConstantDeclaration.setFlags(enumConstantDeclaration.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart);
+ this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations);
+ }
+ }
+
+ /**
+ * @param fieldDeclaration
+ * @param fieldDecl
+ */
+ protected void setModifiers(FieldDeclaration fieldDeclaration, org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDecl) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ fieldDeclaration.internalSetModifiers(fieldDecl.modifiers & CompilerModifiers.AccJustFlag);
+ if (fieldDecl.annotations != null) {
+ fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart);
+ this.setModifiers(fieldDeclaration, fieldDecl.annotations);
+ }
+ }
+
+ protected void setModifiers(org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration fieldDeclaration, InterTypeFieldDeclaration fieldDecl) {
+ // ajh02: method added
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ fieldDeclaration.internalSetModifiers(fieldDecl.modifiers & CompilerModifiers.AccJustFlag);
+ if (fieldDecl.annotations != null) {
+ fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart);
+ this.setModifiers(fieldDeclaration, fieldDecl.annotations);
+ }
+ }
+
+ /**
+ * @param initializer
+ * @param oldInitializer
+ */
+ protected void setModifiers(Initializer initializer, org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer oldInitializer) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL:
+ initializer.internalSetModifiers(oldInitializer.modifiers & CompilerModifiers.AccJustFlag);
+ if (oldInitializer.annotations != null) {
+ initializer.setFlags(initializer.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart);
+ this.setModifiers(initializer, oldInitializer.annotations);
+ }
+ }
+ /**
+ * @param methodDecl
+ * @param methodDeclaration
+ */
+ protected void setModifiers(MethodDeclaration methodDecl, AbstractMethodDeclaration methodDeclaration) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ methodDecl.internalSetModifiers(methodDeclaration.modifiers & CompilerModifiers.AccJustFlag);
+ if (methodDeclaration.annotations != null) {
+ methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart);
+ this.setModifiers(methodDecl, methodDeclaration.annotations);
+ }
+ }
+
+ protected void setModifiers(org.aspectj.org.eclipse.jdt.core.dom.PointcutDeclaration pointcutDecl, PointcutDeclaration pointcutDeclaration) {
+ // ajh02: method added
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ pointcutDecl.internalSetModifiers(pointcutDeclaration.modifiers & CompilerModifiers.AccJustFlag);
+ if (pointcutDeclaration.annotations != null) {
+ pointcutDecl.setFlags(pointcutDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(pointcutDeclaration.declarationSourceStart, pointcutDeclaration.sourceStart);
+ this.setModifiers(pointcutDecl, pointcutDeclaration.annotations);
+ }
+ }
+
+ /**
+ * @param variableDecl
+ * @param argument
+ */
+ protected void setModifiers(SingleVariableDeclaration variableDecl, Argument argument) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ variableDecl.internalSetModifiers(argument.modifiers & CompilerModifiers.AccJustFlag);
+ if (argument.annotations != null) {
+ variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(argument.declarationSourceStart, argument.sourceStart);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = argument.annotations;
+ int indexInAnnotations = 0;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ IExtendedModifier modifier = null;
+ switch(token) {
+ case TerminalTokens.TokenNameabstract:
+ modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamepublic:
+ modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestatic:
+ modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprotected:
+ modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprivate:
+ modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamefinal:
+ modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamenative:
+ modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamesynchronized:
+ modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNametransient:
+ modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamevolatile:
+ modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestrictfp:
+ modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameAT :
+ // we have an annotation
+ if (annotations != null && indexInAnnotations < annotations.length) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
+ modifier = convert(annotation);
+ this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
+ }
+ break;
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ break;
+ default :
+ return;
+ }
+ if (modifier != null) {
+ variableDecl.modifiers().add(modifier);
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+ }
+
+ protected void setModifiers(SingleVariableDeclaration variableDecl, LocalDeclaration localDeclaration) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ variableDecl.internalSetModifiers(localDeclaration.modifiers & CompilerModifiers.AccJustFlag);
+ if (localDeclaration.annotations != null) {
+ variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations;
+ int indexInAnnotations = 0;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ IExtendedModifier modifier = null;
+ switch(token) {
+ case TerminalTokens.TokenNameabstract:
+ modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamepublic:
+ modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestatic:
+ modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprotected:
+ modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprivate:
+ modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamefinal:
+ modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamenative:
+ modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamesynchronized:
+ modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNametransient:
+ modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamevolatile:
+ modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestrictfp:
+ modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameAT :
+ // we have an annotation
+ if (annotations != null && indexInAnnotations < annotations.length) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
+ modifier = convert(annotation);
+ this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
+ }
+ break;
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ break;
+ default :
+ return;
+ }
+ if (modifier != null) {
+ variableDecl.modifiers().add(modifier);
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * @param typeDecl
+ * @param typeDeclaration
+ */
+ protected void setModifiers(TypeDeclaration typeDecl, org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ int modifiers = typeDeclaration.modifiers;
+ modifiers &= ~IConstants.AccInterface; // remove AccInterface flags
+ modifiers &= CompilerModifiers.AccJustFlag;
+ typeDecl.internalSetModifiers(modifiers);
+ if (typeDeclaration.annotations != null) {
+ typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart);
+ this.setModifiers(typeDecl, typeDeclaration.annotations);
+ }
+ }
+
+ /**
+ * @param variableDeclarationExpression
+ * @param localDeclaration
+ */
+ protected void setModifiers(VariableDeclarationExpression variableDeclarationExpression, LocalDeclaration localDeclaration) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ int modifiers = localDeclaration.modifiers & CompilerModifiers.AccJustFlag;
+ modifiers &= ~CompilerModifiers.AccBlankFinal;
+ variableDeclarationExpression.internalSetModifiers(modifiers);
+ if (localDeclaration.annotations != null) {
+ variableDeclarationExpression.setFlags(variableDeclarationExpression.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations;
+ int indexInAnnotations = 0;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ IExtendedModifier modifier = null;
+ switch(token) {
+ case TerminalTokens.TokenNameabstract:
+ modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamepublic:
+ modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestatic:
+ modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprotected:
+ modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprivate:
+ modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamefinal:
+ modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamenative:
+ modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamesynchronized:
+ modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNametransient:
+ modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamevolatile:
+ modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestrictfp:
+ modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameAT :
+ // we have an annotation
+ if (annotations != null && indexInAnnotations < annotations.length) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
+ modifier = convert(annotation);
+ this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
+ }
+ break;
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ break;
+ default :
+ return;
+ }
+ if (modifier != null) {
+ variableDeclarationExpression.modifiers().add(modifier);
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * @param variableDeclarationStatement
+ * @param localDeclaration
+ */
+ protected void setModifiers(VariableDeclarationStatement variableDeclarationStatement, LocalDeclaration localDeclaration) {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ int modifiers = localDeclaration.modifiers & CompilerModifiers.AccJustFlag;
+ modifiers &= ~CompilerModifiers.AccBlankFinal;
+ variableDeclarationStatement.internalSetModifiers(modifiers);
+ if (localDeclaration.annotations != null) {
+ variableDeclarationStatement.setFlags(variableDeclarationStatement.getFlags() | ASTNode.MALFORMED);
+ }
+ break;
+ case AST.JLS3 :
+ this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart);
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations;
+ int indexInAnnotations = 0;
+ try {
+ int token;
+ while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ IExtendedModifier modifier = null;
+ switch(token) {
+ case TerminalTokens.TokenNameabstract:
+ modifier = createModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamepublic:
+ modifier = createModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestatic:
+ modifier = createModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprotected:
+ modifier = createModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameprivate:
+ modifier = createModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamefinal:
+ modifier = createModifier(Modifier.ModifierKeyword.FINAL_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamenative:
+ modifier = createModifier(Modifier.ModifierKeyword.NATIVE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamesynchronized:
+ modifier = createModifier(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD);
+ break;
+ case TerminalTokens.TokenNametransient:
+ modifier = createModifier(Modifier.ModifierKeyword.TRANSIENT_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamevolatile:
+ modifier = createModifier(Modifier.ModifierKeyword.VOLATILE_KEYWORD);
+ break;
+ case TerminalTokens.TokenNamestrictfp:
+ modifier = createModifier(Modifier.ModifierKeyword.STRICTFP_KEYWORD);
+ break;
+ case TerminalTokens.TokenNameAT :
+ // we have an annotation
+ if (annotations != null && indexInAnnotations < annotations.length) {
+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
+ modifier = convert(annotation);
+ this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
+ }
+ break;
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ break;
+ default :
+ return;
+ }
+ if (modifier != null) {
+ variableDeclarationStatement.modifiers().add(modifier);
+ }
+ }
+ } catch(InvalidInputException e) {
+ // ignore
+ }
+ }
+ }
+
+ protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node) {
+ int length = typeName.length;
+ final SimpleName firstToken = new SimpleName(this.ast);
+ firstToken.internalSetIdentifier(new String(typeName[0]));
+ firstToken.index = 1;
+ int start0 = (int)(positions[0]>>>32);
+ int start = start0;
+ int end = (int)(positions[0] & 0xFFFFFFFF);
+ firstToken.setSourceRange(start, end - start + 1);
+ final SimpleName secondToken = new SimpleName(this.ast);
+ secondToken.internalSetIdentifier(new String(typeName[1]));
+ secondToken.index = 2;
+ start = (int)(positions[1]>>>32);
+ end = (int)(positions[1] & 0xFFFFFFFF);
+ secondToken.setSourceRange(start, end - start + 1);
+ QualifiedName qualifiedName = new QualifiedName(this.ast);
+ qualifiedName.setQualifier(firstToken);
+ qualifiedName.setName(secondToken);
+ if (this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ recordNodes(firstToken, node);
+ recordNodes(secondToken, node);
+ recordPendingNameScopeResolution(firstToken);
+ recordPendingNameScopeResolution(secondToken);
+ }
+ qualifiedName.index = 2;
+ qualifiedName.setSourceRange(start0, end - start0 + 1);
+ SimpleName newPart = null;
+ for (int i = 2; i < length; i++) {
+ newPart = new SimpleName(this.ast);
+ newPart.internalSetIdentifier(new String(typeName[i]));
+ newPart.index = i + 1;
+ start = (int)(positions[i]>>>32);
+ end = (int)(positions[i] & 0xFFFFFFFF);
+ newPart.setSourceRange(start, end - start + 1);
+ QualifiedName qualifiedName2 = new QualifiedName(this.ast);
+ qualifiedName2.setQualifier(qualifiedName);
+ qualifiedName2.setName(newPart);
+ qualifiedName = qualifiedName2;
+ qualifiedName.index = newPart.index;
+ qualifiedName.setSourceRange(start0, end - start0 + 1);
+ if (this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordNodes(newPart, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ recordPendingNameScopeResolution(newPart);
+ }
+ }
+ QualifiedName name = qualifiedName;
+ if (this.resolveBindings) {
+ recordNodes(name, node);
+ recordPendingNameScopeResolution(name);
+ }
+ return name;
+ }
+
+ protected QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, int endingIndex, org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node) {
+ int length = endingIndex + 1;
+ final SimpleName firstToken = new SimpleName(this.ast);
+ firstToken.internalSetIdentifier(new String(typeName[0]));
+ firstToken.index = 1;
+ int start0 = (int)(positions[0]>>>32);
+ int start = start0;
+ int end = (int) positions[0];
+ firstToken.setSourceRange(start, end - start + 1);
+ final SimpleName secondToken = new SimpleName(this.ast);
+ secondToken.internalSetIdentifier(new String(typeName[1]));
+ secondToken.index = 2;
+ start = (int)(positions[1]>>>32);
+ end = (int) positions[1];
+ secondToken.setSourceRange(start, end - start + 1);
+ QualifiedName qualifiedName = new QualifiedName(this.ast);
+ qualifiedName.setQualifier(firstToken);
+ qualifiedName.setName(secondToken);
+ if (this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ recordNodes(firstToken, node);
+ recordNodes(secondToken, node);
+ recordPendingNameScopeResolution(firstToken);
+ recordPendingNameScopeResolution(secondToken);
+ }
+ qualifiedName.index = 2;
+ qualifiedName.setSourceRange(start0, end - start0 + 1);
+ SimpleName newPart = null;
+ for (int i = 2; i < length; i++) {
+ newPart = new SimpleName(this.ast);
+ newPart.internalSetIdentifier(new String(typeName[i]));
+ newPart.index = i + 1;
+ start = (int)(positions[i]>>>32);
+ end = (int) positions[i];
+ newPart.setSourceRange(start, end - start + 1);
+ QualifiedName qualifiedName2 = new QualifiedName(this.ast);
+ qualifiedName2.setQualifier(qualifiedName);
+ qualifiedName2.setName(newPart);
+ qualifiedName = qualifiedName2;
+ qualifiedName.index = newPart.index;
+ qualifiedName.setSourceRange(start0, end - start0 + 1);
+ if (this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordNodes(newPart, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ recordPendingNameScopeResolution(newPart);
+ }
+ }
+ if (newPart == null && this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ }
+ return qualifiedName;
+ }
+
+ protected void setTypeNameForAnnotation(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation compilerAnnotation, Annotation annotation) {
+ TypeReference typeReference = compilerAnnotation.type;
+ if (typeReference instanceof QualifiedTypeReference) {
+ QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) typeReference;
+ char[][] tokens = qualifiedTypeReference.tokens;
+ long[] positions = qualifiedTypeReference.sourcePositions;
+ // QualifiedName
+ annotation.setTypeName(setQualifiedNameNameAndSourceRanges(tokens, positions, typeReference));
+ } else {
+ SingleTypeReference singleTypeReference = (SingleTypeReference) typeReference;
+ final SimpleName name = new SimpleName(this.ast);
+ name.internalSetIdentifier(new String(singleTypeReference.token));
+ int start = singleTypeReference.sourceStart;
+ int end = singleTypeReference.sourceEnd;
+ name.setSourceRange(start, end - start + 1);
+ annotation.setTypeName(name);
+ if (this.resolveBindings) {
+ recordNodes(name, typeReference);
+ }
+ }
+ }
+
+ protected void setTypeForField(FieldDeclaration fieldDeclaration, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ // cut the child loose from its parent (without creating garbage)
+ elementType.setParent(null, null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ fieldDeclaration.setType(elementType);
+ } else {
+ int start = type.getStartPosition();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start);
+ subarrayType.setSourceRange(start, end - start + 1);
+ // cut the child loose from its parent (without creating garbage)
+ subarrayType.setParent(null, null);
+ fieldDeclaration.setType(subarrayType);
+ updateInnerPositions(subarrayType, remainingDimensions);
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ fieldDeclaration.setType(type);
+ }
+ } else {
+ if (type.isArrayType()) {
+ // update positions of the component types of the array type
+ int dimensions = ((ArrayType) type).getDimensions();
+ updateInnerPositions(type, dimensions);
+ }
+ fieldDeclaration.setType(type);
+ }
+ }
+
+ protected void setTypeForAroundAdviceDeclaration(AroundAdviceDeclaration adviceDeclaration, Type type) {
+ // ajh02: method added
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ adviceDeclaration.internalSetReturnType(type);
+ break;
+ case AST.JLS3 :
+ adviceDeclaration.setReturnType2(type);
+ break;
+ }
+ }
+
+ protected void setTypeForMethodDeclaration(MethodDeclaration methodDeclaration, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ // cut the child loose from its parent (without creating garbage)
+ elementType.setParent(null, null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ methodDeclaration.internalSetReturnType(elementType);
+ break;
+ case AST.JLS3 :
+ methodDeclaration.setReturnType2(elementType);
+ break;
+ }
+ } else {
+ int start = type.getStartPosition();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start);
+ subarrayType.setSourceRange(start, end - start + 1);
+ // cut the child loose from its parent (without creating garbage)
+ subarrayType.setParent(null, null);
+ updateInnerPositions(subarrayType, remainingDimensions);
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ methodDeclaration.internalSetReturnType(subarrayType);
+ break;
+ case AST.JLS3 :
+ methodDeclaration.setReturnType2(subarrayType);
+ break;
+ }
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ methodDeclaration.internalSetReturnType(type);
+ break;
+ case AST.JLS3 :
+ methodDeclaration.setReturnType2(type);
+ break;
+ }
+ }
+ } else {
+ switch(this.ast.apiLevel) {
+ case AST.JLS2_INTERNAL :
+ methodDeclaration.internalSetReturnType(type);
+ break;
+ case AST.JLS3 :
+ methodDeclaration.setReturnType2(type);
+ break;
+ }
+ }
+ }
+
+ protected void setTypeForMethodDeclaration(AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration, Type type, int extraDimension) {
+ annotationTypeMemberDeclaration.setType(type);
+ }
+
+ protected void setTypeForSingleVariableDeclaration(SingleVariableDeclaration singleVariableDeclaration, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ // cut the child loose from its parent (without creating garbage)
+ elementType.setParent(null, null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ singleVariableDeclaration.setType(elementType);
+ } else {
+ int start = type.getStartPosition();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start);
+ subarrayType.setSourceRange(start, end - start + 1);
+ // cut the child loose from its parent (without creating garbage)
+ subarrayType.setParent(null, null);
+ updateInnerPositions(subarrayType, remainingDimensions);
+ singleVariableDeclaration.setType(subarrayType);
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ singleVariableDeclaration.setType(type);
+ }
+ } else {
+ singleVariableDeclaration.setType(type);
+ }
+ }
+
+ protected void setTypeForVariableDeclarationExpression(VariableDeclarationExpression variableDeclarationExpression, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ // cut the child loose from its parent (without creating garbage)
+ elementType.setParent(null, null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ variableDeclarationExpression.setType(elementType);
+ } else {
+ int start = type.getStartPosition();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start);
+ subarrayType.setSourceRange(start, end - start + 1);
+ // cut the child loose from its parent (without creating garbage)
+ subarrayType.setParent(null, null);
+ updateInnerPositions(subarrayType, remainingDimensions);
+ variableDeclarationExpression.setType(subarrayType);
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ variableDeclarationExpression.setType(type);
+ }
+ } else {
+ variableDeclarationExpression.setType(type);
+ }
+ }
+
+ protected void setTypeForVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ // cut the child loose from its parent (without creating garbage)
+ elementType.setParent(null, null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ variableDeclarationStatement.setType(elementType);
+ } else {
+ int start = type.getStartPosition();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start);
+ subarrayType.setSourceRange(start, end - start + 1);
+ // cut the child loose from its parent (without creating garbage)
+ subarrayType.setParent(null, null);
+ updateInnerPositions(subarrayType, remainingDimensions);
+ variableDeclarationStatement.setType(subarrayType);
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ variableDeclarationStatement.setType(type);
+ }
+ } else {
+ variableDeclarationStatement.setType(type);
+ }
+ }
+
+ protected void updateInnerPositions(Type type, int dimensions) {
+ if (dimensions > 1) {
+ // need to set positions for intermediate array type see 42839
+ int start = type.getStartPosition();
+ Type currentComponentType = ((ArrayType) type).getComponentType();
+ int searchedDimension = dimensions - 1;
+ int rightBracketEndPosition = start;
+ while (currentComponentType.isArrayType()) {
+ rightBracketEndPosition = retrieveProperRightBracketPosition(searchedDimension, start);
+ currentComponentType.setSourceRange(start, rightBracketEndPosition - start + 1);
+ currentComponentType = ((ArrayType) currentComponentType).getComponentType();
+ searchedDimension--;
+ }
+ }
+ }
+}
+
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTMatcher.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTMatcher.java
new file mode 100644
index 000000000..b395dbde3
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTMatcher.java
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+
+public class AjASTMatcher extends ASTMatcher {
+
+ /**
+ * Creates a new AST matcher instance.
+ * <p>
+ * For backwards compatibility, the matcher ignores tag
+ * elements below doc comments by default. Use
+ * {@link #ASTMatcher(boolean) ASTMatcher(true)}
+ * for a matcher that compares doc tags by default.
+ * </p>
+ */
+ public AjASTMatcher() {
+ this(false);
+ }
+
+ /**
+ * Creates a new AST matcher instance.
+ *
+ * @param matchDocTags <code>true</code> if doc comment tags are
+ * to be compared by default, and <code>false</code> otherwise
+ * @see #match(Javadoc,Object)
+ * @since 3.0
+ */
+ public AjASTMatcher(boolean matchDocTags) {
+ super(matchDocTags);
+ }
+
+
+ public boolean match(PointcutDeclaration node, Object other) {
+ // ajh02: method added
+ if (!(other instanceof PointcutDeclaration)) {
+ return false;
+ }
+ PointcutDeclaration o = (PointcutDeclaration) other;
+ int level = node.getAST().apiLevel;
+ if (level == AST.JLS2_INTERNAL) {
+ if (node.getModifiers() != o.getModifiers()) {
+ return false;
+ }
+ }
+ if (level >= AST.JLS3) {
+ if (!safeSubtreeListMatch(node.modifiers(), o.modifiers())) {
+ return false;
+ }
+ }
+ return
+ safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ && safeSubtreeMatch(node.getName(), o.getName())
+ && safeSubtreeMatch(node.getDesignator(), o.getDesignator());
+ }
+
+ public boolean match(DefaultPointcut node, Object other) {
+ return (other instanceof DefaultPointcut);
+ }
+
+ public boolean match(ReferencePointcut node, Object other) {
+ if (!(other instanceof ReferencePointcut)) {
+ return false;
+ }
+ ReferencePointcut o = (ReferencePointcut) other;
+ int level = node.getAST().apiLevel;
+ return safeSubtreeMatch(node.getName(), o.getName());
+ // ajh02: will have to add something here when ReferencePointcuts are given
+ // a list of Types for parameters
+ }
+ public boolean match(NotPointcut node, Object other) {
+ if (!(other instanceof NotPointcut)) {
+ return false;
+ }
+ NotPointcut o = (NotPointcut) other;
+ return safeSubtreeMatch(node.getBody(), o.getBody());
+ }
+ public boolean match(PerObject node, Object other) {
+ if (!(other instanceof PerObject)) {
+ return false;
+ }
+ PerObject o = (PerObject) other;
+ return safeSubtreeMatch(node.getBody(), o.getBody())
+ && o.isThis() == node.isThis();
+ }
+ public boolean match(PerCflow node, Object other) {
+ if (!(other instanceof PerCflow)) {
+ return false;
+ }
+ PerCflow o = (PerCflow) other;
+ return safeSubtreeMatch(node.getBody(), o.getBody())
+ && node.isBelow() == o.isBelow();
+ }
+ public boolean match(PerTypeWithin node, Object other) {
+ if (!(other instanceof PerTypeWithin)) {
+ return false;
+ }
+ PerTypeWithin o = (PerTypeWithin) other;
+ return true; // ajh02: stub, should look at the type pattern
+ }
+ public boolean match(CflowPointcut node, Object other) {
+ if (!(other instanceof CflowPointcut)) {
+ return false;
+ }
+ CflowPointcut o = (CflowPointcut) other;
+ return safeSubtreeMatch(node.getBody(), o.getBody());
+ }
+ public boolean match(AndPointcut node, Object other) {
+ if (!(other instanceof AndPointcut)) {
+ return false;
+ }
+ AndPointcut o = (AndPointcut) other;
+ return safeSubtreeMatch(node.getLeft(), o.getLeft())
+ && safeSubtreeMatch(node.getRight(), o.getRight());
+ }
+ public boolean match(OrPointcut node, Object other) {
+ if (!(other instanceof OrPointcut)) {
+ return false;
+ }
+ OrPointcut o = (OrPointcut) other;
+ return safeSubtreeMatch(node.getLeft(), o.getLeft())
+ && safeSubtreeMatch(node.getRight(), o.getRight());
+ }
+ public boolean match(BeforeAdviceDeclaration node, Object other) {
+ // ajh02: method added
+ if (!(other instanceof BeforeAdviceDeclaration)) {
+ return false;
+ }
+ BeforeAdviceDeclaration o = (BeforeAdviceDeclaration) other;
+ return safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ && safeSubtreeListMatch(node.parameters(), o.parameters())
+ && safeSubtreeMatch(node.getPointcut(), o.getPointcut())
+ && safeSubtreeListMatch(node.thrownExceptions(), o.thrownExceptions())
+ && safeSubtreeMatch(node.getBody(), o.getBody());
+ }
+
+ public boolean match(AfterAdviceDeclaration node, Object other) {
+ // ajh02: todo: should have special methods to match
+ // afterReturning and afterThrowing
+ if (!(other instanceof AfterAdviceDeclaration)) {
+ return false;
+ }
+ AfterAdviceDeclaration o = (AfterAdviceDeclaration) other;
+ return safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ && safeSubtreeListMatch(node.parameters(), o.parameters())
+ && safeSubtreeMatch(node.getPointcut(), o.getPointcut())
+ && safeSubtreeListMatch(node.thrownExceptions(), o.thrownExceptions())
+ && safeSubtreeMatch(node.getBody(), o.getBody());
+ }
+
+ public boolean match(AroundAdviceDeclaration node, Object other) {
+ if (!(other instanceof AroundAdviceDeclaration)) {
+ return false;
+ }
+ AroundAdviceDeclaration o = (AroundAdviceDeclaration) other;
+ int level = node.getAST().apiLevel;
+ if (level == AST.JLS2_INTERNAL) {
+ if (!safeSubtreeMatch(node.internalGetReturnType(), o.internalGetReturnType())) {
+ return false;
+ }
+ }
+ if (level >= AST.JLS3) {
+ if (!safeSubtreeMatch(node.getReturnType2(), o.getReturnType2())) {
+ return false;
+ }
+ if (!safeSubtreeListMatch(node.typeParameters(), o.typeParameters())) {
+ return false;
+ }
+ }
+ return safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ && safeSubtreeListMatch(node.parameters(), o.parameters())
+ && safeSubtreeMatch(node.getPointcut(), o.getPointcut())
+ && safeSubtreeListMatch(node.thrownExceptions(), o.thrownExceptions())
+ && safeSubtreeMatch(node.getBody(), o.getBody());
+ }
+ public boolean match(DeclareDeclaration node, Object other) {
+ // ajh02: method added
+ if (!(other instanceof DeclareDeclaration)) {
+ return false;
+ }
+ DeclareDeclaration o = (DeclareDeclaration) other;
+ int level = node.getAST().apiLevel;
+ return safeSubtreeMatch(node.getJavadoc(), o.getJavadoc());
+ }
+ public boolean match(InterTypeFieldDeclaration node, Object other) {
+ // ajh02: method added
+ if (!(other instanceof InterTypeFieldDeclaration)) {
+ return false;
+ }
+ InterTypeFieldDeclaration o = (InterTypeFieldDeclaration) other;
+ int level = node.getAST().apiLevel;
+ if (level == AST.JLS2_INTERNAL) {
+ if (node.getModifiers() != o.getModifiers()) {
+ return false;
+ }
+ }
+ if (level >= AST.JLS3) {
+ if (!safeSubtreeListMatch(node.modifiers(), o.modifiers())) {
+ return false;
+ }
+ }
+ return
+ safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ && safeSubtreeMatch(node.getType(), o.getType())
+ && safeSubtreeListMatch(node.fragments(), o.fragments());
+ }
+ public boolean match(InterTypeMethodDeclaration node, Object other) {
+ // ajh02: method added
+ if (!(other instanceof InterTypeMethodDeclaration)) {
+ return false;
+ }
+ InterTypeMethodDeclaration o = (InterTypeMethodDeclaration) other;
+ int level = node.getAST().apiLevel;
+ if (level == AST.JLS2_INTERNAL) {
+ if (node.getModifiers() != o.getModifiers()) {
+ return false;
+ }
+ if (!safeSubtreeMatch(node.internalGetReturnType(), o.internalGetReturnType())) {
+ return false;
+ }
+ }
+ if (level >= AST.JLS3) {
+ if (!safeSubtreeListMatch(node.modifiers(), o.modifiers())) {
+ return false;
+ }
+ if (!safeSubtreeMatch(node.getReturnType2(), o.getReturnType2())) {
+ return false;
+ }
+ // n.b. compare type parameters even for constructors
+ if (!safeSubtreeListMatch(node.typeParameters(), o.typeParameters())) {
+ return false;
+ }
+ }
+ return ((node.isConstructor() == o.isConstructor())
+ && safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ && safeSubtreeMatch(node.getName(), o.getName())
+ // n.b. compare return type even for constructors
+ && safeSubtreeListMatch(node.parameters(), o.parameters())
+ && node.getExtraDimensions() == o.getExtraDimensions()
+ && safeSubtreeListMatch(node.thrownExceptions(), o.thrownExceptions())
+ && safeSubtreeMatch(node.getBody(), o.getBody()));
+ }
+
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTVisitor.java
new file mode 100644
index 000000000..075c66a91
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTVisitor.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+public abstract class AjASTVisitor extends ASTVisitor {
+
+ public AjASTVisitor() {
+ super(false);
+ }
+
+ public AjASTVisitor(boolean visitDocTags) {
+ super(visitDocTags);
+ }
+
+ public void endVisit(PointcutDeclaration node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(ReferencePointcut node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(DefaultPointcut node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(NotPointcut node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(PerObject node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(PerCflow node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(CflowPointcut node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(PerTypeWithin node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(AndPointcut node) {
+ // default implementation: do nothing
+ }
+
+ public void endVisit(OrPointcut node) {
+ // default implementation: do nothing
+ }
+ public boolean visit(AdviceDeclaration node) {
+ return true;
+ }
+
+ public boolean visit(AroundAdviceDeclaration node) {
+ return true;
+ }
+ public void endVisit(AroundAdviceDeclaration node) {
+ // default: do nothing
+ }
+ public boolean visit(BeforeAdviceDeclaration node) {
+ return true;
+ }
+ public void endVisit(BeforeAdviceDeclaration node) {
+ // default: do nothing
+ }
+ public boolean visit(AfterAdviceDeclaration node) {
+ return true;
+ }
+ public void endVisit(AfterAdviceDeclaration node) {
+ // default: do nothing
+ }
+ public boolean visit(AfterThrowingAdviceDeclaration node) {
+ return true;
+ }
+ public void endVisit(AfterThrowingAdviceDeclaration node) {
+ // default: do nothing
+ }
+ public boolean visit(AfterReturningAdviceDeclaration node) {
+ return true;
+ }
+ public void endVisit(AfterReturningAdviceDeclaration node) {
+ // default: do nothing
+ }
+ public boolean visit(InterTypeFieldDeclaration node) {
+ // ajh02: method added
+ return true;
+ }
+ public boolean visit(InterTypeMethodDeclaration node) {
+ // ajh02: method added
+ return true;
+ }
+ public void endVisit(InterTypeFieldDeclaration node) {
+ // ajh02: method added
+ // default implementation: do nothing
+ }
+ public void endVisit(InterTypeMethodDeclaration node) {
+ // ajh02: method added
+ // default implementation: do nothing
+ }
+ public boolean visit(DeclareDeclaration node) {
+ // ajh02: method added
+ return true;
+ }
+ public void endVisit(DeclareDeclaration node) {
+ // ajh02: method added
+ // default implementation: do nothing
+ }
+ public boolean visit(PointcutDeclaration node) {
+ return true;
+ }
+
+ public boolean visit(ReferencePointcut node) {
+ return true;
+ }
+
+ public boolean visit(NotPointcut node) {
+ return true;
+ }
+
+ public boolean visit(PerObject node) {
+ return true;
+ }
+
+ public boolean visit(PerCflow node) {
+ return true;
+ }
+
+ public boolean visit(PerTypeWithin node) {
+ return true;
+ }
+
+ public boolean visit(CflowPointcut node) {
+ return true;
+ }
+
+ public boolean visit(AndPointcut node) {
+ return true;
+ }
+
+ public boolean visit(OrPointcut node) {
+ return true;
+ }
+
+
+ public boolean visit(DefaultPointcut node) {
+ return true;
+ }
+
+ public void endVisit(AdviceDeclaration node) {
+ // default implementation: do nothing
+ }
+
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java
new file mode 100644
index 000000000..78d9f9021
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java
@@ -0,0 +1,1640 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Internal AST visitor for serializing an AST in a quick and dirty fashion.
+ * For various reasons the resulting string is not necessarily legal
+ * Java code; and even if it is legal Java code, it is not necessarily the string
+ * that corresponds to the given AST. Although useless for most purposes, it's
+ * fine for generating debug print strings.
+ * <p>
+ * Example usage:
+ * <code>
+ * <pre>
+ * NaiveASTFlattener p = new NaiveASTFlattener();
+ * node.accept(p);
+ * String result = p.getResult();
+ * </pre>
+ * </code>
+ * Call the <code>reset</code> method to clear the previous result before reusing an
+ * existing instance.
+ * </p>
+ *
+ * @since 2.0
+ */
+public class AjNaiveASTFlattener extends AjASTVisitor {
+
+ /**
+ * The string buffer into which the serialized representation of the AST is
+ * written.
+ */
+ private StringBuffer buffer;
+
+ private int indent = 0;
+
+ /**
+ * Creates a new AST printer.
+ */
+ public AjNaiveASTFlattener() {
+ this.buffer = new StringBuffer();
+ }
+
+ /**
+ * Returns the string accumulated in the visit.
+ *
+ * @return the serialized
+ */
+ public String getResult() {
+ return this.buffer.toString();
+ }
+
+ /**
+ * Resets this printer so that it can be used again.
+ */
+ public void reset() {
+ this.buffer.setLength(0);
+ }
+
+ void printIndent() {
+ for (int i = 0; i < this.indent; i++)
+ this.buffer.append(" "); //$NON-NLS-1$
+ }
+
+ /**
+ * Appends the text representation of the given modifier flags, followed by a single space.
+ * Used for 3.0 modifiers and annotations.
+ *
+ * @param ext the list of modifier and annotation nodes
+ * (element type: <code>IExtendedModifiers</code>)
+ */
+ void printModifiers(List ext) {
+ for (Iterator it = ext.iterator(); it.hasNext(); ) {
+ ASTNode p = (ASTNode) it.next();
+ p.accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Appends the text representation of the given modifier flags, followed by a single space.
+ * Used for JLS2 modifiers.
+ *
+ * @param modifiers the modifier flags
+ */
+ void printModifiers(int modifiers) {
+ if (Modifier.isPublic(modifiers)) {
+ this.buffer.append("public ");//$NON-NLS-1$
+ }
+ if (Modifier.isProtected(modifiers)) {
+ this.buffer.append("protected ");//$NON-NLS-1$
+ }
+ if (Modifier.isPrivate(modifiers)) {
+ this.buffer.append("private ");//$NON-NLS-1$
+ }
+ if (Modifier.isStatic(modifiers)) {
+ this.buffer.append("static ");//$NON-NLS-1$
+ }
+ if (Modifier.isAbstract(modifiers)) {
+ this.buffer.append("abstract ");//$NON-NLS-1$
+ }
+ if (Modifier.isFinal(modifiers)) {
+ this.buffer.append("final ");//$NON-NLS-1$
+ }
+ if (Modifier.isSynchronized(modifiers)) {
+ this.buffer.append("synchronized ");//$NON-NLS-1$
+ }
+ if (Modifier.isVolatile(modifiers)) {
+ this.buffer.append("volatile ");//$NON-NLS-1$
+ }
+ if (Modifier.isNative(modifiers)) {
+ this.buffer.append("native ");//$NON-NLS-1$
+ }
+ if (Modifier.isStrictfp(modifiers)) {
+ this.buffer.append("strictfp ");//$NON-NLS-1$
+ }
+ if (Modifier.isTransient(modifiers)) {
+ this.buffer.append("transient ");//$NON-NLS-1$
+ }
+ }
+
+ /*
+ * @see ASTVisitor#visit(AnnotationTypeDeclaration)
+ * @since 3.1
+ */
+ public boolean visit(AnnotationTypeDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ printIndent();
+ printModifiers(node.modifiers());
+ this.buffer.append("@interface ");//$NON-NLS-1$
+ node.getName().accept(this);
+ this.buffer.append(" {");//$NON-NLS-1$
+ for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
+ BodyDeclaration d = (BodyDeclaration) it.next();
+ d.accept(this);
+ }
+ this.buffer.append("}\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(AnnotationTypeMemberDeclaration)
+ * @since 3.1
+ */
+ public boolean visit(AnnotationTypeMemberDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ printIndent();
+ printModifiers(node.modifiers());
+ node.getType().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getName().accept(this);
+ this.buffer.append("()");//$NON-NLS-1$
+ if (node.getDefault() != null) {
+ this.buffer.append(" default ");//$NON-NLS-1$
+ node.getDefault().accept(this);
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(AnonymousClassDeclaration)
+ */
+ public boolean visit(AnonymousClassDeclaration node) {
+ this.buffer.append("{\n");//$NON-NLS-1$
+ this.indent++;
+ for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
+ BodyDeclaration b = (BodyDeclaration) it.next();
+ b.accept(this);
+ }
+ this.indent--;
+ printIndent();
+ this.buffer.append("}\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ArrayAccess)
+ */
+ public boolean visit(ArrayAccess node) {
+ node.getArray().accept(this);
+ this.buffer.append("[");//$NON-NLS-1$
+ node.getIndex().accept(this);
+ this.buffer.append("]");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ArrayCreation)
+ */
+ public boolean visit(ArrayCreation node) {
+ this.buffer.append("new ");//$NON-NLS-1$
+ ArrayType at = node.getType();
+ int dims = at.getDimensions();
+ Type elementType = at.getElementType();
+ elementType.accept(this);
+ for (Iterator it = node.dimensions().iterator(); it.hasNext(); ) {
+ this.buffer.append("[");//$NON-NLS-1$
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ this.buffer.append("]");//$NON-NLS-1$
+ dims--;
+ }
+ // add empty "[]" for each extra array dimension
+ for (int i= 0; i < dims; i++) {
+ this.buffer.append("[]");//$NON-NLS-1$
+ }
+ if (node.getInitializer() != null) {
+ node.getInitializer().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ArrayInitializer)
+ */
+ public boolean visit(ArrayInitializer node) {
+ this.buffer.append("{");//$NON-NLS-1$
+ for (Iterator it = node.expressions().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append("}");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ArrayType)
+ */
+ public boolean visit(ArrayType node) {
+ node.getComponentType().accept(this);
+ this.buffer.append("[]");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(AssertStatement)
+ */
+ public boolean visit(AssertStatement node) {
+ printIndent();
+ this.buffer.append("assert ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ if (node.getMessage() != null) {
+ this.buffer.append(" : ");//$NON-NLS-1$
+ node.getMessage().accept(this);
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(Assignment)
+ */
+ public boolean visit(Assignment node) {
+ node.getLeftHandSide().accept(this);
+ this.buffer.append(node.getOperator().toString());
+ node.getRightHandSide().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(Block)
+ */
+ public boolean visit(Block node) {
+ this.buffer.append("{\n");//$NON-NLS-1$
+ this.indent++;
+ for (Iterator it = node.statements().iterator(); it.hasNext(); ) {
+ Statement s = (Statement) it.next();
+ s.accept(this);
+ }
+ this.indent--;
+ printIndent();
+ this.buffer.append("}\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(BlockComment)
+ * @since 3.0
+ */
+ public boolean visit(BlockComment node) {
+ printIndent();
+ this.buffer.append("/* */");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(BooleanLiteral)
+ */
+ public boolean visit(BooleanLiteral node) {
+ if (node.booleanValue() == true) {
+ this.buffer.append("true");//$NON-NLS-1$
+ } else {
+ this.buffer.append("false");//$NON-NLS-1$
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(BreakStatement)
+ */
+ public boolean visit(BreakStatement node) {
+ printIndent();
+ this.buffer.append("break");//$NON-NLS-1$
+ if (node.getLabel() != null) {
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getLabel().accept(this);
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(CastExpression)
+ */
+ public boolean visit(CastExpression node) {
+ this.buffer.append("(");//$NON-NLS-1$
+ node.getType().accept(this);
+ this.buffer.append(")");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(CatchClause)
+ */
+ public boolean visit(CatchClause node) {
+ this.buffer.append("catch (");//$NON-NLS-1$
+ node.getException().accept(this);
+ this.buffer.append(") ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(CharacterLiteral)
+ */
+ public boolean visit(CharacterLiteral node) {
+ this.buffer.append(node.getEscapedValue());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ClassInstanceCreation)
+ */
+ public boolean visit(ClassInstanceCreation node) {
+ if (node.getExpression() != null) {
+ node.getExpression().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ }
+ this.buffer.append("new ");//$NON-NLS-1$
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ node.internalGetName().accept(this);
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (!node.typeArguments().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ node.getType().accept(this);
+ }
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ if (node.getAnonymousClassDeclaration() != null) {
+ node.getAnonymousClassDeclaration().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(CompilationUnit)
+ */
+ public boolean visit(CompilationUnit node) {
+ if (node.getPackage() != null) {
+ node.getPackage().accept(this);
+ }
+ for (Iterator it = node.imports().iterator(); it.hasNext(); ) {
+ ImportDeclaration d = (ImportDeclaration) it.next();
+ d.accept(this);
+ }
+ for (Iterator it = node.types().iterator(); it.hasNext(); ) {
+ AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
+ d.accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ConditionalExpression)
+ */
+ public boolean visit(ConditionalExpression node) {
+ node.getExpression().accept(this);
+ this.buffer.append(" ? ");//$NON-NLS-1$
+ node.getThenExpression().accept(this);
+ this.buffer.append(" : ");//$NON-NLS-1$
+ node.getElseExpression().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ConstructorInvocation)
+ */
+ public boolean visit(ConstructorInvocation node) {
+ printIndent();
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (!node.typeArguments().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append("this(");//$NON-NLS-1$
+ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(");\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ContinueStatement)
+ */
+ public boolean visit(ContinueStatement node) {
+ printIndent();
+ this.buffer.append("continue");//$NON-NLS-1$
+ if (node.getLabel() != null) {
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getLabel().accept(this);
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(DoStatement)
+ */
+ public boolean visit(DoStatement node) {
+ printIndent();
+ this.buffer.append("do ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ this.buffer.append(" while (");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(");\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(EmptyStatement)
+ */
+ public boolean visit(EmptyStatement node) {
+ printIndent();
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(EnhancedForStatement)
+ * @since 3.1
+ */
+ public boolean visit(EnhancedForStatement node) {
+ printIndent();
+ this.buffer.append("for (");//$NON-NLS-1$
+ node.getParameter().accept(this);
+ this.buffer.append(" : ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(") ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ return false;
+ }
+
+ public boolean visit(PointcutDeclaration node) {
+ printIndent();
+ buffer.append(" pointcut ");
+ node.getName().accept(this);
+ buffer.append("():");
+ buffer.append(((DefaultPointcut)node.getDesignator()).getDetail());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(EnumConstantDeclaration)
+ * @since 3.1
+ */
+ public boolean visit(EnumConstantDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ printIndent();
+ printModifiers(node.modifiers());
+ node.getName().accept(this);
+ if (!node.arguments().isEmpty()) {
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ }
+ if (node.getAnonymousClassDeclaration() != null) {
+ node.getAnonymousClassDeclaration().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(EnumDeclaration)
+ * @since 3.1
+ */
+ public boolean visit(EnumDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ printIndent();
+ printModifiers(node.modifiers());
+ this.buffer.append("enum ");//$NON-NLS-1$
+ node.getName().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ if (!node.superInterfaceTypes().isEmpty()) {
+ this.buffer.append("implements ");//$NON-NLS-1$
+ for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ this.buffer.append("{");//$NON-NLS-1$
+ for (Iterator it = node.enumConstants().iterator(); it.hasNext(); ) {
+ EnumConstantDeclaration d = (EnumConstantDeclaration) it.next();
+ d.accept(this);
+ // enum constant declarations do not include punctuation
+ if (it.hasNext()) {
+ // enum constant declarations are separated by commas
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ if (!node.bodyDeclarations().isEmpty()) {
+ this.buffer.append("; ");//$NON-NLS-1$
+ for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
+ BodyDeclaration d = (BodyDeclaration) it.next();
+ d.accept(this);
+ // other body declarations include trailing punctuation
+ }
+ }
+ this.buffer.append("}\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ExpressionStatement)
+ */
+ public boolean visit(ExpressionStatement node) {
+ printIndent();
+ node.getExpression().accept(this);
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(FieldAccess)
+ */
+ public boolean visit(FieldAccess node) {
+ node.getExpression().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ node.getName().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(FieldDeclaration)
+ */
+ public boolean visit(FieldDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ printIndent();
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ }
+ node.getType().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
+ VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
+ f.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ForStatement)
+ */
+ public boolean visit(ForStatement node) {
+ printIndent();
+ this.buffer.append("for (");//$NON-NLS-1$
+ for (Iterator it = node.initializers().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) buffer.append(", ");//$NON-NLS-1$
+ }
+ this.buffer.append("; ");//$NON-NLS-1$
+ if (node.getExpression() != null) {
+ node.getExpression().accept(this);
+ }
+ this.buffer.append("; ");//$NON-NLS-1$
+ for (Iterator it = node.updaters().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) buffer.append(", ");//$NON-NLS-1$
+ }
+ this.buffer.append(") ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(IfStatement)
+ */
+ public boolean visit(IfStatement node) {
+ printIndent();
+ this.buffer.append("if (");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(") ");//$NON-NLS-1$
+ node.getThenStatement().accept(this);
+ if (node.getElseStatement() != null) {
+ this.buffer.append(" else ");//$NON-NLS-1$
+ node.getElseStatement().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ImportDeclaration)
+ */
+ public boolean visit(ImportDeclaration node) {
+ printIndent();
+ this.buffer.append("import ");//$NON-NLS-1$
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (node.isStatic()) {
+ this.buffer.append("static ");//$NON-NLS-1$
+ }
+ }
+ node.getName().accept(this);
+ if (node.isOnDemand()) {
+ this.buffer.append(".*");//$NON-NLS-1$
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(InfixExpression)
+ */
+ public boolean visit(InfixExpression node) {
+ node.getLeftOperand().accept(this);
+ this.buffer.append(' '); // for cases like x= i - -1; or x= i++ + ++i;
+ this.buffer.append(node.getOperator().toString());
+ this.buffer.append(' ');
+ node.getRightOperand().accept(this);
+ final List extendedOperands = node.extendedOperands();
+ if (extendedOperands.size() != 0) {
+ this.buffer.append(' ');
+ for (Iterator it = extendedOperands.iterator(); it.hasNext(); ) {
+ this.buffer.append(node.getOperator().toString()).append(' ');
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ }
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(InstanceofExpression)
+ */
+ public boolean visit(InstanceofExpression node) {
+ node.getLeftOperand().accept(this);
+ this.buffer.append(" instanceof ");//$NON-NLS-1$
+ node.getRightOperand().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(Initializer)
+ */
+ public boolean visit(Initializer node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ }
+ node.getBody().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(Javadoc)
+ */
+ public boolean visit(Javadoc node) {
+ printIndent();
+ this.buffer.append("/** ");//$NON-NLS-1$
+ for (Iterator it = node.tags().iterator(); it.hasNext(); ) {
+ ASTNode e = (ASTNode) it.next();
+ e.accept(this);
+ }
+ this.buffer.append("\n */\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(LabeledStatement)
+ */
+ public boolean visit(LabeledStatement node) {
+ printIndent();
+ node.getLabel().accept(this);
+ this.buffer.append(": ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(LineComment)
+ * @since 3.0
+ */
+ public boolean visit(LineComment node) {
+ this.buffer.append("//\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MarkerAnnotation)
+ * @since 3.1
+ */
+ public boolean visit(MarkerAnnotation node) {
+ this.buffer.append("@");//$NON-NLS-1$
+ node.getTypeName().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MemberRef)
+ * @since 3.0
+ */
+ public boolean visit(MemberRef node) {
+ if (node.getQualifier() != null) {
+ node.getQualifier().accept(this);
+ }
+ this.buffer.append("#");//$NON-NLS-1$
+ node.getName().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MemberValuePair)
+ * @since 3.1
+ */
+ public boolean visit(MemberValuePair node) {
+ node.getName().accept(this);
+ this.buffer.append("=");//$NON-NLS-1$
+ node.getValue().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MethodRef)
+ * @since 3.0
+ */
+ public boolean visit(MethodRef node) {
+ if (node.getQualifier() != null) {
+ node.getQualifier().accept(this);
+ }
+ this.buffer.append("#");//$NON-NLS-1$
+ node.getName().accept(this);
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.parameters().iterator(); it.hasNext(); ) {
+ MethodRefParameter e = (MethodRefParameter) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MethodRefParameter)
+ * @since 3.0
+ */
+ public boolean visit(MethodRefParameter node) {
+ node.getType().accept(this);
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (node.isVarargs()) {
+ this.buffer.append("...");//$NON-NLS-1$
+ }
+ }
+ if (node.getName() != null) {
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getName().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MethodDeclaration)
+ */
+ public boolean visit(MethodDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ printIndent();
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ if (!node.typeParameters().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeParameters().iterator(); it.hasNext(); ) {
+ TypeParameter t = (TypeParameter) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ }
+ if (!node.isConstructor()) {
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ node.internalGetReturnType().accept(this);
+ } else {
+ if (node.getReturnType2() != null) {
+ node.getReturnType2().accept(this);
+ } else {
+ // methods really ought to have a return type
+ this.buffer.append("void");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ node.getName().accept(this);
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.parameters().iterator(); it.hasNext(); ) {
+ SingleVariableDeclaration v = (SingleVariableDeclaration) it.next();
+ v.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ for (int i = 0; i < node.getExtraDimensions(); i++) {
+ this.buffer.append("[]"); //$NON-NLS-1$
+ }
+ if (!node.thrownExceptions().isEmpty()) {
+ this.buffer.append(" throws ");//$NON-NLS-1$
+ for (Iterator it = node.thrownExceptions().iterator(); it.hasNext(); ) {
+ Name n = (Name) it.next();
+ n.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ if (node.getBody() == null) {
+ this.buffer.append(";\n");//$NON-NLS-1$
+ } else {
+ node.getBody().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(MethodInvocation)
+ */
+ public boolean visit(MethodInvocation node) {
+ if (node.getExpression() != null) {
+ node.getExpression().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (!node.typeArguments().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ }
+ node.getName().accept(this);
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(Modifier)
+ * @since 3.1
+ */
+ public boolean visit(Modifier node) {
+ this.buffer.append(node.getKeyword().toString());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(NormalAnnotation)
+ * @since 3.1
+ */
+ public boolean visit(NormalAnnotation node) {
+ this.buffer.append("@");//$NON-NLS-1$
+ node.getTypeName().accept(this);
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.values().iterator(); it.hasNext(); ) {
+ MemberValuePair p = (MemberValuePair) it.next();
+ p.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(NullLiteral)
+ */
+ public boolean visit(NullLiteral node) {
+ this.buffer.append("null");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(NumberLiteral)
+ */
+ public boolean visit(NumberLiteral node) {
+ this.buffer.append(node.getToken());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(PackageDeclaration)
+ */
+ public boolean visit(PackageDeclaration node) {
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ for (Iterator it = node.annotations().iterator(); it.hasNext(); ) {
+ Annotation p = (Annotation) it.next();
+ p.accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ }
+ printIndent();
+ this.buffer.append("package ");//$NON-NLS-1$
+ node.getName().accept(this);
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ParameterizedType)
+ * @since 3.1
+ */
+ public boolean visit(ParameterizedType node) {
+ node.getType().accept(this);
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ParenthesizedExpression)
+ */
+ public boolean visit(ParenthesizedExpression node) {
+ this.buffer.append("(");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(")");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(PostfixExpression)
+ */
+ public boolean visit(PostfixExpression node) {
+ node.getOperand().accept(this);
+ this.buffer.append(node.getOperator().toString());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(PrefixExpression)
+ */
+ public boolean visit(PrefixExpression node) {
+ this.buffer.append(node.getOperator().toString());
+ node.getOperand().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(PrimitiveType)
+ */
+ public boolean visit(PrimitiveType node) {
+ this.buffer.append(node.getPrimitiveTypeCode().toString());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(QualifiedName)
+ */
+ public boolean visit(QualifiedName node) {
+ node.getQualifier().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ node.getName().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(QualifiedType)
+ * @since 3.1
+ */
+ public boolean visit(QualifiedType node) {
+ node.getQualifier().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ node.getName().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ReturnStatement)
+ */
+ public boolean visit(ReturnStatement node) {
+ printIndent();
+ this.buffer.append("return");//$NON-NLS-1$
+ if (node.getExpression() != null) {
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SimpleName)
+ */
+ public boolean visit(SimpleName node) {
+ this.buffer.append(node.getIdentifier());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SimpleType)
+ */
+ public boolean visit(SimpleType node) {
+ return true;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SingleMemberAnnotation)
+ * @since 3.1
+ */
+ public boolean visit(SingleMemberAnnotation node) {
+ this.buffer.append("@");//$NON-NLS-1$
+ node.getTypeName().accept(this);
+ this.buffer.append("(");//$NON-NLS-1$
+ node.getValue().accept(this);
+ this.buffer.append(")");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SingleVariableDeclaration)
+ */
+ public boolean visit(SingleVariableDeclaration node) {
+ printIndent();
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ }
+ node.getType().accept(this);
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (node.isVarargs()) {
+ this.buffer.append("...");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ node.getName().accept(this);
+ for (int i = 0; i < node.getExtraDimensions(); i++) {
+ this.buffer.append("[]"); //$NON-NLS-1$
+ }
+ if (node.getInitializer() != null) {
+ this.buffer.append("=");//$NON-NLS-1$
+ node.getInitializer().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(StringLiteral)
+ */
+ public boolean visit(StringLiteral node) {
+ this.buffer.append(node.getEscapedValue());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SuperConstructorInvocation)
+ */
+ public boolean visit(SuperConstructorInvocation node) {
+ printIndent();
+ if (node.getExpression() != null) {
+ node.getExpression().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (!node.typeArguments().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append("super(");//$NON-NLS-1$
+ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(");\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SuperFieldAccess)
+ */
+ public boolean visit(SuperFieldAccess node) {
+ if (node.getQualifier() != null) {
+ node.getQualifier().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ }
+ this.buffer.append("super.");//$NON-NLS-1$
+ node.getName().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SuperMethodInvocation)
+ */
+ public boolean visit(SuperMethodInvocation node) {
+ if (node.getQualifier() != null) {
+ node.getQualifier().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ }
+ this.buffer.append("super.");//$NON-NLS-1$
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (!node.typeArguments().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ }
+ node.getName().accept(this);
+ this.buffer.append("(");//$NON-NLS-1$
+ for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
+ Expression e = (Expression) it.next();
+ e.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(")");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SwitchCase)
+ */
+ public boolean visit(SwitchCase node) {
+ if (node.isDefault()) {
+ this.buffer.append("default :\n");//$NON-NLS-1$
+ } else {
+ this.buffer.append("case ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(":\n");//$NON-NLS-1$
+ }
+ this.indent++; //decremented in visit(SwitchStatement)
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SwitchStatement)
+ */
+ public boolean visit(SwitchStatement node) {
+ this.buffer.append("switch (");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(") ");//$NON-NLS-1$
+ this.buffer.append("{\n");//$NON-NLS-1$
+ this.indent++;
+ for (Iterator it = node.statements().iterator(); it.hasNext(); ) {
+ Statement s = (Statement) it.next();
+ s.accept(this);
+ this.indent--; // incremented in visit(SwitchCase)
+ }
+ this.indent--;
+ printIndent();
+ this.buffer.append("}\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(SynchronizedStatement)
+ */
+ public boolean visit(SynchronizedStatement node) {
+ this.buffer.append("synchronized (");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(") ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TagElement)
+ * @since 3.0
+ */
+ public boolean visit(TagElement node) {
+ if (node.isNested()) {
+ // nested tags are always enclosed in braces
+ this.buffer.append("{");//$NON-NLS-1$
+ } else {
+ // top-level tags always begin on a new line
+ this.buffer.append("\n * ");//$NON-NLS-1$
+ }
+ boolean previousRequiresWhiteSpace = false;
+ if (node.getTagName() != null) {
+ this.buffer.append(node.getTagName());
+ previousRequiresWhiteSpace = true;
+ }
+ boolean previousRequiresNewLine = false;
+ for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
+ ASTNode e = (ASTNode) it.next();
+ // assume text elements include necessary leading and trailing whitespace
+ // but Name, MemberRef, MethodRef, and nested TagElement do not include white space
+ boolean currentIncludesWhiteSpace = (e instanceof TextElement);
+ if (previousRequiresNewLine && currentIncludesWhiteSpace) {
+ this.buffer.append("\n * ");//$NON-NLS-1$
+ }
+ previousRequiresNewLine = currentIncludesWhiteSpace;
+ // add space if required to separate
+ if (previousRequiresWhiteSpace && !currentIncludesWhiteSpace) {
+ this.buffer.append(" "); //$NON-NLS-1$
+ }
+ e.accept(this);
+ previousRequiresWhiteSpace = !currentIncludesWhiteSpace && !(e instanceof TagElement);
+ }
+ if (node.isNested()) {
+ this.buffer.append("}");//$NON-NLS-1$
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TextElement)
+ * @since 3.0
+ */
+ public boolean visit(TextElement node) {
+ this.buffer.append(node.getText());
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ThisExpression)
+ */
+ public boolean visit(ThisExpression node) {
+ if (node.getQualifier() != null) {
+ node.getQualifier().accept(this);
+ this.buffer.append(".");//$NON-NLS-1$
+ }
+ this.buffer.append("this");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(ThrowStatement)
+ */
+ public boolean visit(ThrowStatement node) {
+ printIndent();
+ this.buffer.append("throw ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TryStatement)
+ */
+ public boolean visit(TryStatement node) {
+ printIndent();
+ this.buffer.append("try ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ for (Iterator it = node.catchClauses().iterator(); it.hasNext(); ) {
+ CatchClause cc = (CatchClause) it.next();
+ cc.accept(this);
+ }
+ if (node.getFinally() != null) {
+ this.buffer.append(" finally ");//$NON-NLS-1$
+ node.getFinally().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TypeDeclaration)
+ */
+ public boolean visit(TypeDeclaration node) {
+ if (node.getJavadoc() != null) {
+ node.getJavadoc().accept(this);
+ }
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ }
+// this.buffer.append(node.isInterface() ? "interface " : "class");//$NON-NLS-2$//$NON-NLS-1$
+ if (node.isInterface()) {
+ this.buffer.append("interface ");//$NON-NLS-1$
+ } else if (((AjTypeDeclaration)node).isAspect()) {
+ this.buffer.append("aspect ");//$NON-NLS-1$
+ } else {
+ this.buffer.append("class ");//$NON-NLS-1$
+ }
+ node.getName().accept(this);
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (!node.typeParameters().isEmpty()) {
+ this.buffer.append("<");//$NON-NLS-1$
+ for (Iterator it = node.typeParameters().iterator(); it.hasNext(); ) {
+ TypeParameter t = (TypeParameter) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(",");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(">");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ if (node.internalGetSuperclass() != null) {
+ this.buffer.append("extends ");//$NON-NLS-1$
+ node.internalGetSuperclass().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ if (!node.internalSuperInterfaces().isEmpty()) {
+// this.buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$
+ if (node.isInterface()) {
+ this.buffer.append("extends ");//$NON-NLS-1$
+ } else {
+ this.buffer.append("implements ");//$NON-NLS-1$
+ }
+ for (Iterator it = node.internalSuperInterfaces().iterator(); it.hasNext(); ) {
+ Name n = (Name) it.next();
+ n.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ if (node.getSuperclassType() != null) {
+ this.buffer.append("extends ");//$NON-NLS-1$
+ node.getSuperclassType().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ if (!node.superInterfaceTypes().isEmpty()) {
+// this.buffer.append(node.isInterface() ? "extends " : "implements ");//$NON-NLS-2$//$NON-NLS-1$
+ if (node.isInterface()) {
+ this.buffer.append("extends ");//$NON-NLS-1$
+ } else {
+ this.buffer.append("implements ");//$NON-NLS-1$
+ }
+ for (Iterator it = node.superInterfaceTypes().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(" ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append("{\n");//$NON-NLS-1$
+ this.indent++;
+ BodyDeclaration prev = null;
+ for (Iterator it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
+ BodyDeclaration d = (BodyDeclaration) it.next();
+ if (prev instanceof EnumConstantDeclaration) {
+ // enum constant declarations do not include punctuation
+ if (d instanceof EnumConstantDeclaration) {
+ // enum constant declarations are separated by commas
+ this.buffer.append(", ");//$NON-NLS-1$
+ } else {
+ // semicolon separates last enum constant declaration from
+ // first class body declarations
+ this.buffer.append("; ");//$NON-NLS-1$
+ }
+ }
+ d.accept(this);
+ }
+ this.indent--;
+ printIndent();
+ this.buffer.append("}\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TypeDeclarationStatement)
+ */
+ public boolean visit(TypeDeclarationStatement node) {
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ node.internalGetTypeDeclaration().accept(this);
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ node.getDeclaration().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TypeLiteral)
+ */
+ public boolean visit(TypeLiteral node) {
+ node.getType().accept(this);
+ this.buffer.append(".class");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(TypeParameter)
+ * @since 3.1
+ */
+ public boolean visit(TypeParameter node) {
+ node.getName().accept(this);
+ if (!node.typeBounds().isEmpty()) {
+ this.buffer.append(" extends ");//$NON-NLS-1$
+ for (Iterator it = node.typeBounds().iterator(); it.hasNext(); ) {
+ Type t = (Type) it.next();
+ t.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(" & ");//$NON-NLS-1$
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(VariableDeclarationExpression)
+ */
+ public boolean visit(VariableDeclarationExpression node) {
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ }
+ node.getType().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
+ VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
+ f.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(VariableDeclarationFragment)
+ */
+ public boolean visit(VariableDeclarationFragment node) {
+ node.getName().accept(this);
+ for (int i = 0; i < node.getExtraDimensions(); i++) {
+ this.buffer.append("[]");//$NON-NLS-1$
+ }
+ if (node.getInitializer() != null) {
+ this.buffer.append("=");//$NON-NLS-1$
+ node.getInitializer().accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(VariableDeclarationStatement)
+ */
+ public boolean visit(VariableDeclarationStatement node) {
+ printIndent();
+ if (node.getAST().apiLevel() == AST.JLS2_INTERNAL) {
+ printModifiers(node.getModifiers());
+ }
+ if (node.getAST().apiLevel() >= AST.JLS3) {
+ printModifiers(node.modifiers());
+ }
+ node.getType().accept(this);
+ this.buffer.append(" ");//$NON-NLS-1$
+ for (Iterator it = node.fragments().iterator(); it.hasNext(); ) {
+ VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
+ f.accept(this);
+ if (it.hasNext()) {
+ this.buffer.append(", ");//$NON-NLS-1$
+ }
+ }
+ this.buffer.append(";\n");//$NON-NLS-1$
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(WildcardType)
+ * @since 3.1
+ */
+ public boolean visit(WildcardType node) {
+ this.buffer.append("?");//$NON-NLS-1$
+ Type bound = node.getBound();
+ if (bound != null) {
+ if (node.isUpperBound()) {
+ this.buffer.append(" extends ");//$NON-NLS-1$
+ } else {
+ this.buffer.append(" super ");//$NON-NLS-1$
+ }
+ bound.accept(this);
+ }
+ return false;
+ }
+
+ /*
+ * @see ASTVisitor#visit(WhileStatement)
+ */
+ public boolean visit(WhileStatement node) {
+ printIndent();
+ this.buffer.append("while (");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ this.buffer.append(") ");//$NON-NLS-1$
+ node.getBody().accept(this);
+ return false;
+ }
+
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java
new file mode 100644
index 000000000..d76427d7f
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjTypeDeclaration.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This subtype of TypeDeclaration allows for the extensions that AspectJ
+ * has for types - they might be aspects and pointcuts may exist in
+ * classes. This type does not represent an aspect, that is represented
+ * by AspectDeclaration, a further subtype of AjTypeDeclaration.
+ */
+public class AjTypeDeclaration extends TypeDeclaration {
+
+ /**
+ * The "aspect" structural property of this node type.
+ * @since 3.0
+ */
+ public static final SimplePropertyDescriptor ASPECT_PROPERTY =
+ new SimplePropertyDescriptor(TypeDeclaration.class, "aspect", boolean.class, MANDATORY); //$NON-NLS-1$
+
+ // Need to fix up the property lists created during the super's static initializer
+ static {
+ // Need to fix up the property lists created during the super's static initializer
+ List temporary = new ArrayList();
+ createPropertyList(TypeDeclaration.class, temporary);
+ temporary.addAll(PROPERTY_DESCRIPTORS_2_0);
+ addProperty(ASPECT_PROPERTY, temporary);
+ PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(temporary);
+
+ temporary.clear();
+ createPropertyList(TypeDeclaration.class, temporary);
+ temporary.addAll(PROPERTY_DESCRIPTORS_3_0);
+ addProperty(ASPECT_PROPERTY, temporary);
+ PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(temporary);
+ }
+
+ /**
+ * <code>true</code> for an aspect, <code>false</code> for a class or interface.
+ * Defaults to class.
+ */
+ private boolean isAspect = false;
+
+
+ /**
+ * Creates a new AST node for a type declaration owned by the given
+ * AST. By default, the type declaration is for a class of an
+ * unspecified, but legal, name; no modifiers; no javadoc;
+ * no type parameters; no superclass or superinterfaces; and an empty list
+ * of body declarations.
+ * <p>
+ * N.B. This constructor is package-private; all subclasses must be
+ * declared in the same package; clients are unable to declare
+ * additional subclasses.
+ * </p>
+ *
+ * @param ast the AST that is to own this node
+ */
+ public AjTypeDeclaration(AST ast) {
+ super(ast);
+ }
+
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) {
+ if (property == ASPECT_PROPERTY) {
+ if (get) {
+ return isAspect();
+ } else {
+ setAspect(value);
+ return false;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetBooleanProperty(property, get, value);
+ }
+
+
+ /**
+ * Returns whether this type declaration declares a class or an
+ * aspect.
+ *
+ * @return <code>true</code> if this is an aspect declaration,
+ * and <code>false</code> if this is a class or interface declaration
+ */
+ public boolean isAspect() {
+ return this.isAspect;
+ }
+
+ /**
+ * Sets whether this type declaration declares a class or an
+ * aspect.
+ *
+ * @param isAspect <code>true</code> if this is an aspect
+ * declaration, and <code>false</code> if this is a class or interface
+ * declaration
+ */
+ public void setAspect(boolean isAspect) {
+ preValueChange(ASPECT_PROPERTY);
+ this.isAspect = isAspect;
+ postValueChange(ASPECT_PROPERTY);
+ }
+
+ public PointcutDeclaration[] getPointcuts() {
+ // ajh02: method added, currently returning none :-/
+ List bd = bodyDeclarations();
+ // ajh02: 0 bodyDeclarations :-/
+ int pointcutCount = 0;
+ for (Iterator it = bd.listIterator(); it.hasNext(); ) {
+ if (it.next() instanceof PointcutDeclaration) {
+ pointcutCount++;
+ }
+ }
+ PointcutDeclaration[] pointcuts = new PointcutDeclaration[pointcutCount];
+ int next = 0;
+ for (Iterator it = bd.listIterator(); it.hasNext(); ) {
+ Object decl = it.next();
+ if (decl instanceof PointcutDeclaration) {
+ pointcuts[next++] = (PointcutDeclaration) decl;
+ }
+ }
+ return pointcuts;
+ }
+
+ public ASTNode.NodeList getSuperInterfaceNames() {
+ return superInterfaceNames;
+ }
+
+ public ASTNode.NodeList getTypeParameters() {
+ return typeParameters;
+ }
+
+}
+
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AndPointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AndPointcut.java
new file mode 100644
index 000000000..d0e0fad0c
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AndPointcut.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * AndPointcut DOM AST node.
+ * has:
+ * a PointcutDesignator 'left',
+ * a PointcutDesignator 'right'
+ * @author ajh02
+ *
+ */
+public class AndPointcut extends PointcutDesignator {
+
+ private PointcutDesignator left = null;
+ public static final ChildPropertyDescriptor LEFT_PROPERTY =
+ new ChildPropertyDescriptor(AndPointcut.class, "left", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getLeft() {
+ return this.left;
+ }
+ public void setLeft(PointcutDesignator left) {
+ if (left == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.left;
+ preReplaceChild(oldChild, left, LEFT_PROPERTY);
+ this.left = left;
+ postReplaceChild(oldChild, left, LEFT_PROPERTY);
+ }
+
+ private PointcutDesignator right = null;
+ public static final ChildPropertyDescriptor RIGHT_PROPERTY =
+ new ChildPropertyDescriptor(AndPointcut.class, "right", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getRight() {
+ return this.right;
+ }
+ public void setRight(PointcutDesignator right) {
+ if (right == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.right;
+ preReplaceChild(oldChild, right, RIGHT_PROPERTY);
+ this.right = right;
+ postReplaceChild(oldChild, right, RIGHT_PROPERTY);
+ }
+
+
+
+
+ AndPointcut(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(2);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ addProperty(LEFT_PROPERTY, propertyList);
+ addProperty(RIGHT_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == LEFT_PROPERTY) {
+ if (get) {
+ return getLeft();
+ } else {
+ setLeft((PointcutDesignator) child);
+ return null;
+ }
+ } else if (property == RIGHT_PROPERTY) {
+ if (get) {
+ return getRight();
+ } else {
+ setRight((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ AndPointcut result = new AndPointcut(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setRight((PointcutDesignator)getRight().clone(target));
+ result.setLeft((PointcutDesignator)getLeft().clone(target));
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getLeft());
+ acceptChild(visitor, getRight());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.left == null ? 0 : getLeft().treeSize())
+ + (this.right == null ? 0 : getRight().treeSize());
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java
new file mode 100644
index 000000000..a18cb820b
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AroundAdviceDeclaration DOM AST node.
+ * has:
+ * everything an AdviceDeclaration has,
+ * a return type (or return type Mark2)
+ *
+ * It inherits property descriptors from AdviceDeclaration,
+ * but needs to add one for its return type,
+ * but I can't mix descripters from two different classes in a property list,
+ * so I have to redefine them all here and use
+ * a 'around' prefix to distinguish them from the ones defined in AdviceDeclaration.
+ * There has to be a better way, but this works.
+ * @author ajh02
+ *
+ */
+
+public class AroundAdviceDeclaration extends AdviceDeclaration {
+
+ public static final ChildPropertyDescriptor aroundRETURN_TYPE_PROPERTY =
+ new ChildPropertyDescriptor(AroundAdviceDeclaration.class, "returnType", Type.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor aroundRETURN_TYPE2_PROPERTY =
+ new ChildPropertyDescriptor(AroundAdviceDeclaration.class, "returnType2", Type.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildListPropertyDescriptor aroundTYPE_PARAMETERS_PROPERTY =
+ new ChildListPropertyDescriptor(AroundAdviceDeclaration.class, "typeParameters", TypeParameter.class, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor aroundJAVADOC_PROPERTY =
+ internalJavadocPropertyFactory(AroundAdviceDeclaration.class);
+
+ public static final ChildListPropertyDescriptor aroundPARAMETERS_PROPERTY =
+ new ChildListPropertyDescriptor(AroundAdviceDeclaration.class, "parameters", SingleVariableDeclaration.class, CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor aroundPOINTCUT_PROPERTY =
+ new ChildPropertyDescriptor(AroundAdviceDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildListPropertyDescriptor aroundTHROWN_EXCEPTIONS_PROPERTY =
+ new ChildListPropertyDescriptor(AroundAdviceDeclaration.class, "thrownExceptions", Name.class, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public static final ChildPropertyDescriptor aroundBODY_PROPERTY =
+ new ChildPropertyDescriptor(AroundAdviceDeclaration.class, "body", Block.class, OPTIONAL, CYCLE_RISK); //$NON-NLS-1$
+
+ static {
+ List propertyList = new ArrayList(6);
+ createPropertyList(AroundAdviceDeclaration.class, propertyList);
+ addProperty(aroundJAVADOC_PROPERTY, propertyList);
+ addProperty(aroundRETURN_TYPE_PROPERTY, propertyList);
+ addProperty(aroundPARAMETERS_PROPERTY, propertyList);
+ addProperty(aroundTHROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(aroundPOINTCUT_PROPERTY, propertyList);
+ addProperty(aroundBODY_PROPERTY, propertyList);
+ aroundPROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
+
+ propertyList = new ArrayList(7);
+ createPropertyList(AroundAdviceDeclaration.class, propertyList);
+ addProperty(aroundJAVADOC_PROPERTY, propertyList);
+ addProperty(aroundTYPE_PARAMETERS_PROPERTY, propertyList);
+ addProperty(aroundRETURN_TYPE2_PROPERTY, propertyList);
+ addProperty(aroundPARAMETERS_PROPERTY, propertyList);
+ addProperty(aroundTHROWN_EXCEPTIONS_PROPERTY, propertyList);
+ addProperty(aroundPOINTCUT_PROPERTY, propertyList);
+ addProperty(aroundBODY_PROPERTY, propertyList);
+ aroundPROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
+ }
+
+ protected static List aroundPROPERTY_DESCRIPTORS_2_0;
+ protected static List aroundPROPERTY_DESCRIPTORS_3_0;
+
+ public static List propertyDescriptors(int apiLevel) {
+ if (apiLevel == AST.JLS2_INTERNAL) {
+ return aroundPROPERTY_DESCRIPTORS_2_0;
+ } else {
+ return aroundPROPERTY_DESCRIPTORS_3_0;
+ }
+ }
+
+ private Type returnType = null;
+ /**
+ * Indicated whether the return type has been initialized.
+ * @since 3.1
+ */
+ private boolean returnType2Initialized = false;
+ private ASTNode.NodeList typeParameters = null;
+
+ AroundAdviceDeclaration(AST ast) {
+ super(ast);
+ if (ast.apiLevel >= AST.JLS3) { // ajh02: move to aroundAdvice
+ this.typeParameters = new ASTNode.NodeList(aroundTYPE_PARAMETERS_PROPERTY);
+ }
+ }
+
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == aroundRETURN_TYPE_PROPERTY) {
+ if (get) {
+ return getReturnType();
+ } else {
+ setReturnType((Type) child);
+ return null;
+ }
+ }
+ if (property == aroundRETURN_TYPE2_PROPERTY) {
+ if (get) {
+ return getReturnType2();
+ } else {
+ setReturnType2((Type) child);
+ return null;
+ }
+ }
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ final List internalGetChildListProperty(ChildListPropertyDescriptor property) {
+ if (property == aroundTYPE_PARAMETERS_PROPERTY) {
+ return typeParameters();
+ }
+ return super.internalGetChildListProperty(property);
+ }
+
+ public List typeParameters() {
+ // more efficient than just calling unsupportedIn2() to check
+ if (this.typeParameters == null) {
+ unsupportedIn2();
+ }
+ return this.typeParameters;
+ }
+
+ public Type getReturnType() {
+ return internalGetReturnType();
+ }
+
+ /**
+ * Internal synonym for deprecated method. Used to avoid
+ * deprecation warnings.
+ * @since 3.1
+ */
+ /*package*/ final Type internalGetReturnType() {
+ supportedOnlyIn2();
+ if (this.returnType == null) {
+ // lazy init must be thread-safe for readers
+ synchronized (this) {
+ if (this.returnType == null) {
+ preLazyInit();
+ this.returnType = this.ast.newPrimitiveType(PrimitiveType.VOID);
+ postLazyInit(this.returnType, aroundRETURN_TYPE_PROPERTY);
+ }
+ }
+ }
+ return this.returnType;
+ }
+
+ public void setReturnType(Type type) {
+ internalSetReturnType(type);
+ }
+
+ /*package*/ void internalSetReturnType(Type type) {
+ supportedOnlyIn2();
+ if (type == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.returnType;
+ preReplaceChild(oldChild, type, aroundRETURN_TYPE_PROPERTY);
+ this.returnType = type;
+ postReplaceChild(oldChild, type, aroundRETURN_TYPE_PROPERTY);
+ }
+
+ public Type getReturnType2() {
+ unsupportedIn2();
+ if (this.returnType == null && !this.returnType2Initialized) {
+ // lazy init must be thread-safe for readers
+ synchronized (this) {
+ if (this.returnType == null && !this.returnType2Initialized) {
+ preLazyInit();
+ this.returnType = this.ast.newPrimitiveType(PrimitiveType.VOID);
+ this.returnType2Initialized = true;
+ postLazyInit(this.returnType, aroundRETURN_TYPE2_PROPERTY);
+ }
+ }
+ }
+ return this.returnType;
+ }
+
+ public void setReturnType2(Type type) {
+ unsupportedIn2();
+ this.returnType2Initialized = true;
+ ASTNode oldChild = this.returnType;
+ preReplaceChild(oldChild, type, aroundRETURN_TYPE2_PROPERTY);
+ this.returnType = type;
+ postReplaceChild(oldChild, type, aroundRETURN_TYPE2_PROPERTY);
+ }
+
+ ASTNode clone0(AST target) {
+ AroundAdviceDeclaration result = new AroundAdviceDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ result.parameters().addAll(
+ ASTNode.copySubtrees(target, parameters()));
+ result.thrownExceptions().addAll(
+ ASTNode.copySubtrees(target, thrownExceptions()));
+ result.setPointcut(getPointcut());
+ result.setBody(
+ (Block) ASTNode.copySubtree(target, getBody()));
+ return result;
+ }
+
+ int treeSize() {
+ return
+ super.treeSize()
+ + (this.typeParameters == null ? 0 : this.typeParameters.listSize())
+ + (this.returnType == null ? 0 : this.returnType.treeSize());
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ if (ast.apiLevel == AST.JLS2_INTERNAL) {
+ acceptChild(visitor, getReturnType());
+ } else {
+ acceptChild(visitor, getReturnType2());
+ }
+
+ acceptChildren(visitor, this.parameters);
+ acceptChild(visitor, getPointcut());
+ acceptChildren(visitor, this.thrownExceptions);
+ acceptChild(visitor, getBody());
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java
new file mode 100644
index 000000000..5a45ec9ca
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AspectDeclaration.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * AspectDeclaration DOM AST node.
+ * has:
+ * everything a TypeDeclaration has.
+ *
+ * This class could probably do with some work.
+ * @author ajh02
+ *
+ */
+
+public class AspectDeclaration extends AjTypeDeclaration {
+
+ protected ASTNode perClause = null; // stays null if the aspect is an _implicit_ persingleton()
+
+ public static final ChildPropertyDescriptor PERCLAUSE_PROPERTY =
+ new ChildPropertyDescriptor(AspectDeclaration.class, "perClause", ASTNode.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ AspectDeclaration(AST ast, ASTNode perClause) {
+ super(ast);
+ this.perClause = perClause;
+ setAspect(true);
+ }
+
+ public ASTNode getPerClause(){
+ return perClause;
+ }
+
+ public void setPerClause(ASTNode perClause) {
+ if (perClause == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.perClause;
+ preReplaceChild(oldChild, perClause, PERCLAUSE_PROPERTY);
+ this.perClause = perClause;
+ postReplaceChild(oldChild, perClause, PERCLAUSE_PROPERTY);
+ }
+
+ ASTNode clone0(AST target) {
+ AspectDeclaration result = new AspectDeclaration(target, perClause);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ result.internalSetModifiers(getModifiers());
+ result.setSuperclass(
+ (Name) ASTNode.copySubtree(target, getSuperclass()));
+ result.superInterfaces().addAll(
+ ASTNode.copySubtrees(target, superInterfaces()));
+ }
+ result.setInterface(isInterface());
+ result.setAspect(isAspect());
+ result.setName((SimpleName) getName().clone(target));
+ if (this.ast.apiLevel >= AST.JLS3) {
+ result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers()));
+ result.typeParameters().addAll(
+ ASTNode.copySubtrees(target, typeParameters()));
+ result.setSuperclassType(
+ (Type) ASTNode.copySubtree(target, getSuperclassType()));
+ result.superInterfaceTypes().addAll(
+ ASTNode.copySubtrees(target, superInterfaceTypes()));
+ }
+ result.bodyDeclarations().addAll(
+ ASTNode.copySubtrees(target, bodyDeclarations()));
+ result.setPerClause((ASTNode)getPerClause().clone(target));
+ return result;
+ }
+
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = visitor.visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ acceptChild(visitor, getJavadoc());
+ acceptChild(visitor, getName());
+ acceptChild(visitor, getSuperclass());
+ acceptChildren(visitor, this.superInterfaceNames);
+ acceptChild(visitor, this.perClause);
+ acceptChildren(visitor, this.bodyDeclarations);
+ }
+ if (this.ast.apiLevel >= AST.JLS3) {
+ acceptChild(visitor, getJavadoc());
+ acceptChildren(visitor, this.modifiers);
+ acceptChild(visitor, getName());
+ acceptChildren(visitor, this.typeParameters);
+ acceptChild(visitor, getSuperclassType());
+ acceptChildren(visitor, this.superInterfaceTypes);
+ acceptChild(visitor, this.perClause);
+ acceptChildren(visitor, this.bodyDeclarations);
+ }
+ }
+ visitor.endVisit(this);
+ }
+
+
+ public List getAdvice() {
+ // ajh02: method added
+ List bd = bodyDeclarations();
+ List advice = new ArrayList();
+ for (Iterator it = bd.listIterator(); it.hasNext(); ) {
+ Object decl = it.next();
+ if (decl instanceof AdviceDeclaration) {
+ advice.add(decl);
+ }
+ }
+ return advice;
+ }
+
+// public PointcutDeclaration[] getPointcuts() {
+// // ajh02: method added, currently returning none :-/
+// List bd = bodyDeclarations();
+// // ajh02: 0 bodyDeclarations :-/
+// int pointcutCount = 0;
+// for (Iterator it = bd.listIterator(); it.hasNext(); ) {
+// if (it.next() instanceof PointcutDeclaration) {
+// pointcutCount++;
+// }
+// }
+// PointcutDeclaration[] pointcuts = new PointcutDeclaration[pointcutCount];
+// int next = 0;
+// for (Iterator it = bd.listIterator(); it.hasNext(); ) {
+// Object decl = it.next();
+// if (decl instanceof PointcutDeclaration) {
+// pointcuts[next++] = (PointcutDeclaration) decl;
+// }
+// }
+// return pointcuts;
+// }
+
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/BeforeAdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/BeforeAdviceDeclaration.java
new file mode 100644
index 000000000..4bd378d56
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/BeforeAdviceDeclaration.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+/**
+ * BeforeAdviceDeclaration DOM AST node.
+ * @author ajh02
+ */
+
+public class BeforeAdviceDeclaration extends AdviceDeclaration {
+
+ BeforeAdviceDeclaration(AST ast) {
+ super(ast);
+ }
+
+ ASTNode clone0(AST target) {
+ BeforeAdviceDeclaration result = new BeforeAdviceDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ result.parameters().addAll(
+ ASTNode.copySubtrees(target, parameters()));
+ result.thrownExceptions().addAll(
+ ASTNode.copySubtrees(target, thrownExceptions()));
+ result.setPointcut(getPointcut());
+ result.setBody(
+ (Block) ASTNode.copySubtree(target, getBody()));
+ return result;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ acceptChildren(visitor, this.parameters);
+ acceptChild(visitor, getPointcut());
+ acceptChildren(visitor, this.thrownExceptions);
+ acceptChild(visitor, getBody());
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/CflowPointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/CflowPointcut.java
new file mode 100644
index 000000000..f57c415a8
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/CflowPointcut.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * CFlowPointcut DOM AST node.
+ * has:
+ * A PointcutDesignator called 'body'
+ * @author ajh02
+ */
+public class CflowPointcut extends PointcutDesignator {
+
+ private PointcutDesignator body = null;
+ public static final ChildPropertyDescriptor BODY_PROPERTY =
+ new ChildPropertyDescriptor(CflowPointcut.class, "body", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getBody() {
+ return this.body;
+ }
+ public void setBody(PointcutDesignator body) {
+ if (body == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.body;
+ preReplaceChild(oldChild, body, BODY_PROPERTY);
+ this.body = body;
+ postReplaceChild(oldChild, body, BODY_PROPERTY);
+ }
+
+ private boolean isCflowBelow = false;
+ public boolean isCflowBelow(){
+ return isCflowBelow;
+ }
+ public void setIsCflowBelow(boolean isCflowBelow) {
+ this.isCflowBelow = isCflowBelow;
+ }
+
+
+
+
+ CflowPointcut(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(1);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ addProperty(BODY_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == BODY_PROPERTY) {
+ if (get) {
+ return getBody();
+ } else {
+ setBody((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ CflowPointcut result = new CflowPointcut(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setBody((PointcutDesignator)getBody().clone(target));
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getBody());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.body == null ? 0 : getBody().treeSize());
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareDeclaration.java
new file mode 100644
index 000000000..04c309110
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareDeclaration.java
@@ -0,0 +1,150 @@
+
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.aspectj.weaver.patterns.Declare;
+
+/**
+ * DeclareDeclaration DOM AST node.
+ * has:
+ * javadoc
+ *
+ * This class is a stub and should eventually be made abstract
+ * when concrete subclasses exist for all the different types of declare
+ * statements in AspectJ; declare warning, error, parents and precedence.
+ * @author ajh02
+ */
+
+public class DeclareDeclaration extends BodyDeclaration {
+ public static final ChildPropertyDescriptor JAVADOC_PROPERTY =
+ internalJavadocPropertyFactory(DeclareDeclaration.class);
+
+ private static final List PROPERTY_DESCRIPTORS_2_0;
+
+ private static final List PROPERTY_DESCRIPTORS_3_0;
+
+ static {
+ List propertyList = new ArrayList(1);
+ createPropertyList(DeclareDeclaration.class, propertyList);
+ addProperty(JAVADOC_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
+
+ propertyList = new ArrayList(1);
+ createPropertyList(DeclareDeclaration.class, propertyList);
+ addProperty(JAVADOC_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
+ }
+
+ public static List propertyDescriptors(int apiLevel) {
+ if (apiLevel == AST.JLS2_INTERNAL) {
+ return PROPERTY_DESCRIPTORS_2_0;
+ } else {
+ return PROPERTY_DESCRIPTORS_3_0;
+ }
+ }
+
+ public Declare declareDecl;
+ DeclareDeclaration(AST ast, Declare declareDecl) {
+ super(ast);
+
+ System.err.println("DeclareDeclaration constructed.."); // ajh02: line added
+ this.declareDecl = declareDecl;
+
+ }
+
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+
+
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == JAVADOC_PROPERTY) {
+ if (get) {
+ return getJavadoc();
+ } else {
+ setJavadoc((Javadoc) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+
+ final ChildPropertyDescriptor internalJavadocProperty() {
+ return JAVADOC_PROPERTY;
+ }
+
+ final int getNodeType0() {
+ return METHOD_DECLARATION; // ajh02: should add one called DECLARE_DECLARATION or something
+ }
+
+ ASTNode clone0(AST target) {
+ DeclareDeclaration result = new DeclareDeclaration(target,declareDecl);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ return result;
+ }
+
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+
+ /**
+ * Resolves and returns the binding for the method or constructor declared
+ * in this method or constructor declaration.
+ * <p>
+ * Note that bindings are generally unavailable unless requested when the
+ * AST is being built.
+ * </p>
+ *
+ * @return the binding, or <code>null</code> if the binding cannot be
+ * resolved
+ */
+ public IMethodBinding resolveBinding() {
+ return null; // ajh02: :-/
+ //return this.ast.getBindingResolver().resolveMethod(this);
+ }
+
+ int memSize() {
+ return super.memSize() + 9 * 4;
+ }
+
+ int treeSize() {
+ return
+ memSize()
+ + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize());
+ }
+
+ final SimplePropertyDescriptor internalModifiersProperty() {
+ return internalModifiersPropertyFactory(AdviceDeclaration.class); // ajh02: stub method. I don't know what this does
+ }
+ final ChildListPropertyDescriptor internalModifiers2Property() {
+ return internalModifiers2PropertyFactory(AdviceDeclaration.class);// ajh02: stub method. I don't know what this does
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java
new file mode 100644
index 000000000..d7d5d6ee0
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DefaultPointcut.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * DefaultPointcut DOM AST node.
+ * has:
+ * nothing
+ *
+ * This class is a stub and should be deleted when concrete subclasses
+ * exist for all the different types of pointcuts in AspectJ.
+ * @author ajh02
+ */
+
+public class DefaultPointcut extends PointcutDesignator {
+ private String detail;
+ DefaultPointcut(AST ast,String d) {
+ super(ast);
+ this.detail = d;
+ }
+ public String getDetail() { return detail;}
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(0);
+ createPropertyList(DefaultPointcut.class, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ DefaultPointcut result = new DefaultPointcut(target,getDetail());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return memSize();
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeFieldDeclaration.java
new file mode 100644
index 000000000..9b8e4cf36
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeFieldDeclaration.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+
+/**
+ * InterTypeFieldDeclaration DOM AST node.
+ * has:
+ * everything FieldDeclarations have
+ *
+ * Refused Bequest:
+ * has the variableDeclarationFragments list
+ * it redundantly inherits from FieldDeclaration
+ * as fields can be declared like "int b; int a = b = 5;"
+ * but ITD fields can't.
+ * Note:
+ * should also have the name of the type it was declared on!
+ * @author ajh02
+ */
+
+public class InterTypeFieldDeclaration extends FieldDeclaration {
+ InterTypeFieldDeclaration(AST ast) {
+ super(ast);
+ }
+
+ ASTNode clone0(AST target) {
+ InterTypeFieldDeclaration result = new InterTypeFieldDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ result.internalSetModifiers(getModifiers());
+ }
+ if (this.ast.apiLevel >= AST.JLS3) {
+ result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers()));
+ }
+ result.setType((Type) getType().clone(target));
+ result.fragments().addAll(
+ ASTNode.copySubtrees(target, fragments()));
+ return result;
+ }
+
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getJavadoc());
+ if (this.ast.apiLevel >= AST.JLS3) {
+ acceptChildren(visitor, this.modifiers);
+ }
+ acceptChild(visitor, getType());
+ acceptChildren(visitor, this.variableDeclarationFragments);
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java
new file mode 100644
index 000000000..192dbdbe8
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTVisitor;
+import org.aspectj.org.eclipse.jdt.core.dom.Block;
+import org.aspectj.org.eclipse.jdt.core.dom.Javadoc;
+import org.aspectj.org.eclipse.jdt.core.dom.Type;
+
+/**
+ * InterTypeMethodDeclaration DOM AST node.
+ * has:
+ * everything MethodDeclarations have
+ *
+ * Note:
+ * should also have the name of the type it's declared on!
+ * @author ajh02
+ */
+
+public class InterTypeMethodDeclaration extends MethodDeclaration {
+ InterTypeMethodDeclaration(AST ast) {
+ super(ast);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ ASTNode clone0(AST target) {
+ InterTypeMethodDeclaration result = new InterTypeMethodDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ result.internalSetModifiers(getModifiers());
+ result.setReturnType(
+ (Type) ASTNode.copySubtree(target, getReturnType()));
+ }
+ if (this.ast.apiLevel >= AST.JLS3) {
+ result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers()));
+ result.typeParameters().addAll(
+ ASTNode.copySubtrees(target, typeParameters()));
+ result.setReturnType2(
+ (Type) ASTNode.copySubtree(target, getReturnType2()));
+ }
+ result.setConstructor(isConstructor());
+ result.setExtraDimensions(getExtraDimensions());
+ result.setName((SimpleName) getName().clone(target));
+ result.parameters().addAll(
+ ASTNode.copySubtrees(target, parameters()));
+ result.thrownExceptions().addAll(
+ ASTNode.copySubtrees(target, thrownExceptions()));
+ result.setBody(
+ (Block) ASTNode.copySubtree(target, getBody()));
+ return result;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ void accept0(ASTVisitor visitor) {
+ AjASTVisitor ajvis = (AjASTVisitor)visitor;
+ boolean visitChildren = ajvis.visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(ajvis, getJavadoc());
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ acceptChild(ajvis, getReturnType());
+ } else {
+ acceptChildren(ajvis, this.modifiers);
+ acceptChildren(ajvis, (NodeList)this.typeParameters());
+ acceptChild(ajvis, getReturnType2());
+ }
+ // n.b. visit return type even for constructors
+ acceptChild(ajvis, getName());
+ acceptChildren(ajvis, this.parameters);
+ acceptChildren(ajvis, (NodeList)this.thrownExceptions());
+ acceptChild(ajvis, getBody());
+ }
+ ajvis.endVisit(this);
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/NotPointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/NotPointcut.java
new file mode 100644
index 000000000..f897d98b0
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/NotPointcut.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * NotPointcut DOM AST node.
+ * has:
+ * everything PointcutDesignators have
+ * a PointcutDesignator called 'body'
+ *
+ * @author ajh02
+ */
+
+public class NotPointcut extends PointcutDesignator {
+
+ private PointcutDesignator body = null;
+ public static final ChildPropertyDescriptor BODY_PROPERTY =
+ new ChildPropertyDescriptor(NotPointcut.class, "body", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getBody() {
+ return this.body;
+ }
+ public void setBody(PointcutDesignator body) {
+ if (body == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.body;
+ preReplaceChild(oldChild, body, BODY_PROPERTY);
+ this.body = body;
+ postReplaceChild(oldChild, body, BODY_PROPERTY);
+ }
+
+
+
+
+ NotPointcut(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(1);
+ createPropertyList(NotPointcut.class, propertyList);
+ addProperty(BODY_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == BODY_PROPERTY) {
+ if (get) {
+ return getBody();
+ } else {
+ setBody((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ NotPointcut result = new NotPointcut(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setBody((PointcutDesignator)body.clone0(target));
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getBody());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.body == null ? 0 : getBody().treeSize());
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/OrPointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/OrPointcut.java
new file mode 100644
index 000000000..f9ee05023
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/OrPointcut.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * OrPointcut DOM AST node.
+ * has:
+ * everything PointcutDesignators have
+ * a PointcutDesignator called 'left'
+ * a PointcutDesignator called 'right'
+ *
+ * @author ajh02
+ */
+public class OrPointcut extends PointcutDesignator {
+
+ private PointcutDesignator left = null;
+ public static final ChildPropertyDescriptor LEFT_PROPERTY =
+ new ChildPropertyDescriptor(OrPointcut.class, "left", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getLeft() {
+ return this.left;
+ }
+ public void setLeft(PointcutDesignator left) {
+ if (left == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.left;
+ preReplaceChild(oldChild, left, LEFT_PROPERTY);
+ this.left = left;
+ postReplaceChild(oldChild, left, LEFT_PROPERTY);
+ }
+
+ private PointcutDesignator right = null;
+ public static final ChildPropertyDescriptor RIGHT_PROPERTY =
+ new ChildPropertyDescriptor(OrPointcut.class, "right", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getRight() {
+ return this.right;
+ }
+ public void setRight(PointcutDesignator right) {
+ if (right == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.right;
+ preReplaceChild(oldChild, right, RIGHT_PROPERTY);
+ this.right = right;
+ postReplaceChild(oldChild, right, RIGHT_PROPERTY);
+ }
+
+
+
+
+ OrPointcut(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(2);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ addProperty(LEFT_PROPERTY, propertyList);
+ addProperty(RIGHT_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == LEFT_PROPERTY) {
+ if (get) {
+ return getLeft();
+ } else {
+ setLeft((PointcutDesignator) child);
+ return null;
+ }
+ } else if (property == RIGHT_PROPERTY) {
+ if (get) {
+ return getRight();
+ } else {
+ setRight((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ OrPointcut result = new OrPointcut(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setRight((PointcutDesignator)getRight().clone(target));
+ result.setLeft((PointcutDesignator)getLeft().clone(target));
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getLeft());
+ acceptChild(visitor, getRight());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.left == null ? 0 : getLeft().treeSize())
+ + (this.right == null ? 0 : getRight().treeSize());
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerCflow.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerCflow.java
new file mode 100644
index 000000000..a8054b3d8
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerCflow.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * PerCflow DOM AST node.
+ * has:
+ * everything PointcutDesignators have
+ * a PointcutDesignator called 'body'
+ *
+ * @author ajh02
+ */
+public class PerCflow extends PointcutDesignator {
+ // ajh02: should make an abstract PerClause Pointcut parent
+ // of this and all the other PerClause nodes
+
+
+ private PointcutDesignator body = null;
+ public static final ChildPropertyDescriptor BODY_PROPERTY =
+ new ChildPropertyDescriptor(PerCflow.class, "body", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getBody() {
+ return this.body;
+ }
+ public void setBody(PointcutDesignator body) {
+ if (body == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.body;
+ preReplaceChild(oldChild, body, BODY_PROPERTY);
+ this.body = body;
+ postReplaceChild(oldChild, body, BODY_PROPERTY);
+ }
+
+ private boolean isBelow = false; // percflow or percflowbelow
+ public boolean isBelow(){
+ return isBelow;
+ }
+ public void setIsBelow(boolean isBelow){
+ this.isBelow = isBelow;
+ }
+
+
+
+ PerCflow(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(1);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ addProperty(BODY_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == BODY_PROPERTY) {
+ if (get) {
+ return getBody();
+ } else {
+ setBody((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ PerCflow result = new PerCflow(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setBody((PointcutDesignator)getBody().clone(target));
+ result.setIsBelow(isBelow);
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getBody());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.body == null ? 0 : getBody().treeSize());
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerObject.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerObject.java
new file mode 100644
index 000000000..957214753
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerObject.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * OrPointcut DOM AST node.
+ * has:
+ * everything PointcutDesignators have
+ * a PointcutDesignator called 'body'
+ *
+ * @author ajh02
+ */
+public class PerObject extends PointcutDesignator {
+ // ajh02: should make an abstract PerClause Pointcut parent
+ // of this and all the other PerClause nodes
+
+
+ private PointcutDesignator body = null;
+ public static final ChildPropertyDescriptor BODY_PROPERTY =
+ new ChildPropertyDescriptor(PerObject.class, "body", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public PointcutDesignator getBody() {
+ return this.body;
+ }
+ public void setBody(PointcutDesignator body) {
+ if (body == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.body;
+ preReplaceChild(oldChild, body, BODY_PROPERTY);
+ this.body = body;
+ postReplaceChild(oldChild, body, BODY_PROPERTY);
+ }
+
+ private boolean isThis = false; // if it's not a perthis, it's a pertarget
+ public boolean isThis(){
+ return isThis;
+ }
+ public void setIsThis(boolean isThis){
+ this.isThis = isThis;
+ }
+
+
+
+ PerObject(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(1);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ addProperty(BODY_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == BODY_PROPERTY) {
+ if (get) {
+ return getBody();
+ } else {
+ setBody((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ PerObject result = new PerObject(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setBody((PointcutDesignator)getBody().clone(target));
+ result.setIsThis(isThis);
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getBody());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.body == null ? 0 : getBody().treeSize());
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerTypeWithin.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerTypeWithin.java
new file mode 100644
index 000000000..5a83a9ea9
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PerTypeWithin.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * OrPointcut DOM AST node.
+ * has:
+ * everything PointcutDesignators have
+ *
+ * note:
+ * should also have a typepattern or something. I haven't put one in yet.
+ * @author ajh02
+ */
+public class PerTypeWithin extends PointcutDesignator {
+
+ PerTypeWithin(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(1);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ // add the type thingy here
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ // ajh02: todo add type thingy here
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ PerTypeWithin result = new PerTypeWithin(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ // remeber to set the type thingy here
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ // ajh02: remember to visit the type thingy here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize(); // stub
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java
new file mode 100644
index 000000000..d583a12e1
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * PointcutDeclaration DOM AST node.
+ * has:
+ * a name
+ * an optional pointcut designator called 'designator'
+ * javadoc
+ * modifiers
+ *
+ * note:
+ * should also have a property for its parameter list,
+ * like the one MethodDeclarations have.
+ * @author ajh02
+ */
+public class PointcutDeclaration extends BodyDeclaration {
+
+ private SimpleName pointcutName = null;
+ public static final ChildPropertyDescriptor NAME_PROPERTY =
+ new ChildPropertyDescriptor(PointcutDeclaration.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ private PointcutDesignator pointcutDesignator = null;
+ public static final ChildPropertyDescriptor DESIGNATOR_PROPERTY =
+ new ChildPropertyDescriptor(PointcutDeclaration.class, "designator", PointcutDesignator.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$
+
+ public PointcutDesignator getDesignator() {
+ return this.pointcutDesignator;
+ }
+
+ public void setDesignator(PointcutDesignator pointcutDesignator) {
+ ASTNode oldChild = this.pointcutDesignator;
+ preReplaceChild(oldChild, pointcutDesignator, DESIGNATOR_PROPERTY);
+ this.pointcutDesignator = pointcutDesignator;
+ postReplaceChild(oldChild, pointcutDesignator, DESIGNATOR_PROPERTY);
+ }
+
+ public SimpleName getName() {
+ if (this.pointcutName == null) {
+ // lazy init must be thread-safe for readers
+ synchronized (this) {
+ if (this.pointcutName == null) {
+ preLazyInit();
+ this.pointcutName = new SimpleName(this.ast);
+ postLazyInit(this.pointcutName, NAME_PROPERTY);
+ }
+ }
+ }
+ return this.pointcutName;
+ }
+
+ public void setName(SimpleName pointcutName) {
+ if (pointcutName == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.pointcutName;
+ preReplaceChild(oldChild, pointcutName, NAME_PROPERTY);
+ this.pointcutName = pointcutName;
+ postReplaceChild(oldChild, pointcutName, NAME_PROPERTY);
+ }
+
+ /**
+ * The "javadoc" structural property of this node type.
+ * @since 3.0
+ */
+ public static final ChildPropertyDescriptor JAVADOC_PROPERTY =
+ internalJavadocPropertyFactory(PointcutDeclaration.class);
+
+ /**
+ * The "modifiers" structural property of this node type (JLS2 API only).
+ * @since 3.0
+ */
+ public static final SimplePropertyDescriptor MODIFIERS_PROPERTY =
+ internalModifiersPropertyFactory(PointcutDeclaration.class);
+
+ /**
+ * The "modifiers" structural property of this node type (added in JLS3 API).
+ * @since 3.1
+ */
+ public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY =
+ internalModifiers2PropertyFactory(PointcutDeclaration.class);
+
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ * @since 3.0
+ */
+ private static final List PROPERTY_DESCRIPTORS_2_0;
+
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ * @since 3.1
+ */
+ private static final List PROPERTY_DESCRIPTORS_3_0;
+
+ static {
+ List propertyList = new ArrayList(5);
+ createPropertyList(PointcutDeclaration.class, propertyList);
+ addProperty(JAVADOC_PROPERTY, propertyList);
+ addProperty(MODIFIERS_PROPERTY, propertyList);
+ addProperty(NAME_PROPERTY, propertyList);
+ addProperty(DESIGNATOR_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList);
+
+ propertyList = new ArrayList(5);
+ createPropertyList(PointcutDeclaration.class, propertyList);
+ addProperty(JAVADOC_PROPERTY, propertyList);
+ addProperty(MODIFIERS2_PROPERTY, propertyList);
+ addProperty(NAME_PROPERTY, propertyList);
+ addProperty(DESIGNATOR_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList);
+ }
+
+ /**
+ * Returns a list of structural property descriptors for this node type.
+ * Clients must not modify the result.
+ *
+ * @param apiLevel the API level; one of the
+ * <code>AST.JLS&ast;</code> constants
+
+ * @return a list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor})
+ * @since 3.0
+ */
+ public static List propertyDescriptors(int apiLevel) {
+ if (apiLevel == AST.JLS2_INTERNAL) {
+ return PROPERTY_DESCRIPTORS_2_0;
+ } else {
+ return PROPERTY_DESCRIPTORS_3_0;
+ }
+ }
+
+ /**
+ * Creates a new unparented field declaration statement node owned
+ * by the given AST. By default, the field declaration has: no modifiers,
+ * an unspecified (but legal) type, and an empty list of variable
+ * declaration fragments (which is syntactically illegal).
+ * <p>
+ * N.B. This constructor is package-private.
+ * </p>
+ *
+ * @param ast the AST that is to own this node
+ */
+ PointcutDeclaration(AST ast) {
+ super(ast);
+ }
+
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ * @since 3.0
+ */
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) {
+ if (property == MODIFIERS_PROPERTY) {
+ if (get) {
+ return getModifiers();
+ } else {
+ internalSetModifiers(value);
+ return 0;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetIntProperty(property, get, value);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == JAVADOC_PROPERTY) {
+ if (get) {
+ return getJavadoc();
+ } else {
+ setJavadoc((Javadoc) child);
+ return null;
+ }
+ }
+ if (property == NAME_PROPERTY) {
+ if (get) {
+ return getName();
+ } else {
+ setName((SimpleName) child);
+ return null;
+ }
+ }
+ if (property == DESIGNATOR_PROPERTY) {
+ if (get) {
+ return getDesignator();
+ } else {
+ setDesignator((PointcutDesignator) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final List internalGetChildListProperty(ChildListPropertyDescriptor property) {
+ if (property == MODIFIERS2_PROPERTY) {
+ return modifiers();
+ }
+ // allow default implementation to flag the error
+ return super.internalGetChildListProperty(property);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on BodyDeclaration.
+ */
+ final ChildPropertyDescriptor internalJavadocProperty() {
+ return JAVADOC_PROPERTY;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on BodyDeclaration.
+ */
+ final SimplePropertyDescriptor internalModifiersProperty() {
+ return MODIFIERS_PROPERTY;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on BodyDeclaration.
+ */
+ final ChildListPropertyDescriptor internalModifiers2Property() {
+ return MODIFIERS2_PROPERTY;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final int getNodeType0() {
+ return FIELD_DECLARATION; // ajh02: hmmmmmmm.. should make a POINTCUT_DECLARATION thing
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ ASTNode clone0(AST target) {
+ PointcutDeclaration result = new PointcutDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setJavadoc(
+ (Javadoc) ASTNode.copySubtree(target, getJavadoc()));
+ if (this.ast.apiLevel == AST.JLS2_INTERNAL) {
+ result.internalSetModifiers(getModifiers());
+ }
+ if (this.ast.apiLevel >= AST.JLS3) {
+ result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers()));
+ }
+ result.setName((SimpleName) getName().clone(target));
+ result.setDesignator((PointcutDesignator) getDesignator().clone(target));
+ return result;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ void accept0(ASTVisitor visitor) {
+ AjASTVisitor ajvis = ((AjASTVisitor)visitor);
+ boolean visitChildren = ajvis.visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(ajvis, getJavadoc());
+ if (this.ast.apiLevel >= AST.JLS3) {
+ acceptChildren(ajvis, this.modifiers);
+ }
+ acceptChild(ajvis, getName());
+ acceptChild(ajvis, getDesignator());
+ }
+ ajvis.endVisit(this);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ int memSize() {
+ return super.memSize() + 2 * 4;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
+ int treeSize() {
+ return
+ memSize()
+ + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize())
+ + (this.pointcutName == null ? 0 : getName().treeSize())
+ + (this.modifiers == null ? 0 : this.modifiers.listSize())
+ + (this.pointcutDesignator == null ? 0 : getDesignator().treeSize());
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDesignator.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDesignator.java
new file mode 100644
index 000000000..9a54578cc
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDesignator.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * abstract PointcutDesignator DOM AST node.
+ * has:
+ * nothing at the moment
+ *
+ * @author ajh02
+ */
+public abstract class PointcutDesignator extends ASTNode {
+ PointcutDesignator(AST ast) {
+ super(ast);
+ }
+ final int getNodeType0() {
+ return FIELD_DECLARATION; // ajh02: hmmmmmmm.. should make a POINTCUT_DESIGNATOR thing
+ }
+ int memSize() {
+ return 0; // ajh02: stub method
+ }
+} \ No newline at end of file
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/ReferencePointcut.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/ReferencePointcut.java
new file mode 100644
index 000000000..83de6fdc7
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/ReferencePointcut.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.org.eclipse.jdt.core.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.org.eclipse.jdt.core.dom.AST;
+import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
+
+/**
+ * ReferencePointcut DOM AST node.
+ * has:
+ * a name
+ *
+ * note:
+ * should also have a parameter list like method invokations do?
+ * @author ajh02
+ */
+public class ReferencePointcut extends PointcutDesignator {
+
+ private SimpleName pointcutName = null;
+ public static final ChildPropertyDescriptor NAME_PROPERTY =
+ new ChildPropertyDescriptor(ReferencePointcut.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$
+ public SimpleName getName() {
+ if (this.pointcutName == null) {
+ // lazy init must be thread-safe for readers
+ synchronized (this) {
+ if (this.pointcutName == null) {
+ preLazyInit();
+ this.pointcutName = new SimpleName(this.ast);
+ postLazyInit(this.pointcutName, NAME_PROPERTY);
+ }
+ }
+ }
+ return this.pointcutName;
+ }
+ public void setName(SimpleName pointcutName) {
+ if (pointcutName == null) {
+ throw new IllegalArgumentException();
+ }
+ ASTNode oldChild = this.pointcutName;
+ preReplaceChild(oldChild, pointcutName, NAME_PROPERTY);
+ this.pointcutName = pointcutName;
+ postReplaceChild(oldChild, pointcutName, NAME_PROPERTY);
+ }
+
+
+
+
+ ReferencePointcut(AST ast) {
+ super(ast);
+ }
+ public static List propertyDescriptors(int apiLevel) {
+ List propertyList = new ArrayList(1);
+ createPropertyList(ReferencePointcut.class, propertyList);
+ addProperty(NAME_PROPERTY, propertyList);
+ return reapPropertyList(propertyList);
+ }
+ final List internalStructuralPropertiesForType(int apiLevel) {
+ return propertyDescriptors(apiLevel);
+ }
+ final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
+ if (property == NAME_PROPERTY) {
+ if (get) {
+ return getName();
+ } else {
+ setName((SimpleName) child);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetChildProperty(property, get, child);
+ }
+ ASTNode clone0(AST target) {
+ ReferencePointcut result = new ReferencePointcut(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.setName((SimpleName) getName().clone(target));
+ return result;
+ }
+ final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
+ // dispatch to correct overloaded match method
+ return ((AjASTMatcher)matcher).match(this, other);
+ }
+ void accept0(ASTVisitor visitor) {
+ boolean visitChildren = ((AjASTVisitor)visitor).visit(this);
+ if (visitChildren) {
+ // visit children in normal left to right reading order
+ acceptChild(visitor, getName());
+ // todo: accept the parameters here
+ }
+ ((AjASTVisitor)visitor).endVisit(this);
+ }
+ int treeSize() {
+ return
+ memSize()
+ + (this.pointcutName == null ? 0 : getName().treeSize());
+ }
+} \ No newline at end of file