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:
parent
ba0a125734
commit
939af66d2e
6 changed files with 51 additions and 22 deletions
|
@ -1,6 +1,9 @@
|
||||||
2003-09-25 Hoda Amer
|
2003-09-25 Hoda Amer
|
||||||
Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier()
|
Enabled CompleteParseASTExpressionTest.testPostfixTypenameIdentifier()
|
||||||
|
|
||||||
|
2003-09-25 Andrew Niefer
|
||||||
|
added testNoResourceSearching() to OtherPatternTests
|
||||||
|
|
||||||
2003-09-24 Hoda Amer
|
2003-09-24 Hoda Amer
|
||||||
Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(),
|
Added testNewTypeId(), testCastExpression(), testPostfixDynamicCast(),
|
||||||
testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast()
|
testPostfixReinterpretCast(), testPostfixStaticCast(), and testPostfixConstCast()
|
||||||
|
|
|
@ -22,8 +22,10 @@ import org.eclipse.cdt.core.search.IMatch;
|
||||||
import org.eclipse.cdt.core.search.SearchEngine;
|
import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
|
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.NamespaceDeclarationPattern;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
|
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -237,4 +239,22 @@ public class OtherPatternTests extends BaseSearchTest {
|
||||||
Set matches = resultCollector.getSearchResults();
|
Set matches = resultCollector.getSearchResults();
|
||||||
assertEquals( matches.size(), 3 );
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
2003-09-23 Andrew Niefer
|
||||||
fix bug 43498 Search with ? fails on first letter of second word
|
fix bug 43498 Search with ? fails on first letter of second word
|
||||||
-modifications to CSearchPattern.scanForNames()
|
-modifications to CSearchPattern.scanForNames()
|
||||||
|
|
|
@ -277,15 +277,16 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
|
|
||||||
if( workspaceRoot != null ){
|
if( workspaceRoot != null ){
|
||||||
resource = workspaceRoot.getFileForLocation( path );
|
resource = workspaceRoot.getFileForLocation( path );
|
||||||
if( resource == null ){
|
// if( resource == null ){
|
||||||
IFile file = workspaceRoot.getFile( path );
|
// //TODO:What to do if the file is not in the workspace?
|
||||||
try{
|
// IFile file = currentResource.getProject().getFile( inclusion.getName() );
|
||||||
file.createLink( path, 0, null );
|
// try{
|
||||||
} catch ( CoreException e ){
|
// file.createLink( path, 0, null );
|
||||||
file = null;
|
// } catch ( CoreException e ){
|
||||||
}
|
// file = null;
|
||||||
resource = file;
|
// }
|
||||||
}
|
// resource = file;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceStack.addFirst( ( currentResource != null ) ? (Object)currentResource : (Object)currentPath );
|
resourceStack.addFirst( ( currentResource != null ) ? (Object)currentResource : (Object)currentPath );
|
||||||
|
@ -368,23 +369,18 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
currentResource = workspaceRoot.findMember( pathString, true );
|
currentResource = workspaceRoot.findMember( pathString, true );
|
||||||
|
|
||||||
try{
|
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 ){
|
if( currentResource != null && currentResource instanceof IFile ){
|
||||||
IFile file = (IFile) currentResource;
|
IFile file = (IFile) currentResource;
|
||||||
reader = new InputStreamReader( file.getContents() );
|
reader = new InputStreamReader( file.getContents() );
|
||||||
realPath = currentResource.getLocation();
|
realPath = currentResource.getLocation();
|
||||||
project = file.getProject();
|
project = file.getProject();
|
||||||
} else continue;
|
}
|
||||||
} catch ( CoreException e ){
|
} catch ( CoreException e ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
if( currentResource == null ) {
|
||||||
IPath path = new Path( pathString );
|
IPath path = new Path( pathString );
|
||||||
try {
|
try {
|
||||||
currentPath = path;
|
currentPath = path;
|
||||||
|
@ -407,7 +403,7 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
||||||
if( project != null ){
|
if( project != null ){
|
||||||
language = CoreModel.getDefault().hasCCNature( project ) ? ParserLanguage.CPP : ParserLanguage.C;
|
language = CoreModel.getDefault().hasCCNature( project ) ? ParserLanguage.CPP : ParserLanguage.C;
|
||||||
} else {
|
} else {
|
||||||
//TODO no probject, what language do we use?
|
//TODO no project, what language do we use?
|
||||||
language = ParserLanguage.CPP;
|
language = ParserLanguage.CPP;
|
||||||
}
|
}
|
||||||
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this );
|
IScanner scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETE_PARSE, language, this );
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
2003-09-25 Hoda Amer
|
2003-09-25 Hoda Amer
|
||||||
Solution to bug#43646: Code Assist won't work if missing end bracket
|
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
|
2003-09-25 Alain Magloire
|
||||||
|
|
||||||
Add HelpContext IDs in the preference page.
|
Add HelpContext IDs in the preference page.
|
||||||
|
|
|
@ -82,12 +82,13 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
|
||||||
public boolean acceptMatch( IMatch match ) throws CoreException
|
public boolean acceptMatch( IMatch match ) throws CoreException
|
||||||
{
|
{
|
||||||
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
|
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
|
||||||
if( searchMatch.resource == null )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( !super.acceptMatch( match ) )
|
if( !super.acceptMatch( match ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( searchMatch.resource == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
|
IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
|
||||||
|
|
||||||
HashMap markerAttributes = new HashMap( 2 );
|
HashMap markerAttributes = new HashMap( 2 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue