1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Andrew Niefer

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
This commit is contained in:
John Camelon 2003-09-25 19:51:50 +00:00
parent ba0a125734
commit 939af66d2e
6 changed files with 51 additions and 22 deletions

View file

@ -1,6 +1,9 @@
2003-09-25 Hoda Amer
Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier()
2003-09-25 Andrew Niefer
added testNoResourceSearching() to OtherPatternTests
2003-09-24 Hoda Amer
Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(),
testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast()

View file

@ -22,8 +22,10 @@ import org.eclipse.cdt.core.search.IMatch;
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 @@ public class OtherPatternTests extends BaseSearchTest {
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 );
}
}

View file

@ -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()

View file

@ -277,15 +277,16 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
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 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
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 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
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 );

View file

@ -1,6 +1,11 @@
2003-09-25 Hoda Amer
Solution to bug#43646: Code Assist won't work if missing end bracket
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.

View file

@ -82,12 +82,13 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
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 );