From 518cc7a686de5ca0f9e86d85f906438073c913c1 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Fri, 18 Jun 2004 11:56:07 +0000 Subject: [PATCH] Part 2 of Fix for Bug 62668 --- core/org.eclipse.cdt.ui/ChangeLog | 6 +++++ .../internal/ui/search/CSearchResultPage.java | 26 ++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index ce3b0866114..0cd08f78c33 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,9 @@ +2004-06-18 Bogdan Gheorghe + Part 2 of Fix for Bug 62668: [Search] Search results rely on case of file names in include statement + rather then the filesystem + + * src/org/eclipse/cdt/internal/ui/search/CSearchResultPage.java + 2004-06-18 Bogdan Gheorghe Partial Fix for Bug 62668: [Search] Search results rely on case of file names in include statement rather then the filesystem diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultPage.java index af22d07c0df..1e9abfc968e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultPage.java @@ -11,6 +11,8 @@ package org.eclipse.cdt.internal.ui.search; +import java.io.File; +import java.io.IOException; import java.util.HashMap; import org.eclipse.cdt.core.model.CModelException; @@ -26,6 +28,8 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; @@ -114,12 +118,12 @@ public class CSearchResultPage extends AbstractTextSearchViewPage { e.printStackTrace(); } } else if (element instanceof IFile) { - editor= IDE.openEditor(CUIPlugin.getActivePage(), (IFile) element, false); + editor= IDE.openEditor(CUIPlugin.getActivePage(), getCanonicalFile((IFile) element), false); } else if (element instanceof BasicSearchMatch){ BasicSearchMatch searchMatch = (BasicSearchMatch) element; if (searchMatch.resource != null){ - editor = IDE.openEditor(CUIPlugin.getActivePage(), (IFile) searchMatch.resource, false); - showWithMarker(editor, (IFile) searchMatch.resource, currentOffset, currentLength); + editor = IDE.openEditor(CUIPlugin.getActivePage(), getCanonicalFile((IFile) searchMatch.resource), false); + showWithMarker(editor, getCanonicalFile((IFile) searchMatch.resource), currentOffset, currentLength); }} if (editor instanceof ITextEditor) { ITextEditor textEditor= (ITextEditor) editor; @@ -127,7 +131,7 @@ public class CSearchResultPage extends AbstractTextSearchViewPage { } else if (editor != null){ if (element instanceof IFile) { IFile file= (IFile) element; - showWithMarker(editor, file, currentOffset, currentLength); + showWithMarker(editor, getCanonicalFile(file), currentOffset, currentLength); } } } @@ -257,5 +261,19 @@ public class CSearchResultPage extends AbstractTextSearchViewPage { addGroupActions(tbm); } + private IFile getCanonicalFile(IFile originalFile){ + + File tempFile = originalFile.getRawLocation().toFile(); + String canonicalPath = null; + try { + canonicalPath = tempFile.getCanonicalPath(); + } catch (IOException e1) {} + + if (canonicalPath != null){ + IPath path = new Path(canonicalPath); + originalFile = CUIPlugin.getWorkspace().getRoot().getFileForLocation(path); + } + return originalFile; + } }