From 6d991143ef0742e35c453eeb53bb5ff4c2ead522 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Thu, 4 May 2006 14:38:02 +0000 Subject: [PATCH] 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. --- .../org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java | 7 ++----- .../cdt/internal/core/pdom/PDOMCodeReaderFactory.java | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java index 1c679186108..d148b430855 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java @@ -113,14 +113,11 @@ public class GCCLanguage extends PlatformObject implements ILanguage { PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class); CodeReader reader; IFile rfile = (IFile)file.getResource(); + String path = rfile != null ? rfile.getLocation().toOSString() : file.getPath().toOSString(); if (file instanceof IWorkingCopy) { // get the working copy contents - reader = new CodeReader(((IWorkingCopy)file).getOriginalElement().getPath().toOSString(), file.getContents()); + reader = new CodeReader(path, file.getContents()); } else { - String path - = rfile != null - ? rfile.getLocation().toOSString() - : file.getPath().toOSString(); reader = codeReaderFactory.createCodeReaderForTranslationUnit(path); if (reader == null) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java index 83745efa9c7..0fe993994a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMCodeReaderFactory.java @@ -97,6 +97,9 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory { // Don't parse inclusion if it is already captured try { try { + File file = new File(path); + if (!file.exists()) + return null; path = new File(path).getCanonicalPath(); } catch (IOException e) { // ignore and use the path we were passed in