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

Unified Diff: pkg/analysis_server/lib/src/context_manager.dart

Issue 1852113002: More strong mode changes in analysis_server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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/analysis_server/lib/src/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 95b940b38125ba6c9d0f1ae2ddda63498b4334a5..13f2052d00c895ccacc0c29dd5d9e649ee7f9209 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -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];

Powered by Google App Engine
This is Rietveld 408576698