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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java

Issue 17277004: Split list of referenced libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java
===================================================================
--- editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java (revision 24187)
+++ editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java (working copy)
@@ -15,8 +15,6 @@
import com.google.dart.engine.AnalysisEngine;
import com.google.dart.engine.ast.CompilationUnit;
-import com.google.dart.engine.ast.ExportDirective;
-import com.google.dart.engine.ast.ImportDirective;
import com.google.dart.engine.ast.StringInterpolation;
import com.google.dart.engine.ast.StringLiteral;
import com.google.dart.engine.ast.UriBasedDirective;
@@ -71,7 +69,7 @@
/**
* A list containing all of the libraries that are imported into this library.
*/
- private HashMap<ImportDirective, Library> importedLibraries = new HashMap<ImportDirective, Library>();
+ private Library[] importedLibraries = EMPTY_ARRAY;
/**
* A table mapping URI-based directive to the actual URI value.
@@ -86,7 +84,7 @@
/**
* A list containing all of the libraries that are exported from this library.
*/
- private HashMap<ExportDirective, Library> exportedLibraries = new HashMap<ExportDirective, Library>();
+ private Library[] exportedLibraries = EMPTY_ARRAY;
/**
* A table mapping the sources for the compilation units in this library to their corresponding
@@ -100,6 +98,11 @@
private LibraryScope libraryScope;
/**
+ * An empty array that can be used to initialize lists of libraries.
+ */
+ private static final Library[] EMPTY_ARRAY = new Library[0];
+
+ /**
* Initialize a newly created data holder that can maintain the data associated with a library.
*
* @param analysisContext the analysis context in which this library is being analyzed
@@ -115,24 +118,6 @@
}
/**
- * Record that the given library is exported from this library.
- *
- * @param importLibrary the library that is exported from this library
- */
- public void addExport(ExportDirective directive, Library exportLibrary) {
- exportedLibraries.put(directive, exportLibrary);
- }
-
- /**
- * Record that the given library is imported into this library.
- *
- * @param importLibrary the library that is imported into this library
- */
- public void addImport(ImportDirective directive, Library importLibrary) {
- importedLibraries.put(directive, importLibrary);
- }
-
- /**
* Return the AST structure associated with the given source.
*
* @param source the source representing the compilation unit whose AST is to be returned
@@ -179,45 +164,21 @@
}
/**
- * Return the library exported by the given directive.
- *
- * @param directive the directive that exports the library to be returned
- * @return the library exported by the given directive
- */
- public Library getExport(ExportDirective directive) {
- return exportedLibraries.get(directive);
- }
-
- /**
* Return an array containing the libraries that are exported from this library.
*
* @return an array containing the libraries that are exported from this library
*/
public Library[] getExports() {
- HashSet<Library> libraries = new HashSet<Library>();
- libraries.addAll(exportedLibraries.values());
- return libraries.toArray(new Library[libraries.size()]);
+ return exportedLibraries;
}
/**
- * Return the library imported by the given directive.
- *
- * @param directive the directive that imports the library to be returned
- * @return the library imported by the given directive
- */
- public Library getImport(ImportDirective directive) {
- return importedLibraries.get(directive);
- }
-
- /**
* Return an array containing the libraries that are imported into this library.
*
* @return an array containing the libraries that are imported into this library
*/
public Library[] getImports() {
- HashSet<Library> libraries = new HashSet<Library>();
- libraries.addAll(importedLibraries.values());
- return libraries.toArray(new Library[libraries.size()]);
+ return importedLibraries;
}
/**
@@ -227,10 +188,14 @@
* @return the libraries that are either imported or exported from this library
*/
public Library[] getImportsAndExports() {
- HashSet<Library> libraries = new HashSet<Library>(importedLibraries.size()
- + exportedLibraries.size());
- libraries.addAll(importedLibraries.values());
- libraries.addAll(exportedLibraries.values());
+ HashSet<Library> libraries = new HashSet<Library>(importedLibraries.length
+ + exportedLibraries.length);
+ for (Library library : importedLibraries) {
+ libraries.add(library);
+ }
+ for (Library library : exportedLibraries) {
+ libraries.add(library);
+ }
return libraries.toArray(new Library[libraries.size()]);
}
@@ -354,6 +319,24 @@
}
/**
+ * Set the libraries that are exported by this library to be those in the given array.
+ *
+ * @param exportedLibraries the libraries that are exported by this library
+ */
+ public void setExportedLibraries(Library[] exportedLibraries) {
+ this.exportedLibraries = exportedLibraries;
+ }
+
+ /**
+ * Set the libraries that are imported into this library to be those in the given array.
+ *
+ * @param importedLibraries the libraries that are imported into this library
+ */
+ public void setImportedLibraries(Library[] importedLibraries) {
+ this.importedLibraries = importedLibraries;
+ }
+
+ /**
* Set the library element representing this library to the given library element.
*
* @param libraryElement the library element representing this library

Powered by Google App Engine
This is Rietveld 408576698