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

Unified Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 11726005: Dartdoc comments retrieved as metadata through dart2js mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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: sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 636fcc530952bc44532781cfc2215c708c93adf1..220b9fe613f88d1786b292099b0f0d550a55915c 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -103,6 +103,32 @@ abstract class Backend {
void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) {}
}
+class CommentTokenMapEntry {
ahe 2013/01/03 13:04:09 Document class please. How about: /// An entry in
+ final key;
ahe 2013/01/03 13:04:09 Add types one these two fields please.
+ final value;
+
+ CommentTokenMapEntry(this.key, this.value);
+}
+
+/**
+ * Map of tokens and the first associated comment.
ahe 2013/01/03 13:04:09 One line comment?
+ */
+class CommentTokenMap {
+ Link<CommentTokenMapEntry> entries = const Link<CommentTokenMapEntry>();
+
+ Token operator[] (Token key) {
+ for (CommentTokenMapEntry entry in entries) {
ahe 2013/01/03 13:04:09 This seems like a sub-optimal implementation. I wo
+ if (entry.key == key) {
+ return entry.value;
+ }
+ }
+ }
+
+ void operator[]= (Token key, Token value) {
+ entries = entries.prepend(new CommentTokenMapEntry(key, value));
+ }
+}
+
abstract class Compiler implements DiagnosticListener {
final Map<String, LibraryElement> libraries;
final Stopwatch totalCompileTime = new Stopwatch();
@@ -111,6 +137,11 @@ abstract class Compiler implements DiagnosticListener {
String assembledCode;
Types types;
+ /**
+ * Map from token to the first preceeding comment token.
+ */
+ final CommentTokenMap commentMap = new CommentTokenMap();
+
final bool enableMinification;
final bool enableTypeAssertions;
final bool enableUserAssertions;
@@ -125,6 +156,11 @@ abstract class Compiler implements DiagnosticListener {
final bool rejectDeprecatedFeatures;
final bool checkDeprecationInSdk;
+ /**
+ * If [:true:], comment tokens are collected in [commentMap] during scanning.
+ */
+ final bool preserveComments;
+
bool disableInlining = false;
final Tracer tracer;
@@ -247,6 +283,7 @@ abstract class Compiler implements DiagnosticListener {
this.analyzeAll: false,
this.rejectDeprecatedFeatures: false,
this.checkDeprecationInSdk: false,
+ this.preserveComments: false,
List<String> strips: const []})
: libraries = new Map<String, LibraryElement>(),
progress = new Stopwatch() {
@@ -898,6 +935,28 @@ abstract class Compiler implements DiagnosticListener {
=> interceptorsLibrary.findLocal(name);
bool get isMockCompilation => false;
+
+ Token processAndStripComments(Token currentToken) {
+ Token firstToken = currentToken;
+ Token prevToken;
+ while (currentToken.kind != EOF_TOKEN) {
+ if (identical(currentToken.kind, COMMENT_TOKEN)) {
+ Token firstCommentToken = currentToken;
+ while (identical(currentToken.kind, COMMENT_TOKEN)) {
+ currentToken = currentToken.next;
+ }
+ commentMap[currentToken] = firstCommentToken;
+ if (prevToken == null) {
+ firstToken = currentToken;
+ } else {
+ prevToken.next = currentToken;
+ }
+ }
+ prevToken = currentToken;
+ currentToken = currentToken.next;
+ }
+ return firstToken;
+ }
}
class CompilerTask {

Powered by Google App Engine
This is Rietveld 408576698