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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/search.dart

Issue 2529473002: Implement search for other local elements. (Closed)
Patch Set: Add tests for function/method type parameters. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/search.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/search.dart b/pkg/analyzer/lib/src/dart/analysis/search.dart
index 3bdcdd17b10ccf1ac023c837c8c909c4153f5d1e..719f93db81925a2994ff30d68aa497367db72103 100644
--- a/pkg/analyzer/lib/src/dart/analysis/search.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
@@ -29,8 +29,17 @@ class Search {
}
ElementKind kind = element.kind;
- if (kind == ElementKind.LABEL || kind == ElementKind.LOCAL_VARIABLE) {
+ if (kind == ElementKind.FUNCTION || kind == ElementKind.METHOD) {
+ if (element.enclosingElement is ExecutableElement) {
+ return _searchReferences_Local(element, (n) => n is Block);
+ }
+// return _searchReferences_Function(element);
+ } else if (kind == ElementKind.LABEL ||
+ kind == ElementKind.LOCAL_VARIABLE) {
return _searchReferences_Local(element, (n) => n is Block);
+ } else if (kind == ElementKind.TYPE_PARAMETER) {
+ return _searchReferences_Local(
+ element, (n) => n.parent is CompilationUnit);
}
// TODO(scheglov) support other kinds
return const <SearchResult>[];
@@ -58,6 +67,9 @@ class Search {
// Prepare the enclosing node.
AstNode enclosingNode = node.getAncestor(isRootNode);
+ if (enclosingNode == null) {
+ return const <SearchResult>[];
+ }
// Find the matches.
_LocalReferencesVisitor visitor =
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698