summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-08-19 12:29:04 +0000
committeracolyer <acolyer>2004-08-19 12:29:04 +0000
commit65c67a4e848311efb7402f5d06bd1a833720b94b (patch)
treefdb6a106aa7059922e42adb079516a04c4093514 /org.aspectj.ajdt.core
parent2834a7c26b42b8d98af57ef9733ae94fa4aa4a5b (diff)
downloadaspectj-65c67a4e848311efb7402f5d06bd1a833720b94b.tar.gz
aspectj-65c67a4e848311efb7402f5d06bd1a833720b94b.zip
fix for Bugzilla Bug 37020
wrong line for method execution join point
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java4
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java58
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java58
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java4
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java19
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jarbin1235 -> 1275 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/child.jarbin677 -> 719 bytes
-rw-r--r--org.aspectj.ajdt.core/testdata/OutjarTest/parent.jarbin589 -> 628 bytes
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java2
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java2
13 files changed, 143 insertions, 12 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
index 9d10f6381..31a10f412 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
@@ -29,7 +29,6 @@ import org.aspectj.weaver.TypeX;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -47,7 +46,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
*
* @author Jim Hugunin
*/
-public class AdviceDeclaration extends MethodDeclaration {
+public class AdviceDeclaration extends AjMethodDeclaration {
public PointcutDesignator pointcutDesignator;
int baseArgumentCount;
@@ -76,6 +75,7 @@ public class AdviceDeclaration extends MethodDeclaration {
protected int generateInfoAttributes(ClassFile classFile) {
List l = new ArrayList(1);
l.add(new EclipseAttributeAdapter(makeAttribute()));
+ addDeclarationStartLineAttribute(l,classFile);
return classFile.generateMethodInfoAttribute(binding, l);
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
new file mode 100644
index 000000000..30b8040d0
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation
+ *******************************************************************************/
+package org.aspectj.ajdt.internal.compiler.ast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.weaver.AjAttribute;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
+
+/**
+ * Root class for all ConstructorDeclaration objects created by the parser.
+ * Enables us to generate extra attributes in the method_info attribute
+ * to support aspectj.
+ */
+public class AjConstructorDeclaration extends ConstructorDeclaration {
+
+ /**
+ * @param compilationResult
+ */
+ public AjConstructorDeclaration(CompilationResult compilationResult) {
+ super(compilationResult);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#generateInfoAttributes(org.eclipse.jdt.internal.compiler.ClassFile)
+ */
+ protected int generateInfoAttributes(ClassFile classFile) {
+ // add extra attributes into list then call 2-arg version of generateInfoAttributes...
+ List extras = new ArrayList();
+ addDeclarationStartLineAttribute(extras,classFile);
+ return classFile.generateMethodInfoAttribute(binding,extras);
+ }
+
+ protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) {
+ if (!classFile.codeStream.generateLineNumberAttributes) return;
+
+ int[] separators = compilationResult().lineSeparatorPositions;
+ int declarationStartLine = 1;
+ for (int i = 0; i < separators.length; i++) {
+ if (sourceStart < separators[i]) break;
+ declarationStartLine++;
+ }
+
+ extraAttributeList.add(
+ new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine)));
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
new file mode 100644
index 000000000..a086269ea
--- /dev/null
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation
+ *******************************************************************************/
+package org.aspectj.ajdt.internal.compiler.ast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.weaver.AjAttribute;
+import org.eclipse.jdt.internal.compiler.ClassFile;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+
+/**
+ * Root class for all MethodDeclaration objects created by the parser.
+ * Enables us to generate extra attributes in the method_info attribute
+ * to support aspectj.
+ */
+public class AjMethodDeclaration extends MethodDeclaration {
+
+ /**
+ * @param compilationResult
+ */
+ public AjMethodDeclaration(CompilationResult compilationResult) {
+ super(compilationResult);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#generateInfoAttributes(org.eclipse.jdt.internal.compiler.ClassFile)
+ */
+ protected int generateInfoAttributes(ClassFile classFile) {
+ // add extra attributes into list then call 2-arg version of generateInfoAttributes...
+ List extras = new ArrayList();
+ addDeclarationStartLineAttribute(extras,classFile);
+ return classFile.generateMethodInfoAttribute(binding,extras);
+ }
+
+ protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) {
+ if (!classFile.codeStream.generateLineNumberAttributes) return;
+
+ int[] separators = compilationResult().lineSeparatorPositions;
+ int declarationStartLine = 1;
+ for (int i = 0; i < separators.length; i++) {
+ if (sourceStart < separators[i]) break;
+ declarationStartLine++;
+ }
+
+ extraAttributeList.add(
+ new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine)));
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java
index b1a57c116..76bfc05a4 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java
@@ -25,7 +25,7 @@ import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.parser.Parser;
-public class DeclareDeclaration extends MethodDeclaration {
+public class DeclareDeclaration extends AjMethodDeclaration {
public Declare declareDecl;
/**
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
index 5103a8a78..e69767ff5 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
@@ -21,11 +21,10 @@ import org.aspectj.weaver.patterns.IfPointcut;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
//import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.parser.Parser;
-public class IfMethodDeclaration extends MethodDeclaration {
+public class IfMethodDeclaration extends AjMethodDeclaration {
IfPointcut ifPointcut;
public IfMethodDeclaration(CompilationResult compilationResult, IfPointcut ifPointcut) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
index 6efe2dd75..26007511b 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
@@ -24,7 +24,6 @@ import org.aspectj.ajdt.internal.core.builder.EclipseSourceContext;
import org.aspectj.weaver.*;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.core.compiler.CharOperation;
@@ -34,7 +33,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
*
* @author Jim Hugunin
*/
-public abstract class InterTypeDeclaration extends MethodDeclaration {
+public abstract class InterTypeDeclaration extends AjMethodDeclaration {
public TypeReference onType;
protected ReferenceBinding onTypeBinding;
@@ -134,6 +133,7 @@ public abstract class InterTypeDeclaration extends MethodDeclaration {
} else {
l = new ArrayList(0);
}
+ addDeclarationStartLineAttribute(l,classFile);
return classFile.generateMethodInfoAttribute(binding, l);
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
index b0595257e..e1c6673b7 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
@@ -26,7 +26,6 @@ import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
@@ -41,7 +40,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
*
* @author Jim Hugunin
*/
-public class PointcutDeclaration extends MethodDeclaration {
+public class PointcutDeclaration extends AjMethodDeclaration {
public static final char[] mangledPrefix = "ajc$pointcut$".toCharArray();
public PointcutDesignator pointcutDesignator;
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
index 4c79c9a5a..9879e5a55 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java
@@ -13,6 +13,8 @@
package org.aspectj.ajdt.internal.compiler.parser;
import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.AjConstructorDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.AjMethodDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.IfPseudoToken;
@@ -31,6 +33,7 @@ import org.aspectj.weaver.patterns.Declare;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
@@ -46,7 +49,21 @@ import org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory;
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
*/
public class DeclarationFactory implements IDeclarationFactory {
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory#createMethodDeclaration(org.eclipse.jdt.internal.compiler.CompilationResult)
+ */
+ public MethodDeclaration createMethodDeclaration(CompilationResult result) {
+ return new AjMethodDeclaration(result);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory#createConstructorDeclaration(org.eclipse.jdt.internal.compiler.CompilationResult)
+ */
+ public ConstructorDeclaration createConstructorDeclaration(CompilationResult result) {
+ return new AjConstructorDeclaration(result);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.compiler.parser.Parser.IDeclarationFactory#createProceed(org.eclipse.jdt.internal.compiler.ast.MessageSend)
*/
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
index 37151cc0f..d8aba690e 100644
--- a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
index df45a1dd6..7f06e1b09 100644
--- a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
index eba9b328a..66a5e9ee9 100644
--- a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
+++ b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
index cd0ec9ddd..a1a0e4c83 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BasicCommandTestCase.java
@@ -72,7 +72,7 @@ public class BasicCommandTestCase extends CommandTestCase {
checkCompile("src1/ThisAndModifiers.java", NO_ERRORS);
}
public void testDeclares() {
- checkCompile("src1/Declares.java", new int[] {3});
+ checkCompile("src1/Declares.java", new int[] {2});
}
public void testDeclareWarning() {
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java
index 527fe9304..433478de8 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java
@@ -36,7 +36,7 @@ public class PerformanceTestCase extends CommandTestCase {
}
public void testLazyTjp() throws IOException {
- checkCompile("src1/LazyTjp.aj", new String[] {"-XlazyTjp","-Xlint:error"}, new int[] {97});
+ checkCompile("src1/LazyTjp.aj", new String[] {"-XlazyTjp","-Xlint:error"}, new int[] {96});
TestUtil.runMain("out", "LazyTjp");
}
}