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

Unified Diff: pkg/analysis_server/lib/analysis/index/index_dart.dart

Issue 1060063008: Add API for contributing to the index (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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: pkg/analysis_server/lib/analysis/index/index_dart.dart
diff --git a/pkg/analysis_server/lib/analysis/index/index_dart.dart b/pkg/analysis_server/lib/analysis/index/index_dart.dart
new file mode 100644
index 0000000000000000000000000000000000000000..511c7eedafa617c7174a4b49588f0312998210f9
--- /dev/null
+++ b/pkg/analysis_server/lib/analysis/index/index_dart.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// 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 analysis_server.analysis.index.index_core;
+
+import 'package:analysis_server/analysis/index/index_core.dart';
+import 'package:analyzer/src/generated/ast.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/source.dart';
+
+/**
+ * An [IndexContributor] that can be used to contribute relationships for Dart
+ * files.
+ *
+ * Clients are expected to subtype this class when implementing plugins.
+ */
+abstract class DartIndexContributor extends IndexContributor {
+ @override
+ void contributeTo(IndexStore store, AnalysisContext context, Source source) {
+ if (!AnalysisEngine.isDartFileName(source.fullName)) {
+ return;
+ }
+ List<Source> libraries = context.getLibrariesContaining(source);
+ if (libraries.isEmpty) {
+ return;
+ }
+ libraries.forEach((Source library) {
+ CompilationUnit unit = context.resolveCompilationUnit2(source, library);
+ if (unit != null) {
+ internalContributeTo(store, unit);
+ }
+ });
+ }
+
+ /**
+ * Contribute relationships to the given index [store] based on the given
+ * fully resolved compilation[unit].
+ */
+ void internalContributeTo(IndexStore store, CompilationUnit unit);
+}

Powered by Google App Engine
This is Rietveld 408576698