Chromium Code Reviews| Index: compiler/java/com/google/dart/compiler/parser/DartParserCommentsHelper.java |
| diff --git a/compiler/java/com/google/dart/compiler/parser/DartParserCommentsHelper.java b/compiler/java/com/google/dart/compiler/parser/DartParserCommentsHelper.java |
| index 7c2be7f77f1f084a564bb2f795e8884aa3d55b45..a6d75217fc0032a21bec5147f5381038cd6a137b 100644 |
| --- a/compiler/java/com/google/dart/compiler/parser/DartParserCommentsHelper.java |
| +++ b/compiler/java/com/google/dart/compiler/parser/DartParserCommentsHelper.java |
| @@ -11,6 +11,7 @@ import com.google.dart.compiler.ast.ASTVisitor; |
| import com.google.dart.compiler.ast.DartComment; |
| import com.google.dart.compiler.ast.DartDeclaration; |
| import com.google.dart.compiler.ast.DartField; |
| +import com.google.dart.compiler.ast.DartIdentifier; |
| import com.google.dart.compiler.ast.DartMethodDefinition; |
| import com.google.dart.compiler.ast.DartNode; |
| import com.google.dart.compiler.ast.DartUnit; |
| @@ -41,14 +42,16 @@ public class DartParserCommentsHelper { |
| } |
| @Override |
| - protected DartScanner createScanner(String sourceCode, Source source, DartCompilerListener listener) { |
| + protected DartScanner createScanner(String sourceCode, Source source, |
| + DartCompilerListener listener) { |
| commentLocs = Lists.newArrayList(); |
| return new CommentScanner(sourceCode, 0, source, listener); |
| } |
| private class CommentScanner extends DartScanner { |
| - CommentScanner(String sourceCode, int start, Source sourceReference, DartCompilerListener listener) { |
| + CommentScanner(String sourceCode, int start, Source sourceReference, |
| + DartCompilerListener listener) { |
| super(sourceCode, start, sourceReference, listener); |
| } |
| @@ -147,6 +150,7 @@ public class DartParserCommentsHelper { |
| if (decl != null) { |
| String commentStr = sourceCode.substring(comment.getSourceInfo().getOffset(), |
| comment.getSourceInfo().getEnd()); |
| + tokenizeComment(comment, commentStr); |
| // may be @Metadata |
| if (commentStr.contains("@deprecated")) { |
| decl.setObsoleteMetadata(decl.getObsoleteMetadata().makeDeprecated()); |
| @@ -163,6 +167,40 @@ public class DartParserCommentsHelper { |
| } |
| } |
| + // XXX |
| + private static void tokenizeComment(DartComment comment, String src) { |
| + int lastIndex = 0; |
| + while (true) { |
| + int openIndex = src.indexOf('[', lastIndex); |
| + if (openIndex == -1) { |
| + break; |
| + } |
| + int closeIndex = src.indexOf(']', openIndex); |
| + if (closeIndex == -1) { |
| + break; |
| + } |
| + lastIndex = closeIndex; |
| + openIndex++; |
| + String tokenSrc = src.substring(openIndex, closeIndex); |
| + if (tokenSrc.startsWith(":") && tokenSrc.endsWith(":")) { |
|
Brian Wilkerson
2012/11/05 16:07:12
You might also want to explicitly test for quote c
|
| + } else if (tokenSrc.startsWith("new ")) { |
|
Brian Wilkerson
2012/11/05 16:07:12
Perhaps add a TODO comment here, unless you're pla
|
| + } else { |
| + DartScanner scanner = new DartScanner(tokenSrc); |
| + if (scanner.next() == Token.IDENTIFIER) { |
| + String name = new String(scanner.getTokenValue()); |
| + DartIdentifier id = new DartIdentifier(name); |
| + { |
| + SourceInfo sourceInfo = comment.getSourceInfo(); |
| + int offset = sourceInfo.getOffset() + openIndex; |
| + int length = name.length(); |
| + id.setSourceInfo(new SourceInfo(sourceInfo.getSource(), offset, length)); |
| + } |
| + comment.addTokenIdentifier(id); |
| + } |
| + } |
| + } |
| + } |
| + |
| private static DartDeclaration<?> adjustDartdocTarget(DartNode currentNode, DartNode nextNode) { |
| if (currentNode instanceof DartField && nextNode instanceof DartMethodDefinition) { |
| if (currentNode.getSourceInfo().equals(nextNode.getSourceInfo())) { |