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

Unified Diff: pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart

Issue 2566223002: Implement 'analysis.occurrences' for the new analysis driver. (Closed)
Patch Set: Created 4 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/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
diff --git a/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart b/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
index 9434d193281f467b5a7a97deb0774b7dc8142ae6..3204b2ff4bd7f09cc75fefb6ffe22999917ca9da 100644
--- a/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
+++ b/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
@@ -14,6 +14,19 @@ import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
+void addDartOccurrences(OccurrencesCollector collector, CompilationUnit unit) {
+ _DartUnitOccurrencesComputerVisitor visitor =
+ new _DartUnitOccurrencesComputerVisitor();
+ unit.accept(visitor);
+ visitor.elementsOffsets.forEach((engineElement, offsets) {
+ int length = engineElement.nameLength;
+ protocol.Element serverElement = protocol.convertElement(engineElement);
+ protocol.Occurrences occurrences =
+ new protocol.Occurrences(serverElement, offsets, length);
+ collector.addOccurrences(occurrences);
+ });
+}
+
/**
* A computer for occurrences in a Dart [CompilationUnit].
*/
@@ -26,17 +39,7 @@ class DartOccurrencesComputer implements OccurrencesContributor {
CompilationUnit unit =
context.getResolvedCompilationUnit2(source, libraries.first);
if (unit != null) {
- _DartUnitOccurrencesComputerVisitor visitor =
- new _DartUnitOccurrencesComputerVisitor();
- unit.accept(visitor);
- visitor.elementsOffsets.forEach((engineElement, offsets) {
- int length = engineElement.nameLength;
- protocol.Element serverElement =
- protocol.convertElement(engineElement);
- protocol.Occurrences occurrences =
- new protocol.Occurrences(serverElement, offsets, length);
- collector.addOccurrences(occurrences);
- });
+ addDartOccurrences(collector, unit);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698