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

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

Issue 770333003: First step to resolving simple API changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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: pkg/analyzer/lib/src/generated/engine.dart
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index 26ef329a55ec0f099f398e59a26d13ee711fe412..9d50042f4bbe6748d89f6d4fc473b4cb5137ebe2 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -1137,6 +1137,26 @@ class AnalysisContextImpl implements InternalAnalysisContext {
return sources;
}
+ Element findElementById(int id) {
+ _ElementByIdFinder finder = new _ElementByIdFinder(id);
+ try {
+ MapIterator<Source, SourceEntry> iterator = _cache.iterator();
+ while (iterator.moveNext()) {
+ SourceEntry sourceEntry = iterator.value;
+ if (sourceEntry.kind == SourceKind.LIBRARY) {
+ DartEntry dartEntry = sourceEntry;
+ LibraryElement library = dartEntry.getValue(DartEntry.ELEMENT);
+ if (library != null) {
+ library.accept(finder);
+ }
+ }
+ }
+ } on _ElementByIdFinderException catch (e) {
+ return finder.result;
+ }
+ return null;
+ }
+
@override
List<Source> get librarySources => _getSources(SourceKind.LIBRARY);
@@ -5013,6 +5033,25 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
}
+class _ElementByIdFinder extends GeneralizingElementVisitor {
+ final int _id;
+ Element result;
+
+ _ElementByIdFinder(this._id);
+
+ @override
+ visitElement(Element element) {
+ if (element.id == _id) {
+ result = element;
+ throw new _ElementByIdFinderException();
+ }
+ super.visitElement(element);
+ }
+}
+
+class _ElementByIdFinderException {
+}
+
/**
* An `AnalysisTaskResultRecorder` is used by an analysis context to record the
* results of a task.

Powered by Google App Engine
This is Rietveld 408576698