Chromium Code Reviews| Index: pkg/analyzer/lib/src/summary/summarize_elements.dart |
| diff --git a/pkg/analyzer/lib/src/summary/summarize_elements.dart b/pkg/analyzer/lib/src/summary/summarize_elements.dart |
| index b63128786de196a860b13bf8b3e222d9b878eb29..915f97f220059c06802eb0ab14fb871402b2f72d 100644 |
| --- a/pkg/analyzer/lib/src/summary/summarize_elements.dart |
| +++ b/pkg/analyzer/lib/src/summary/summarize_elements.dart |
| @@ -38,7 +38,10 @@ ReferenceKind _getReferenceKind(Element element) { |
| } else if (element is ConstructorElement) { |
| return ReferenceKind.constructor; |
| } else if (element is FunctionElement) { |
| - return ReferenceKind.topLevelFunction; |
| + if (element.enclosingElement is CompilationUnitElement) { |
| + return ReferenceKind.topLevelFunction; |
| + } |
| + return ReferenceKind.function; |
| } else if (element is FunctionTypeAliasElement) { |
| return ReferenceKind.typedef; |
| } else if (element is PropertyAccessorElement) { |
| @@ -519,7 +522,10 @@ class _CompilationUnitSerializer { |
| UnlinkedExecutableBuilder b = new UnlinkedExecutableBuilder(); |
| b.name = executableElement.name; |
| b.nameOffset = executableElement.nameOffset; |
| - if (executableElement is! ConstructorElement) { |
| + if (executableElement.enclosingElement is VariableElement) { |
| + // TODO(scheglov) remove this check and serialize initializer types |
| + // Note that for code like `var v = null` w need to support Bottom. |
| + } else if (executableElement is! ConstructorElement) { |
| if (!executableElement.hasImplicitReturnType) { |
| b.returnType = serializeTypeRef( |
| executableElement.type.returnType, executableElement); |
| @@ -700,6 +706,9 @@ class _CompilationUnitSerializer { |
| b.defaultValue = serializeConstExpr(initializer); |
| } |
| } |
| + if (parameter is! Member && parameter.initializer != null) { |
|
Paul Berry
2016/02/17 21:15:30
Can you include a comment explaining why we want t
scheglov
2016/02/17 21:27:51
Done.
|
| + b.initializer = serializeExecutable(parameter.initializer); |
| + } |
| { |
| SourceRange visibleRange = parameter.visibleRange; |
| if (visibleRange != null) { |
| @@ -913,6 +922,12 @@ class _CompilationUnitSerializer { |
| b.visibleLength = visibleRange.length; |
| } |
| } |
| + if (variable.initializer != null) { |
| + // TODO(scheglov) local functions and variables |
| + b.initializer = serializeExecutable(variable.initializer); |
| +// b.initializer = new UnlinkedExecutableBuilder( |
|
Paul Berry
2016/02/17 21:15:30
Was this commented out code left here unintentiona
scheglov
2016/02/17 21:27:51
This code should be removed.
Thanks.
|
| +// nameOffset: variable.initializer.nameOffset); |
| + } |
| return b; |
| } |
| @@ -996,6 +1011,10 @@ class _CompilationUnitSerializer { |
| if (prefix != null) { |
| prefixReference = serializePrefix(prefix); |
| } |
| + } else if (element.isSynthetic && |
|
Paul Berry
2016/02/17 21:15:30
It seems like this code shouldn't be reachable.
scheglov
2016/02/17 21:27:51
You're right.
I don't remember why I added it, but
|
| + element is FunctionElement && |
| + element.enclosingElement is VariableElement) { |
| + prefixReference = 0; |
| } else { |
| prefixReference = _getElementReferenceId(enclosing, linked: linked); |
| } |