]> source.dussan.org Git - aspectj.git/commitdiff
164356: test and fix: ajdoc
authoraclement <aclement>
Thu, 20 Mar 2008 00:12:47 +0000 (00:12 +0000)
committeraclement <aclement>
Thu, 20 Mar 2008 00:12:47 +0000 (00:12 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java

index 12a51fc9efdee03bd4596c3adf277047bf530fca..4cf4d5e8e56fc52ce078aa404ab7b2733f03e721 100644 (file)
@@ -58,6 +58,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.util.Util;
+import org.aspectj.util.CharOperation;
 import org.aspectj.util.LangUtil;
 import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.Member;
@@ -667,8 +668,9 @@ public class AsmHierarchyBuilder extends ASTVisitor {
        protected String generateJavadocComment(ASTNode astNode) {
                if (buildConfig != null && !buildConfig.isGenerateJavadocsInModelMode()) return null;
                
-               StringBuffer sb = new StringBuffer(); // !!! specify length?
-               boolean completed = false;
+
+        // StringBuffer sb = new StringBuffer(); // !!! specify length?
+        // boolean completed = false;
                int startIndex = -1;
                if (astNode instanceof MethodDeclaration) {
                        startIndex = ((MethodDeclaration)astNode).declarationSourceStart;
@@ -680,20 +682,29 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                
                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]);
-                       } 
-                       return sb.toString();
-               } else {
-                       return null;
+               } else if (currCompilationResult.compilationUnit.getContents()[startIndex] == '/') {
+            char[] comment = CharOperation.subarray(currCompilationResult.compilationUnit.getContents(), startIndex, astNode.sourceStart);
+            while (comment.length > 2) {
+                int star = CharOperation.indexOf('*', comment);
+                if (star == -1)
+                    return null;
+                // looking for '/**' and not '//' or '//*'
+                if (star != 0 && (comment[star - 1] == '/') && (comment[star + 1] == '*') && (star - 2 < 0 || comment[star - 2] != '/')) {
+                    boolean completed = false;
+                    StringBuffer sb = new StringBuffer();
+                    for (int i = 0; i < comment.length && !completed; i++) {
+                        char curr = comment[i];
+                        if (curr == '/' && sb.length() > 2 && sb.charAt(sb.length() - 1) == '*') {
+                            completed = true; // found */
+                        }
+                        sb.append(comment[i]);
+                    }
+                    return sb.toString();
+                }
+                comment = CharOperation.subarray(comment, star + 1, comment.length);
+            }
                }
-               
+               return null;
        }
        
        /**