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

Unified Diff: pkg/analyzer_plugin/lib/src/protocol/protocol_internal.dart

Issue 2967683002: Clean up some code in plugins (Closed)
Patch Set: Created 3 years, 6 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_plugin/lib/src/protocol/protocol_internal.dart
diff --git a/pkg/analyzer_plugin/lib/src/protocol/protocol_internal.dart b/pkg/analyzer_plugin/lib/src/protocol/protocol_internal.dart
index 6c03ebbb1af6767dc3125ea63e5bc49abdc24b20..006ada13a49770ab69f4d3a363cb469d0df2f056 100644
--- a/pkg/analyzer_plugin/lib/src/protocol/protocol_internal.dart
+++ b/pkg/analyzer_plugin/lib/src/protocol/protocol_internal.dart
@@ -131,22 +131,21 @@ bool mapEqual(Map mapA, Map mapB, bool valueEqual(a, b)) {
* Translate the input [map], applying [keyCallback] to all its keys, and
* [valueCallback] to all its values.
*/
-Map/*<KR, VR>*/ mapMap/*<KP, VP, KR, VR>*/(Map/*<KP, VP>*/ map,
- {dynamic/*=KR*/ keyCallback(/*<KP>*/ key),
- dynamic/*=VR*/ valueCallback(/*<VP>*/ value)}) {
- Map/*<KR, VR>*/ result = new HashMap/*<KR, VR>*/();
+Map<KR, VR> mapMap<KP, VP, KR, VR>(Map<KP, VP> map,
+ {KR keyCallback(KP key), VR valueCallback(VP value)}) {
+ Map<KR, VR> result = new HashMap<KR, VR>();
map.forEach((key, value) {
- Object/*=KR*/ resultKey;
- Object/*=VR*/ resultValue;
+ KR resultKey;
+ VR resultValue;
if (keyCallback != null) {
resultKey = keyCallback(key);
} else {
- resultKey = key as Object/*=KR*/;
+ resultKey = key as KR;
}
if (valueCallback != null) {
resultValue = valueCallback(value);
} else {
- resultValue = value as Object/*=VR*/;
+ resultValue = value as VR;
}
result[resultKey] = resultValue;
});
@@ -225,56 +224,6 @@ RefactoringOptions refactoringOptionsFromJson(JsonDecoder jsonDecoder,
return null;
}
-///**
-// * Create a [RefactoringFeedback] corresponding the given [kind].
-// */
-//RefactoringFeedback refactoringFeedbackFromJson(
-// JsonDecoder jsonDecoder, String jsonPath, Object json, Map feedbackJson) {
-// RefactoringKind kind = jsonDecoder.refactoringKind;
-// if (kind == RefactoringKind.EXTRACT_LOCAL_VARIABLE) {
-// return new ExtractLocalVariableFeedback.fromJson(
-// jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.EXTRACT_METHOD) {
-// return new ExtractMethodFeedback.fromJson(jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.INLINE_LOCAL_VARIABLE) {
-// return new InlineLocalVariableFeedback.fromJson(
-// jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.INLINE_METHOD) {
-// return new InlineMethodFeedback.fromJson(jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.RENAME) {
-// return new RenameFeedback.fromJson(jsonDecoder, jsonPath, json);
-// }
-// return null;
-//}
-//
-///**
-// * Create a [RefactoringOptions] corresponding the given [kind].
-// */
-//RefactoringOptions refactoringOptionsFromJson(JsonDecoder jsonDecoder,
-// String jsonPath, Object json, RefactoringKind kind) {
-// if (kind == RefactoringKind.EXTRACT_LOCAL_VARIABLE) {
-// return new ExtractLocalVariableOptions.fromJson(
-// jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.EXTRACT_METHOD) {
-// return new ExtractMethodOptions.fromJson(jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.INLINE_METHOD) {
-// return new InlineMethodOptions.fromJson(jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.MOVE_FILE) {
-// return new MoveFileOptions.fromJson(jsonDecoder, jsonPath, json);
-// }
-// if (kind == RefactoringKind.RENAME) {
-// return new RenameOptions.fromJson(jsonDecoder, jsonPath, json);
-// }
-// return null;
-//}
-
/**
* Type of callbacks used to decode parts of JSON objects. [jsonPath] is a
* string describing the part of the JSON object being decoded, and [value] is
@@ -341,12 +290,12 @@ abstract class JsonDecoder {
*
* The type parameter [E] is the expected type of the elements in the list.
*/
- List/*<E>*/ decodeList/*<E>*/(String jsonPath, Object json,
- [JsonDecoderCallback/*<E>*/ decoder]) {
+ List<E> decodeList<E>(String jsonPath, Object json,
+ [JsonDecoderCallback<E> decoder]) {
if (json == null) {
- return/*<E>*/ [];
+ return <E>[];
} else if (json is List) {
- List/*<E>*/ result = /*<E>*/ [];
+ List<E> result = <E>[];
for (int i = 0; i < json.length; i++) {
result.add(decoder('$jsonPath[$i]', json[i]));
}
@@ -360,24 +309,24 @@ abstract class JsonDecoder {
* Decode a JSON object that is expected to be a Map. [keyDecoder] is used
* to decode the keys, and [valueDecoder] is used to decode the values.
*/
- Map/*<K, V>*/ decodeMap/*<K, V>*/(String jsonPath, Object json,
- {JsonDecoderCallback/*<K>*/ keyDecoder,
- JsonDecoderCallback/*<V>*/ valueDecoder}) {
+ Map<K, V> decodeMap<K, V>(String jsonPath, Object json,
+ {JsonDecoderCallback<K> keyDecoder,
+ JsonDecoderCallback<V> valueDecoder}) {
if (json == null) {
return {};
} else if (json is Map) {
- Map/*<K, V>*/ result = /*<K, V>*/ {};
+ Map<K, V> result = <K, V>{};
json.forEach((String key, value) {
- Object/*=K*/ decodedKey;
+ K decodedKey;
if (keyDecoder != null) {
decodedKey = keyDecoder('$jsonPath.key', key);
} else {
- decodedKey = key as Object/*=K*/;
+ decodedKey = key as K;
}
if (valueDecoder != null) {
value = valueDecoder('$jsonPath[${JSON.encode(key)}]', value);
}
- result[decodedKey] = value as Object/*=V*/;
+ result[decodedKey] = value as V;
});
return result;
} else {

Powered by Google App Engine
This is Rietveld 408576698