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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/search/SearchEngineImpl.java

Issue 10915031: Issue 4796. Support for renaming named parameters in invocations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/search/SearchEngineImpl.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/search/SearchEngineImpl.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/search/SearchEngineImpl.java
index a4bec43e44997b8ef76fd55830ae00cb3f7ebb17..f8a029ef2182cff4cbd6b883c10bbc1f85899bf8 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/search/SearchEngineImpl.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/search/SearchEngineImpl.java
@@ -360,6 +360,14 @@ public class SearchEngineImpl implements SearchEngine {
public void performSearch(SearchListener listener) throws SearchException;
}
+ private static Resource getResource(CompilationUnit compilationUnit) throws SearchException {
+ try {
+ return ResourceFactory.getResource(compilationUnit);
+ } catch (DartModelException exception) {
+ throw new SearchException(exception);
+ }
+ }
+
/**
* The index used to respond to the search requests.
*/
@@ -577,23 +585,32 @@ public class SearchEngineImpl implements SearchEngine {
if (listener == null) {
throw new IllegalArgumentException("listener cannot be null");
}
- SearchListener filteredListener = new CountingSearchListener(4, applyFilter(filter, listener));
- index.getRelationships(
- createElement(variable),
- IndexConstants.IS_ACCESSED_BY_QUALIFIED,
- new RelationshipCallbackImpl(MatchKind.FIELD_READ, filteredListener));
- index.getRelationships(
- createElement(variable),
- IndexConstants.IS_MODIFIED_BY_QUALIFIED,
- new RelationshipCallbackImpl(MatchKind.FIELD_WRITE, filteredListener));
- index.getRelationships(
- createElement(variable),
- IndexConstants.IS_ACCESSED_BY_UNQUALIFIED,
- new RelationshipCallbackImpl(MatchKind.FIELD_READ, filteredListener));
- index.getRelationships(
- createElement(variable),
- IndexConstants.IS_MODIFIED_BY_UNQUALIFIED,
- new RelationshipCallbackImpl(MatchKind.FIELD_WRITE, filteredListener));
+ if (variable.isParameter()) {
+ SearchListener filteredListener = new CountingSearchListener(1, applyFilter(filter, listener));
+ Element element = createMethodParameterElement(variable);
+ index.getRelationships(
+ element,
+ IndexConstants.IS_REFERENCED_BY,
+ new RelationshipCallbackImpl(MatchKind.NAMED_PARAMETER_REFERENCE, filteredListener));
+ } else {
+ SearchListener filteredListener = new CountingSearchListener(4, applyFilter(filter, listener));
+ index.getRelationships(
+ createElement(variable),
+ IndexConstants.IS_ACCESSED_BY_QUALIFIED,
+ new RelationshipCallbackImpl(MatchKind.FIELD_READ, filteredListener));
+ index.getRelationships(
+ createElement(variable),
+ IndexConstants.IS_MODIFIED_BY_QUALIFIED,
+ new RelationshipCallbackImpl(MatchKind.FIELD_WRITE, filteredListener));
+ index.getRelationships(
+ createElement(variable),
+ IndexConstants.IS_ACCESSED_BY_UNQUALIFIED,
+ new RelationshipCallbackImpl(MatchKind.FIELD_READ, filteredListener));
+ index.getRelationships(
+ createElement(variable),
+ IndexConstants.IS_MODIFIED_BY_UNQUALIFIED,
+ new RelationshipCallbackImpl(MatchKind.FIELD_WRITE, filteredListener));
+ }
}
@Override
@@ -945,6 +962,14 @@ public class SearchEngineImpl implements SearchEngine {
return new Element[] {IndexConstants.UNIVERSE};
}
+ private Element createMethodParameterElement(DartVariableDeclaration parameter)
+ throws SearchException {
+ DartFunction function = (DartFunction) parameter.getParent();
+ Element functionElement = createElement(function);
+ return new Element(functionElement.getResource(), functionElement.getElementId()
+ + ResourceFactory.SEPARATOR_CHAR + parameter.getElementName());
+ }
+
/**
* Use the given runner to perform the given number of asynchronous searches, then wait until the
* search has completed and return the results that were produced.
@@ -962,14 +987,6 @@ public class SearchEngineImpl implements SearchEngine {
return listener.getMatches();
}
- private Resource getResource(CompilationUnit compilationUnit) throws SearchException {
- try {
- return ResourceFactory.getResource(compilationUnit);
- } catch (DartModelException exception) {
- throw new SearchException(exception);
- }
- }
-
private Resource getResource(IFile file) throws SearchException {
try {
return ResourceFactory.getResource(file);

Powered by Google App Engine
This is Rietveld 408576698