mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
Bug 307362: open definition for sym-linked duplicates.
This commit is contained in:
parent
d7c1b4bf22
commit
2361b4c075
2 changed files with 18 additions and 29 deletions
|
@ -474,7 +474,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
||||||
try {
|
try {
|
||||||
sourceRange = target.getSourceRange();
|
sourceRange = target.getSourceRange();
|
||||||
if (tu != null && sourceRange != null) {
|
if (tu != null && sourceRange != null) {
|
||||||
fAction.open(tu.getLocation(), sourceRange.getIdStartPos(), sourceRange.getIdLength());
|
fAction.open(tu, sourceRange.getIdStartPos(), sourceRange.getIdLength());
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,11 +14,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search.actions;
|
package org.eclipse.cdt.internal.ui.search.actions;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
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.Path;
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -26,8 +23,9 @@ import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import com.ibm.icu.text.MessageFormat;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||||
|
@ -87,27 +85,6 @@ public class SelectionParseAction extends Action {
|
||||||
return (ITextSelection) selection;
|
return (ITextSelection) selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the editor on the given name.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
protected void open(IName name) throws CoreException {
|
|
||||||
clearStatusLine();
|
|
||||||
|
|
||||||
IASTFileLocation fileloc = name.getFileLocation();
|
|
||||||
if (fileloc == null) {
|
|
||||||
reportSymbolLookupFailure(name.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPath path = new Path(fileloc.getFileName());
|
|
||||||
int currentOffset = fileloc.getNodeOffset();
|
|
||||||
int currentLength = fileloc.getNodeLength();
|
|
||||||
|
|
||||||
open(path, currentOffset, currentLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void open(IPath path, int currentOffset, int currentLength) throws CoreException {
|
protected void open(IPath path, int currentOffset, int currentLength) throws CoreException {
|
||||||
clearStatusLine();
|
clearStatusLine();
|
||||||
|
|
||||||
|
@ -119,7 +96,19 @@ public class SelectionParseAction extends Action {
|
||||||
reportSourceFileOpenFailure(path);
|
reportSourceFileOpenFailure(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void open(ITranslationUnit tu, int currentOffset, int currentLength) throws CoreException {
|
||||||
|
clearStatusLine();
|
||||||
|
|
||||||
|
IEditorPart editor = EditorUtility.openInEditor(tu, true);
|
||||||
|
if (editor instanceof ITextEditor) {
|
||||||
|
ITextEditor textEditor = (ITextEditor) editor;
|
||||||
|
textEditor.selectAndReveal(currentOffset, currentLength);
|
||||||
|
} else {
|
||||||
|
reportSourceFileOpenFailure(tu.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void reportSourceFileOpenFailure(IPath path) {
|
protected void reportSourceFileOpenFailure(IPath path) {
|
||||||
showStatusLineMessage(MessageFormat.format(
|
showStatusLineMessage(MessageFormat.format(
|
||||||
CSearchMessages.SelectionParseAction_FileOpenFailure_format,
|
CSearchMessages.SelectionParseAction_FileOpenFailure_format,
|
||||||
|
|
Loading…
Add table
Reference in a new issue