Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 10661022: Issue 3752. Support for @override annotations (as structured doc comments) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index 47acd159c327788f1529c04ef9af83d6e8408cc0..bfb9291f38ff6fd6422b914dcf1b7291a1afd818 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -93,6 +93,7 @@ import com.google.dart.compiler.ast.DartWhileStatement;
import com.google.dart.compiler.ast.LibraryNode;
import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.ast.Modifiers;
+import com.google.dart.compiler.metrics.CompilerMetrics;
import com.google.dart.compiler.parser.DartScanner.Location;
import com.google.dart.compiler.parser.DartScanner.Position;
import com.google.dart.compiler.util.Lists;
@@ -112,6 +113,8 @@ import java.util.Set;
*/
public class DartParser extends CompletionHooksParserBase {
+ private final Source source;
+ private final String sourceCode;
private final boolean isDietParse;
private final Set<String> prefixes;
private final boolean corelibParse;
@@ -201,48 +204,60 @@ public class DartParser extends CompletionHooksParserBase {
public DartParser(Source source,
String sourceCode,
- DartCompilerListener listener) {
- this(new DartScannerParserContext(source, sourceCode, listener));
- }
-
- public DartParser(ParserContext ctx) {
- this(ctx, false);
- }
-
- public DartParser(ParserContext ctx, Set<String> prefixes, boolean isDietParse) {
- this(ctx, isDietParse, prefixes);
- }
-
- public DartParser(ParserContext ctx, boolean isDietParse) {
- this(ctx, isDietParse, Collections.<String>emptySet());
- }
-
- public DartParser(ParserContext ctx, boolean isDietParse, Set<String> prefixes) {
- super(ctx);
+ boolean isDietParse,
+ Set<String> prefixes,
+ DartCompilerListener listener,
+ CompilerMetrics compilerMetrics) {
+ super(new DartParserCommentsHelper.CommentParserContext(source, sourceCode, listener, compilerMetrics));
+ this.source = source;
+ this.sourceCode = sourceCode;
this.isDietParse = isDietParse;
this.prefixes = prefixes;
- {
- Source source = ctx.getSource();
- this.corelibParse = source != null && SystemLibraryManager.isDartUri(source.getUri());
- }
- }
-
- private DartParser(Source source, DartCompilerListener listener) throws IOException {
- this(source, source.getSourceReader(), listener);
- }
-
- private DartParser(Source source,
- Reader sourceReader,
- DartCompilerListener listener) throws IOException {
- this(new DartScannerParserContext(source, read(sourceReader), listener));
+ this.corelibParse = source != null && SystemLibraryManager.isDartUri(source.getUri());
}
- public static DartParser getSourceParser(Source source, DartCompilerListener listener)
- throws IOException {
- return new DartParser(source, listener);
+// public DartParser(ParserContext ctx) {
Brian Wilkerson 2012/06/25 14:24:38 Do we need this commented out code, or can we dele
scheglov 2012/06/26 19:46:34 Done.
+// this(ctx, false);
+// }
+//
+// public DartParser(ParserContext ctx, Set<String> prefixes, boolean isDietParse) {
+// this(ctx, isDietParse, prefixes);
+// }
+//
+// public DartParser(ParserContext ctx, boolean isDietParse) {
+// this(ctx, isDietParse, Collections.<String>emptySet());
+// }
+//
+// public DartParser(ParserContext ctx, boolean isDietParse, Set<String> prefixes) {
+// super(ctx);
+// this.isDietParse = isDietParse;
+// this.prefixes = prefixes;
+// {
+// Source source = ctx.getSource();
+// this.corelibParse = source != null && SystemLibraryManager.isDartUri(source.getUri());
+// }
+// }
+//
+// private DartParser(Source source, DartCompilerListener listener) throws IOException {
+// this(source, source.getSourceReader(), listener);
+// }
+//
+// private DartParser(Source source,
+// Reader sourceReader,
+// DartCompilerListener listener) throws IOException {
+// this(new DartScannerParserContext(source, read(sourceReader), listener));
+// }
+//
+// public static DartParser getSourceParser(Source source, DartCompilerListener listener)
+// throws IOException {
+// return new DartParser(source, listener);
+// }
+
+ public static String read(Source source) throws IOException {
+ return read(source.getSourceReader());
}
-
- private static String read(Reader reader) throws IOException {
+
+ public static String read(Reader reader) throws IOException {
try {
return CharStreams.toString(reader);
} finally {
@@ -302,11 +317,12 @@ public class DartParser extends CompletionHooksParserBase {
*/
@Terminals(tokens={Token.EOS, Token.CLASS, Token.LIBRARY, Token.IMPORT, Token.SOURCE,
Token.RESOURCE, Token.NATIVE})
- public DartUnit parseUnit(DartSource source) {
+ public DartUnit parseUnit() {
+ DartSource dartSource = (DartSource) source;
try {
beginCompilationUnit();
- ctx.unitAboutToCompile(source, isDietParse);
- DartUnit unit = new DartUnit(source, isDietParse);
+ ctx.unitAboutToCompile(dartSource, isDietParse);
+ DartUnit unit = new DartUnit(dartSource, isDietParse);
// parse any directives at the beginning of the source
parseDirectives(unit);
@@ -353,6 +369,12 @@ public class DartParser extends CompletionHooksParserBase {
}
}
expect(Token.EOS);
+ // add comments
+ {
+ List<int[]> commentLocs = ((DartParserCommentsHelper.CommentParserContext) ctx).getCommentLocs();
+ DartParserCommentsHelper.addComments(unit, source, sourceCode, commentLocs);
+ }
+ // done
return done(unit);
} catch (StringInterpolationParseError exception) {
throw new InternalCompilerException("Failed to parse " + source.getUri(), exception);

Powered by Google App Engine
This is Rietveld 408576698