OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library analysis_server.analysis.index.index_dart; | |
6 | |
7 import 'package:analysis_server/analysis/index/index_core.dart'; | |
8 import 'package:analyzer/src/generated/ast.dart'; | |
9 import 'package:analyzer/src/generated/engine.dart'; | |
10 import 'package:analyzer/src/generated/source.dart'; | |
11 | |
12 /** | |
13 * An [IndexContributor] that can be used to contribute relationships for Dart | |
14 * files. | |
15 * | |
16 * Clients are expected to subtype this class when implementing plugins. | |
17 */ | |
18 abstract class DartIndexContributor extends IndexContributor { | |
19 @override | |
20 void contributeTo(IndexStore store, AnalysisContext context, Source source) { | |
21 if (!AnalysisEngine.isDartFileName(source.fullName)) { | |
22 return; | |
23 } | |
24 List<Source> libraries = context.getLibrariesContaining(source); | |
25 if (libraries.isEmpty) { | |
26 return; | |
27 } | |
28 libraries.forEach((Source library) { | |
29 CompilationUnit unit = context.resolveCompilationUnit2(source, library); | |
30 if (unit != null) { | |
31 internalContributeTo(store, unit); | |
32 } | |
33 }); | |
34 } | |
35 | |
36 /** | |
37 * Contribute relationships to the given index [store] based on the given | |
38 * fully resolved compilation[unit]. | |
39 */ | |
40 void internalContributeTo(IndexStore store, CompilationUnit unit); | |
41 } | |
OLD | NEW |