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

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

Issue 2672973002: Replace computeNode() with AstProvider in search. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/dart/analysis/driver.dart'; 9 import 'package:analyzer/src/dart/analysis/driver.dart';
10 import 'package:analyzer/src/dart/ast/utilities.dart'; 10 import 'package:analyzer/src/dart/ast/utilities.dart';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (element.enclosingElement is ClassElement) { 59 if (element.enclosingElement is ClassElement) {
60 return nameNode.getAncestor((node) => node is MethodDeclaration); 60 return nameNode.getAncestor((node) => node is MethodDeclaration);
61 } else if (element.enclosingElement is CompilationUnitElement) { 61 } else if (element.enclosingElement is CompilationUnitElement) {
62 return nameNode.getAncestor((node) => node is FunctionDeclaration); 62 return nameNode.getAncestor((node) => node is FunctionDeclaration);
63 } 63 }
64 return null; 64 return null;
65 } 65 }
66 if (element is TopLevelVariableElement) { 66 if (element is TopLevelVariableElement) {
67 return nameNode.getAncestor((node) => node is VariableDeclaration); 67 return nameNode.getAncestor((node) => node is VariableDeclaration);
68 } 68 }
69 return null; 69 return nameNode;
70 } 70 }
71 71
72 @override 72 @override
73 Future<T> getParsedNodeForElement<T extends AstNode>(Element element) async { 73 Future<T> getParsedNodeForElement<T extends AstNode>(Element element) async {
74 CompilationUnit unit = await getParsedUnitForElement(element); 74 CompilationUnit unit = await getParsedUnitForElement(element);
75 return findNodeForElement(unit, element) as T; 75 return findNodeForElement(unit, element) as T;
76 } 76 }
77 77
78 @override 78 @override
79 Future<T> getResolvedNodeForElement<T extends AstNode>( 79 Future<T> getResolvedNodeForElement<T extends AstNode>(
(...skipping 18 matching lines...) Expand all
98 return parseResult.unit; 98 return parseResult.unit;
99 } 99 }
100 100
101 @override 101 @override
102 Future<CompilationUnit> getResolvedUnitForElement(Element element) async { 102 Future<CompilationUnit> getResolvedUnitForElement(Element element) async {
103 String path = element.source.fullName; 103 String path = element.source.fullName;
104 AnalysisResult analysisResult = await driver.getResult(path); 104 AnalysisResult analysisResult = await driver.getResult(path);
105 return analysisResult?.unit; 105 return analysisResult?.unit;
106 } 106 }
107 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698