1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Part 2 of Fix for Bug 62668

This commit is contained in:
Bogdan Gheorghe 2004-06-18 11:56:07 +00:00
parent 564b89c196
commit 518cc7a686
2 changed files with 28 additions and 4 deletions

View file

@ -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 2004-06-18 Bogdan Gheorghe
Partial Fix for Bug 62668: [Search] Search results rely on case of file names in include statement Partial Fix for Bug 62668: [Search] Search results rely on case of file names in include statement
rather then the filesystem rather then the filesystem

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
import java.io.File;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.cdt.core.model.CModelException; 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.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException; 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.IMenuManager;
import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.MenuManager;
@ -114,12 +118,12 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
e.printStackTrace(); e.printStackTrace();
} }
} else if (element instanceof IFile) { } 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){ } else if (element instanceof BasicSearchMatch){
BasicSearchMatch searchMatch = (BasicSearchMatch) element; BasicSearchMatch searchMatch = (BasicSearchMatch) element;
if (searchMatch.resource != null){ if (searchMatch.resource != null){
editor = IDE.openEditor(CUIPlugin.getActivePage(), (IFile) searchMatch.resource, false); editor = IDE.openEditor(CUIPlugin.getActivePage(), getCanonicalFile((IFile) searchMatch.resource), false);
showWithMarker(editor, (IFile) searchMatch.resource, currentOffset, currentLength); showWithMarker(editor, getCanonicalFile((IFile) searchMatch.resource), currentOffset, currentLength);
}} }}
if (editor instanceof ITextEditor) { if (editor instanceof ITextEditor) {
ITextEditor textEditor= (ITextEditor) editor; ITextEditor textEditor= (ITextEditor) editor;
@ -127,7 +131,7 @@ public class CSearchResultPage extends AbstractTextSearchViewPage {
} else if (editor != null){ } else if (editor != null){
if (element instanceof IFile) { if (element instanceof IFile) {
IFile file= (IFile) element; 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); 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;
}
} }