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

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

Issue 610323005: Issue 19670. Extend the 'Create Field' Quick Fix to support getter context. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
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 0af23c4ed94de21f33a1339f093fc9ed6bbf4fba..d0078aefdf4e15ca36de4e5b8a171c2342ee4693 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -33,6 +33,25 @@ bool allListsIdentical(List<List> lists, int position) {
/**
+ * Climbs up [PrefixedIdentifier] and [ProperyAccess] nodes that include [node].
+ */
+Expression climbPropertyAccess(AstNode node) {
+ while (true) {
+ AstNode parent = node.parent;
+ if (parent is PrefixedIdentifier && parent.identifier == node) {
+ node = parent;
+ continue;
+ }
+ if (parent is PropertyAccess && parent.propertyName == node) {
+ node = parent;
+ continue;
+ }
+ return node;
+ }
+}
+
+
+/**
* TODO(scheglov) replace with nodes once there will be [CompilationUnit#getComments].
*
* Returns [SourceRange]s of all comments in [unit].
@@ -73,6 +92,7 @@ String getDefaultValueCode(DartType type) {
}
+
/**
* Return the name of the [Element] kind.
*/
@@ -80,8 +100,6 @@ String getElementKindName(Element element) {
return element.kind.displayName;
}
-
-
/**
* Returns the name to display in the UI for the given [Element].
*/
@@ -94,6 +112,7 @@ String getElementQualifiedName(Element element) {
}
}
+
/**
* If the given [AstNode] is in a [ClassDeclaration], returns the
* [ClassElement]. Otherwise returns `null`.
@@ -167,7 +186,6 @@ AstNode getEnclosingExecutableNode(AstNode node) {
}
-
/**
* Returns [getExpressionPrecedence] for the parent of [node],
* or `0` if the parent node is [ParenthesizedExpression].
@@ -203,7 +221,6 @@ Map<String, Element> getImportNamespace(ImportElement imp) {
return namespace.definedNames;
}
-
/**
* Returns the line prefix from the given source, i.e. basically just a
* whitespace prefix of the given [String].
@@ -236,6 +253,7 @@ VariableElement getLocalOrParameterVariableElement(SimpleIdentifier node) {
return null;
}
+
/**
* @return the [LocalVariableElement] if given [SimpleIdentifier] is the reference to
* local variable, or <code>null</code> in the other case.
@@ -388,7 +406,6 @@ Statement getSingleStatement(Statement statement) {
return statement;
}
-
/**
* Returns the [String] content of the given [Source].
*/
@@ -396,6 +413,7 @@ String getSourceContent(AnalysisContext context, Source source) {
return context.getContents(source).data;
}
+
/**
* Returns the given [Statement] if not a [Block], or all the children
* [Statement]s if a [Block].

Powered by Google App Engine
This is Rietveld 408576698