|
From: <caw...@us...> - 2007-04-13 18:53:48
|
Revision: 2312
http://svn.sourceforge.net/rubyeclipse/?rev=2312&view=rev
Author: cawilliams
Date: 2007-04-13 11:53:42 -0700 (Fri, 13 Apr 2007)
Log Message:
-----------
Modified Paths:
--------------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 18:50:01 UTC (rev 2311)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-04-13 18:53:42 UTC (rev 2312)
@@ -142,18 +142,10 @@
}
private void suggestGlobals() {
- BasicSearchEngine engine = new BasicSearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.GLOBAL, "$*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
- CollectingSearchRequestor requestor = new CollectingSearchRequestor();
- try {
- engine.search(pattern, participants, scope, requestor, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (SearchMatch match: requestor.getResults()) {
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
if (!fContext.prefixStartsWith(name))
@@ -164,19 +156,11 @@
}
}
- private void suggestTypeNames() {
- BasicSearchEngine engine = new BasicSearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ private void suggestTypeNames() {
SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript().getRubyProject()});
- CollectingSearchRequestor requestor = new CollectingSearchRequestor();
- try {
- engine.search(pattern, participants, scope, requestor, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (SearchMatch match: requestor.getResults()) {
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
if (!fContext.prefixStartsWith(name))
@@ -186,6 +170,19 @@
fRequestor.accept(proposal);
}
}
+
+ private List<SearchMatch> search(SearchPattern pattern, IRubySearchScope scope) {
+ BasicSearchEngine engine = new BasicSearchEngine();
+ SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ try {
+ engine.search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return requestor.getResults();
+ }
private CompletionProposal createProposal(int replaceStart, int type, String name) {
CompletionProposal proposal = new CompletionProposal(type, name, 100);
@@ -194,21 +191,13 @@
}
private void suggestConstantNames() {
- BasicSearchEngine engine = new BasicSearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ // TODO Do a regexp search for anything starting with an uppercase?
SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {fContext.getScript()});
- CollectingSearchRequestor requestor = new CollectingSearchRequestor();
- try {
- engine.search(pattern, participants, scope, requestor, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (SearchMatch match: requestor.getResults()) {
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
IRubyElement element = (IRubyElement) match.getElement();
String name = element.getElementName();
- // TODO Skip if not starting with an uppercase?
if (!fContext.prefixStartsWith(name))
continue;
CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|