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

Unified Diff: pkg/analyzer/lib/src/generated/source.dart

Issue 2011183004: Precompute `IgnoreInfo` in Scanner. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | pkg/analyzer/lib/src/task/dart.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/source.dart
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index 4ba4c51a1060f86001605bdf29801a90cb7f9b0a..f66bc24cd9ffea81d7323a232a5c4a4e7e4fd1f3 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -177,6 +177,36 @@ class DartUriResolver extends UriResolver {
}
/**
+ * Information about analysis `//ignore:` comments within a source file.
+ */
+class IgnoreInfo {
scheglov 2016/05/27 18:05:47 This could live in src/dart.dart
pquitslund 2016/05/27 21:50:53 Done.
+ final Map<int, List<String>> _ignoreMap = new HashMap<int, List<String>>();
+
+ /**
+ * Map of line numbers to associated ignored error codes.
+ */
+ Map<int, Iterable<String>> get ignores => _ignoreMap;
+
+ /**
+ * Ignore this [errorCode] at [line].
+ */
+ void add(int line, String errorCode) {
+ _ignoreMap.putIfAbsent(line, () => new List<String>()).add(errorCode);
+ }
+
+ /**
+ * Whether this info object defines any ignores.
+ */
+ bool get hasIgnores => ignores.length > 0;
scheglov 2016/05/27 18:05:47 => ignores.isNotEmpty;
pquitslund 2016/05/27 21:50:53 Done.
+
+ /**
+ * Test whether this [errorCode] is ignored at the given [line].
+ */
+ bool ignoredAt(String errorCode, int line) =>
+ _ignoreMap[line]?.contains(errorCode) == true;
+}
+
+/**
* Information about line and column information within a source file.
*/
class LineInfo {
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | pkg/analyzer/lib/src/task/dart.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698