Index: pkg/compiler/lib/src/serialization/element_serialization.dart |
diff --git a/pkg/compiler/lib/src/serialization/element_serialization.dart b/pkg/compiler/lib/src/serialization/element_serialization.dart |
index 86c3337ac57553c2a3f2851236f8f84b88791f58..83e6eb42d46240e0c1aee0c08b54bb55fda6b5cf 100644 |
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart |
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart |
@@ -57,18 +57,18 @@ enum SerializedElementKind { |
/// and [ConstantExpression] that the serialized [Element] depends upon are also |
/// serialized. |
const List<ElementSerializer> ELEMENT_SERIALIZERS = const [ |
- const LibrarySerializer(), |
- const CompilationUnitSerializer(), |
- const ClassSerializer(), |
- const ConstructorSerializer(), |
- const FieldSerializer(), |
- const FunctionSerializer(), |
- const TypedefSerializer(), |
- const TypeVariableSerializer(), |
- const ParameterSerializer(), |
- const ImportSerializer(), |
- const ExportSerializer(), |
- const PrefixSerializer(), |
+ const LibrarySerializer(), |
+ const CompilationUnitSerializer(), |
+ const ClassSerializer(), |
+ const ConstructorSerializer(), |
+ const FieldSerializer(), |
+ const FunctionSerializer(), |
+ const TypedefSerializer(), |
+ const TypeVariableSerializer(), |
+ const ParameterSerializer(), |
+ const ImportSerializer(), |
+ const ExportSerializer(), |
+ const PrefixSerializer(), |
]; |
/// Interface for a function that can serialize a set of element kinds. |
@@ -79,15 +79,14 @@ abstract class ElementSerializer { |
/// Serializes [element] into the [encoder] using the [kind] computed |
/// by [getSerializedKind]. |
- void serialize(Element element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind); |
+ void serialize( |
+ Element element, ObjectEncoder encoder, SerializedElementKind kind); |
} |
class SerializerUtil { |
/// Serialize the declared members of [element] into [encoder]. |
- static void serializeMembers(Iterable<Element> members, |
- ObjectEncoder encoder) { |
+ static void serializeMembers( |
+ Iterable<Element> members, ObjectEncoder encoder) { |
MapEncoder mapEncoder = encoder.createMap(Key.MEMBERS); |
for (Element member in members) { |
String name = member.name; |
@@ -115,8 +114,8 @@ class SerializerUtil { |
} |
/// Serialize the parameters of [element] into [encoder]. |
- static void serializeParameters(FunctionElement element, |
- ObjectEncoder encoder) { |
+ static void serializeParameters( |
+ FunctionElement element, ObjectEncoder encoder) { |
FunctionType type = element.type; |
encoder.setType(Key.RETURN_TYPE, type.returnType); |
encoder.setElements(Key.PARAMETERS, element.parameters); |
@@ -186,27 +185,24 @@ class LibrarySerializer implements ElementSerializer { |
return imports; |
} |
- static List<Element> getImportedElements( |
- LibraryElement element) { |
+ static List<Element> getImportedElements(LibraryElement element) { |
Set<Element> importedElements = new Set<Element>(); |
element.forEachImport(SerializerUtil.flattenElements(importedElements)); |
if (element.isPatched) { |
- element.implementation.forEachImport( |
- SerializerUtil.flattenElements(importedElements)); |
+ element.implementation |
+ .forEachImport(SerializerUtil.flattenElements(importedElements)); |
} |
return importedElements.toList(); |
} |
- static List<Element> getExportedElements( |
- LibraryElement element) { |
+ static List<Element> getExportedElements(LibraryElement element) { |
Set<Element> exportedElements = new Set<Element>(); |
element.forEachExport(SerializerUtil.flattenElements(exportedElements)); |
return exportedElements.toList(); |
} |
- void serialize(LibraryElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(LibraryElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setUri( |
Key.CANONICAL_URI, element.canonicalUri, element.canonicalUri); |
encoder.setString(Key.LIBRARY_NAME, element.libraryName); |
@@ -219,7 +215,6 @@ class LibrarySerializer implements ElementSerializer { |
encoder.setElements(Key.IMPORT_SCOPE, getImportedElements(element)); |
encoder.setElements(Key.EXPORT_SCOPE, getExportedElements(element)); |
- |
} |
} |
@@ -233,9 +228,8 @@ class CompilationUnitSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(CompilationUnitElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(CompilationUnitElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setElement(Key.LIBRARY, element.library); |
encoder.setUri( |
Key.URI, element.library.canonicalUri, element.script.resourceUri); |
@@ -281,9 +275,8 @@ class ClassSerializer implements ElementSerializer { |
return members; |
} |
- void serialize(ClassElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize( |
+ ClassElement element, ObjectEncoder encoder, SerializedElementKind kind) { |
encoder.setElement(Key.LIBRARY, element.library); |
encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit); |
encoder.setString(Key.NAME, element.name); |
@@ -335,9 +328,8 @@ class ConstructorSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(ConstructorElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(ConstructorElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setElement(Key.CLASS, element.enclosingClass); |
encoder.setType(Key.TYPE, element.type); |
encoder.setString(Key.NAME, element.name); |
@@ -348,10 +340,9 @@ class ConstructorSerializer implements ElementSerializer { |
if (element.isExternal) return; |
if (element.isConst && !element.isFromEnvironmentConstructor) { |
ConstantConstructor constantConstructor = element.constantConstructor; |
- ObjectEncoder constantEncoder = |
- encoder.createObject(Key.CONSTRUCTOR); |
- const ConstantConstructorSerializer().visit( |
- constantConstructor, constantEncoder); |
+ ObjectEncoder constantEncoder = encoder.createObject(Key.CONSTRUCTOR); |
+ const ConstantConstructorSerializer() |
+ .visit(constantConstructor, constantEncoder); |
} |
} |
} |
@@ -368,9 +359,8 @@ class FieldSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(FieldElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize( |
+ FieldElement element, ObjectEncoder encoder, SerializedElementKind kind) { |
encoder.setString(Key.NAME, element.name); |
SerializerUtil.serializePosition(element, encoder); |
encoder.setType(Key.TYPE, element.type); |
@@ -420,9 +410,8 @@ class FunctionSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(FunctionElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(FunctionElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setString(Key.NAME, element.name); |
SerializerUtil.serializePosition(element, encoder); |
SerializerUtil.serializeParameters(element, encoder); |
@@ -455,9 +444,8 @@ class TypedefSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(TypedefElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(TypedefElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setString(Key.NAME, element.name); |
SerializerUtil.serializePosition(element, encoder); |
encoder.setType(Key.ALIAS, element.alias); |
@@ -477,9 +465,8 @@ class TypeVariableSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(TypeVariableElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(TypeVariableElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setElement(Key.TYPE_DECLARATION, element.typeDeclaration); |
encoder.setString(Key.NAME, element.name); |
SerializerUtil.serializePosition(element, encoder); |
@@ -501,9 +488,8 @@ class ParameterSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(ParameterElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(ParameterElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setElement(Key.FUNCTION, element.functionDeclaration); |
encoder.setString(Key.NAME, element.name); |
SerializerUtil.serializePosition(element, encoder); |
@@ -530,9 +516,8 @@ class ImportSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(ImportElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(ImportElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setElement(Key.LIBRARY, element.library); |
encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit); |
encoder.setElement(Key.LIBRARY_DEPENDENCY, element.importedLibrary); |
@@ -555,9 +540,8 @@ class ExportSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(ExportElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(ExportElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setElement(Key.LIBRARY, element.library); |
encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit); |
encoder.setElement(Key.LIBRARY_DEPENDENCY, element.exportedLibrary); |
@@ -576,9 +560,8 @@ class PrefixSerializer implements ElementSerializer { |
return null; |
} |
- void serialize(PrefixElement element, |
- ObjectEncoder encoder, |
- SerializedElementKind kind) { |
+ void serialize(PrefixElement element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
encoder.setString(Key.NAME, element.name); |
encoder.setElement(Key.LIBRARY, element.library); |
encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit); |
@@ -593,7 +576,6 @@ class PrefixSerializer implements ElementSerializer { |
/// |
/// This is used by the [Deserializer]. |
class ElementDeserializer { |
- |
/// Deserializes an [Element] from an [ObjectDecoder]. |
/// |
/// The class is called from the [Deserializer] when an [Element] |
@@ -601,8 +583,7 @@ class ElementDeserializer { |
/// [DartType], and [ConstantExpression] that the deserialized [Element] |
/// depends upon are available. |
static Element deserialize( |
- ObjectDecoder decoder, |
- SerializedElementKind elementKind) { |
+ ObjectDecoder decoder, SerializedElementKind elementKind) { |
switch (elementKind) { |
case SerializedElementKind.LIBRARY: |
return new LibraryElementZ(decoder); |
@@ -666,4 +647,4 @@ class ElementDeserializer { |
} |
throw new UnsupportedError("Unexpected element kind '${elementKind}."); |
} |
-} |
+} |