mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +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
|
2004-04-21 Alain Magloire
|
||||||
Disable the PathEntry property page.
|
Disable the PathEntry property page.
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,11 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
|
||||||
} else if (element instanceof IFile) {
|
} else if (element instanceof IFile) {
|
||||||
editor= IDE.openEditor(CUIPlugin.getActivePage(), (IFile) element, false);
|
editor= IDE.openEditor(CUIPlugin.getActivePage(), (IFile) element, false);
|
||||||
} else if (element instanceof BasicSearchMatch){
|
} else if (element instanceof BasicSearchMatch){
|
||||||
BasicSearchMatch x = (BasicSearchMatch) element;
|
BasicSearchMatch searchMatch = (BasicSearchMatch) element;
|
||||||
editor = IDE.openEditor(CUIPlugin.getActivePage(), (IFile) x.resource, false);
|
if (searchMatch.resource != null){
|
||||||
showWithMarker(editor, (IFile) x.resource, currentOffset, currentLength);
|
editor = IDE.openEditor(CUIPlugin.getActivePage(), (IFile) searchMatch.resource, false);
|
||||||
}
|
showWithMarker(editor, (IFile) searchMatch.resource, currentOffset, currentLength);
|
||||||
|
}}
|
||||||
if (editor instanceof ITextEditor) {
|
if (editor instanceof ITextEditor) {
|
||||||
ITextEditor textEditor= (ITextEditor) editor;
|
ITextEditor textEditor= (ITextEditor) editor;
|
||||||
textEditor.selectAndReveal(currentOffset, currentLength);
|
textEditor.selectAndReveal(currentOffset, currentLength);
|
||||||
|
|
|
@ -11,14 +11,19 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
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.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.BasicSearchResultCollector;
|
||||||
import org.eclipse.cdt.core.search.IMatch;
|
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.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.search.ui.text.Match;
|
import org.eclipse.search.ui.text.Match;
|
||||||
|
|
||||||
public class NewSearchResultCollector extends BasicSearchResultCollector {
|
public class NewSearchResultCollector extends BasicSearchResultCollector {
|
||||||
|
@ -57,15 +62,59 @@ public class NewSearchResultCollector extends BasicSearchResultCollector {
|
||||||
*/
|
*/
|
||||||
public boolean acceptMatch(IMatch match) throws CoreException {
|
public boolean acceptMatch(IMatch match) throws CoreException {
|
||||||
|
|
||||||
if (super.acceptMatch(match)){
|
BasicSearchMatch searchMatch = (BasicSearchMatch) match;
|
||||||
|
|
||||||
|
if( !super.acceptMatch( match ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( searchMatch.resource == null &&
|
||||||
|
searchMatch.path == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (searchMatch.resource != null){
|
||||||
fMatchCount++;
|
fMatchCount++;
|
||||||
int start = match.getStartOffset();
|
int start = match.getStartOffset();
|
||||||
int end = match.getEndOffset();
|
int end = match.getEndOffset();
|
||||||
fSearch.addMatch(new Match(match,start,end-start));
|
fSearch.addMatch(new Match(match,start,end-start));
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue