OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.task.dart; | 5 library analyzer.src.task.dart; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 4133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4144 if (uriContent != null) { | 4144 if (uriContent != null) { |
4145 uriContent = uriContent.trim(); | 4145 uriContent = uriContent.trim(); |
4146 directive.uriContent = uriContent; | 4146 directive.uriContent = uriContent; |
4147 } | 4147 } |
4148 defaultSource = _resolveUri(isImport, uriLiteral, uriContent); | 4148 defaultSource = _resolveUri(isImport, uriLiteral, uriContent); |
4149 directive.uriSource = defaultSource; | 4149 directive.uriSource = defaultSource; |
4150 } | 4150 } |
4151 | 4151 |
4152 // Resolve all configurations and try to choose one. | 4152 // Resolve all configurations and try to choose one. |
4153 if (directive is NamespaceDirectiveImpl) { | 4153 if (directive is NamespaceDirectiveImpl) { |
4154 Source configurationSource; | 4154 String configuredUri; |
| 4155 Source configuredSource; |
4155 for (Configuration configuration in directive.configurations) { | 4156 for (Configuration configuration in directive.configurations) { |
4156 Source source = _resolveUri(isImport, configuration.libraryUri, | 4157 String configurationUri = configuration.uri.stringValue; |
4157 configuration.libraryUri.stringValue); | 4158 Source source = |
| 4159 _resolveUri(isImport, configuration.uri, configurationUri); |
4158 configuration.uriSource = source; | 4160 configuration.uriSource = source; |
4159 if (configurationSource == null) { | 4161 if (configuredSource == null) { |
4160 String variableName = | 4162 String variableName = |
4161 configuration.name.components.map((i) => i.name).join('.'); | 4163 configuration.name.components.map((i) => i.name).join('.'); |
4162 String variableValue = context.declaredVariables.get(variableName); | 4164 String variableValue = context.declaredVariables.get(variableName); |
4163 if (configuration.value != null && | 4165 if (configuration.value != null && |
4164 variableValue == configuration.value.stringValue || | 4166 variableValue == configuration.value.stringValue || |
4165 variableValue == 'true') { | 4167 variableValue == 'true') { |
4166 configurationSource = source; | 4168 configuredUri = configuration.uri.stringValue; |
| 4169 configuredSource = source; |
4167 } | 4170 } |
4168 } | 4171 } |
4169 } | 4172 } |
4170 Source referencedSource = configurationSource ?? defaultSource; | 4173 String selectedUri = configuredUri ?? directive.uriContent; |
4171 directive.selectedSource = referencedSource; | 4174 Source selectedSource = configuredSource ?? defaultSource; |
4172 return referencedSource; | 4175 directive.selectedUri = selectedUri; |
| 4176 directive.selectedSource = selectedSource; |
| 4177 return selectedSource; |
4173 } | 4178 } |
4174 return defaultSource; | 4179 return defaultSource; |
4175 } | 4180 } |
4176 | 4181 |
4177 /** | 4182 /** |
4178 * Return the result of resolve the given [uriContent], reporting errors | 4183 * Return the result of resolve the given [uriContent], reporting errors |
4179 * against the [uriLiteral]. | 4184 * against the [uriLiteral]. |
4180 */ | 4185 */ |
4181 Source _resolveUri( | 4186 Source _resolveUri( |
4182 bool isImport, StringLiteral uriLiteral, String uriContent) { | 4187 bool isImport, StringLiteral uriLiteral, String uriContent) { |
(...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6441 | 6446 |
6442 @override | 6447 @override |
6443 bool moveNext() { | 6448 bool moveNext() { |
6444 if (_newSources.isEmpty) { | 6449 if (_newSources.isEmpty) { |
6445 return false; | 6450 return false; |
6446 } | 6451 } |
6447 currentTarget = _newSources.removeLast(); | 6452 currentTarget = _newSources.removeLast(); |
6448 return true; | 6453 return true; |
6449 } | 6454 } |
6450 } | 6455 } |
OLD | NEW |