mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 70137: Cannot use context-search at template member definition
This commit is contained in:
parent
66af49f629
commit
2f5b010e80
3 changed files with 51 additions and 1 deletions
|
@ -171,6 +171,14 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
return fInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CEditor corresponding to this CContentOutlinePage.
|
||||
* @param return
|
||||
*/
|
||||
public CEditor getEditor() {
|
||||
return fEditor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the editor to signal that the content has updated.
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.search.DOMSearchUtil;
|
||||
|
@ -38,11 +39,14 @@ import org.eclipse.cdt.internal.ui.search.CSearchQuery;
|
|||
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
||||
import org.eclipse.cdt.internal.ui.search.DOMQuery;
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.text.TextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.search.ui.NewSearchUI;
|
||||
|
@ -95,7 +99,23 @@ public abstract class FindAction extends SelectionParseAction {
|
|||
ISelection sel = getSelection();
|
||||
|
||||
if (sel instanceof IStructuredSelection) {
|
||||
run((IStructuredSelection) sel);
|
||||
Object obj = ((IStructuredSelection)sel).getFirstElement();
|
||||
|
||||
// if possible, try to perform a full blown DOM query before the Index query, if this fails, then perform an Index query
|
||||
if (obj instanceof ISourceReference && fSite.getSelectionProvider() instanceof ProblemTreeViewer) {
|
||||
try {
|
||||
fEditor = ((ProblemTreeViewer)fSite.getSelectionProvider()).getEditor();
|
||||
IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
|
||||
ISourceReference ref = (ISourceReference)obj;
|
||||
|
||||
TextSelection selection = new TextSelection(doc, ref.getSourceRange().getIdStartPos(), ref.getSourceRange().getIdLength());
|
||||
run(selection);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
run((IStructuredSelection) sel);
|
||||
} else if (sel instanceof ITextSelection) {
|
||||
run((ITextSelection) sel);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,11 @@ package org.eclipse.cdt.internal.ui.util;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jface.viewers.IBaseLabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
@ -26,6 +29,7 @@ import org.eclipse.swt.widgets.Widget;
|
|||
public class ProblemTreeViewer extends TreeViewer {
|
||||
|
||||
protected ResourceToItemsMapper fResourceToItemsMapper;
|
||||
private CEditor editor = null;
|
||||
|
||||
/*
|
||||
* @see TreeViewer#TreeViewer(Composite)
|
||||
|
@ -141,5 +145,23 @@ public class ProblemTreeViewer extends TreeViewer {
|
|||
// or lots of TUs exist in one folder so lets skip it....
|
||||
return cp.hasChildren(element);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method declared on ISelectionProvider.
|
||||
*/
|
||||
public void addSelectionChangedListener(ISelectionChangedListener listener) {
|
||||
super.addSelectionChangedListener(listener);
|
||||
if (listener instanceof CContentOutlinePage) {
|
||||
editor =((CContentOutlinePage)listener).getEditor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the editor corresponding to the opened CEditor that is listening to the selection changes on the Outline View.
|
||||
* @return
|
||||
*/
|
||||
public CEditor getEditor() {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue