| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.dart.element.builder; | 5 library analyzer.src.dart.element.builder; |
| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 exportElement.uriOffset = uriLiteral.offset; | 173 exportElement.uriOffset = uriLiteral.offset; |
| 174 exportElement.uriEnd = uriLiteral.end; | 174 exportElement.uriEnd = uriLiteral.end; |
| 175 } | 175 } |
| 176 exportElement.uri = node.uriContent; | 176 exportElement.uri = node.uriContent; |
| 177 exportElement.combinators = _buildCombinators(node); | 177 exportElement.combinators = _buildCombinators(node); |
| 178 exportElement.exportedLibrary = exportedLibrary; | 178 exportElement.exportedLibrary = exportedLibrary; |
| 179 setElementDocumentationComment(exportElement, node); | 179 setElementDocumentationComment(exportElement, node); |
| 180 node.element = exportElement; | 180 node.element = exportElement; |
| 181 exports.add(exportElement); | 181 exports.add(exportElement); |
| 182 if (exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) { | 182 if (exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) { |
| 183 int offset = node.offset; |
| 184 int length = node.length; |
| 185 if (uriLiteral != null) { |
| 186 offset = uriLiteral.offset; |
| 187 length = uriLiteral.length; |
| 188 } |
| 183 errors.add(new AnalysisError( | 189 errors.add(new AnalysisError( |
| 184 exportedSource, | 190 libraryElement.source, |
| 185 uriLiteral.offset, | 191 offset, |
| 186 uriLiteral.length, | 192 length, |
| 187 CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY, | 193 CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY, |
| 188 [uriLiteral.toSource()])); | 194 [uriLiteral.toSource()])); |
| 189 } | 195 } |
| 190 } | 196 } |
| 191 } | 197 } |
| 192 return null; | 198 return null; |
| 193 } | 199 } |
| 194 | 200 |
| 195 @override | 201 @override |
| 196 Object visitImportDirective(ImportDirective node) { | 202 Object visitImportDirective(ImportDirective node) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 227 if (prefix == null) { | 233 if (prefix == null) { |
| 228 prefix = new PrefixElementImpl.forNode(prefixNode); | 234 prefix = new PrefixElementImpl.forNode(prefixNode); |
| 229 nameToPrefixMap[prefixName] = prefix; | 235 nameToPrefixMap[prefixName] = prefix; |
| 230 } | 236 } |
| 231 importElement.prefix = prefix; | 237 importElement.prefix = prefix; |
| 232 prefixNode.staticElement = prefix; | 238 prefixNode.staticElement = prefix; |
| 233 } | 239 } |
| 234 node.element = importElement; | 240 node.element = importElement; |
| 235 imports.add(importElement); | 241 imports.add(importElement); |
| 236 if (importSourceKindMap[importedSource] != SourceKind.LIBRARY) { | 242 if (importSourceKindMap[importedSource] != SourceKind.LIBRARY) { |
| 243 int offset = node.offset; |
| 244 int length = node.length; |
| 245 if (uriLiteral != null) { |
| 246 offset = uriLiteral.offset; |
| 247 length = uriLiteral.length; |
| 248 } |
| 237 ErrorCode errorCode = (importElement.isDeferred | 249 ErrorCode errorCode = (importElement.isDeferred |
| 238 ? StaticWarningCode.IMPORT_OF_NON_LIBRARY | 250 ? StaticWarningCode.IMPORT_OF_NON_LIBRARY |
| 239 : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY); | 251 : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY); |
| 240 errors.add(new AnalysisError(importedSource, uriLiteral.offset, | 252 errors.add(new AnalysisError(libraryElement.source, offset, length, |
| 241 uriLiteral.length, errorCode, [uriLiteral.toSource()])); | 253 errorCode, [uriLiteral.toSource()])); |
| 242 } | 254 } |
| 243 } | 255 } |
| 244 } | 256 } |
| 245 return null; | 257 return null; |
| 246 } | 258 } |
| 247 | 259 |
| 248 @override | 260 @override |
| 249 Object visitLibraryDirective(LibraryDirective node) { | 261 Object visitLibraryDirective(LibraryDirective node) { |
| 250 (node.element as LibraryElementImpl)?.metadata = | 262 (node.element as LibraryElementImpl)?.metadata = |
| 251 _getElementAnnotations(node.metadata); | 263 _getElementAnnotations(node.metadata); |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 super.visitSimpleFormalParameter(node); | 1070 super.visitSimpleFormalParameter(node); |
| 1059 (node.element as ElementImpl).metadata = | 1071 (node.element as ElementImpl).metadata = |
| 1060 _createElementAnnotations(node.metadata); | 1072 _createElementAnnotations(node.metadata); |
| 1061 return null; | 1073 return null; |
| 1062 } | 1074 } |
| 1063 | 1075 |
| 1064 @override | 1076 @override |
| 1065 Object visitSwitchCase(SwitchCase node) { | 1077 Object visitSwitchCase(SwitchCase node) { |
| 1066 for (Label label in node.labels) { | 1078 for (Label label in node.labels) { |
| 1067 SimpleIdentifier labelName = label.label; | 1079 SimpleIdentifier labelName = label.label; |
| 1068 LabelElementImpl element = new LabelElementImpl.forNode(labelName, false,
true); | 1080 LabelElementImpl element = |
| 1081 new LabelElementImpl.forNode(labelName, false, true); |
| 1069 _currentHolder.addLabel(element); | 1082 _currentHolder.addLabel(element); |
| 1070 labelName.staticElement = element; | 1083 labelName.staticElement = element; |
| 1071 } | 1084 } |
| 1072 return super.visitSwitchCase(node); | 1085 return super.visitSwitchCase(node); |
| 1073 } | 1086 } |
| 1074 | 1087 |
| 1075 @override | 1088 @override |
| 1076 Object visitSwitchDefault(SwitchDefault node) { | 1089 Object visitSwitchDefault(SwitchDefault node) { |
| 1077 for (Label label in node.labels) { | 1090 for (Label label in node.labels) { |
| 1078 SimpleIdentifier labelName = label.label; | 1091 SimpleIdentifier labelName = label.label; |
| 1079 LabelElementImpl element = new LabelElementImpl.forNode(labelName, false,
true); | 1092 LabelElementImpl element = |
| 1093 new LabelElementImpl.forNode(labelName, false, true); |
| 1080 _currentHolder.addLabel(element); | 1094 _currentHolder.addLabel(element); |
| 1081 labelName.staticElement = element; | 1095 labelName.staticElement = element; |
| 1082 } | 1096 } |
| 1083 return super.visitSwitchDefault(node); | 1097 return super.visitSwitchDefault(node); |
| 1084 } | 1098 } |
| 1085 | 1099 |
| 1086 @override | 1100 @override |
| 1087 Object visitTypeParameter(TypeParameter node) { | 1101 Object visitTypeParameter(TypeParameter node) { |
| 1088 SimpleIdentifier parameterName = node.name; | 1102 SimpleIdentifier parameterName = node.name; |
| 1089 TypeParameterElementImpl typeParameter = | 1103 TypeParameterElementImpl typeParameter = |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 return null; | 1413 return null; |
| 1400 } | 1414 } |
| 1401 | 1415 |
| 1402 /** | 1416 /** |
| 1403 * Return the lexical identifiers associated with the given [identifiers]. | 1417 * Return the lexical identifiers associated with the given [identifiers]. |
| 1404 */ | 1418 */ |
| 1405 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 1419 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { |
| 1406 return identifiers.map((identifier) => identifier.name).toList(); | 1420 return identifiers.map((identifier) => identifier.name).toList(); |
| 1407 } | 1421 } |
| 1408 } | 1422 } |
| OLD | NEW |