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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/MemoryIndexStoreImpl.java

Issue 135803003: Translate index. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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/index/MemoryIndexStoreImpl.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/MemoryIndexStoreImpl.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/MemoryIndexStoreImpl.java
index 4279ad537fa3ecd5e3759c53b0ce27d5c4d9de4b..e51bcbea7ca62a844cdd14f4c7a1a14b433b54e3 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/MemoryIndexStoreImpl.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/MemoryIndexStoreImpl.java
@@ -188,7 +188,7 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
public boolean aboutToIndex(AnalysisContext context, CompilationUnitElement unitElement) {
context = unwrapContext(context);
// may be already removed in other thread
- if (removedContexts.containsKey(context)) {
+ if (isRemovedContext(context)) {
return false;
}
// validate unit
@@ -260,7 +260,7 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
public boolean aboutToIndex(AnalysisContext context, Source source) {
context = unwrapContext(context);
// may be already removed in other thread
- if (removedContexts.containsKey(context)) {
+ if (isRemovedContext(context)) {
return false;
}
// remove locations
@@ -371,10 +371,10 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
return;
}
// may be already removed in other thread
- if (removedContexts.containsKey(elementContext)) {
+ if (isRemovedContext(elementContext)) {
return;
}
- if (removedContexts.containsKey(locationContext)) {
+ if (isRemovedContext(locationContext)) {
return;
}
// record: key -> location(s)
@@ -382,7 +382,7 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
{
Set<Location> locations = keyToLocations.remove(key);
if (locations == null) {
- locations = Sets.newSetFromMap(new IdentityHashMap<Location, Boolean>(4));
+ locations = createLocationIdentitySet();
} else {
keyCount--;
}
@@ -435,7 +435,7 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
return;
}
// mark as removed
- removedContexts.put(context, WEAK_SET_VALUE);
+ markRemovedContext(context);
removeSources(context, null);
// remove context
contextToSourceToKeys.remove(context);
@@ -517,6 +517,13 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
}
/**
+ * Creates new {@link Set} that uses object identity instead of equals.
+ */
+ private Set<Location> createLocationIdentitySet() {
+ return Sets.newSetFromMap(new IdentityHashMap<Location, Boolean>(4));
+ }
+
+ /**
* @return the canonical {@link ElementRelationKey} for given {@link Element} and
* {@link Relationship}, i.e. unique instance for this combination.
*/
@@ -531,6 +538,20 @@ public class MemoryIndexStoreImpl implements MemoryIndexStore {
}
/**
+ * Checks if given {@link AnalysisContext} is marked as removed.
+ */
+ private boolean isRemovedContext(AnalysisContext context) {
+ return removedContexts.containsKey(context);
+ }
+
+ /**
+ * Marks given {@link AnalysisContext} as removed.
+ */
+ private void markRemovedContext(AnalysisContext context) {
+ removedContexts.put(context, WEAK_SET_VALUE);
+ }
+
+ /**
* Removes locations recorded in the given library/unit pair.
*/
private void removeLocations(AnalysisContext context, Source library, Source unit) {

Powered by Google App Engine
This is Rietveld 408576698