[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Search, partially address bug 43664
|
partial fix for bug 43664 - Search cannot report matches outside of
workspace.
This enables non-ui reporting of matches outside the workspace. So
clients of search, like code assist will get external results.
We still need a resource to report a match to the search view so no
external matches in the UI.
core:
Modify Matchlocator to not try and create a link if we have no resource,
instead just use the path
core.tests:
added testNoResourceSearching() to OtherPatternTests
ui:
modify CSearchResultCollector to accept matches without resources, but not
attempt to report
them in the UI.
* src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
tests pass on both windows & linux
-Andrew
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.27
diff -u -r1.27 ChangeLog
--- search/ChangeLog 24 Sep 2003 13:36:40 -0000 1.27
+++ search/ChangeLog 25 Sep 2003 18:53:59 -0000
@@ -1,3 +1,7 @@
+2003-09-25 Andrew Niefer
+ - partial fix for 43664 Modify Matchlocator to not try and create a link if we have no
+ resource, instead just use the path
+
2003-09-23 Andrew Niefer
fix bug 43498 Search with ? fails on first letter of second word
-modifications to CSearchPattern.scanForNames()
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.31
diff -u -r1.31 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 22 Sep 2003 18:38:24 -0000 1.31
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 25 Sep 2003 18:53:59 -0000
@@ -277,15 +277,16 @@
if( workspaceRoot != null ){
resource = workspaceRoot.getFileForLocation( path );
- if( resource == null ){
- IFile file = workspaceRoot.getFile( path );
- try{
- file.createLink( path, 0, null );
- } catch ( CoreException e ){
- file = null;
- }
- resource = file;
- }
+// if( resource == null ){
+// //TODO:What to do if the file is not in the workspace?
+// IFile file = currentResource.getProject().getFile( inclusion.getName() );
+// try{
+// file.createLink( path, 0, null );
+// } catch ( CoreException e ){
+// file = null;
+// }
+// resource = file;
+// }
}
resourceStack.addFirst( ( currentResource != null ) ? (Object)currentResource : (Object)currentPath );
@@ -368,23 +369,18 @@
currentResource = workspaceRoot.findMember( pathString, true );
try{
- if( currentResource == null ){
- IPath path = new Path( pathString );
- IFile file = workspaceRoot.getFile( path );
- file.createLink( path, 0, null );
- project = file.getProject();
- }
if( currentResource != null && currentResource instanceof IFile ){
IFile file = (IFile) currentResource;
reader = new InputStreamReader( file.getContents() );
realPath = currentResource.getLocation();
project = file.getProject();
- } else continue;
+ }
} catch ( CoreException e ){
continue;
}
}
- } else {
+ }
+ if( currentResource == null ) {
IPath path = new Path( pathString );
try {
currentPath = path;
@@ -407,7 +403,7 @@
if( project != null ){
language = CoreModel.getDefault().hasCCNature( project ) ? ParserLanguage.CPP : ParserLanguage.C;
} else {
- //TODO no probject, what language do we use?
+ //TODO no project, what language do we use?
language = ParserLanguage.CPP;
}
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this );
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- ChangeLog 25 Sep 2003 14:26:33 -0000 1.113
+++ ChangeLog 25 Sep 2003 18:54:10 -0000
@@ -1,3 +1,6 @@
+2003-09-25 Andrew Niefer
+ added testNoResourceSearching() to OtherPatternTests
+
2003-09-24 Hoda Amer
Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(),
testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast()
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java,v
retrieving revision 1.13
diff -u -r1.13 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 18 Sep 2003 15:14:59 -0000 1.13
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 25 Sep 2003 18:54:11 -0000
@@ -22,8 +22,10 @@
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
+import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
+import org.eclipse.core.runtime.Path;
/**
* @author aniefer
@@ -237,4 +239,22 @@
Set matches = resultCollector.getSearchResults();
assertEquals( matches.size(), 3 );
}
+
+ public void testNoResourceSearching(){
+ String pluginRoot = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
+ String path = pluginRoot + "resources/search/include.h";
+
+ ICSearchPattern pattern = SearchEngine.createSearchPattern( "Head", CLASS, REFERENCES, true );
+
+ resultCollector.setProgressMonitor( monitor );
+
+ resultCollector.aboutToStart();
+ MatchLocator matchLocator = new MatchLocator( pattern, resultCollector, scope, monitor );
+ matchLocator.locateMatches( new String [] { path }, workspace, null );
+ resultCollector.done();
+
+ Set matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 4 );
+ }
+
}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.189
diff -u -r1.189 ChangeLog
--- ChangeLog 25 Sep 2003 14:10:30 -0000 1.189
+++ ChangeLog 25 Sep 2003 18:54:24 -0000
@@ -1,3 +1,8 @@
+2003-09-25 Andrew Niefer
+ modify CSearchResultCollector to accept matches without resources, but not attempt to report
+ them in the UI. Addresses 43664 for non-ui clients of search
+ * src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
+
2003-09-25 Alain Magloire
Add HelpContext IDs in the preference page.
Index: src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java,v
retrieving revision 1.10
diff -u -r1.10 CSearchResultCollector.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java 12 Sep 2003 13:13:58 -0000 1.10
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java 25 Sep 2003 18:54:24 -0000
@@ -82,12 +82,13 @@
public boolean acceptMatch( IMatch match ) throws CoreException
{
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
- if( searchMatch.resource == null )
- return false;
-
+
if( !super.acceptMatch( match ) )
return false;
-
+
+ if( searchMatch.resource == null )
+ return false;
+
IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
HashMap markerAttributes = new HashMap( 2 );