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

Unified Diff: pkg/analyzer/lib/src/dart/element/builder.dart

Issue 1689283002: Serialize parameters visible ranges. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Changes for review comments. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/builder.dart
diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart
index ac051b984a1e07ab85da83e46c0e06dc336adfc5..ea89015f3051a09837ab5818825cbb882865e45a 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -695,7 +695,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
if (_inFunction) {
Block enclosingBlock = node.getAncestor((node) => node is Block);
if (enclosingBlock != null) {
- element.setVisibleRange(enclosingBlock.offset, enclosingBlock.length);
+ element.setVisibleRange(
+ enclosingBlock.offset, enclosingBlock.length);
}
}
if (node.returnType == null) {
@@ -1318,23 +1319,17 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
}
/**
- * Return the body of the function that contains the given parameter, or `null` if no
- * function body could be found.
- *
- * @param node the parameter contained in the function whose body is to be returned
- * @return the body of the function that contains the given parameter
+ * Return the body of the function that contains the given [parameter], or
+ * `null` if no function body could be found.
*/
- FunctionBody _getFunctionBody(FormalParameter node) {
- AstNode parent = node.parent;
- while (parent != null) {
- if (parent is ConstructorDeclaration) {
- return parent.body;
- } else if (parent is FunctionExpression) {
- return parent.body;
- } else if (parent is MethodDeclaration) {
- return parent.body;
- }
- parent = parent.parent;
+ FunctionBody _getFunctionBody(FormalParameter parameter) {
+ AstNode parent = parameter?.parent?.parent;
+ if (parent is ConstructorDeclaration) {
+ return parent.body;
+ } else if (parent is FunctionExpression) {
+ return parent.body;
+ } else if (parent is MethodDeclaration) {
+ return parent.body;
}
return null;
}
@@ -1358,7 +1353,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
void _setParameterVisibleRange(
FormalParameter node, ParameterElementImpl element) {
FunctionBody body = _getFunctionBody(node);
- if (body != null) {
+ if (body is BlockFunctionBody || body is ExpressionFunctionBody) {
element.setVisibleRange(body.offset, body.length);
}
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698