mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 43664: Search should report matches outside of workspace
This commit is contained in:
parent
81a02aa350
commit
7c700e68e9
14 changed files with 337 additions and 84 deletions
|
@ -1,3 +1,20 @@
|
|||
2004-11-19 Bogdan Gheorghe
|
||||
Fix for 43664 : Search should report matches outside of workspace
|
||||
|
||||
* src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java
|
||||
* src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
|
||||
* src/org/eclipse/cdt/internal/ui/editor/ExternalSearchEditor.java
|
||||
* src/org/eclipse/cdt/internal/ui/editor/ExternalSearchFile.java
|
||||
* src/org/eclipse/cdt/internal/ui/preferences/CSearchPreferencePage.java
|
||||
* src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
|
||||
* src/org/eclipse/cdt/internal/ui/search/CSearchResultPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/search/NewSearchResultCollector.java
|
||||
* src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
|
||||
* src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
|
||||
* src/org/eclipse/cdt/ui/CUIPlugin.java
|
||||
* plugin.properties
|
||||
* plugin.xml
|
||||
|
||||
2004-11-12 David Inglis
|
||||
|
||||
Fixed bug # 78292
|
||||
|
|
|
@ -271,3 +271,6 @@ Folding.label= F&olding
|
|||
cCompareFontDefiniton.label= C/C++ compare text font
|
||||
cCompareFontDefiniton.description= The C/C++ compare text font is used by C/C++ compare/merge tools.
|
||||
|
||||
# External Search Editor
|
||||
|
||||
ExternalSearchEditor.name=External Search Editor
|
||||
|
|
|
@ -499,6 +499,13 @@
|
|||
class="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
|
||||
id="org.eclipse.cdt.ui.editor.asm.AsmEditor">
|
||||
</editor>
|
||||
<editor
|
||||
symbolicFontName="org.eclipse.cdt.ui.editors.textfont"
|
||||
class="org.eclipse.cdt.internal.ui.editor.ExternalSearchEditor"
|
||||
icon="icons/full/obj16/c_file_obj.gif"
|
||||
name="%ExternalSearchEditor.name"
|
||||
id="org.eclipse.cdt.ui.editor.ExternalSearchEditor"/>
|
||||
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.themes">
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/**********************************************************************
|
||||
Copyright (c) 2002, 2004 IBM Rational Software and others.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Common Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/cpl-v10.html
|
||||
|
||||
Contributors:
|
||||
IBM Rational Software - Initial Contribution
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
|
||||
|
||||
|
||||
public class ExternalSearchAnnotationModel extends
|
||||
AbstractMarkerAnnotationModel implements IResourceChangeListener {
|
||||
|
||||
protected IWorkspace fWorkspace;
|
||||
protected IResource fMarkerResource;
|
||||
protected boolean fChangesApplied;
|
||||
|
||||
/**
|
||||
* @param resource
|
||||
*/
|
||||
public ExternalSearchAnnotationModel(IResource resource) {
|
||||
this.fMarkerResource = resource;
|
||||
this.fWorkspace = resource.getWorkspace();
|
||||
}
|
||||
|
||||
protected IMarker[] retrieveMarkers() throws CoreException {
|
||||
if (fMarkerResource != null)
|
||||
return fMarkerResource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_INFINITE);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void deleteMarkers(IMarker[] markers) throws CoreException {
|
||||
}
|
||||
|
||||
protected void listenToMarkerChanges(boolean listen) {
|
||||
}
|
||||
|
||||
protected boolean isAcceptable(IMarker marker) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/**********************************************************************
|
||||
Copyright (c) 2002, 2004 IBM Rational Software and others.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Common Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/cpl-v10.html
|
||||
|
||||
Contributors:
|
||||
IBM Rational Software - Initial Contribution
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
import org.eclipse.ui.editors.text.FileDocumentProvider;
|
||||
|
||||
public class ExternalSearchDocumentProvider extends FileDocumentProvider {
|
||||
|
||||
public ExternalSearchDocumentProvider(){
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see AbstractDocumentProvider#createElementInfo(Object)
|
||||
*/
|
||||
protected ElementInfo createElementInfo(Object element) throws CoreException {
|
||||
|
||||
if (element instanceof ExternalEditorInput) {
|
||||
|
||||
ExternalEditorInput externalInput = (ExternalEditorInput) element;
|
||||
|
||||
IDocument d = createDocument(externalInput);
|
||||
IAnnotationModel m= createExternalSearchAnnotationModel(externalInput);
|
||||
|
||||
FileInfo info= new FileInfo(d, m, null);
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param externalInput
|
||||
* @return
|
||||
*/
|
||||
private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) {
|
||||
|
||||
Object storage = externalInput.getStorage();
|
||||
ExternalSearchFile externalSearchFile = null;
|
||||
if (storage instanceof ExternalSearchFile){
|
||||
externalSearchFile = (ExternalSearchFile) storage;
|
||||
}
|
||||
|
||||
if (externalSearchFile == null)
|
||||
return null;
|
||||
|
||||
IProject projectToUseForMarker = null;
|
||||
|
||||
IFile resourceFile = CUIPlugin.getWorkspace().getRoot().getFileForLocation(externalSearchFile.searchMatch.referringElement);
|
||||
|
||||
if (resourceFile == null){
|
||||
IProject[] proj = CUIPlugin.getWorkspace().getRoot().getProjects();
|
||||
|
||||
for (int i=0; i<proj.length; i++){
|
||||
if (proj[i].isOpen()){
|
||||
projectToUseForMarker = proj[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
projectToUseForMarker = resourceFile.getProject();
|
||||
}
|
||||
|
||||
if (projectToUseForMarker != null){
|
||||
ExternalSearchAnnotationModel model = new ExternalSearchAnnotationModel(projectToUseForMarker);
|
||||
return model;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see AbstractDocumentProvider#createDocument(Object)
|
||||
*/
|
||||
protected IDocument createDocument(Object element) throws CoreException {
|
||||
IDocument document= super.createDocument(element);
|
||||
if (document != null){
|
||||
CTextTools textTools = CUIPlugin.getDefault().getTextTools();
|
||||
textTools.setupCDocument(document);
|
||||
}
|
||||
return document;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/**********************************************************************
|
||||
Copyright (c) 2002, 2004 IBM Rational Software and others.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Common Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/cpl-v10.html
|
||||
|
||||
Contributors:
|
||||
IBM Rational Software - Initial Contribution
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
import org.eclipse.jface.action.IContributionItem;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
|
||||
public class ExternalSearchEditor extends CEditor {
|
||||
|
||||
public ExternalSearchEditor(){
|
||||
super();
|
||||
setDocumentProvider(CUIPlugin.getDefault().getExternalSearchDocumentProvider());
|
||||
}
|
||||
public void editorContextMenuAboutToShow(IMenuManager menu) {
|
||||
super.editorContextMenuAboutToShow(menu);
|
||||
IContributionItem[] contrItem = menu.getItems();
|
||||
for (int i=0; i<contrItem.length; i++){
|
||||
if (contrItem[i] instanceof ActionContributionItem)
|
||||
((ActionContributionItem) contrItem[i]).getAction().setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/**********************************************************************
|
||||
Copyright (c) 2002, 2004 IBM Rational Software and others.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Common Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/cpl-v10.html
|
||||
|
||||
Contributors:
|
||||
IBM Rational Software - Initial Contribution
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public class ExternalSearchFile extends FileStorage {
|
||||
|
||||
IPath referringElement;
|
||||
BasicSearchMatch searchMatch;
|
||||
/**
|
||||
* @param path
|
||||
*/
|
||||
public ExternalSearchFile(IPath path, BasicSearchMatch searchMatch) {
|
||||
super(path);
|
||||
this.searchMatch = searchMatch;
|
||||
}
|
||||
}
|
|
@ -23,8 +23,6 @@ import org.eclipse.jface.dialogs.IDialogConstants;
|
|||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
|
@ -41,7 +39,7 @@ public class CSearchPreferencePage extends PreferencePage
|
|||
implements
|
||||
IWorkbenchPreferencePage {
|
||||
|
||||
Combo fExternLinks;
|
||||
private Combo fExternLinks;
|
||||
private Button fExternEnabled;
|
||||
|
||||
protected OverlayPreferenceStore fOverlayStore;
|
||||
|
@ -83,38 +81,6 @@ public class CSearchPreferencePage extends PreferencePage
|
|||
layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
|
||||
result.setLayout(layout);
|
||||
|
||||
Group group= new Group(result, SWT.NONE);
|
||||
group.setLayout(new GridLayout());
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
group.setText(PreferencesMessages.getString("CSearchPreferences.ExternalSearchLinks.ExternalSearchLinksGroup")); //$NON-NLS-1$
|
||||
|
||||
fExternEnabled = createCheckButton(group, PreferencesMessages.getString("CSearchPreferences.ExternalSearchLinks.EnableMessage")); //$NON-NLS-1$
|
||||
fExternEnabled.addSelectionListener(new SelectionListener() {
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Button button = (Button) e.widget;
|
||||
boolean externLinkEnabled = false;
|
||||
fExternLinks.setEnabled(false);
|
||||
if (button.getSelection()){
|
||||
fExternLinks.setEnabled(true);
|
||||
externLinkEnabled = true;
|
||||
}
|
||||
|
||||
fOverlayStore.setValue(CSearchPage.EXTERNALMATCH_ENABLED, externLinkEnabled);
|
||||
}
|
||||
});
|
||||
|
||||
fExternLinks = createComboBox(group,PreferencesMessages.getString("CSearchPreferences.ExternalSearchLinks.EnableMarkerLinkType"),new String[]{PreferencesMessages.getString("CSearchPreferences.ExternalSearchLinks.Invisible")},PreferencesMessages.getString("CSearchPreferences.ExternalSearchLinks.Invisible")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
fExternLinks.addSelectionListener(new SelectionListener() {
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Combo combo = (Combo) e.widget;
|
||||
fOverlayStore.setValue(CSearchPage.EXTERNALMATCH_VISIBLE, combo.getSelectionIndex());
|
||||
}
|
||||
});
|
||||
|
||||
Group indexerTimeoutGroup= new Group(result, SWT.NONE);
|
||||
indexerTimeoutGroup.setLayout(new GridLayout());
|
||||
indexerTimeoutGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
@ -129,12 +95,6 @@ public class CSearchPreferencePage extends PreferencePage
|
|||
}
|
||||
|
||||
private void initialize(){
|
||||
boolean extEnabled = fOverlayStore.getBoolean(CSearchPage.EXTERNALMATCH_ENABLED);
|
||||
fExternEnabled.setSelection(extEnabled);
|
||||
|
||||
fExternLinks.select(fOverlayStore.getInt(CSearchPage.EXTERNALMATCH_VISIBLE));
|
||||
fExternLinks.setEnabled(extEnabled);
|
||||
|
||||
fTextControl.setText(fOverlayStore.getString(SourceIndexer.CDT_INDEXER_TIMEOUT));
|
||||
}
|
||||
|
||||
|
@ -216,8 +176,6 @@ public class CSearchPreferencePage extends PreferencePage
|
|||
* @param store
|
||||
*/
|
||||
public static void initDefaults(IPreferenceStore store) {
|
||||
store.setDefault(CSearchPage.EXTERNALMATCH_ENABLED, false);
|
||||
store.setDefault(CSearchPage.EXTERNALMATCH_VISIBLE, 0);
|
||||
store.setDefault(SourceIndexer.CDT_INDEXER_TIMEOUT,TIMEOUT_VALUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -127,6 +128,15 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
|||
else
|
||||
return false;
|
||||
}
|
||||
else if (editorInput instanceof ExternalEditorInput){
|
||||
String externalPath = ((ExternalEditorInput) editorInput).getFullPath();
|
||||
String searchMatchPath = searchMatch.getLocation().toString();
|
||||
if (searchMatchPath != null)
|
||||
return externalPath.equals(searchMatchPath);
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
} else if (match.getElement() instanceof IFile) {
|
||||
if (editorInput instanceof IFileEditorInput) {
|
||||
return ((IFileEditorInput)editorInput).getFile().equals(match.getElement());
|
||||
|
@ -217,9 +227,41 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
|||
IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
|
||||
return computeContainedMatches(result, fileEditorInput.getFile());
|
||||
}
|
||||
else if (editorInput instanceof ExternalEditorInput){
|
||||
ExternalEditorInput externalInput=(ExternalEditorInput) editorInput;
|
||||
return computerContainedMatches(result,externalInput.getFullPath());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result
|
||||
* @param fullPath
|
||||
* @return
|
||||
*/
|
||||
private Match[] computerContainedMatches(AbstractTextSearchResult result, String fullPath) {
|
||||
Set matches= new HashSet();
|
||||
Object[] test=result.getElements();
|
||||
collectMatches(matches, test, fullPath);
|
||||
return (Match[]) matches.toArray(new Match[matches.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param matches
|
||||
* @param test
|
||||
* @param fullPath
|
||||
*/
|
||||
private void collectMatches(Set matches, Object[] test, String fullPath) {
|
||||
for (int i=0; i<test.length; i++){
|
||||
Match[]testMatches=this.getMatches(test[i]);
|
||||
for (int k=0;k<testMatches.length;k++){
|
||||
String pathString = ((CSearchMatch) testMatches[k]).getSearchMatch().getLocation().toString();
|
||||
if (((CSearchMatch) testMatches[k]).getSearchMatch().getLocation().toString().equals(fullPath))
|
||||
matches.add(testMatches[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.search.ui.text.IFileMatchAdapter#computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult, org.eclipse.core.resources.IFile)
|
||||
*/
|
||||
|
@ -243,6 +285,9 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa
|
|||
for (int i=0; i<test.length; i++){
|
||||
Match[]testMatches=this.getMatches(test[i]);
|
||||
for (int k=0;k<testMatches.length;k++){
|
||||
if (((CSearchMatch) testMatches[k]).getSearchMatch().getResource() == null)
|
||||
continue;
|
||||
|
||||
if (((CSearchMatch) testMatches[k]).getSearchMatch().getResource().equals(file))
|
||||
matches.add(testMatches[k]);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.editor.ExternalSearchFile;
|
||||
import org.eclipse.cdt.internal.ui.search.actions.GroupAction;
|
||||
import org.eclipse.cdt.internal.ui.search.actions.SortAction;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
|
@ -42,7 +43,9 @@ import org.eclipse.search.ui.NewSearchUI;
|
|||
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
||||
import org.eclipse.search.ui.text.Match;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
@ -124,7 +127,20 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
|
|||
if (searchMatch.resource != null){
|
||||
editor = IDE.openEditor(CUIPlugin.getActivePage(), getCanonicalFile((IFile) searchMatch.resource), false);
|
||||
showWithMarker(editor, getCanonicalFile((IFile) searchMatch.resource), currentOffset, currentLength);
|
||||
}}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
IEditorInput input =EditorUtility.getEditorInput(new ExternalSearchFile(searchMatch.path, searchMatch));
|
||||
IWorkbenchPage p= CUIPlugin.getActivePage();
|
||||
IEditorPart editorPart= p.openEditor(input, "org.eclipse.cdt.ui.editor.ExternalSearchEditor"); //$NON-NLS-1$
|
||||
if (editorPart instanceof ITextEditor) {
|
||||
ITextEditor textEditor= (ITextEditor) editorPart;
|
||||
textEditor.selectAndReveal(searchMatch.startOffset, searchMatch.endOffset - searchMatch.startOffset);
|
||||
}
|
||||
} catch (CModelException e) {}
|
||||
catch (CoreException e) {}
|
||||
}
|
||||
}
|
||||
if (editor instanceof ITextEditor) {
|
||||
ITextEditor textEditor= (ITextEditor) editor;
|
||||
textEditor.selectAndReveal(currentOffset, currentLength);
|
||||
|
|
|
@ -11,20 +11,17 @@
|
|||
|
||||
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.search.BasicSearchMatch;
|
||||
import org.eclipse.cdt.core.search.BasicSearchResultCollector;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
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 {
|
||||
|
@ -98,42 +95,14 @@ public class NewSearchResultCollector extends BasicSearchResultCollector {
|
|||
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 = getUniqueFile(externalMatchLocation, refProject);
|
||||
//Delete links file to keep up to date with latest prefs
|
||||
if (linksFile.exists() &&
|
||||
linksFile.isLinked())
|
||||
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.setTeamPrivateMember(true);
|
||||
}
|
||||
|
||||
}
|
||||
searchMatch.resource = linksFile;
|
||||
searchMatch.path = externalMatchLocation;
|
||||
fMatchCount++;
|
||||
int start = match.getStartOffset();
|
||||
int end = match.getEndOffset();
|
||||
String classifier = PARENT + match.getParentName() + NAME + match.getName() + LOCATION + match.getLocation().toOSString() + ELEMENTTYPE + match.getElementType() + VISIBILITY + match.getVisibility();
|
||||
fSearch.addMatch(new CSearchMatch(classifier,start,end-start, match));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
fMatchCount++;
|
||||
int start = match.getStartOffset();
|
||||
int end = match.getEndOffset();
|
||||
String classifier = PARENT + match.getParentName() + NAME + match.getName() + LOCATION + match.getLocation().toOSString() + ELEMENTTYPE + match.getElementType() + VISIBILITY + match.getVisibility();
|
||||
fSearch.addMatch(new CSearchMatch(classifier,start,end-start, match));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.editor.ExternalSearchEditor;
|
||||
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
||||
|
@ -66,6 +67,9 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
public void fillContextMenu(IMenuManager menu) {
|
||||
super.fillContextMenu(menu);
|
||||
|
||||
if ((fEditor != null) && (fEditor instanceof ExternalSearchEditor))
|
||||
return;
|
||||
|
||||
IMenuManager incomingMenu = menu;
|
||||
|
||||
IMenuManager declarationsMenu = new MenuManager(CSearchMessages.getString("group.declarations"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.editor.ExternalSearchEditor;
|
||||
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
||||
|
@ -62,6 +63,9 @@ public class ReferencesSearchGroup extends ActionGroup {
|
|||
|
||||
super.fillContextMenu(menu);
|
||||
|
||||
if ((fEditor != null) && (fEditor instanceof ExternalSearchEditor))
|
||||
return;
|
||||
|
||||
IMenuManager incomingMenu = menu;
|
||||
|
||||
IMenuManager refsMenu = new MenuManager(CSearchMessages.getString("group.references"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
|
||||
|
|
|
@ -32,9 +32,11 @@ import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
|
|||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||
import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
|
||||
import org.eclipse.cdt.internal.ui.browser.typehierarchy.ITypeHierarchyViewPart;
|
||||
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
|
||||
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
|
||||
import org.eclipse.cdt.internal.ui.editor.CustomBufferFactory;
|
||||
import org.eclipse.cdt.internal.ui.editor.ExternalSearchDocumentProvider;
|
||||
import org.eclipse.cdt.internal.ui.editor.SharedTextColors;
|
||||
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
|
||||
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
|
||||
|
@ -315,6 +317,7 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
|
||||
private CoreModel fCoreModel;
|
||||
private CDocumentProvider fDocumentProvider;
|
||||
private ExternalSearchDocumentProvider fExternalDocumentProvider;
|
||||
private IBufferFactory fBufferFactory;
|
||||
private WorkingCopyManager fWorkingCopyManager;
|
||||
private CTextTools fTextTools;
|
||||
|
@ -339,7 +342,16 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
}
|
||||
return fDocumentProvider;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the used external search document provider
|
||||
*/
|
||||
public synchronized ExternalSearchDocumentProvider getExternalSearchDocumentProvider() {
|
||||
if (fExternalDocumentProvider == null) {
|
||||
fExternalDocumentProvider = new ExternalSearchDocumentProvider();
|
||||
}
|
||||
return fExternalDocumentProvider;
|
||||
}
|
||||
/**
|
||||
* Returns the working copy manager
|
||||
* @return IWorkingCopyManager
|
||||
|
|
Loading…
Add table
Reference in a new issue