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 32069 Details for
Bug 110465
Continue AST work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch containing fix and testcase for problem raised in comment #14
pr110465-org-aspectj-ajdt-core-20051221patch.txt (text/plain), 8.25 KB, created by
Helen Beeken
on 2005-12-21 04:05:59 EST
(
hide
)
Description:
patch containing fix and testcase for problem raised in comment #14
Filename:
MIME Type:
Creator:
Helen Beeken
Created:
2005-12-21 04:05:59 EST
Size:
8.25 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.4 >diff -u -r1.4 AjASTConverter.java >--- src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java 13 Dec 2005 08:50:36 -0000 1.4 >+++ src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java 21 Dec 2005 09:03:57 -0000 >@@ -20,6 +20,7 @@ > 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.InterTypeDeclaration; > import org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration; > import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration; > import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration; >@@ -204,7 +205,6 @@ > 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); > >@@ -225,12 +225,23 @@ > } > ///////////////////////// > >+ // set modifiers after checking whether we're an itd, otherwise >+ // the modifiers are not set on the correct object. >+ setModifiers(methodDecl, methodDeclaration); >+ >+ // for ITD's use the declaredSelector > final SimpleName methodName = new SimpleName(this.ast); >- methodName.internalSetIdentifier(new String(methodDeclaration.selector)); >+ if (methodDeclaration instanceof InterTypeDeclaration) { >+ InterTypeDeclaration itd = (InterTypeDeclaration) methodDeclaration; >+ methodName.internalSetIdentifier(new String(itd.getDeclaredSelector())); >+ } else { >+ 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; >@@ -3580,7 +3591,7 @@ > // ajh02: method added > switch(this.ast.apiLevel) { > case AST.JLS2_INTERNAL : >- fieldDeclaration.internalSetModifiers(fieldDecl.modifiers & CompilerModifiers.AccJustFlag); >+ fieldDeclaration.internalSetModifiers(fieldDecl.declaredModifiers & CompilerModifiers.AccJustFlag); > if (fieldDecl.annotations != null) { > fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); > } >@@ -3615,7 +3626,11 @@ > protected void setModifiers(MethodDeclaration methodDecl, AbstractMethodDeclaration methodDeclaration) { > switch(this.ast.apiLevel) { > case AST.JLS2_INTERNAL : >- methodDecl.internalSetModifiers(methodDeclaration.modifiers & CompilerModifiers.AccJustFlag); >+ if (methodDeclaration instanceof InterTypeDeclaration) { >+ methodDecl.internalSetModifiers(((InterTypeDeclaration)methodDeclaration).declaredModifiers & CompilerModifiers.AccJustFlag); >+ } else { >+ methodDecl.internalSetModifiers(methodDeclaration.modifiers & CompilerModifiers.AccJustFlag); >+ } > if (methodDeclaration.annotations != null) { > methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); > } >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.3 >diff -u -r1.3 AjcTests.java >--- testsrc/org/aspectj/tools/ajc/AjcTests.java 23 Sep 2005 15:50:34 -0000 1.3 >+++ testsrc/org/aspectj/tools/ajc/AjcTests.java 21 Dec 2005 09:03:57 -0000 >@@ -27,6 +27,7 @@ > TestSuite suite = new TestSuite(AjcTests.class.getName()); > suite.addTestSuite(org.aspectj.tools.ajc.MainTest.class); > suite.addTestSuite(ASTVisitorTest.class); >+ suite.addTestSuite(ASTitdTest.class); > return suite; > } > >Index: testsrc/org/aspectj/tools/ajc/ASTitdTest.java >=================================================================== >RCS file: testsrc/org/aspectj/tools/ajc/ASTitdTest.java >diff -N testsrc/org/aspectj/tools/ajc/ASTitdTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ testsrc/org/aspectj/tools/ajc/ASTitdTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************** >+ * Copyright (c) 2005 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.tools.ajc; >+ >+import java.lang.reflect.Modifier; >+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.AjASTVisitor; >+import org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit; >+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.MethodDeclaration; >+ >+public class ASTitdTest extends TestCase { >+ >+ public void testAspectWithPublicMethodITD() { >+ checkNameAndModifiers("aspect A{ public void B.x(){} }","name = x, modifier = public"); >+ } >+ >+ public void testAspectWithPrivateMethodITD() { >+ checkNameAndModifiers("aspect A{ private void B.x(){} }","name = x, modifier = private"); >+ } >+ >+ public void testAspectWithPublicAbstractMethodITD() { >+ checkNameAndModifiers("aspect A{ public abstract void B.x(){} }","name = x, modifier = public abstract"); >+ } >+ >+ public void testAspectWithConstructorITD() { >+ checkNameAndModifiers("class A {}aspect B {public A.new(){}}","name = A_new, modifier = public"); >+ } >+ >+ public void testAspectWithPublicFieldITD() { >+ checkNameAndModifiers("class A {}aspect B {public int A.a;}","name = a, modifier = public"); >+ } >+ >+ private void checkNameAndModifiers(String source, String expectedOutput){ >+ ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to use 2 for returnType - in 3 it has "returnType2" >+ parser.setCompilerOptions(new HashMap());//JavaCore.getOptions()); >+ parser.setSource(source.toCharArray()); >+ CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); >+ ITDTestVisitor visitor = new ITDTestVisitor(); >+ cu2.accept(visitor); >+ String result = visitor.toString(); >+ //System.err.println("actual:\n" + result); >+ assertTrue("Expected:\n"+ expectedOutput + "====Actual:\n" + result, >+ expectedOutput.equals(result)); >+ } >+ >+} >+ >+class ITDTestVisitor extends AjASTVisitor { >+ >+ StringBuffer b = new StringBuffer(); >+ boolean visitDocTags; >+ >+ ITDTestVisitor() { >+ this(false); >+ } >+ >+ public String toString(){ >+ return b.toString(); >+ } >+ >+ ITDTestVisitor(boolean visitDocTags) { >+ super(visitDocTags); >+ this.visitDocTags = visitDocTags; >+ } >+ >+ public boolean visit(MethodDeclaration node) { >+ if (node instanceof InterTypeMethodDeclaration) >+ return visit((InterTypeMethodDeclaration)node); >+ return true; >+ } >+ public boolean visit(InterTypeFieldDeclaration node) { >+ b.append("name = " + node.fragments().get(0) + ", modifier = " + Modifier.toString(node.getModifiers())); >+ return true; >+ } >+ public boolean visit(InterTypeMethodDeclaration node) { >+ b.append("name = " + node.getName() + ", modifier = " + Modifier.toString(node.getModifiers())); >+ return true; >+ } >+}
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