Index: pkg/analyzer/lib/src/summary/summarize_ast.dart |
diff --git a/pkg/analyzer/lib/src/summary/summarize_ast.dart b/pkg/analyzer/lib/src/summary/summarize_ast.dart |
index d0ad34c7503559df9b7d8a4844911b3122fd648d..4b14beede96b30e80db3d126f39714b9a166f1df 100644 |
--- a/pkg/analyzer/lib/src/summary/summarize_ast.dart |
+++ b/pkg/analyzer/lib/src/summary/summarize_ast.dart |
@@ -93,9 +93,8 @@ class _ConstExprSerializer extends AbstractConstExprSerializer { |
Expression target = access.target; |
if (target is Identifier) { |
EntityRefBuilder targetRef = serializeIdentifier(target); |
- return new EntityRefBuilder( |
- reference: visitor.serializeReference( |
- targetRef.reference, access.propertyName.name)); |
+ return new EntityRefBuilder(reference: visitor.serializeReference( |
+ targetRef.reference, access.propertyName.name)); |
} else { |
// TODO(scheglov) should we handle other targets in malformed constants? |
throw new StateError('Unexpected target type: ${target.runtimeType}'); |
@@ -349,6 +348,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
* and store the result in [classes]. |
*/ |
void serializeClass( |
+ AstNode node, |
Token abstractKeyword, |
String name, |
int nameOffset, |
@@ -395,6 +395,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
b.isAbstract = abstractKeyword != null; |
b.documentationComment = serializeDocumentation(documentationComment); |
b.annotations = serializeAnnotations(annotations); |
+ serializeCodeRange(b, node); |
classes.add(b); |
scopes.removeLast(); |
assert(scopes.length == oldScopesLength); |
@@ -402,6 +403,42 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
variables = oldVariables; |
} |
+ void serializeCodeRange(Object b, AstNode node) { |
+ if (b is UnlinkedClassBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedEnumBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedExecutableBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedParamBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedTypedefBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedTypeParamBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedUnitBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } else if (b is UnlinkedVariableBuilder) { |
+ b.hasCodeRange = true; |
+ b.codeOffset = node.offset; |
+ b.codeLength = node.length; |
+ } |
+ } |
+ |
/** |
* Serialize a [Combinator] into an [UnlinkedCombinator]. |
*/ |
@@ -438,6 +475,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
b.libraryNameLength = libraryNameLength; |
b.libraryDocumentationComment = libraryDocumentationComment; |
b.libraryAnnotations = libraryAnnotations; |
+ serializeCodeRange(b, compilationUnit); |
b.classes = classes; |
b.enums = enums; |
b.executables = executables; |
@@ -485,6 +523,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
* [UnlinkedExecutable]. |
*/ |
UnlinkedExecutableBuilder serializeExecutable( |
+ AstNode node, |
String name, |
int nameOffset, |
bool isGetter, |
@@ -537,6 +576,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
} |
b.documentationComment = serializeDocumentation(documentationComment); |
b.annotations = serializeAnnotations(annotations); |
+ serializeCodeRange(b, node); |
if (returnType == null && !isSemanticallyStatic) { |
b.inferredReturnTypeSlot = assignSlot(); |
} |
@@ -615,6 +655,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
b.name = node.identifier.name; |
b.nameOffset = node.identifier.offset; |
b.annotations = serializeAnnotations(node.metadata); |
+ serializeCodeRange(b, node); |
switch (node.kind) { |
case ParameterKind.REQUIRED: |
b.kind = UnlinkedParamKind.required; |
@@ -772,6 +813,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
b.type = serializeTypeName(variables.type); |
b.documentationComment = serializeDocumentation(documentationComment); |
b.annotations = serializeAnnotations(annotations); |
+ serializeCodeRange(b, variables.parent); |
if (variable.isConst || |
variable.isFinal && isField && !isDeclaredStatic) { |
Expression initializer = variable.initializer; |
@@ -808,6 +850,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
TypeName superclass = |
node.extendsClause == null ? null : node.extendsClause.superclass; |
serializeClass( |
+ node, |
node.abstractKeyword, |
node.name.name, |
node.name.offset, |
@@ -824,6 +867,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
@override |
void visitClassTypeAlias(ClassTypeAlias node) { |
serializeClass( |
+ node, |
node.abstractKeyword, |
node.name.name, |
node.name.offset, |
@@ -915,6 +959,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
.toList(); |
b.documentationComment = serializeDocumentation(node.documentationComment); |
b.annotations = serializeAnnotations(node.metadata); |
+ serializeCodeRange(b, node); |
enums.add(b); |
} |
@@ -950,6 +995,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
@override |
void visitFunctionDeclaration(FunctionDeclaration node) { |
executables.add(serializeExecutable( |
+ node, |
node.name.name, |
node.name.offset, |
node.isGetter, |
@@ -969,6 +1015,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
void visitFunctionExpression(FunctionExpression node) { |
if (node.parent is! FunctionDeclaration) { |
executables.add(serializeExecutable( |
+ node, |
null, |
node.offset, |
false, |
@@ -1004,6 +1051,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
.toList(); |
b.documentationComment = serializeDocumentation(node.documentationComment); |
b.annotations = serializeAnnotations(node.metadata); |
+ serializeCodeRange(b, node); |
typedefs.add(b); |
scopes.removeLast(); |
assert(scopes.length == oldScopesLength); |
@@ -1063,6 +1111,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
@override |
void visitMethodDeclaration(MethodDeclaration node) { |
executables.add(serializeExecutable( |
+ node, |
node.name.name, |
node.name.offset, |
node.isGetter, |
@@ -1111,6 +1160,7 @@ class _SummarizeAstVisitor extends RecursiveAstVisitor { |
b.bound = serializeTypeName(node.bound); |
} |
b.annotations = serializeAnnotations(node.metadata); |
+ serializeCodeRange(b, node); |
return b; |
} |