OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.engine.internal.scope; | 14 package com.google.dart.engine.internal.scope; |
15 | 15 |
16 import com.google.dart.engine.AnalysisEngine; | 16 import com.google.dart.engine.AnalysisEngine; |
| 17 import com.google.dart.engine.ast.AstNode; |
17 import com.google.dart.engine.ast.Identifier; | 18 import com.google.dart.engine.ast.Identifier; |
18 import com.google.dart.engine.element.Element; | 19 import com.google.dart.engine.element.Element; |
19 import com.google.dart.engine.element.ImportElement; | 20 import com.google.dart.engine.element.ImportElement; |
20 import com.google.dart.engine.element.LibraryElement; | 21 import com.google.dart.engine.element.LibraryElement; |
21 import com.google.dart.engine.error.AnalysisError; | 22 import com.google.dart.engine.error.AnalysisError; |
22 import com.google.dart.engine.error.AnalysisErrorListener; | 23 import com.google.dart.engine.error.AnalysisErrorListener; |
23 import com.google.dart.engine.error.StaticWarningCode; | 24 import com.google.dart.engine.error.StaticWarningCode; |
24 import com.google.dart.engine.internal.element.MultiplyDefinedElementImpl; | 25 import com.google.dart.engine.internal.element.MultiplyDefinedElementImpl; |
| 26 import com.google.dart.engine.source.Source; |
25 import com.google.dart.engine.utilities.general.StringUtilities; | 27 import com.google.dart.engine.utilities.general.StringUtilities; |
26 | 28 |
27 import java.util.ArrayList; | 29 import java.util.ArrayList; |
28 import java.util.Arrays; | 30 import java.util.Arrays; |
29 | 31 |
30 /** | 32 /** |
31 * Instances of the class {@code LibraryImportScope} represent the scope contain
ing all of the names | 33 * Instances of the class {@code LibraryImportScope} represent the scope contain
ing all of the names |
32 * available from imported libraries. | 34 * available from imported libraries. |
33 * | 35 * |
34 * @coverage dart.engine.resolver | 36 * @coverage dart.engine.resolver |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 super.define(element); | 71 super.define(element); |
70 } | 72 } |
71 } | 73 } |
72 | 74 |
73 @Override | 75 @Override |
74 public AnalysisErrorListener getErrorListener() { | 76 public AnalysisErrorListener getErrorListener() { |
75 return errorListener; | 77 return errorListener; |
76 } | 78 } |
77 | 79 |
78 @Override | 80 @Override |
| 81 protected Source getSource(AstNode node) { |
| 82 Source source = super.getSource(node); |
| 83 if (source == null) { |
| 84 source = definingLibrary.getDefiningCompilationUnit().getSource(); |
| 85 } |
| 86 return source; |
| 87 } |
| 88 |
| 89 @Override |
79 protected Element internalLookup(Identifier identifier, String name, | 90 protected Element internalLookup(Identifier identifier, String name, |
80 LibraryElement referencingLibrary) { | 91 LibraryElement referencingLibrary) { |
81 Element foundElement = localLookup(name, referencingLibrary); | 92 Element foundElement = localLookup(name, referencingLibrary); |
82 if (foundElement != null) { | 93 if (foundElement != null) { |
83 return foundElement; | 94 return foundElement; |
84 } | 95 } |
85 for (int i = 0; i < importedNamespaces.length; i++) { | 96 for (int i = 0; i < importedNamespaces.length; i++) { |
86 Namespace nameSpace = importedNamespaces[i]; | 97 Namespace nameSpace = importedNamespaces[i]; |
87 Element element = nameSpace.get(name); | 98 Element element = nameSpace.get(name); |
88 if (element != null) { | 99 if (element != null) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // All members were removed | 245 // All members were removed |
235 AnalysisEngine.getInstance().getLogger().logInformation( | 246 AnalysisEngine.getInstance().getLogger().logInformation( |
236 "Multiply defined SDK element: " + foundElement); | 247 "Multiply defined SDK element: " + foundElement); |
237 return foundElement; | 248 return foundElement; |
238 } | 249 } |
239 Element[] remaining = new Element[to]; | 250 Element[] remaining = new Element[to]; |
240 System.arraycopy(conflictingMembers, 0, remaining, 0, to); | 251 System.arraycopy(conflictingMembers, 0, remaining, 0, to); |
241 return new MultiplyDefinedElementImpl(definingLibrary.getContext(), remainin
g); | 252 return new MultiplyDefinedElementImpl(definingLibrary.getContext(), remainin
g); |
242 } | 253 } |
243 } | 254 } |
OLD | NEW |