Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 34184 Details for
Bug 110465
Continue AST work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch proposed in comment #28 plus more tests
pr110465-comment28.txt (text/plain), 19.89 KB, created by
Helen Beeken
on 2006-02-06 06:23:02 EST
(
hide
)
Description:
patch proposed in comment #28 plus more tests
Filename:
MIME Type:
Creator:
Helen Beeken
Created:
2006-02-06 06:23:02 EST
Size:
19.89 KB
patch
obsolete
>Index: src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java,v >retrieving revision 1.7 >diff -u -r1.7 AjASTConverter.java >--- src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java 27 Jan 2006 15:51:14 -0000 1.7 >+++ src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java 6 Feb 2006 11:15:07 -0000 >@@ -525,6 +525,14 @@ > } else { > pointcutDecl.setDesignator(new org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut(this.ast,pointcutDeclaration.toString())); > } >+ org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = pointcutDeclaration.arguments; >+ if (parameters != null) { >+ int parametersLength = parameters.length; >+ for (int i = 0; i < parametersLength; i++) { >+ pointcutDecl.parameters().add(convert(parameters[i])); >+ } >+ } >+ > // The javadoc comment is now got from list store in compilation unit declaration > if (this.resolveBindings) { > recordNodes(pointcutDecl, pointcutDeclaration); >Index: src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java,v >retrieving revision 1.2 >diff -u -r1.2 AjNaiveASTFlattener.java >--- src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java 23 Sep 2005 15:53:15 -0000 1.2 >+++ src/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java 6 Feb 2006 11:15:08 -0000 >@@ -514,7 +514,15 @@ > printIndent(); > buffer.append(" pointcut "); > node.getName().accept(this); >- buffer.append("():"); >+ buffer.append("("); >+ List parameters = node.parameters(); >+ for (Iterator iter = parameters.iterator(); iter.hasNext();) { >+ SingleVariableDeclaration element = (SingleVariableDeclaration) iter.next(); >+ buffer.append(element.getType().toString()+" "+element.getName()); >+ if (iter.hasNext()) >+ buffer.append(", "); >+ } >+ buffer.append("):"); > buffer.append(((DefaultPointcut)node.getDesignator()).getDetail()); > buffer.append(";\n"); > return false; >Index: src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java,v >retrieving revision 1.2 >diff -u -r1.2 PointcutDeclaration.java >--- src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java 11 Nov 2005 08:16:23 -0000 1.2 >+++ src/org/aspectj/org/eclipse/jdt/core/dom/PointcutDeclaration.java 6 Feb 2006 11:15:08 -0000 >@@ -19,6 +19,7 @@ > * has: > * a name > * an optional pointcut designator called 'designator' >+ * a SingleVariableDeclaration list called 'parameters' > * javadoc > * modifiers > * >@@ -36,6 +37,12 @@ > private PointcutDesignator pointcutDesignator = null; > public static final ChildPropertyDescriptor DESIGNATOR_PROPERTY = > new ChildPropertyDescriptor(PointcutDeclaration.class, "designator", PointcutDesignator.class, OPTIONAL, NO_CYCLE_RISK); //$NON-NLS-1$ >+ >+ /** >+ * The "parameters" structural property of this node type. >+ */ >+ public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY = >+ new ChildListPropertyDescriptor(PointcutDeclaration.class, "parameters", SingleVariableDeclaration.class, CYCLE_RISK); //$NON-NLS-1$ > > public PointcutDesignator getDesignator() { > return this.pointcutDesignator; >@@ -110,20 +117,24 @@ > private static final List PROPERTY_DESCRIPTORS_3_0; > > static { >- List propertyList = new ArrayList(5); >+ List propertyList = new ArrayList(6); > createPropertyList(PointcutDeclaration.class, propertyList); > addProperty(JAVADOC_PROPERTY, propertyList); > addProperty(MODIFIERS_PROPERTY, propertyList); > addProperty(NAME_PROPERTY, propertyList); > addProperty(DESIGNATOR_PROPERTY, propertyList); >+ addProperty(PARAMETERS_PROPERTY, propertyList); >+ > PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); > >- propertyList = new ArrayList(5); >+ propertyList = new ArrayList(6); > createPropertyList(PointcutDeclaration.class, propertyList); > addProperty(JAVADOC_PROPERTY, propertyList); > addProperty(MODIFIERS2_PROPERTY, propertyList); > addProperty(NAME_PROPERTY, propertyList); > addProperty(DESIGNATOR_PROPERTY, propertyList); >+ addProperty(PARAMETERS_PROPERTY, propertyList); >+ > PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); > } > >@@ -161,6 +172,8 @@ > super(ast); > } > >+ protected ASTNode.NodeList parameters = >+ new ASTNode.NodeList(PARAMETERS_PROPERTY); > > /* (omit javadoc for this method) > * Method declared on ASTNode. >@@ -225,6 +238,9 @@ > if (property == MODIFIERS2_PROPERTY) { > return modifiers(); > } >+ if (property == PARAMETERS_PROPERTY) { >+ return parameters(); >+ } > // allow default implementation to flag the error > return super.internalGetChildListProperty(property); > } >@@ -272,7 +288,11 @@ > result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); > } > result.setName((SimpleName) getName().clone(target)); >- result.setDesignator((PointcutDesignator) getDesignator().clone(target)); >+ if (getDesignator() != null) { >+ result.setDesignator((PointcutDesignator) getDesignator().clone(target)); >+ } >+ result.parameters().addAll( >+ ASTNode.copySubtrees(target, parameters())); > return result; > } > >@@ -299,16 +319,28 @@ > } > acceptChild(ajvis, getName()); > acceptChild(ajvis, getDesignator()); >+ acceptChildren(visitor, this.parameters); > } > ajvis.endVisit(this); > } > } > >+ /** >+ * 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; >+ } >+ > /* (omit javadoc for this method) > * Method declared on ASTNode. > */ > int memSize() { >- return super.memSize() + 2 * 4; >+ return super.memSize() + 3 * 4; > } > > /* (omit javadoc for this method) >@@ -320,6 +352,7 @@ > + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) > + (this.pointcutName == null ? 0 : getName().treeSize()) > + (this.modifiers == null ? 0 : this.modifiers.listSize()) >+ + this.parameters.listSize() > + (this.pointcutDesignator == null ? 0 : getDesignator().treeSize()); > } > } >Index: testsrc/org/aspectj/tools/ajc/ASTVisitorTest.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/ASTVisitorTest.java,v >retrieving revision 1.7 >diff -u -r1.7 ASTVisitorTest.java >--- testsrc/org/aspectj/tools/ajc/ASTVisitorTest.java 27 Jan 2006 15:51:15 -0000 1.7 >+++ testsrc/org/aspectj/tools/ajc/ASTVisitorTest.java 6 Feb 2006 11:15:09 -0000 >@@ -180,6 +180,38 @@ > "(compilationUnit(aspect(simpleName)(pointcut(simpleName))))"); > } > >+ public void testPointcutWithoutArguments(){ >+ check("aspect A {pointcut a(): adviceexecution();}", >+ "(compilationUnit(aspect(simpleName)(pointcut(simpleName))))"); >+ } >+ >+ public void testPointcutWithOnePrimitiveArgument(){ >+ check("aspect A {pointcut a(int a): adviceexecution();}", >+ "(compilationUnit(aspect(simpleName)(pointcut(simpleName)(primitiveType)(simpleName))))"); >+ } >+ >+ public void testPointcutWithTwoPrimitiveArguments(){ >+ check("aspect A {pointcut a(int a, double b): adviceexecution();}", >+ "(compilationUnit(aspect(simpleName)(pointcut" + >+ "(simpleName)(primitiveType)(simpleName)(primitiveType)" + >+ "(simpleName))))"); >+ } >+ >+ public void testPointcutWithOneTypedArgument(){ >+ check("aspect A {pointcut a(A a): adviceexecution();}", >+ "(compilationUnit(aspect(simpleName)(pointcut" + >+ "(simpleName)(simpleName)" + >+ "(simpleName))))"); >+ } >+ >+ public void testPointcutWithTwoTypedArgument(){ >+ check("aspect A {pointcut a(A a, B b): adviceexecution();}", >+ "(compilationUnit(aspect(simpleName)(pointcut" + >+ "(simpleName)(simpleName)" + >+ "(simpleName)(simpleName)" + >+ "(simpleName))))"); >+ } >+ > public void testFieldITD(){ > check("class A {}aspect B {int A.a;}", > "(compilationUnit(class(simpleName))(aspect(simpleName)(fieldITD(primitiveType)(simpleName))))"); >Index: testsrc/org/aspectj/tools/ajc/AjASTTest.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjASTTest.java,v >retrieving revision 1.3 >diff -u -r1.3 AjASTTest.java >--- testsrc/org/aspectj/tools/ajc/AjASTTest.java 31 Jan 2006 12:53:11 -0000 1.3 >+++ testsrc/org/aspectj/tools/ajc/AjASTTest.java 6 Feb 2006 11:15:11 -0000 >@@ -45,6 +45,7 @@ > import org.aspectj.org.eclipse.jdt.core.dom.DeclareWarningDeclaration; > import org.aspectj.org.eclipse.jdt.core.dom.DefaultPointcut; > import org.aspectj.org.eclipse.jdt.core.dom.DefaultTypePattern; >+import org.aspectj.org.eclipse.jdt.core.dom.IExtendedModifier; > import org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration; > import org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration; > import org.aspectj.org.eclipse.jdt.core.dom.NotPointcut; >@@ -393,6 +394,131 @@ > "the ReferencePointcut",rp,pd.getDesignator()); > } > >+ public void testGetAndSetPointcutArguments(){ >+ AjAST ajast = createAjAST(); >+ PointcutDeclaration pd = ajast.newPointcutDeclaration(); >+ assertEquals("by default the number of arguments is zero",pd.parameters().size(), 0); >+ List l = pd.parameters(); >+ assertEquals("there shouldn't be any arguments associated with" + >+ "the pointcut yet",0,l.size()); >+ SingleVariableDeclaration p1 = ajast.newSingleVariableDeclaration(); >+ l.add(p1); >+ assertEquals("there should be one parameter associated with" + >+ "the pointcut",1,pd.parameters().size()); >+ assertEquals("there should be a SingleVariableDeclaration associated with" + >+ "the pointcut",p1,pd.parameters().get(0)); >+ } >+ >+ public void testPropertyDescriptorsForPointcutDeclaration() { >+ AjAST ajast = createAjAST(); >+ PointcutDeclaration d = ajast.newPointcutDeclaration(); >+ List props = PointcutDeclaration.propertyDescriptors(AST.JLS3); >+ boolean foundJavadoc = false; >+ boolean foundModifiers = false; >+ boolean foundName = false; >+ boolean foundParamList = false; >+ boolean foundDesignator = false; >+ for (Iterator iter = props.iterator(); iter.hasNext();) { >+ Object o = iter.next(); >+ if ((o instanceof ChildPropertyDescriptor)) { >+ ChildPropertyDescriptor element = (ChildPropertyDescriptor)o; >+ String id = element.getId(); >+ if (id.equals("javadoc")) { >+ foundJavadoc = true; >+ } else if (id.equals("designator")) { >+ foundDesignator = true; >+ } else if (id.equals("name")) { >+ foundName = true; >+ } else { >+ fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + element.getId()); >+ } >+ } else if (o instanceof ChildListPropertyDescriptor) { >+ ChildListPropertyDescriptor element = (ChildListPropertyDescriptor)o; >+ if (element.getId().equals("parameters")) { >+ foundParamList= true; >+ } else if (element.getId().equals("modifiers")) { >+ foundModifiers = true; >+ } >+ } else { >+ fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + o); >+ } >+ } >+ assertTrue("PointcutDeclaration should have a javadoc PropertyDescriptor",foundJavadoc); >+ assertTrue("PointcutDeclaration should have a designator PropertyDescriptor",foundDesignator); >+ assertTrue("PointcutDeclaration should have an name PropertyDescriptor",foundName); >+ assertTrue("PointcutDeclaration should have a parameters PropertyDescriptor",foundParamList); >+ assertTrue("PointcutDeclaration should have a modifiers PropertyDescriptor",foundModifiers); >+ } >+ >+ public void testClonePointcutDeclaration() { >+ AjAST ajast = createAjAST(); >+ PointcutDeclaration d = ajast.newPointcutDeclaration(); >+ d.setName(ajast.newSimpleName("pointcut_name")); >+ d.parameters().add(ajast.newSingleVariableDeclaration()); >+ PointcutDeclaration copy = (PointcutDeclaration)ASTNode.copySubtree(ajast,d); >+ assertEquals("there should be one parameter associated with" + >+ "the pointcut copy",1,copy.parameters().size()); >+ assertEquals("the PointcutDeclaration clone should have the name ", "pointcut_name", >+ copy.getName().toString()); >+ } >+ >+ public void testInternalPointcutDeclaration() { >+ AjAST ajast = createAjAST(); >+ PointcutDeclaration d = ajast.newPointcutDeclaration(); >+ List props = PointcutDeclaration.propertyDescriptors(AST.JLS3); >+ for (Iterator iter = props.iterator(); iter.hasNext();) { >+ Object o = iter.next(); >+ if (o instanceof ChildPropertyDescriptor) { >+ ChildPropertyDescriptor element = (ChildPropertyDescriptor)o; >+ if (element.getId().equals("name")) { >+ assertNotNull("PointcutDeclaration's " + element.getId() + " property" + >+ " should not be null since it is lazily created", >+ d.getStructuralProperty(element)); >+ } else { >+ assertNull("PointcutDeclaration's " + element.getId() + " property" + >+ " should be null since we haven't set it yet", >+ d.getStructuralProperty(element)); >+ } >+ } else if (o instanceof ChildListPropertyDescriptor) { >+ ChildListPropertyDescriptor element = (ChildListPropertyDescriptor)o; >+ assertNotNull("PointcutDeclaration's " + element.getId() + " property" + >+ "should not be null since it is a list", >+ d.getStructuralProperty(element)); >+ boolean isIExtendedModifier = element.getElementType().equals(IExtendedModifier.class); >+ boolean isSingleVariable = element.getElementType().equals(SingleVariableDeclaration.class); >+ assertTrue("should only be able to put SingleVariableDeclaration's" + >+ " (which itself has node type IExtendedModifier) into the list", >+ isIExtendedModifier || isSingleVariable); >+ } else if (o instanceof SimplePropertyDescriptor) { >+ SimplePropertyDescriptor element = (SimplePropertyDescriptor)o; >+ assertNotNull("PointcutDeclaration's " + element.getId() + " property" + >+ "should not be null since it is a boolean", >+ d.getStructuralProperty(element)); >+ } else { >+ fail("unknown PropertyDescriptor associated with PointcutDeclaration: " + o); >+ } >+ } >+ for (Iterator iter = props.iterator(); iter.hasNext();) { >+ Object o = iter.next(); >+ if (o instanceof ChildPropertyDescriptor) { >+ ChildPropertyDescriptor element = (ChildPropertyDescriptor) o; >+ if (element.getId().equals("designator")) { >+ ReferencePointcut rp = ajast.newReferencePointcut(); >+ d.setStructuralProperty(element,rp); >+ assertEquals("PointcutDeclaration's designator property should" + >+ " now be a ReferencePointcut",rp,d.getStructuralProperty(element)); >+ } else if (element.getId().equals("javadoc")) { >+ // do nothing since makes no sense to have javadoc >+ } else if (element.getId().equals("name")) { >+ SimpleName sn = ajast.newSimpleName("p"); >+ d.setStructuralProperty(element,sn); >+ assertEquals("PointcutDeclaration's name property should" + >+ " now be a SimpleName",sn,d.getStructuralProperty(element)); >+ } >+ } >+ } >+ } >+ > // -------------- AspectDeclaration tests --------------- > > public void testNewAspectDeclaration() { >Index: testsrc/org/aspectj/tools/ajc/AjcTests.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTests.java,v >retrieving revision 1.5 >diff -u -r1.5 AjcTests.java >--- testsrc/org/aspectj/tools/ajc/AjcTests.java 26 Jan 2006 10:57:25 -0000 1.5 >+++ testsrc/org/aspectj/tools/ajc/AjcTests.java 6 Feb 2006 11:15:11 -0000 >@@ -29,6 +29,7 @@ > suite.addTestSuite(ASTVisitorTest.class); > suite.addTestSuite(ASTitdTest.class); > suite.addTestSuite(AjASTTest.class); >+ suite.addTestSuite(AjNaiveASTFlattenerTest.class); > return suite; > } > >Index: testsrc/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java >=================================================================== >RCS file: testsrc/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java >diff -N testsrc/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ testsrc/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/******************************************************************** >+ * 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 >+ * Eduardo Piveta - initial version >+ * Helen Hawkins - ammended to fit within JUnit framework >+ *******************************************************************/ >+package org.aspectj.tools.ajc; >+ >+import java.util.HashMap; >+ >+import junit.framework.TestCase; >+ >+import org.aspectj.org.eclipse.jdt.core.dom.AST; >+import org.aspectj.org.eclipse.jdt.core.dom.ASTParser; >+import org.aspectj.org.eclipse.jdt.core.dom.AjNaiveASTFlattener; >+import org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit; >+ >+public class AjNaiveASTFlattenerTest extends TestCase { >+ >+ public void testNoPointcutArgs() { >+ check("public aspect A { pointcut y(): call(* *.*(..));}", >+ "public aspect A {\n pointcut y():call(* *.*(..));\n}\n"); >+ } >+ >+ public void testOneIntPointcutArg() { >+ check("public aspect A { pointcut y(int a): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(int a):call(* *.*(..));\n}\n"); >+ } >+ >+ public void testOneIntOneDoublePointcutArg() { >+ check("public aspect A { pointcut y(int a, double b): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(int a, double b):call(* *.*(..));\n}\n"); >+ } >+ >+ public void testOneTypedPointcutArg() { >+ check("public aspect A { pointcut y(X a): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(X a):call(* *.*(..));\n}\n"); >+ } >+ >+ public void testTwoTypedPointcutArgs() { >+ check("public aspect A { pointcut y(X a, X b): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(X a, X b):call(* *.*(..));\n}\n"); >+ } >+ >+ public void testOneTypedAndOneIntPointcutArg() { >+ check("public aspect A { pointcut y(X a, int b): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(X a, int b):call(* *.*(..));\n}\n"); >+ } >+ >+ public void testOneIntAndOneTypedPointcutArg() { >+ check("public aspect A { pointcut y(int a, X b): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(int a, X b):call(* *.*(..));\n}\n"); >+ } >+ >+ public void testOneIntOneDoubleAndOneTypedPointcutArg() { >+ check("public aspect A { pointcut y(int a, double b, Y c): call(* *.*(..));}", >+ "public aspect A {\n pointcut y(int a, double b, Y c):call(* *.*(..));\n}\n"); >+ } >+ >+ private void check(String source, String expectedOutput) { >+ ASTParser parser = ASTParser.newParser(AST.JLS2); >+ parser.setCompilerOptions(new HashMap()); >+ parser.setSource(source.toCharArray()); >+ CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); >+ AjNaiveASTFlattener visitor = new AjNaiveASTFlattener(); >+ cu2.accept(visitor); >+ String result = visitor.getResult(); >+ System.err.println(result); >+ assertTrue("Expected:\n"+ expectedOutput + "====Actual:\n" + result, >+ expectedOutput.equals(result)); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
aclement
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 110465
:
31372
|
31373
|
31943
|
32069
|
32485
|
33584
|
33695
|
34121
| 34184 |
55758