aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authormkersten <mkersten>2004-04-07 04:11:47 +0000
committermkersten <mkersten>2004-04-07 04:11:47 +0000
commit865310a81d644d7ec6ead8f662af1dc4e79b8f07 (patch)
treeb1fd450c6ea2d011b9ab25c742cf58576a9e075c /org.aspectj.ajdt.core
parent0838dbbc6b02c59485da9cda1dccc27423aab799 (diff)
downloadaspectj-865310a81d644d7ec6ead8f662af1dc4e79b8f07.tar.gz
aspectj-865310a81d644d7ec6ead8f662af1dc4e79b8f07.zip
I added -XjavadocsInModel to make the addition of Javadoc strings to the ASM only happen when request it (prevent bloat of the model with strings.
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java9
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java71
4 files changed, 78 insertions, 7 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
index 969d994fe..82fdb0b47 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
@@ -439,6 +439,9 @@ public class BuildArgParser extends Main {
} else if (arg.equals("-emacssym")) {
buildConfig.setEmacsSymMode(true);
buildConfig.setGenerateModelMode(true);
+ } else if (arg.equals("-XjavadocsInModel")) {
+ buildConfig.setGenerateModelMode(true);
+ buildConfig.setGenerateJavadocsInModelMode(true);
} else if (arg.equals("-noweave") || arg.equals( "-XnoWeave")) {
buildConfig.setNoWeave(true);
} else if (arg.equals("-XserializableAspects")) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index e75cee9b3..848b4db6d 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -305,7 +305,7 @@ public class EclipseFactory {
public void finishedCompilationUnit(CompilationUnitDeclaration unit) {
if (buildManager.doGenerateModel()) {
- AsmHierarchyBuilder.build(unit, buildManager.getStructureModel());
+ AsmHierarchyBuilder.build(unit, buildManager.getStructureModel(), buildManager.buildConfig);
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
index 27812ead7..ca3ca7b01 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
@@ -54,6 +54,7 @@ public class AjBuildConfig { // XXX needs bootclasspath?
private Map ajOptions = new HashMap();
private File configFile;
private boolean generateModelMode = false;
+ private boolean generateJavadocsInModelMode = false;
private boolean emacsSymMode = false;
private boolean noWeave = false;
private boolean XserializableAspects = false;
@@ -533,4 +534,12 @@ public class AjBuildConfig { // XXX needs bootclasspath?
return XreweavableCompressClasses;
}
+ public boolean isGenerateJavadocsInModelMode() {
+ return generateJavadocsInModelMode;
+ }
+
+ public void setGenerateJavadocsInModelMode(
+ boolean generateJavadocsInModelMode) {
+ this.generateJavadocsInModelMode = generateJavadocsInModelMode;
+ }
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index 8434d1e82..a04930a3f 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -19,7 +19,6 @@ import java.util.*;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.asm.*;
-//import org.aspectj.asm.internal.*;
import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.util.LangUtil;
@@ -36,19 +35,21 @@ public class AsmHierarchyBuilder extends ASTVisitor {
public static void build(
CompilationUnitDeclaration unit,
- IHierarchy structureModel) {
+ IHierarchy structureModel, AjBuildConfig buildConfig) {
LangUtil.throwIaxIfNull(unit, "unit");
- new AsmHierarchyBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
+ new AsmHierarchyBuilder(unit.compilationResult(), buildConfig).internalBuild(unit, structureModel);
}
private final Stack stack;
private final CompilationResult currCompilationResult;
private AsmElementFormatter formatter = new AsmElementFormatter();
+ private AjBuildConfig buildConfig;
- protected AsmHierarchyBuilder(CompilationResult result) {
+ protected AsmHierarchyBuilder(CompilationResult result, AjBuildConfig buildConfig) {
LangUtil.throwIaxIfNull(result, "result");
currCompilationResult = result;
stack = new Stack();
+ this.buildConfig = buildConfig;
}
/**
@@ -187,6 +188,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
"",
new ArrayList());
peNode.setSourceSignature(genSourceSignature(typeDeclaration));
+ peNode.setFormalComment(generateJavadocComment(typeDeclaration));
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
@@ -213,6 +215,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
"",
new ArrayList());
peNode.setSourceSignature(genSourceSignature(memberTypeDeclaration));
+ peNode.setFormalComment(generateJavadocComment(memberTypeDeclaration));
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
@@ -245,6 +248,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
"",
new ArrayList());
peNode.setSourceSignature(genSourceSignature(memberTypeDeclaration));
+ peNode.setFormalComment(generateJavadocComment(memberTypeDeclaration));
//??? we add this to the compilation unit
findEnclosingClass(stack).addChild(peNode);
@@ -277,7 +281,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
"",
IProgramElement.Kind.ERROR,
makeLocation(methodDeclaration),
- methodDeclaration.modifiers,
+ methodDeclaration.modifiers,
"",
new ArrayList());
@@ -286,6 +290,7 @@ public class AsmHierarchyBuilder extends ASTVisitor {
peNode.setModifiers(methodDeclaration.modifiers);
peNode.setCorrespondingType(methodDeclaration.returnType.toString());
peNode.setSourceSignature(genSourceSignature(methodDeclaration));
+ peNode.setFormalComment(generateJavadocComment(methodDeclaration));
// TODO: add return type test
if (peNode.getKind().equals(IProgramElement.Kind.METHOD)) {
@@ -386,18 +391,72 @@ public class AsmHierarchyBuilder extends ASTVisitor {
new ArrayList());
peNode.setCorrespondingType(fieldDeclaration.type.toString());
peNode.setSourceSignature(genSourceSignature(fieldDeclaration));
+ peNode.setFormalComment(generateJavadocComment(fieldDeclaration));
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
+
public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
stack.pop();
}
+
+ /**
+ * Checks if comments should be added to the model before generating.
+ */
+ private String generateJavadocComment(ASTNode astNode) {
+ if (buildConfig != null && !buildConfig.isGenerateJavadocsInModelMode()) return null;
+
+ StringBuffer sb = new StringBuffer(); // !!! specify length?
+ boolean completed = false;
+ int startIndex = -1;
+ if (astNode instanceof MethodDeclaration) {
+ startIndex = ((MethodDeclaration)astNode).declarationSourceStart;
+ } else if (astNode instanceof FieldDeclaration) {
+ startIndex = ((FieldDeclaration)astNode).declarationSourceStart;
+ } else if (astNode instanceof TypeDeclaration) {
+ startIndex = ((TypeDeclaration)astNode).declarationSourceStart;
+ }
+
+ if (startIndex == -1) {
+ return null;
+ } else if (currCompilationResult.compilationUnit.getContents()[startIndex] == '/' // look for /**
+ && currCompilationResult.compilationUnit.getContents()[startIndex+1] == '*'
+ && currCompilationResult.compilationUnit.getContents()[startIndex+2] == '*') {
+
+ for (int i = startIndex; i < astNode.sourceStart && !completed; i++) {
+ char curr = currCompilationResult.compilationUnit.getContents()[i];
+ if (curr == '/' && sb.length() > 2 && sb.charAt(sb.length()-1) == '*') completed = true; // found */
+ sb.append(currCompilationResult.compilationUnit.getContents()[i]);
+ }
+// System.err.println(">> " + sb.toString());
+ return sb.toString();
+ } else {
+ return null;
+ }
+
+ }
+ /**
+ * Doesn't print qualified allocation expressions.
+ */
private String genSourceSignature(FieldDeclaration fieldDeclaration) {
StringBuffer output = new StringBuffer();
- fieldDeclaration.print(0, output);
+ fieldDeclaration.printModifiers(fieldDeclaration.modifiers, output);
+ fieldDeclaration.type.print(0, output).append(' ').append(fieldDeclaration.name);
+
+ if (fieldDeclaration.initialization != null
+ && !(fieldDeclaration.initialization instanceof QualifiedAllocationExpression)) {
+ output.append(" = "); //$NON-NLS-1$
+ if (fieldDeclaration.initialization instanceof ExtendedStringLiteral) {
+ output.append("\"<extended string literal>\"");
+ } else {
+ fieldDeclaration.initialization.printExpression(0, output);
+ }
+ }
+
+ output.append(';');
return output.toString();
}