mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 22:55:26 +02:00
Fix for external search markers
This commit is contained in:
parent
add4485083
commit
727994dc39
3 changed files with 62 additions and 9 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-04-21 Bogdan Gheorghe
|
||||
Fixed external markers not working with new Search UI problem.
|
||||
|
||||
2004-04-21 Alain Magloire
|
||||
Disable the PathEntry property page.
|
||||
|
||||
|
|
|
@ -58,10 +58,11 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
|
|||
} else if (element instanceof IFile) {
|
||||
editor= IDE.openEditor(CUIPlugin.getActivePage(), (IFile) element, false);
|
||||
} else if (element instanceof BasicSearchMatch){
|
||||
BasicSearchMatch x = (BasicSearchMatch) element;
|
||||
editor = IDE.openEditor(CUIPlugin.getActivePage(), (IFile) x.resource, false);
|
||||
showWithMarker(editor, (IFile) x.resource, currentOffset, currentLength);
|
||||
}
|
||||
BasicSearchMatch searchMatch = (BasicSearchMatch) element;
|
||||
if (searchMatch.resource != null){
|
||||
editor = IDE.openEditor(CUIPlugin.getActivePage(), (IFile) searchMatch.resource, false);
|
||||
showWithMarker(editor, (IFile) searchMatch.resource, currentOffset, currentLength);
|
||||
}}
|
||||
if (editor instanceof ITextEditor) {
|
||||
ITextEditor textEditor= (ITextEditor) editor;
|
||||
textEditor.selectAndReveal(currentOffset, currentLength);
|
||||
|
|
|
@ -11,14 +11,19 @@
|
|||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
import org.eclipse.cdt.core.search.BasicSearchResultCollector;
|
||||
import org.eclipse.cdt.core.search.IMatch;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.search.ui.text.Match;
|
||||
|
||||
public class NewSearchResultCollector extends BasicSearchResultCollector {
|
||||
|
@ -56,17 +61,61 @@ public class NewSearchResultCollector extends BasicSearchResultCollector {
|
|||
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#acceptMatch(org.eclipse.cdt.core.search.IMatch)
|
||||
*/
|
||||
public boolean acceptMatch(IMatch match) throws CoreException {
|
||||
|
||||
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
|
||||
|
||||
if (super.acceptMatch(match)){
|
||||
if( !super.acceptMatch( match ) )
|
||||
return false;
|
||||
|
||||
if( searchMatch.resource == null &&
|
||||
searchMatch.path == null)
|
||||
return false;
|
||||
|
||||
if (searchMatch.resource != null){
|
||||
fMatchCount++;
|
||||
int start = match.getStartOffset();
|
||||
int end = match.getEndOffset();
|
||||
fSearch.addMatch(new Match(match,start,end-start));
|
||||
return true;
|
||||
}
|
||||
|
||||
else {
|
||||
//Check to see if external markers are enabled
|
||||
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
|
||||
if (store.getBoolean(CSearchPage.EXTERNALMATCH_ENABLED)){
|
||||
//Create Link in referring file's project
|
||||
IPath refLocation = searchMatch.getReferenceLocation();
|
||||
IFile refFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(refLocation);
|
||||
IProject refProject = refFile.getProject();
|
||||
IPath externalMatchLocation = searchMatch.getLocation();
|
||||
IFile linksFile = refProject.getFile(externalMatchLocation.lastSegment());
|
||||
//Delete links file to keep up to date with latest prefs
|
||||
if (linksFile.exists())
|
||||
linksFile.delete(true,null);
|
||||
|
||||
//Check to see if the file already exists - create if doesn't, mark team private
|
||||
if (!linksFile.exists()){
|
||||
linksFile.createLink(externalMatchLocation,IResource.NONE,null);
|
||||
int number = store.getInt(CSearchPage.EXTERNALMATCH_VISIBLE);
|
||||
if (number==0){
|
||||
linksFile.setDerived(true);
|
||||
}
|
||||
else{
|
||||
linksFile.setTeamPrivateMember(true);
|
||||
}
|
||||
|
||||
}
|
||||
searchMatch.resource = linksFile;
|
||||
fMatchCount++;
|
||||
int start = match.getStartOffset();
|
||||
int end = match.getEndOffset();
|
||||
fSearch.addMatch(new Match(match,start,end-start));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue