OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 package com.google.dart.compiler; | 5 package com.google.dart.compiler; |
6 | 6 |
| 7 import com.google.common.collect.Sets; |
7 import com.google.common.io.CharStreams; | 8 import com.google.common.io.CharStreams; |
8 import com.google.common.io.Closeables; | 9 import com.google.common.io.Closeables; |
9 import com.google.dart.compiler.ast.DartNode; | 10 import com.google.dart.compiler.ast.DartNode; |
10 import com.google.dart.compiler.ast.DartUnit; | 11 import com.google.dart.compiler.ast.DartUnit; |
11 import com.google.dart.compiler.ast.LibraryNode; | 12 import com.google.dart.compiler.ast.LibraryNode; |
12 import com.google.dart.compiler.ast.LibraryUnit; | 13 import com.google.dart.compiler.ast.LibraryUnit; |
13 import com.google.dart.compiler.metrics.CompilerMetrics; | 14 import com.google.dart.compiler.metrics.CompilerMetrics; |
14 import com.google.dart.compiler.parser.DartParser; | 15 import com.google.dart.compiler.parser.DartParser; |
15 import com.google.dart.compiler.parser.DartScannerParserContext; | |
16 import com.google.dart.compiler.resolver.CoreTypeProvider; | 16 import com.google.dart.compiler.resolver.CoreTypeProvider; |
17 import com.google.dart.compiler.resolver.CoreTypeProviderImplementation; | 17 import com.google.dart.compiler.resolver.CoreTypeProviderImplementation; |
18 import com.google.dart.compiler.resolver.Element; | 18 import com.google.dart.compiler.resolver.Element; |
19 import com.google.dart.compiler.resolver.LibraryElement; | 19 import com.google.dart.compiler.resolver.LibraryElement; |
20 import com.google.dart.compiler.resolver.MemberBuilder; | 20 import com.google.dart.compiler.resolver.MemberBuilder; |
21 import com.google.dart.compiler.resolver.Resolver; | 21 import com.google.dart.compiler.resolver.Resolver; |
22 import com.google.dart.compiler.resolver.Scope; | 22 import com.google.dart.compiler.resolver.Scope; |
23 import com.google.dart.compiler.resolver.SupertypeResolver; | 23 import com.google.dart.compiler.resolver.SupertypeResolver; |
24 import com.google.dart.compiler.resolver.TopLevelElementBuilder; | 24 import com.google.dart.compiler.resolver.TopLevelElementBuilder; |
25 import com.google.dart.compiler.type.TypeAnalyzer; | 25 import com.google.dart.compiler.type.TypeAnalyzer; |
(...skipping 25 matching lines...) Expand all Loading... |
51 this.listener = listener; | 51 this.listener = listener; |
52 typeProvider = new CoreTypeProviderImplementation(coreLibrary.getScope(), li
stener); | 52 typeProvider = new CoreTypeProviderImplementation(coreLibrary.getScope(), li
stener); |
53 this.context = new Context(); | 53 this.context = new Context(); |
54 } | 54 } |
55 | 55 |
56 public DartNode analyze() throws IOException { | 56 public DartNode analyze() throws IOException { |
57 Source originalSource = delta.getSourceBefore(); | 57 Source originalSource = delta.getSourceBefore(); |
58 DartUnit unit = delta.getUnitAfter(); | 58 DartUnit unit = delta.getUnitAfter(); |
59 if (unit == null) { | 59 if (unit == null) { |
60 DartSource source = delta.getSourceAfter(); | 60 DartSource source = delta.getSourceAfter(); |
61 unit = getParser(source).parseUnit(source); | 61 unit = getParser(source).parseUnit(); |
62 } | 62 } |
63 Scope scope = deltaLibraryScope(originalSource, unit); | 63 Scope scope = deltaLibraryScope(originalSource, unit); |
64 // We have to create supertypes and member elements for the entire unit. For
example, if you're | 64 // We have to create supertypes and member elements for the entire unit. For
example, if you're |
65 // doing code-completion, you are only interested in the current expression,
but you may be | 65 // doing code-completion, you are only interested in the current expression,
but you may be |
66 // code-completing on a type that is defined outside the current class. | 66 // code-completing on a type that is defined outside the current class. |
67 new SupertypeResolver().exec(unit, context, typeProvider); | 67 new SupertypeResolver().exec(unit, context, typeProvider); |
68 new MemberBuilder().exec(unit, context, typeProvider); | 68 new MemberBuilder().exec(unit, context, typeProvider); |
69 | 69 |
70 // The following two phases can be narrowed down to the interest area. We cu
rrently ignore the | 70 // The following two phases can be narrowed down to the interest area. We cu
rrently ignore the |
71 // interest area, but long term, we will need to narrow down to the interest
area to handle | 71 // interest area, but long term, we will need to narrow down to the interest
area to handle |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 public LibrarySource getImportFor(String relPath) { | 143 public LibrarySource getImportFor(String relPath) { |
144 return null; | 144 return null; |
145 } | 145 } |
146 }; | 146 }; |
147 } | 147 } |
148 | 148 |
149 private DartParser getParser(Source source) throws IOException { | 149 private DartParser getParser(Source source) throws IOException { |
150 Reader r = source.getSourceReader(); | 150 Reader r = source.getSourceReader(); |
151 String sourceString = CharStreams.toString(r); | 151 String sourceString = CharStreams.toString(r); |
152 Closeables.close(r, false); | 152 Closeables.close(r, false); |
153 return new DartParser(new DartScannerParserContext(source, sourceString, lis
tener), false); | 153 return new DartParser(source, sourceString, false, Sets.<String>newHashSet()
, listener, null); |
154 } | 154 } |
155 | 155 |
156 private class Context implements DartCompilerListener, DartCompilerContext { | 156 private class Context implements DartCompilerListener, DartCompilerContext { |
157 @Override | 157 @Override |
158 public LibraryUnit getApplicationUnit() { | 158 public LibraryUnit getApplicationUnit() { |
159 throw new AssertionError(); | 159 throw new AssertionError(); |
160 } | 160 } |
161 | 161 |
162 @Override | 162 @Override |
163 public LibraryUnit getAppLibraryUnit() { | 163 public LibraryUnit getAppLibraryUnit() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 @Override | 212 @Override |
213 public void unitAboutToCompile(DartSource source, boolean diet) { | 213 public void unitAboutToCompile(DartSource source, boolean diet) { |
214 } | 214 } |
215 | 215 |
216 @Override | 216 @Override |
217 public void unitCompiled(DartUnit unit) { | 217 public void unitCompiled(DartUnit unit) { |
218 } | 218 } |
219 } | 219 } |
220 } | 220 } |
OLD | NEW |