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

Unified Diff: pkg/analysis_server/lib/src/services/correction/util.dart

Issue 2969343002: Stop depending of visiting LocalVariableElement(s) in Executableelement.visitChildren(). (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/refactoring/extract_method.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/correction/util.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 2e73715e74333551b069e6ef61ec3a653912cef7..63533761ad71bb8d76975a5e3bedd0ab7e4650fc 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -218,6 +218,15 @@ String getDefaultValueCode(DartType type) {
}
/**
+ * Return all [LocalElement]s defined in the given [node].
+ */
+List<LocalElement> getDefinedLocalElements(AstNode node) {
+ var collector = new _LocalElementsCollector();
+ node.accept(collector);
+ return collector.elements;
+}
+
+/**
* Return the name of the [Element] kind.
*/
String getElementKindName(Element element) {
@@ -1537,3 +1546,20 @@ class _InvertedCondition {
static _InvertedCondition _simple(String source) =>
new _InvertedCondition(2147483647, source);
}
+
+/**
+ * Visitor that collects defined [LocalElement]s.
+ */
+class _LocalElementsCollector extends RecursiveAstVisitor {
+ final elements = <LocalElement>[];
+
+ @override
+ visitSimpleIdentifier(SimpleIdentifier node) {
+ if (node.inDeclarationContext()) {
+ Element element = node.staticElement;
+ if (element is LocalElement) {
+ elements.add(element);
+ }
+ }
+ }
+}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/refactoring/extract_method.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698