mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fix for Bug 63957: Error with external search markers & changed label
provider to provide proper paths for external links
This commit is contained in:
parent
f5ae1a741d
commit
b0fba2c9e5
4 changed files with 49 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-06-15 Bogdan Gheorghe
|
||||
Fix for Bug 63957: Error with external search markers - changed label
|
||||
provider to provide proper paths for external links
|
||||
|
||||
2004-06-15 Bogdan Gheorghe
|
||||
Disable background type cache on startup for now
|
||||
|
||||
|
|
|
@ -216,8 +216,8 @@ public class CSearchPreferencePage extends PreferencePage
|
|||
* @param store
|
||||
*/
|
||||
public static void initDefaults(IPreferenceStore store) {
|
||||
store.setDefault(CSearchPage.EXTERNALMATCH_ENABLED, true);
|
||||
store.setDefault(CSearchPage.EXTERNALMATCH_VISIBLE, 1);
|
||||
store.setDefault(CSearchPage.EXTERNALMATCH_ENABLED, false);
|
||||
store.setDefault(CSearchPage.EXTERNALMATCH_VISIBLE, 0);
|
||||
store.setDefault(SourceIndexer.CDT_INDEXER_TIMEOUT,TIMEOUT_VALUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class NewSearchResultCollector extends BasicSearchResultCollector {
|
|||
IFile refFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(refLocation);
|
||||
IProject refProject = refFile.getProject();
|
||||
IPath externalMatchLocation = searchMatch.getLocation();
|
||||
IFile linksFile = refProject.getFile("_cdtsrchlnk_" + externalMatchLocation.lastSegment()); //$NON-NLS-1$
|
||||
IFile linksFile = getUniqueFile(externalMatchLocation, refProject);
|
||||
//Delete links file to keep up to date with latest prefs
|
||||
if (linksFile.exists() &&
|
||||
linksFile.isLinked())
|
||||
|
@ -106,6 +106,7 @@ public class NewSearchResultCollector extends BasicSearchResultCollector {
|
|||
|
||||
}
|
||||
searchMatch.resource = linksFile;
|
||||
searchMatch.path = externalMatchLocation;
|
||||
fMatchCount++;
|
||||
int start = match.getStartOffset();
|
||||
int end = match.getEndOffset();
|
||||
|
@ -119,4 +120,36 @@ public class NewSearchResultCollector extends BasicSearchResultCollector {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param externalMatchLocation
|
||||
* @param refProject
|
||||
* @return
|
||||
*/
|
||||
private IFile getUniqueFile(IPath externalMatchLocation, IProject refProject) {
|
||||
IFile file = null;
|
||||
String fileName = ""; //$NON-NLS-1$
|
||||
//Total number of segments in file name
|
||||
int segments = externalMatchLocation.segmentCount() - 1;
|
||||
for (int linkNumber=0; linkNumber<Integer.MAX_VALUE; linkNumber++){
|
||||
if (fileName !="") //$NON-NLS-1$
|
||||
fileName = "lnk" + linkNumber + "_" + externalMatchLocation.segment(segments); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
else
|
||||
fileName = externalMatchLocation.segment(segments);
|
||||
|
||||
file=refProject.getFile(fileName);
|
||||
IPath path = file.getLocation();
|
||||
|
||||
//If the location passed in is equal to a location of a file
|
||||
//that is already linked then return the file
|
||||
if (externalMatchLocation.equals(path))
|
||||
break;
|
||||
|
||||
//If the file doesn't already exist in the workspace return
|
||||
if (!file.exists())
|
||||
break;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -158,7 +158,15 @@ public class CSearchResultLabelProvider extends LabelProvider {
|
|||
IResource resource = match.getResource();
|
||||
|
||||
String result = ""; //$NON-NLS-1$
|
||||
String path = (resource != null ) ? resource.getFullPath().toString() : ""; //$NON-NLS-1$
|
||||
String path = ""; //$NON-NLS-1$
|
||||
if (resource != null){
|
||||
if (resource.isLinked()){
|
||||
path = match.getLocation().toOSString();
|
||||
}
|
||||
else{
|
||||
path = resource.getFullPath().toOSString();
|
||||
}
|
||||
}
|
||||
|
||||
switch( getOrder() ){
|
||||
case SHOW_NAME_ONLY:
|
||||
|
|
Loading…
Add table
Reference in a new issue