mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Patch for Andrew Niefer
core : - modified MatchLocator to not report local declarations when boolean is set - modified SearchEngine.search to take an additional parameter "excludeLocalDeclarations" core.tests: - modified resources/cfiles/CompletionProposalsTestStart.cpp - modified CompletionProposalsTest.testCompletionProposals - updated calls to SearchEngine.search ui: - update calls to SearchEngine.search. CodeCompletion passes true for excludeLocalDeclarations
This commit is contained in:
parent
65f3447d5a
commit
e806c7013d
12 changed files with 40 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-09-22 Andrew Niefer
|
||||
- modified resources/cfiles/CompletionProposalsTestStart.cpp
|
||||
- modified CompletionProposalsTest.testCompletionProposals
|
||||
- updated calls to SearchEngine.search
|
||||
|
||||
2003-09-19 Sean Evoy
|
||||
Updated the build test to check the binary parser specification in the
|
||||
target specification.
|
||||
|
|
|
@ -106,8 +106,9 @@ public class CompletionProposalsTest extends TestCase{
|
|||
try{
|
||||
TranslationUnit headerTu = new TranslationUnit(fCProject, headerFile);
|
||||
TranslationUnit tu = new TranslationUnit(fCProject, bodyFile);
|
||||
Document document = new Document(tu.getBuffer().getContents());
|
||||
int pos = 255;
|
||||
String buffer = tu.getBuffer().getContents();
|
||||
Document document = new Document(buffer);
|
||||
int pos = buffer.indexOf(" a ") + 2; //255;
|
||||
int length = 0;
|
||||
CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
|
||||
ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, length, tu);
|
||||
|
|
|
@ -15,6 +15,10 @@ struct aStruct{
|
|||
int aStructField = 0;
|
||||
};
|
||||
|
||||
void foo(){
|
||||
int aLocalDeclaration = 1;
|
||||
}
|
||||
|
||||
void anotherClass::anotherMethod(){
|
||||
a
|
||||
a
|
||||
};
|
|
@ -185,7 +185,7 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
|||
|
||||
protected void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
|
||||
resultCollector.setProgressMonitor( monitor );
|
||||
searchEngine.search( workspace, pattern, scope, collector );
|
||||
searchEngine.search( workspace, pattern, scope, collector, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-09-19 Andrew Niefer
|
||||
fix bug 43327 Code Complete finds local variables
|
||||
- modified MatchLocator to not report local declarations when boolean is set
|
||||
- modified SearchEngine.search to take an additional parameter "excludeLocalDeclarations"
|
||||
|
||||
2003-09-15 Andrew Niefer
|
||||
- modify CSearchPattern to handle escaping wildcards (bug43063)
|
||||
- modify enterFunctionBody and enterMethodBody to fix bug42979
|
||||
|
|
|
@ -113,7 +113,7 @@ public class SearchEngine implements ICSearchConstants{
|
|||
* @param _scope
|
||||
* @param _collector
|
||||
*/
|
||||
public void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector) {
|
||||
public void search(IWorkspace workspace, ICSearchPattern pattern, ICSearchScope scope, ICSearchResultCollector collector, boolean excludeLocalDeclarations) {
|
||||
if( VERBOSE ) {
|
||||
System.out.println("Searching for " + pattern + " in " + scope); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
@ -153,6 +153,7 @@ public class SearchEngine implements ICSearchConstants{
|
|||
subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 95 );
|
||||
|
||||
MatchLocator matchLocator = new MatchLocator( pattern, collector, scope, subMonitor );
|
||||
matchLocator.setShouldExcludeLocalDeclarations( excludeLocalDeclarations );
|
||||
|
||||
if( progressMonitor != null && progressMonitor.isCanceled() )
|
||||
throw new OperationCanceledException();
|
||||
|
|
|
@ -451,6 +451,11 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
}
|
||||
} else {
|
||||
if( currentScope instanceof IASTFunction || currentScope instanceof IASTMethod ){
|
||||
//local declaration, only report if not being filtered
|
||||
if( shouldExcludeLocalDeclarations ){
|
||||
return;
|
||||
}
|
||||
|
||||
object = (ISourceElementCallbackDelegate) currentScope;
|
||||
} else {
|
||||
object = node;
|
||||
|
@ -499,6 +504,12 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
return oldScope;
|
||||
}
|
||||
|
||||
public void setShouldExcludeLocalDeclarations( boolean exclude ){
|
||||
shouldExcludeLocalDeclarations = exclude;
|
||||
}
|
||||
|
||||
private boolean shouldExcludeLocalDeclarations = false;
|
||||
|
||||
private ISourceElementCallbackDelegate lastDeclaration;
|
||||
|
||||
private ICSearchPattern searchPattern;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2003-09-22 Andrew Niefer
|
||||
fix for bug 43327 Code Complete finds local variables
|
||||
- update calls to SearchEngine.search. CodeCompletion passes true for excludeLocalDeclarations
|
||||
|
||||
2003-09-22 Andrew Niefer
|
||||
associate context ID ICHelpContextIds.C_SEARCH_PAGE with the CSearchPage dialog
|
||||
add C_SEARCH_PAGE to the ICHelpContextIds.
|
||||
|
|
|
@ -125,7 +125,7 @@ public class OpenDeclarationsAction extends Action {
|
|||
orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.FIELD, ICSearchConstants.DECLARATIONS, true ));
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.NAMESPACE, ICSearchConstants.DECLARATIONS, true ));
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( sel, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, true ));
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector);
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
|
||||
elementsFound.addAll(resultCollector.getSearchResults());
|
||||
|
||||
if (elementsFound.isEmpty() == false) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
|
|||
pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
|
||||
}
|
||||
|
||||
engine.search( _workspace, pattern, _scope, _collector );
|
||||
engine.search( _workspace, pattern, _scope, _collector, false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -535,7 +535,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, true ));
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, true ));
|
||||
orPattern.addPattern(SearchEngine.createSearchPattern( prefix, ICSearchConstants.MACRO, ICSearchConstants.DECLARATIONS, true ));
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector);
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, resultCollector, true);
|
||||
elementsFound.addAll(resultCollector.getSearchResults());
|
||||
|
||||
if((currentScope instanceof IMethod) || (currentScope instanceof IMethodDeclaration) ){
|
||||
|
|
|
@ -449,7 +449,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
elements[0] = cProject;
|
||||
ICSearchScope scope = SearchEngine.createCSearchScope(elements, true);
|
||||
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), pattern, scope, resultCollector);
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), pattern, scope, resultCollector, false);
|
||||
elementsFound.addAll(resultCollector.getSearchResults());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue