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

Unified Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1707073002: Serialize and resynthesize variable initializers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes 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
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..c30393678c034d307bdea3e6d0acbdf3ff8e6778 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,10 @@ class _CompilationUnitSerializer {
b.defaultValue = serializeConstExpr(initializer);
}
}
+ // TODO(scheglov) VariableMember.initializer is not implemented
+ if (parameter is! VariableMember && parameter.initializer != null) {
+ b.initializer = serializeExecutable(parameter.initializer);
+ }
{
SourceRange visibleRange = parameter.visibleRange;
if (visibleRange != null) {
@@ -913,6 +923,10 @@ class _CompilationUnitSerializer {
b.visibleLength = visibleRange.length;
}
}
+ // TODO(scheglov) VariableMember.initializer is not implemented
+ if (variable is! VariableMember && variable.initializer != null) {
+ b.initializer = serializeExecutable(variable.initializer);
+ }
return b;
}
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698