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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java

Issue 10692198: Cache model elements for compiler elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove debug output, tweak for caching Created 8 years, 5 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.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java
index bf23137be24ad06d3dedeada6cd47c67fc8d9a34..cc1689405cdb22c0299b9f3b6f3876c6137a6399 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java
@@ -166,6 +166,8 @@ public class IndexContributor extends ASTVisitor<Void> {
*/
private IntStack unnamedFunctionCount = new IntStack();
+ private DartImport[] libraryImports;
+
/**
* Initialize a newly created contributor to contribute data and relationships to the given index
* while processing the AST structure associated with the given compilation unit.
@@ -182,6 +184,7 @@ public class IndexContributor extends ASTVisitor<Void> {
this.compilationUnit = compilationUnit;
libraryResource = getResource(library.getDefiningCompilationUnit());
libraryElement = new Element(libraryResource, LIBRARY_ELEMENT_ID);
+ libraryImports = library.getImports();
compilationUnitResource = getResource(compilationUnit);
compilationUnitElement = new Element(
compilationUnitResource,
@@ -1189,14 +1192,12 @@ public class IndexContributor extends ASTVisitor<Void> {
private void recordImportReference(LibraryElement importLibraryElement, String prefix, int offset) {
try {
DartLibrary importLibraryModel = BindingUtils.getDartElement(importLibraryElement);
- CompilationUnit enclosingLibraryUnit = library.getDefiningCompilationUnit();
- Resource enclosingLibraryResource = ResourceFactory.getResource(enclosingLibraryUnit);
- for (DartImport imprt : library.getImports()) {
+ for (DartImport imprt : libraryImports) {
if (Objects.equal(imprt.getLibrary(), importLibraryModel)
&& Objects.equal(imprt.getPrefix(), prefix)) {
String imprtId = ElementFactory.composeElementId(imprt.getPrefix() + ":"
+ imprt.getLibrary().getElementName());
- Element imprtElement = new Element(enclosingLibraryResource, imprtId);
+ Element imprtElement = new Element(libraryResource, imprtId);
int length = StringUtils.length(prefix);
Location location = createLocation(offset, length);
recordRelationship(imprtElement, IndexConstants.IS_REFERENCED_BY, location);

Powered by Google App Engine
This is Rietveld 408576698