diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 8df74cc06e6..1456cef4e1f 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -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. diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java index 171a7123638..9112e7c0d8c 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java @@ -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); diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.cpp b/core/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.cpp index db3f29c3e8f..a185ef1379b 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.cpp @@ -15,6 +15,10 @@ struct aStruct{ int aStructField = 0; }; +void foo(){ + int aLocalDeclaration = 1; +} + void anotherClass::anotherMethod(){ - a + a }; \ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java index 4e8a878c338..9e4daace918 100644 --- a/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java +++ b/core/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java @@ -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 ); } } diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index de18a269492..a0228fa6e16 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -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 diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java index 117c297ecab..cb4606817dd 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java @@ -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(); diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index ef85d5a389f..7fd5df9fe74 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -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; diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index c01d6378ac8..250ec71b50e 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -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. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java index ff5552df456..0349a5344a6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java @@ -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) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java index 8b94162781c..02da45d92da 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java @@ -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 ); } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java index 070a23a22bf..f86799c0f8c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java @@ -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) ){ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java index 8f00ebaf686..1cc61ed6699 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java @@ -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()); }