diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 2ab2f54d587..213031b856e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -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); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java index d21a527b031..7adfed80841 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java @@ -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(); @@ -119,7 +96,19 @@ public class SelectionParseAction extends Action { 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) { showStatusLineMessage(MessageFormat.format( CSearchMessages.SelectionParseAction_FileOpenFailure_format,