| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 * @param node the root of the AST structure to be resolved | 38 * @param node the root of the AST structure to be resolved |
| 39 * @param errorListener the listener to which analysis errors will be reported | 39 * @param errorListener the listener to which analysis errors will be reported |
| 40 * @return the scope in which the given AST structure should be resolved | 40 * @return the scope in which the given AST structure should be resolved |
| 41 * @throws AnalysisException if the AST structure has not been resolved or is
not part of a | 41 * @throws AnalysisException if the AST structure has not been resolved or is
not part of a |
| 42 * {@link CompilationUnit} | 42 * {@link CompilationUnit} |
| 43 */ | 43 */ |
| 44 public static Scope scopeFor(ASTNode node, AnalysisErrorListener errorListener
) | 44 public static Scope scopeFor(ASTNode node, AnalysisErrorListener errorListener
) |
| 45 throws AnalysisException { | 45 throws AnalysisException { |
| 46 if (node == null) { | 46 if (node == null) { |
| 47 throw new AnalysisException("Cannot create scope: node is null"); | 47 throw new AnalysisException("Cannot create scope: node is null"); |
| 48 } else if (node instanceof CompilationUnit) { |
| 49 ScopeBuilder builder = new ScopeBuilder(errorListener); |
| 50 return builder.scopeForAstNode(node); |
| 48 } | 51 } |
| 49 ASTNode parent = node.getParent(); | 52 ASTNode parent = node.getParent(); |
| 50 if (parent == null) { | 53 if (parent == null) { |
| 51 throw new AnalysisException("Cannot create scope: node is not part of a Co
mpilationUnit"); | 54 throw new AnalysisException("Cannot create scope: node is not part of a Co
mpilationUnit"); |
| 52 } | 55 } |
| 53 ScopeBuilder builder = new ScopeBuilder(errorListener); | 56 ScopeBuilder builder = new ScopeBuilder(errorListener); |
| 54 return builder.scopeForAstNode(parent); | 57 return builder.scopeForAstNode(parent); |
| 55 } | 58 } |
| 56 | 59 |
| 57 /** | 60 /** |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (unitElement == null) { | 125 if (unitElement == null) { |
| 123 throw new AnalysisException("Cannot create scope: compilation unit is not
resolved"); | 126 throw new AnalysisException("Cannot create scope: compilation unit is not
resolved"); |
| 124 } | 127 } |
| 125 LibraryElement libraryElement = unitElement.getLibrary(); | 128 LibraryElement libraryElement = unitElement.getLibrary(); |
| 126 if (libraryElement == null) { | 129 if (libraryElement == null) { |
| 127 throw new AnalysisException("Cannot create scope: compilation unit is not
part of a library"); | 130 throw new AnalysisException("Cannot create scope: compilation unit is not
part of a library"); |
| 128 } | 131 } |
| 129 return new LibraryScope(libraryElement, errorListener); | 132 return new LibraryScope(libraryElement, errorListener); |
| 130 } | 133 } |
| 131 } | 134 } |
| OLD | NEW |