Index: pkg/analysis_server/lib/src/domains/analysis/occurrences.dart |
diff --git a/pkg/analysis_server/lib/src/domains/analysis/occurrences.dart b/pkg/analysis_server/lib/src/domains/analysis/occurrences.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b8fd2a0dd98fb1597b8d36cb6a84fb90f833408e |
--- /dev/null |
+++ b/pkg/analysis_server/lib/src/domains/analysis/occurrences.dart |
@@ -0,0 +1,45 @@ |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
Brian Wilkerson
2015/09/11 20:26:24
2015
|
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library domains.analysis.occurrences; |
+ |
+import 'package:analysis_server/analysis/occurrences_core.dart'; |
+import 'package:analysis_server/src/analysis_server.dart'; |
+import 'package:analysis_server/src/protocol_server.dart' as protocol; |
+import 'package:analyzer/src/generated/engine.dart' |
+ show AnalysisContext, AnalysisEngine; |
+import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; |
+import 'package:analyzer/src/generated/source.dart' show Source; |
+ |
+/** |
+ * Compute all known occurrences for the given [source]. |
+ */ |
+OccurrencesCollectorImpl computeOccurrences( |
+ AnalysisServer server, AnalysisContext context, Source source) { |
+ OccurrencesCollectorImpl collector = new OccurrencesCollectorImpl(); |
+ List<OccurrencesContributor> contributors = |
+ server.serverPlugin.occurrencesContributors; |
+ for (OccurrencesContributor contributor in contributors) { |
+ try { |
+ contributor.computeOccurrences(collector, context, source); |
+ } catch (exception, stackTrace) { |
+ AnalysisEngine.instance.logger.logError( |
+ 'Exception from occurrences contributor: ${contributor.runtimeType}', |
+ new CaughtException(exception, stackTrace)); |
+ } |
+ } |
+ return collector; |
+} |
+ |
+/** |
+ * A concrete implementation of [OccurrencesCollector]. |
+ */ |
+class OccurrencesCollectorImpl implements OccurrencesCollector { |
+ final List<protocol.Occurrences> allOccurrences = <protocol.Occurrences>[]; |
+ |
+ @override |
+ void addOccurrences(protocol.Occurrences occurrences) { |
+ allOccurrences.add(occurrences); |
+ } |
+} |