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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/search.dart

Issue 2521363003: Implement SearchEngine for the new 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 unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/visitor.dart'; 10 import 'package:analyzer/dart/element/visitor.dart';
(...skipping 21 matching lines...) Expand all
32 if (kind == ElementKind.LABEL || kind == ElementKind.LOCAL_VARIABLE) { 32 if (kind == ElementKind.LABEL || kind == ElementKind.LOCAL_VARIABLE) {
33 return _searchReferences_Local(element, (n) => n is Block); 33 return _searchReferences_Local(element, (n) => n is Block);
34 } 34 }
35 // TODO(scheglov) support other kinds 35 // TODO(scheglov) support other kinds
36 return const <SearchResult>[]; 36 return const <SearchResult>[];
37 } 37 }
38 38
39 Future<List<SearchResult>> _searchReferences_Local( 39 Future<List<SearchResult>> _searchReferences_Local(
40 Element element, bool isRootNode(AstNode n)) async { 40 Element element, bool isRootNode(AstNode n)) async {
41 String path = element.source.fullName; 41 String path = element.source.fullName;
42 if (!_driver.addedFiles.contains(path)) {
43 return const <SearchResult>[];
44 }
42 45
43 // Prepare the unit. 46 // Prepare the unit.
44 AnalysisResult analysisResult = await _driver.getResult(path); 47 AnalysisResult analysisResult = await _driver.getResult(path);
45 CompilationUnit unit = analysisResult.unit; 48 CompilationUnit unit = analysisResult.unit;
46 if (unit == null) { 49 if (unit == null) {
47 return const <SearchResult>[]; 50 return const <SearchResult>[];
48 } 51 }
49 52
50 // Prepare the node. 53 // Prepare the node.
51 AstNode node = new NodeLocator(element.nameOffset).searchWithin(unit); 54 AstNode node = new NodeLocator(element.nameOffset).searchWithin(unit);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 200 }
198 201
199 void _addResult(AstNode node, SearchResultKind kind) { 202 void _addResult(AstNode node, SearchResultKind kind) {
200 bool isQualified = node.parent is Label; 203 bool isQualified = node.parent is Label;
201 var finder = new _ContainingElementFinder(node.offset); 204 var finder = new _ContainingElementFinder(node.offset);
202 enclosingUnitElement.accept(finder); 205 enclosingUnitElement.accept(finder);
203 results.add(new SearchResult._(element, finder.containingElement, kind, 206 results.add(new SearchResult._(element, finder.containingElement, kind,
204 node.offset, node.length, true, isQualified)); 207 node.offset, node.length, true, isQualified));
205 } 208 }
206 } 209 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/search/search_engine_internal2.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698