mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 21:35:40 +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 {
|
||||
sourceRange = target.getSourceRange();
|
||||
if (tu != null && sourceRange != null) {
|
||||
fAction.open(tu.getLocation(), sourceRange.getIdStartPos(), sourceRange.getIdLength());
|
||||
fAction.open(tu, sourceRange.getIdStartPos(), sourceRange.getIdLength());
|
||||
}
|
||||
} catch (CoreException 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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,11 +14,8 @@
|
|||
|
||||
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.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -26,8 +23,9 @@ import org.eclipse.ui.IEditorPart;
|
|||
import org.eclipse.ui.IWorkbenchSite;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
|
@ -87,27 +85,6 @@ public class SelectionParseAction extends Action {
|
|||
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 {
|
||||
clearStatusLine();
|
||||
|
||||
|
@ -120,6 +97,18 @@ public class SelectionParseAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
showStatusLineMessage(MessageFormat.format(
|
||||
CSearchMessages.SelectionParseAction_FileOpenFailure_format,
|
||||
|
|
Loading…
Add table
Reference in a new issue