From: aclement Date: Thu, 26 Jan 2006 10:53:03 +0000 (+0000) Subject: new distinct nodes for the different types of declare - all follow the standard ASTNo... X-Git-Tag: POST_MEMORY_CHANGES~150 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=861823254fc58b165b1c1e80689497293e03c7ef;p=aspectj.git new distinct nodes for the different types of declare - all follow the standard ASTNode pattern of having properties defined (modifiers/javadoc/etc). --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAnnotationDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAnnotationDeclaration.java new file mode 100644 index 000000000..9e20dd9df --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAnnotationDeclaration.java @@ -0,0 +1,110 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +/** + * Abstract class for the different declare annotation + * declaration AST node types. + * + * Has everything a DeclareDeclaration has plus: + * a PatternNode called 'pattern' + * a SimpleName called 'annotationName' + * + * Unsupported for JLS2. + */ +public abstract class DeclareAnnotationDeclaration extends DeclareDeclaration { + + abstract ChildPropertyDescriptor internalPatternNodeProperty(); + abstract ChildPropertyDescriptor internalAnnotationNameProperty(); + + /** + * Creates and returns a structural property descriptor for the + * "annotationName" property declared on the given concrete node type. + * + * @return the property descriptor + */ + static final ChildPropertyDescriptor internalAnnotationNamePropertyFactory(Class nodeClass) { + return new ChildPropertyDescriptor(nodeClass, "annotationName", SimpleName.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + } + + /** + * Creates and returns a structural property descriptor for the + * "pattern" property declared on the given concrete node type. + * + * @return the property descriptor + */ + static final ChildPropertyDescriptor internalPatternNodePropertyFactory(Class nodeClass) { + return new ChildPropertyDescriptor(nodeClass, "pattern", PatternNode.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + } + + PatternNode pattern; + SimpleName name = null; + + DeclareAnnotationDeclaration(AST ast) { + super(ast); + unsupportedIn2(); + } + + public PatternNode getPatternNode(){ + return pattern; + } + + public void setPatternNode(PatternNode pattern) { + if (pattern == null) { + throw new IllegalArgumentException(); + } + ASTNode oldChild = this.pattern; + preReplaceChild(oldChild, pattern, internalPatternNodeProperty()); + this.pattern = pattern; + postReplaceChild(oldChild, pattern, internalPatternNodeProperty()); + } + + /** + * Returns the name of the annotation type member declared in this declaration. + * + * @return the name node + */ + public SimpleName getAnnotationName() { + if (this.name == null) { + // lazy init must be thread-safe for readers + synchronized (this) { + if (this.name == null) { + preLazyInit(); + this.name = new SimpleName(this.ast); + postLazyInit(this.name, internalAnnotationNameProperty()); + } + } + } + return this.name; + } + + /** + * Sets the name of the annotation type member declared in this declaration to the + * given name. + * + * @param name the new member name + * @exception IllegalArgumentException if: + * + */ + public void setAnnotationName(SimpleName name) { + if (name == null) { + throw new IllegalArgumentException(); + } + ASTNode oldChild = this.name; + preReplaceChild(oldChild, name, internalAnnotationNameProperty()); + this.name = name; + postReplaceChild(oldChild, name, internalAnnotationNameProperty()); + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtConstructorDeclaration.java new file mode 100644 index 000000000..2fb1f45d3 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtConstructorDeclaration.java @@ -0,0 +1,183 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareAtConstructorDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has. + * + * Unsupported for JLS2. + */ +public class DeclareAtConstructorDeclaration extends DeclareAnnotationDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareAtConstructorDeclaration.class); + + public static final ChildPropertyDescriptor PATTERN_PROPERTY = + internalPatternNodePropertyFactory(DeclareAtConstructorDeclaration.class); + + public static final ChildPropertyDescriptor ANNOTATION_NAME_PROPERTY = + internalAnnotationNamePropertyFactory(DeclareAtConstructorDeclaration.class); + + private static final List PROPERTY_DESCRIPTORS; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareAtConstructorDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(PATTERN_PROPERTY, propertyList); + addProperty(ANNOTATION_NAME_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); + } + + DeclareAtConstructorDeclaration(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone0(AST target) { + DeclareAtConstructorDeclaration result = new DeclareAtConstructorDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPatternNode((PatternNode) ASTNode.copySubtree(target, + getPatternNode())); + result.setAnnotationName((SimpleName) ASTNode.copySubtree(target, + getAnnotationName())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor) visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor, getPatternNode()); + acceptChild(visitor, getAnnotationName()); + } + ((AjASTVisitor) visitor).endVisit(this); + } + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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) { + return PROPERTY_DESCRIPTORS; + } + + /* + * (omit javadoc for this method) Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* + * (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 == PATTERN_PROPERTY) { + if (get) { + return getPatternNode(); + } else { + setPatternNode((PatternNode) child); + return null; + } + } + if (property == ANNOTATION_NAME_PROPERTY) { + if (get) { + return getAnnotationName(); + } else { + setAnnotationName((SimpleName) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalPatternNodeProperty() { + return PATTERN_PROPERTY; + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalAnnotationNameProperty() { + return ANNOTATION_NAME_PROPERTY; + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtFieldDeclaration.java new file mode 100644 index 000000000..5c4268437 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtFieldDeclaration.java @@ -0,0 +1,183 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareAtFieldDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has. + * + * Unsupported for JLS2. + */ +public class DeclareAtFieldDeclaration extends DeclareAnnotationDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareAtFieldDeclaration.class); + + public static final ChildPropertyDescriptor PATTERN_PROPERTY = + internalPatternNodePropertyFactory(DeclareAtFieldDeclaration.class); + + public static final ChildPropertyDescriptor ANNOTATION_NAME_PROPERTY = + internalAnnotationNamePropertyFactory(DeclareAtFieldDeclaration.class); + + private static final List PROPERTY_DESCRIPTORS; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareAtFieldDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(PATTERN_PROPERTY, propertyList); + addProperty(ANNOTATION_NAME_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); + } + + DeclareAtFieldDeclaration(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone0(AST target) { + DeclareAtFieldDeclaration result = new DeclareAtFieldDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPatternNode((PatternNode) ASTNode.copySubtree(target, + getPatternNode())); + result.setAnnotationName((SimpleName) ASTNode.copySubtree(target, + getAnnotationName())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor) visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor, getPatternNode()); + acceptChild(visitor, getAnnotationName()); + } + ((AjASTVisitor) visitor).endVisit(this); + } + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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) { + return PROPERTY_DESCRIPTORS; + } + + /* + * (omit javadoc for this method) Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* + * (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 == PATTERN_PROPERTY) { + if (get) { + return getPatternNode(); + } else { + setPatternNode((PatternNode) child); + return null; + } + } + if (property == ANNOTATION_NAME_PROPERTY) { + if (get) { + return getAnnotationName(); + } else { + setAnnotationName((SimpleName) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalPatternNodeProperty() { + return PATTERN_PROPERTY; + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalAnnotationNameProperty() { + return ANNOTATION_NAME_PROPERTY; + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtMethodDeclaration.java new file mode 100644 index 000000000..1fab22b6b --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtMethodDeclaration.java @@ -0,0 +1,183 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareAtMethodDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has. + * + * Unsupported for JLS2. + */ +public class DeclareAtMethodDeclaration extends DeclareAnnotationDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareAtMethodDeclaration.class); + + public static final ChildPropertyDescriptor PATTERN_PROPERTY = + internalPatternNodePropertyFactory(DeclareAtMethodDeclaration.class); + + public static final ChildPropertyDescriptor ANNOTATION_NAME_PROPERTY = + internalAnnotationNamePropertyFactory(DeclareAtMethodDeclaration.class); + + private static final List PROPERTY_DESCRIPTORS; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareAtMethodDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(PATTERN_PROPERTY, propertyList); + addProperty(ANNOTATION_NAME_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); + } + + DeclareAtMethodDeclaration(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone0(AST target) { + DeclareAtMethodDeclaration result = new DeclareAtMethodDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPatternNode((PatternNode) ASTNode.copySubtree(target, + getPatternNode())); + result.setAnnotationName((SimpleName) ASTNode.copySubtree(target, + getAnnotationName())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor) visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor, getPatternNode()); + acceptChild(visitor, getAnnotationName()); + } + ((AjASTVisitor) visitor).endVisit(this); + } + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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) { + return PROPERTY_DESCRIPTORS; + } + + /* + * (omit javadoc for this method) Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* + * (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 == PATTERN_PROPERTY) { + if (get) { + return getPatternNode(); + } else { + setPatternNode((PatternNode) child); + return null; + } + } + if (property == ANNOTATION_NAME_PROPERTY) { + if (get) { + return getAnnotationName(); + } else { + setAnnotationName((SimpleName) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalPatternNodeProperty() { + return PATTERN_PROPERTY; + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalAnnotationNameProperty() { + return ANNOTATION_NAME_PROPERTY; + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtTypeDeclaration.java new file mode 100644 index 000000000..bbc2200d5 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareAtTypeDeclaration.java @@ -0,0 +1,183 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareAtTypeDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has. + * + * Unsupported for JLS2. + */ +public class DeclareAtTypeDeclaration extends DeclareAnnotationDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareAtTypeDeclaration.class); + + public static final ChildPropertyDescriptor PATTERN_PROPERTY = + internalPatternNodePropertyFactory(DeclareAtTypeDeclaration.class); + + public static final ChildPropertyDescriptor ANNOTATION_NAME_PROPERTY = + internalAnnotationNamePropertyFactory(DeclareAtTypeDeclaration.class); + + private static final List PROPERTY_DESCRIPTORS; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareAtTypeDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(PATTERN_PROPERTY, propertyList); + addProperty(ANNOTATION_NAME_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); + } + + DeclareAtTypeDeclaration(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone0(AST target) { + DeclareAtTypeDeclaration result = new DeclareAtTypeDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPatternNode((PatternNode) ASTNode.copySubtree(target, + getPatternNode())); + result.setAnnotationName((SimpleName) ASTNode.copySubtree(target, + getAnnotationName())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor) visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor, getPatternNode()); + acceptChild(visitor, getAnnotationName()); + } + ((AjASTVisitor) visitor).endVisit(this); + } + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - therefore + * we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* + * (omit javadoc for this method) Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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) { + return PROPERTY_DESCRIPTORS; + } + + /* + * (omit javadoc for this method) Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* + * (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 == PATTERN_PROPERTY) { + if (get) { + return getPatternNode(); + } else { + setPatternNode((PatternNode) child); + return null; + } + } + if (property == ANNOTATION_NAME_PROPERTY) { + if (get) { + return getAnnotationName(); + } else { + setAnnotationName((SimpleName) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalPatternNodeProperty() { + return PATTERN_PROPERTY; + } + + /* (omit javadoc for this method) + * Method declared on DeclareAnnotationDeclaration. + */ + ChildPropertyDescriptor internalAnnotationNameProperty() { + return ANNOTATION_NAME_PROPERTY; + } + +} 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 index f33350582..5eb602344 100644 --- 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 @@ -11,110 +11,39 @@ *******************************************************************************/ 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; +public abstract class DeclareDeclaration extends BodyDeclaration { - 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) { + DeclareDeclaration(AST ast) { 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; - } - + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ 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. + */ + int memSize() { + return super.memSize() + 9 * 4; } /* (omit javadoc for this method) * Method declared on ASTNode. */ - void accept0(ASTVisitor visitor) { - if (visitor instanceof AjASTVisitor) { - boolean visitChildren = ((AjASTVisitor)visitor).visit(this); - if (visitChildren) { - // visit children in normal left to right reading order - acceptChild(visitor, getJavadoc()); - } - ((AjASTVisitor)visitor).endVisit(this); - } + int treeSize() { + return + memSize() + + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()); } /** @@ -133,20 +62,4 @@ public class DeclareDeclaration extends BodyDeclaration { //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/DeclareErrorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareErrorDeclaration.java new file mode 100644 index 000000000..886574048 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareErrorDeclaration.java @@ -0,0 +1,210 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareErrorDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has plus: + * a PointcutDesignator called 'pointcut' + * a StringLiteral called 'message' + */ +public class DeclareErrorDeclaration extends DeclareDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareErrorDeclaration.class); + + public static final ChildPropertyDescriptor POINTCUT_PROPERTY = + new ChildPropertyDescriptor(DeclareErrorDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + public static final ChildPropertyDescriptor MESSAGE_PROPERTY = + new ChildPropertyDescriptor(DeclareErrorDeclaration.class, "message", StringLiteral.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + + private static final List PROPERTY_DESCRIPTORS_2_0; + private static final List PROPERTY_DESCRIPTORS_3_0; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareErrorDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(POINTCUT_PROPERTY, propertyList); + addProperty(MESSAGE_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); + + propertyList = new ArrayList(3); + createPropertyList(DeclareErrorDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(POINTCUT_PROPERTY, propertyList); + addProperty(MESSAGE_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); + } + + private PointcutDesignator pointcut; + private StringLiteral message; + + DeclareErrorDeclaration(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone0(AST target) { + DeclareErrorDeclaration result = new DeclareErrorDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc( + (Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPointcut((PointcutDesignator)ASTNode.copySubtree(target,getPointcut())); + result.setMessage((StringLiteral)ASTNode.copySubtree(target,getMessage())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor)visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor,getPointcut()); + acceptChild(visitor,getMessage()); + } + ((AjASTVisitor)visitor).endVisit(this); + } + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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; + } + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* (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 == POINTCUT_PROPERTY) { + if (get) { + return getPointcut(); + } else { + setPointcut((PointcutDesignator) child); + return null; + } + } + if (property == MESSAGE_PROPERTY) { + if (get) { + return getMessage(); + } else { + setMessage((StringLiteral) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + + 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); + } + + public StringLiteral getMessage(){ + return message; + } + + public void setMessage(StringLiteral message) { + if (message == null) { + throw new IllegalArgumentException(); + } + ASTNode oldChild = this.message; + preReplaceChild(oldChild, message, MESSAGE_PROPERTY); + this.message = message; + postReplaceChild(oldChild, message, MESSAGE_PROPERTY); + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java new file mode 100644 index 000000000..0961d4e8d --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java @@ -0,0 +1,258 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareParentsDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has plus: + * a TypePattern called 'childTypePattern' + * a boolean called 'isExtends' + * a TypePattern list called 'typePatternsList' + */ +public class DeclareParentsDeclaration extends DeclareDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareParentsDeclaration.class); + + public static final ChildPropertyDescriptor CHILD_TYPE_PATTERN_PROPERTY = + new ChildPropertyDescriptor(DeclareParentsDeclaration.class, "childTypePattern", TypePattern.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + public static final SimplePropertyDescriptor IS_EXTENDS_PROPERTY = + new SimplePropertyDescriptor(DeclareParentsDeclaration.class, "isExtends", boolean.class, MANDATORY); //$NON-NLS-1$ + + public static final ChildListPropertyDescriptor PARENTS_TYPE_PATTERNS_LIST_PROPERTY = + new ChildListPropertyDescriptor(DeclareParentsDeclaration.class, "typePatternsList", TypePattern.class, NO_CYCLE_RISK); //$NON-NLS-1$ + + private static final List PROPERTY_DESCRIPTORS_2_0; + private static final List PROPERTY_DESCRIPTORS_3_0; + + static { + List propertyList = new ArrayList(4); + createPropertyList(DeclareParentsDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(CHILD_TYPE_PATTERN_PROPERTY, propertyList); + addProperty(IS_EXTENDS_PROPERTY, propertyList); + addProperty(PARENTS_TYPE_PATTERNS_LIST_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); + + propertyList = new ArrayList(4); + createPropertyList(DeclareParentsDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(CHILD_TYPE_PATTERN_PROPERTY, propertyList); + addProperty(IS_EXTENDS_PROPERTY, propertyList); + addProperty(PARENTS_TYPE_PATTERNS_LIST_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); + } + + private boolean isExtends; + private TypePattern childTypePattern; + protected ASTNode.NodeList parentTypePatterns =new ASTNode.NodeList(PARENTS_TYPE_PATTERNS_LIST_PROPERTY); + + + DeclareParentsDeclaration(AST ast) { + this(ast,false); + } + + DeclareParentsDeclaration(AST ast, boolean isExtends) { + super(ast); + this.isExtends = isExtends; + } + + ASTNode clone0(AST target) { + DeclareParentsDeclaration result = new DeclareParentsDeclaration(target/*,declareDecl*/); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc( + (Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setChildTypePattern( + (TypePattern) ASTNode.copySubtree(target, getChildTypePattern())); + result.setExtends(isExtends()); + result.parentTypePatterns().addAll( + ASTNode.copySubtrees(target, parentTypePatterns())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor)visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor, getChildTypePattern()); + acceptChildren(visitor, this.parentTypePatterns); + } + ((AjASTVisitor)visitor).endVisit(this); + } + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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; + } + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* (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 == CHILD_TYPE_PATTERN_PROPERTY) { + if (get) { + return getChildTypePattern(); + } else { + setChildTypePattern((TypePattern) 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. + */ + boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { + if (property == IS_EXTENDS_PROPERTY) { + if (get) { + return isExtends(); + } else { + setExtends(value); + return false; + } + } + return super.internalGetSetBooleanProperty(property,get,value); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + List internalGetChildListProperty(ChildListPropertyDescriptor property) { + if (property == PARENTS_TYPE_PATTERNS_LIST_PROPERTY) { + return parentTypePatterns(); + } + // allow default implementation to flag the error + return super.internalGetChildListProperty(property); + } + + /** + * Returns the live ordered list of parent type patterns for this + * declare precedence. + * + * @return the live list of parent type patterns + * (element type: TypePattern) + */ + public List parentTypePatterns() { + return this.parentTypePatterns; + } + + + public TypePattern getChildTypePattern(){ + return childTypePattern; + } + + public void setChildTypePattern(TypePattern typePattern) { + if (typePattern == null) { + throw new IllegalArgumentException(); + } + ASTNode oldChild = this.childTypePattern; + preReplaceChild(oldChild, typePattern, CHILD_TYPE_PATTERN_PROPERTY); + this.childTypePattern = typePattern; + postReplaceChild(oldChild, typePattern, CHILD_TYPE_PATTERN_PROPERTY); + } + + /** + * Returns whether this declareParents declares an extends + * or implements. + * + * @return true if this is an extends declaration, + * and false if this is an implements declaration + */ + public boolean isExtends() { + return this.isExtends; + } + + /** + * Sets whether this declareParents declares an extends or implements. + * + * @param isExtends true for an extends declaration, + * and false for an implements declaration + */ + public void setExtends(boolean isExtends) { + preValueChange(IS_EXTENDS_PROPERTY); + this.isExtends = isExtends; + postValueChange(IS_EXTENDS_PROPERTY); + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java new file mode 100644 index 000000000..a40c70f41 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java @@ -0,0 +1,187 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + + +/** + * DeclarePrecedenceDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has plus: + * a TypePattern list called 'parentTypePatterns' + */ +public class DeclarePrecedenceDeclaration extends DeclareDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclarePrecedenceDeclaration.class); + + public static final ChildListPropertyDescriptor TYPE_PATTERNS_LIST_PROPERTY = + new ChildListPropertyDescriptor(DeclarePrecedenceDeclaration.class, "parentTypePatterns", TypePattern.class, NO_CYCLE_RISK); //$NON-NLS-1$ + + private static final List PROPERTY_DESCRIPTORS_2_0; + private static final List PROPERTY_DESCRIPTORS_3_0; + + static { + List propertyList = new ArrayList(2); + createPropertyList(DeclarePrecedenceDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(TYPE_PATTERNS_LIST_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); + + propertyList = new ArrayList(2); + createPropertyList(DeclarePrecedenceDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(TYPE_PATTERNS_LIST_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); + } + + protected ASTNode.NodeList typePatterns =new ASTNode.NodeList(TYPE_PATTERNS_LIST_PROPERTY); + + DeclarePrecedenceDeclaration(AST ast) { + super(ast); + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + ASTNode clone0(AST target) { + DeclarePrecedenceDeclaration result = new DeclarePrecedenceDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc( + (Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.typePatterns().addAll( + ASTNode.copySubtrees(target, typePatterns())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor)visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChildren(visitor, this.typePatterns); + } + ((AjASTVisitor)visitor).endVisit(this); + } + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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; + } + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* (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; + } + } + // 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 == TYPE_PATTERNS_LIST_PROPERTY) { + return typePatterns(); + } + // allow default implementation to flag the error + return super.internalGetChildListProperty(property); + } + + /** + * Returns the live ordered list of type patterns for this + * declare precedence. + * + * @return the live list of type patterns + * (element type: TypePattern) + */ + public List typePatterns() { + return this.typePatterns; + } + + int treeSize() { + return + memSize() + + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + + (this.modifiers == null ? 0 : this.modifiers.listSize()) + + this.typePatterns.listSize(); + } +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java new file mode 100644 index 000000000..34c40f14e --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java @@ -0,0 +1,205 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareSoftDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has plus: + * a Type called 'type' + * a PointcutDesignator called 'pointcut' + */ +public class DeclareSoftDeclaration extends DeclareDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareSoftDeclaration.class); + + public static final ChildPropertyDescriptor TYPE_PATTERN_PROPERTY = + new ChildPropertyDescriptor(DeclareSoftDeclaration.class, "typePattern", TypePattern.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + public static final ChildPropertyDescriptor POINTCUT_PROPERTY = + new ChildPropertyDescriptor(DeclareSoftDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + + private static final List PROPERTY_DESCRIPTORS_2_0; + private static final List PROPERTY_DESCRIPTORS_3_0; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareSoftDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(POINTCUT_PROPERTY, propertyList); + addProperty(TYPE_PATTERN_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); + + propertyList = new ArrayList(3); + createPropertyList(DeclareSoftDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(POINTCUT_PROPERTY, propertyList); + addProperty(TYPE_PATTERN_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); + } + + private TypePattern typePattern; + private PointcutDesignator pointcut; + + DeclareSoftDeclaration(AST ast) { + super(ast); + } + + ASTNode clone0(AST target) { + DeclareSoftDeclaration result = new DeclareSoftDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc( + (Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPointcut((PointcutDesignator)ASTNode.copySubtree(target,getPointcut())); + result.setTypePattern((TypePattern)ASTNode.copySubtree(target,getTypePattern())); + + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor)visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor, getJavadoc()); + acceptChild(visitor,getPointcut()); + acceptChild(visitor,getTypePattern()); + } + ((AjASTVisitor)visitor).endVisit(this); + } + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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; + } + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* (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 == POINTCUT_PROPERTY) { + if (get) { + return getPointcut(); + } else { + setPointcut((PointcutDesignator) child); + return null; + } + } + if (property == TYPE_PATTERN_PROPERTY) { + if (get) { + return getTypePattern(); + } else { + setTypePattern((TypePattern) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + public TypePattern getTypePattern(){ + return typePattern; + } + + public void setTypePattern(TypePattern typePattern) { + if (typePattern == null) { + throw new IllegalArgumentException(); + } + ASTNode oldChild = this.typePattern; + preReplaceChild(oldChild, typePattern, TYPE_PATTERN_PROPERTY); + this.typePattern = typePattern; + postReplaceChild(oldChild, typePattern, TYPE_PATTERN_PROPERTY); + } + + 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); + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareWarningDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareWarningDeclaration.java new file mode 100644 index 000000000..dfaba4cb9 --- /dev/null +++ b/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/DeclareWarningDeclaration.java @@ -0,0 +1,204 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - iniital version + *******************************************************************/ +package org.aspectj.org.eclipse.jdt.core.dom; + +import java.util.ArrayList; +import java.util.List; + +/** + * DeclareWarningDeclaration DOM AST node. + * + * Has everything a DeclareDeclaration has plus: + * a PointcutDesignator called 'pointcut' + * a StringLiteral called 'message' + */ +public class DeclareWarningDeclaration extends DeclareDeclaration { + + public static final ChildPropertyDescriptor JAVADOC_PROPERTY = + internalJavadocPropertyFactory(DeclareWarningDeclaration.class); + + public static final ChildPropertyDescriptor POINTCUT_PROPERTY = + new ChildPropertyDescriptor(DeclareWarningDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + public static final ChildPropertyDescriptor MESSAGE_PROPERTY = + new ChildPropertyDescriptor(DeclareWarningDeclaration.class, "message", StringLiteral.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + + + private static final List PROPERTY_DESCRIPTORS_2_0; + private static final List PROPERTY_DESCRIPTORS_3_0; + + static { + List propertyList = new ArrayList(3); + createPropertyList(DeclareWarningDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(POINTCUT_PROPERTY, propertyList); + addProperty(MESSAGE_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); + + propertyList = new ArrayList(3); + createPropertyList(DeclareWarningDeclaration.class, propertyList); + addProperty(JAVADOC_PROPERTY, propertyList); + addProperty(POINTCUT_PROPERTY, propertyList); + addProperty(MESSAGE_PROPERTY, propertyList); + PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); + } + + private PointcutDesignator pointcut; + private StringLiteral message; + + DeclareWarningDeclaration(AST ast) { + super(ast); + } + + ASTNode clone0(AST target) { + DeclareWarningDeclaration result = new DeclareWarningDeclaration(target); + result.setSourceRange(this.getStartPosition(), this.getLength()); + result.setJavadoc( + (Javadoc) ASTNode.copySubtree(target, getJavadoc())); + result.setPointcut((PointcutDesignator)ASTNode.copySubtree(target,getPointcut())); + result.setMessage((StringLiteral)ASTNode.copySubtree(target,getMessage())); + 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) { + if (visitor instanceof AjASTVisitor) { + boolean visitChildren = ((AjASTVisitor)visitor).visit(this); + if (visitChildren) { + // visit children in normal left to right reading order + acceptChild(visitor,getJavadoc()); + acceptChild(visitor,getPointcut()); + acceptChild(visitor,getMessage()); + } + ((AjASTVisitor)visitor).endVisit(this); + } + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + SimplePropertyDescriptor internalModifiersProperty() { + return internalModifiersPropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + * + * There are no modifiers declared for DeclareErrorDeclaration - + * therefore we don't do anything with this + */ + ChildListPropertyDescriptor internalModifiers2Property() { + return internalModifiers2PropertyFactory(DeclareErrorDeclaration.class); + } + + /* (omit javadoc for this method) + * Method declared on BodyDeclaration. + */ + ChildPropertyDescriptor internalJavadocProperty() { + return JAVADOC_PROPERTY; + } + + /** + * 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; + } + } + + /* (omit javadoc for this method) + * Method declared on ASTNode. + */ + final List internalStructuralPropertiesForType(int apiLevel) { + return propertyDescriptors(apiLevel); + } + + /* (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 == POINTCUT_PROPERTY) { + if (get) { + return getPointcut(); + } else { + setPointcut((PointcutDesignator) child); + return null; + } + } + if (property == MESSAGE_PROPERTY) { + if (get) { + return getMessage(); + } else { + setMessage((StringLiteral) child); + return null; + } + } + // allow default implementation to flag the error + return super.internalGetSetChildProperty(property, get, child); + } + + 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); + } + + public StringLiteral getMessage(){ + return message; + } + + public void setMessage(StringLiteral message) { + if (message == null) { + throw new IllegalArgumentException(); + } + ASTNode oldChild = this.message; + preReplaceChild(oldChild, message, MESSAGE_PROPERTY); + this.message = message; + postReplaceChild(oldChild, message, MESSAGE_PROPERTY); + } + +} 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 index a81661272..b0567f9a2 100644 --- 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 @@ -33,6 +33,9 @@ public class DefaultPointcut extends PointcutDesignator { this.detail = d; } public String getDetail() { return detail;} + public void setDetail(String d) { + this.detail = d; + } public static List propertyDescriptors(int apiLevel) { List propertyList = new ArrayList(0); createPropertyList(DefaultPointcut.class, propertyList);