1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

Fix for 140118. Use the getLocation on the working copy's resource to the the correct filename. Also, make sure we return a null code reader when trying to include a file that's not there.

This commit is contained in:
Doug Schaefer 2006-05-04 14:38:02 +00:00
parent 65b8437bda
commit 6d991143ef
2 changed files with 5 additions and 5 deletions

View file

@ -113,14 +113,11 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class); PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class);
CodeReader reader; CodeReader reader;
IFile rfile = (IFile)file.getResource(); IFile rfile = (IFile)file.getResource();
String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString();
if (file instanceof IWorkingCopy) { if (file instanceof IWorkingCopy) {
// get the working copy contents // get the working copy contents
reader = new CodeReader(((IWorkingCopy)file).getOriginalElement().getPath().toOSString(), file.getContents()); reader = new CodeReader(path, file.getContents());
} else { } else {
String path
= rfile != null
? rfile.getLocation().toOSString()
: file.getPath().toOSString();
reader = codeReaderFactory.createCodeReaderForTranslationUnit(path); reader = codeReaderFactory.createCodeReaderForTranslationUnit(path);
if (reader == null) if (reader == null)
return null; return null;

View file

@ -97,6 +97,9 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
// Don't parse inclusion if it is already captured // Don't parse inclusion if it is already captured
try { try {
try { try {
File file = new File(path);
if (!file.exists())
return null;
path = new File(path).getCanonicalPath(); path = new File(path).getCanonicalPath();
} catch (IOException e) { } catch (IOException e) {
// ignore and use the path we were passed in // ignore and use the path we were passed in