Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: REJECTED Re: [cdt-patch] fix bug43327 Code Complete finds local variables

We blame the error on different EOL conventions on linux, so the test 
ended up trying to do the code complete at the wrong offset.

Attached is my patch updated with a fix, I tried it on linux and it works 
for me.

-Andrew






John Camelon/Ottawa/IBM@IBMCA 
Sent by: cdt-patch-admin@xxxxxxxxxxx
09/22/2003 09:41 AM
Please respond to
cdt-patch@xxxxxxxxxxx


To
cdt-patch@xxxxxxxxxxx
cc

Subject
REJECTED Re: [cdt-patch] fix bug43327 Code Complete finds local variables






JUnit runs clean on Windows, but we get a failure on Linux.  Both JREs are 

1.3. 

The offending null object is an array called results. 
   assertEquals(results.length, 7); 

This looks similar to the problems Bogdan had previously in one of his 
tests, maybe he could shed some light on what's going on.

java.lang.NullPointerException
        at 
org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest.testCompletionProposals(CompletionProposalsTest.java:119)
        at java.lang.reflect.Method.invoke(Native Method)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at 
org.eclipse.cdt.core.suite.AutomatedIntegrationSuite.run(AutomatedIntegrationSuite.java:116)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
        at 
org.eclipse.pde.internal.junit.ui.RemotePluginTestRunner.main(RemotePluginTestRunner.java:30)
        at 
org.eclipse.pde.internal.junit.ui.UITestApplication.runEventLoop(UITestApplication.java:35)
        at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385)
        at 
org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858)
        at org.eclipse.core.boot.BootLoader.run(BootLoader.java:431)
        at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24)


Fix this and give it another shot. 

Also, from this point on, I will need to see defect numbers in the 
ChangeLog/patch summary, as we should 
only be fixing the appropriately triaged defects.

Thanks,
JohnC

cdt-patch-admin@xxxxxxxxxxx wrote on 09/19/2003 04:08:52 PM:

> 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
> 
> Andrew
> 
> [attachment "patch_09.19.03(cdt.core).txt" deleted by John 
> Camelon/Ottawa/IBM] [attachment "patch_09.19.03(cdt.core.tests).txt"
> deleted by John Camelon/Ottawa/IBM] [attachment "patch_09.19.03(cdt.
> ui).txt" deleted by John Camelon/Ottawa/IBM] 
_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch

Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.25
diff -u -r1.25 ChangeLog
--- search/ChangeLog	18 Sep 2003 15:15:08 -0000	1.25
+++ search/ChangeLog	22 Sep 2003 17:14:26 -0000
@@ -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
Index: search/org/eclipse/cdt/core/search/SearchEngine.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java,v
retrieving revision 1.8
diff -u -r1.8 SearchEngine.java
--- search/org/eclipse/cdt/core/search/SearchEngine.java	5 Sep 2003 18:31:39 -0000	1.8
+++ search/org/eclipse/cdt/core/search/SearchEngine.java	22 Sep 2003 17:14:26 -0000
@@ -113,7 +113,7 @@
 	 * @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 @@
 			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();
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.30
diff -u -r1.30 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	18 Sep 2003 15:15:08 -0000	1.30
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java	22 Sep 2003 17:14:27 -0000
@@ -451,6 +451,11 @@
 				}
 			} 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;
@@ -498,6 +503,12 @@
 		currentScope = (scopeStack.size() > 0 ) ? (IASTScope) scopeStack.removeFirst() : null;
 		return oldScope;
 	}
+	
+	public void setShouldExcludeLocalDeclarations( boolean exclude ){
+		shouldExcludeLocalDeclarations = exclude;
+	}
+	
+	private boolean shouldExcludeLocalDeclarations = false;
 	
 	private ISourceElementCallbackDelegate lastDeclaration;
 	
Index: model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java,v
retrieving revision 1.5
diff -u -r1.5 CompletionProposalsTest.java
--- model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java	10 Sep 2003 14:26:04 -0000	1.5
+++ model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java	22 Sep 2003 17:19:36 -0000
@@ -106,8 +106,9 @@
 		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);
Index: resources/cfiles/CompletionProposalsTestStart.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.cpp,v
retrieving revision 1.1
diff -u -r1.1 CompletionProposalsTestStart.cpp
--- resources/cfiles/CompletionProposalsTestStart.cpp	2 Sep 2003 17:17:01 -0000	1.1
+++ resources/cfiles/CompletionProposalsTestStart.cpp	22 Sep 2003 17:19:37 -0000
@@ -15,6 +15,10 @@
 	int aStructField = 0;
 };
 
+void foo(){
+   int aLocalDeclaration = 1;
+}
+
 void anotherClass::anotherMethod(){
-  a
+  a 
 };
Index: search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java,v
retrieving revision 1.8
diff -u -r1.8 BaseSearchTest.java
--- search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java	19 Sep 2003 16:00:44 -0000	1.8
+++ search/org/eclipse/cdt/core/search/tests/BaseSearchTest.java	22 Sep 2003 17:19:37 -0000
@@ -185,7 +185,7 @@
 	
 	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 );
 	}
 	
 }
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.181
diff -u -r1.181 ChangeLog
--- ChangeLog	22 Sep 2003 15:17:30 -0000	1.181
+++ ChangeLog	22 Sep 2003 17:21:32 -0000
@@ -1,4 +1,8 @@
 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.
 
Index: src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java,v
retrieving revision 1.1
diff -u -r1.1 OpenDeclarationsAction.java
--- src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java	26 Aug 2003 19:15:37 -0000	1.1
+++ src/org/eclipse/cdt/internal/ui/editor/OpenDeclarationsAction.java	22 Sep 2003 17:21:33 -0000
@@ -125,7 +125,7 @@
 				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) {
Index: src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java,v
retrieving revision 1.7
diff -u -r1.7 CSearchOperation.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java	5 Sep 2003 18:31:52 -0000	1.7
+++ src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java	22 Sep 2003 17:21:33 -0000
@@ -78,7 +78,7 @@
 			pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
 		}
 		
-		engine.search( _workspace, pattern, _scope, _collector );
+		engine.search( _workspace, pattern, _scope, _collector, false );
 	}
 	
 	/**
Index: src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java,v
retrieving revision 1.10
diff -u -r1.10 CCompletionProcessor.java
--- src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java	27 Aug 2003 13:17:47 -0000	1.10
+++ src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java	22 Sep 2003 17:21:33 -0000
@@ -535,7 +535,7 @@
 		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) ){
Index: src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java,v
retrieving revision 1.8
diff -u -r1.8 NewClassWizardPage.java
--- src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java	18 Sep 2003 19:46:12 -0000	1.8
+++ src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java	22 Sep 2003 17:21:34 -0000
@@ -449,7 +449,7 @@
 		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());
 	}
 	

Back to the top