Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: compiler/java/com/google/dart/compiler/DeltaAnalyzer.java

Issue 10536180: Issue 3530. Import elements into separate import namespace (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
Brian Wilkerson 2012/06/14 20:57:07 nit: copyright year
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.io.CharStreams; 7 import com.google.common.io.CharStreams;
8 import com.google.common.io.Closeables; 8 import com.google.common.io.Closeables;
9 import com.google.dart.compiler.ast.DartNode; 9 import com.google.dart.compiler.ast.DartNode;
10 import com.google.dart.compiler.ast.DartUnit; 10 import com.google.dart.compiler.ast.DartUnit;
11 import com.google.dart.compiler.ast.LibraryNode; 11 import com.google.dart.compiler.ast.LibraryNode;
12 import com.google.dart.compiler.ast.LibraryUnit; 12 import com.google.dart.compiler.ast.LibraryUnit;
13 import com.google.dart.compiler.metrics.CompilerMetrics; 13 import com.google.dart.compiler.metrics.CompilerMetrics;
14 import com.google.dart.compiler.parser.DartParser; 14 import com.google.dart.compiler.parser.DartParser;
15 import com.google.dart.compiler.parser.DartScannerParserContext; 15 import com.google.dart.compiler.parser.DartScannerParserContext;
16 import com.google.dart.compiler.resolver.TopLevelElementBuilder;
17 import com.google.dart.compiler.resolver.CoreTypeProvider; 16 import com.google.dart.compiler.resolver.CoreTypeProvider;
18 import com.google.dart.compiler.resolver.CoreTypeProviderImplementation; 17 import com.google.dart.compiler.resolver.CoreTypeProviderImplementation;
19 import com.google.dart.compiler.resolver.Element; 18 import com.google.dart.compiler.resolver.Element;
20 import com.google.dart.compiler.resolver.LibraryElement; 19 import com.google.dart.compiler.resolver.LibraryElement;
21 import com.google.dart.compiler.resolver.MemberBuilder; 20 import com.google.dart.compiler.resolver.MemberBuilder;
22 import com.google.dart.compiler.resolver.Resolver; 21 import com.google.dart.compiler.resolver.Resolver;
23 import com.google.dart.compiler.resolver.Scope; 22 import com.google.dart.compiler.resolver.Scope;
24 import com.google.dart.compiler.resolver.SupertypeResolver; 23 import com.google.dart.compiler.resolver.SupertypeResolver;
24 import com.google.dart.compiler.resolver.TopLevelElementBuilder;
25 import com.google.dart.compiler.type.TypeAnalyzer; 25 import com.google.dart.compiler.type.TypeAnalyzer;
26 26
27 import java.io.IOException; 27 import java.io.IOException;
28 import java.io.Reader; 28 import java.io.Reader;
29 import java.io.Writer; 29 import java.io.Writer;
30 import java.net.URI; 30 import java.net.URI;
31 31
32 class DeltaAnalyzer { 32 class DeltaAnalyzer {
33 private final SourceDelta delta; 33 private final SourceDelta delta;
34 private final LibraryElement enclosingLibrary; 34 private final LibraryElement enclosingLibrary;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return unit; 75 return unit;
76 } 76 }
77 77
78 private Scope deltaLibraryScope(Source originalSource, DartUnit unit) { 78 private Scope deltaLibraryScope(Source originalSource, DartUnit unit) {
79 // Create a library unit which holds the new unit. 79 // Create a library unit which holds the new unit.
80 LibraryUnit libraryUnit = new LibraryUnit(makeLibrarySource("delta")); 80 LibraryUnit libraryUnit = new LibraryUnit(makeLibrarySource("delta"));
81 // Copy all the imports 81 // Copy all the imports
82 for (LibraryNode path : enclosingLibrary.getLibraryUnit().getImportPaths()) { 82 for (LibraryNode path : enclosingLibrary.getLibraryUnit().getImportPaths()) {
83 libraryUnit.addImportPath(path); 83 libraryUnit.addImportPath(path);
84 } 84 }
85 for (LibraryUnit importUnit : enclosingLibrary.getLibraryUnit().getImports() ) { 85 for (LibraryUnit importUnit : enclosingLibrary.getLibraryUnit().getImportedL ibraries()) {
86 libraryUnit.addImport(importUnit, importUnit.getEntryNode()); 86 libraryUnit.addImport(importUnit, importUnit.getEntryNode());
87 } 87 }
88 libraryUnit.initializePrefixes(enclosingLibrary.getLibraryUnit());
89 libraryUnit.putUnit(unit); 88 libraryUnit.putUnit(unit);
90 89
91 // Create top-level elements for the new unit. 90 // Create top-level elements for the new unit.
92 new TopLevelElementBuilder().exec(libraryUnit, context); 91 new TopLevelElementBuilder().exec(libraryUnit, context);
93 new TopLevelElementBuilder().fillInLibraryScope(libraryUnit, listener); 92 new TopLevelElementBuilder().fillInLibraryScope(libraryUnit, listener);
94 93
95 // Copy all the elements from the old library, except the ones declared in t he original source. 94 // Copy all the elements from the old library, except the ones declared in t he original source.
96 Scope scope = libraryUnit.getElement().getScope(); 95 Scope scope = libraryUnit.getElement().getScope();
97 for (Element member : enclosingLibrary.getMembers()) { 96 for (Element member : enclosingLibrary.getMembers()) {
98 if (member.getSourceInfo().getSource() != originalSource) { 97 if (member.getSourceInfo().getSource() != originalSource) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 211
213 @Override 212 @Override
214 public void unitAboutToCompile(DartSource source, boolean diet) { 213 public void unitAboutToCompile(DartSource source, boolean diet) {
215 } 214 }
216 215
217 @Override 216 @Override
218 public void unitCompiled(DartUnit unit) { 217 public void unitCompiled(DartUnit unit) {
219 } 218 }
220 } 219 }
221 } 220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698