More strong mode changes in analysis_server

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1852113002 .
This commit is contained in:
Brian Wilkerson 2016-04-03 17:56:30 -07:00
parent 5d82c5f68e
commit 97c613aad4
11 changed files with 86 additions and 31 deletions

View file

@ -30,7 +30,10 @@ main(List<String> arguments) {
}
source = args[SOURCE_OPTION];
priorityFile = args[PRIORITY_FILE_OPTION];
metricNames.addAll(args[METRIC_NAME_OPTION]);
List names = args[METRIC_NAME_OPTION] as List;
for (var name in names) {
metricNames.add(name as String);
}
unittestConfiguration.timeout = new Duration(minutes: 20);
var test;

View file

@ -592,7 +592,7 @@ class ContextManagerImpl implements ContextManager {
info.context.analysisOptions = new AnalysisOptionsImpl();
// Apply inherited options.
options = _getEmbeddedOptions(info.context);
options = _toStringMap(_getEmbeddedOptions(info.context));
if (options != null) {
configureContextOptions(info.context, options);
}
@ -600,7 +600,7 @@ class ContextManagerImpl implements ContextManager {
// Check for embedded options.
YamlMap embeddedOptions = _getEmbeddedOptions(info.context);
if (embeddedOptions != null) {
options = new Merger().merge(embeddedOptions, options);
options = _toStringMap(new Merger().merge(embeddedOptions, options));
}
}
@ -627,8 +627,9 @@ class ContextManagerImpl implements ContextManager {
if (analyzer is Map) {
// Set ignore patterns.
YamlList exclude = analyzer[AnalyzerOptions.exclude];
if (exclude is List<String>) {
setIgnorePatternsForContext(info, exclude);
List<String> excludeList = _toStringList(exclude);
if (excludeList != null) {
setIgnorePatternsForContext(info, excludeList);
}
}
}
@ -1560,6 +1561,44 @@ class ContextManagerImpl implements ContextManager {
return false;
}
/**
* If all of the elements of [list] are strings, return a list of strings
* containing the same elements. Otherwise, return `null`.
*/
List<String> _toStringList(YamlList list) {
if (list == null) {
return null;
}
List<String> stringList = <String>[];
for (var element in list) {
if (element is String) {
stringList.add(element);
} else {
return null;
}
}
return stringList;
}
/**
* If the given [object] is a map, and all of the keys in the map are strings,
* return a map containing the same mappings. Otherwise, return `null`.
*/
Map<String, Object> _toStringMap(Object object) {
if (object is Map) {
Map<String, Object> stringMap = new HashMap<String, Object>();
for (var key in object.keys) {
if (key is String) {
stringMap[key] = object[key];
} else {
return null;
}
}
return stringMap;
}
return null;
}
void _updateContextPackageUriResolver(
Folder contextFolder, FolderDisposition disposition) {
AnalysisContext context = folderMap[contextFolder];

View file

@ -131,16 +131,24 @@ 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.
*/
mapMap(Map map, {dynamic keyCallback(key), dynamic valueCallback(value)}) {
Map result = {};
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.forEach((key, value) {
Object/*=KR*/ resultKey;
Object/*=VR*/ resultValue;
if (keyCallback != null) {
key = keyCallback(key);
resultKey = keyCallback(key);
} else {
resultKey = key as Object/*=KR*/;
}
if (valueCallback != null) {
value = valueCallback(value);
resultValue = valueCallback(value);
} else {
resultValue = value as Object/*=VR*/;
}
result[key] = value;
result[resultKey] = resultValue;
});
return result;
}

View file

@ -53,15 +53,14 @@ class TypeHierarchyComputer {
/**
* Returns the computed type hierarchy, maybe `null`.
*/
Future<List<TypeHierarchyItem>> compute() {
Future<List<TypeHierarchyItem>> compute() async {
if (_pivotClass != null) {
InterfaceType type = _pivotClass.type;
_createSuperItem(type);
return _createSubclasses(_items[0], 0, type).then((_) {
return new Future.value(_items);
});
await _createSubclasses(_items[0], 0, type);
return _items;
}
return new Future.value(null);
return null;
}
/**

View file

@ -6,7 +6,6 @@ library services.src.refactoring.rename_library;
import 'dart:async';
import 'package:analysis_server/plugin/protocol/protocol.dart';
import 'package:analysis_server/src/services/correction/status.dart';
import 'package:analysis_server/src/services/refactoring/naming_conventions.dart';
import 'package:analysis_server/src/services/refactoring/refactoring.dart';
@ -44,7 +43,7 @@ class RenameLibraryRefactoringImpl extends RenameRefactoringImpl {
}
@override
Future<SourceChange> fillChange() {
Future fillChange() {
addDeclarationEdit(element);
return searchEngine.searchReferences(element).then(addReferenceEdits);
}

View file

@ -35,13 +35,13 @@ List<Element> getClassMembers(ClassElement clazz, [String name]) {
List<Element> members = <Element>[];
visitChildren(clazz, (Element element) {
if (element.isSynthetic) {
return;
return false;
}
if (element is ConstructorElement) {
return;
return false;
}
if (name != null && element.displayName != name) {
return;
return false;
}
if (element is ExecutableElement) {
members.add(element);
@ -49,6 +49,7 @@ List<Element> getClassMembers(ClassElement clazz, [String name]) {
if (element is FieldElement) {
members.add(element);
}
return false;
});
return members;
}

View file

@ -1341,8 +1341,8 @@ class GetHandler {
context?.sourceFactory?.dartSdk?.context?.analysisOptions);
},
(StringBuffer buffer) {
List<Linter> lints = context
.getConfigurationData(CONFIGURED_LINTS_KEY) as List<Linter>;
List<Linter> lints =
context.getConfigurationData(CONFIGURED_LINTS_KEY);
buffer.write('<p><b>Lints</b></p>');
if (lints.isEmpty) {
buffer.write('<p>none</p>');
@ -1355,8 +1355,7 @@ class GetHandler {
}
List<ErrorProcessor> errorProcessors =
context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS)
as List<ErrorProcessor>;
context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS);
int processorCount = errorProcessors?.length ?? 0;
buffer
.write('<p><b>Error Processor count</b>: $processorCount</p>');

View file

@ -30,7 +30,7 @@ compilationUnitMatcher(String file) {
@reflectiveTest
class UpdateContentTest extends AbstractAnalysisTest {
Map<String, List<AnalysisError>> filesErrors = {};
Map<String, List<String>> filesErrors = {};
int serverErrorCount = 0;
int navigationCount = 0;
@ -42,7 +42,8 @@ class UpdateContentTest extends AbstractAnalysisTest {
void processNotification(Notification notification) {
if (notification.event == ANALYSIS_ERRORS) {
var decoded = new AnalysisErrorsParams.fromNotification(notification);
_format(AnalysisError e) => "${e.location.startLine}: ${e.message}";
String _format(AnalysisError e) =>
"${e.location.startLine}: ${e.message}";
filesErrors[decoded.file] = decoded.errors.map(_format).toList();
}
if (notification.event == ANALYSIS_NAVIGATION) {

View file

@ -173,7 +173,8 @@ class EnumTester<EngineEnum, ApiEnum extends Enum> {
return;
}
String enumName = MirrorSystem.getName(symbol);
EngineEnum engineValue = engineClass.getField(symbol).reflectee;
EngineEnum engineValue =
engineClass.getField(symbol).reflectee as EngineEnum;
expect(engineValue, new isInstanceOf<EngineEnum>());
if (exceptions.containsKey(engineValue)) {
ApiEnum expectedResult = exceptions[engineValue];

View file

@ -266,7 +266,8 @@ class ResponseTest {
Response original = new Response('myId', result: {'foo': 'bar'});
Response response = new Response.fromJson(original.toJson());
expect(response.id, equals('myId'));
Map<String, Object> result = response.toJson()['result'];
Map<String, Object> result =
response.toJson()['result'] as Map<String, Object>;
expect(result.length, equals(1));
expect(result['foo'], equals('bar'));
}

View file

@ -519,9 +519,13 @@ abstract class DartCompletionContributorTest extends AbstractContextTest {
return cs;
}
Future performAnalysis(int times, Completer completer) {
if (completer.isCompleted) return completer.future;
if (times == 0 || context == null) return new Future.value();
Future/*<E>*/ performAnalysis/*<E>*/(int times, Completer/*<E>*/ completer) {
if (completer.isCompleted) {
return completer.future;
}
if (times == 0 || context == null) {
return new Future.value();
}
context.performAnalysisTask();
// We use a delayed future to allow microtask events to finish. The
// Future.value or Future() constructors use scheduleMicrotask themselves and