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 29d0e0d874aaa2395d3c9d8706ef5fb43f973f63..96a42dc4bdb91e30c9537f45b5611507a14fb2ab 100644 |
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart |
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart |
@@ -12,7 +12,11 @@ import '../dart_types.dart'; |
import '../diagnostics/messages.dart'; |
import '../elements/elements.dart'; |
import '../elements/modelx.dart' |
- show DeferredLoaderGetterElementX, ErroneousElementX; |
+ show |
+ DeferredLoaderGetterElementX, |
+ ErroneousElementX, |
+ WarnOnUseElementX, |
+ WrappedMessage; |
import 'constant_serialization.dart'; |
import 'keys.dart'; |
import 'modelz.dart'; |
@@ -55,6 +59,7 @@ enum SerializedElementKind { |
PREFIX, |
DEFERRED_LOAD_LIBRARY, |
LOCAL_VARIABLE, |
+ WARN_ON_USE, |
EXTERNAL_LIBRARY, |
EXTERNAL_LIBRARY_MEMBER, |
EXTERNAL_CLASS_MEMBER, |
@@ -84,6 +89,7 @@ const List<ElementSerializer> ELEMENT_SERIALIZERS = const [ |
const ImportSerializer(), |
const ExportSerializer(), |
const LocalVariableSerializer(), |
+ const WarnOnUseSerializer(), |
]; |
/// Interface for a function that can serialize a set of element kinds. |
@@ -216,12 +222,7 @@ class ErrorSerializer implements ElementSerializer { |
encoder.setElement(Key.ENCLOSING, element.enclosingElement); |
encoder.setString(Key.NAME, element.name); |
encoder.setEnum(Key.MESSAGE_KIND, element.messageKind); |
- if (element.messageArguments.isNotEmpty) { |
- MapEncoder mapEncoder = encoder.createMap(Key.ARGUMENTS); |
- element.messageArguments.forEach((String key, var value) { |
- mapEncoder.setString(key, Message.convertToString(value)); |
- }); |
- } |
+ serializeMessageArguments(encoder, Key.ARGUMENTS, element.messageArguments); |
} |
} |
@@ -749,6 +750,25 @@ class DeferredLoadLibrarySerializer implements ElementSerializer { |
} |
} |
+class WarnOnUseSerializer implements ElementSerializer { |
+ const WarnOnUseSerializer(); |
+ |
+ SerializedElementKind getSerializedKind(Element element) { |
+ if (element.isWarnOnUse) { |
+ return SerializedElementKind.WARN_ON_USE; |
+ } |
+ return null; |
+ } |
+ |
+ void serialize(WarnOnUseElementX element, ObjectEncoder encoder, |
+ SerializedElementKind kind) { |
+ encoder.setElement(Key.ENCLOSING, element.enclosingElement); |
+ encoder.setElement(Key.ELEMENT, element.wrappedElement); |
+ serializeWrappedMessage(encoder, Key.WARNING, element.warning); |
+ serializeWrappedMessage(encoder, Key.INFO, element.info); |
+ } |
+} |
+ |
/// Utility class for deserializing [Element]s. |
/// |
/// This is used by the [Deserializer]. |
@@ -767,13 +787,8 @@ class ElementDeserializer { |
String name = decoder.getString(Key.NAME); |
MessageKind messageKind = |
decoder.getEnum(Key.MESSAGE_KIND, MessageKind.values); |
- Map<String, String> arguments = <String, String>{}; |
- MapDecoder mapDecoder = decoder.getMap(Key.ARGUMENTS, isOptional: true); |
- if (mapDecoder != null) { |
- mapDecoder.forEachKey((String key) { |
- arguments[key] = mapDecoder.getString(key); |
- }); |
- } |
+ Map<String, String> arguments = |
+ deserializeMessageArguments(decoder, Key.ARGUMENTS); |
return new ErroneousElementX(messageKind, arguments, name, enclosing); |
case SerializedElementKind.LIBRARY: |
return new LibraryElementZ(decoder); |
@@ -844,6 +859,13 @@ class ElementDeserializer { |
return new DeferredLoaderGetterElementX(decoder.getElement(Key.PREFIX)); |
case SerializedElementKind.LOCAL_VARIABLE: |
return new LocalVariableElementZ(decoder); |
+ case SerializedElementKind.WARN_ON_USE: |
+ Element enclosing = decoder.getElement(Key.ENCLOSING); |
+ Element element = decoder.getElement(Key.ELEMENT); |
+ WrappedMessage warning = |
+ deserializeWrappedMessage(decoder, Key.WARNING); |
+ WrappedMessage info = deserializeWrappedMessage(decoder, Key.INFO); |
+ return new WarnOnUseElementX(warning, info, enclosing, element); |
case SerializedElementKind.EXTERNAL_LIBRARY: |
case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: |
case SerializedElementKind.EXTERNAL_CLASS_MEMBER: |