diff options
author | Greg Watson | 2011-08-17 10:27:48 +0000 |
---|---|---|
committer | Markus Schorn | 2011-08-17 10:27:48 +0000 |
commit | ffca7f9d6bc38f101c22a80acafea04f18c5119b (patch) | |
tree | 00e1c0a746dd081c414771de84d73ac6103ba08d | |
parent | c17176f43ce1a8e10fb6f3a13101262256bd9f95 (diff) | |
download | org.eclipse.cdt-ffca7f9d6bc38f101c22a80acafea04f18c5119b.tar.gz org.eclipse.cdt-ffca7f9d6bc38f101c22a80acafea04f18c5119b.tar.xz org.eclipse.cdt-ffca7f9d6bc38f101c22a80acafea04f18c5119b.zip |
Bug 349730: Content for non-local files
-rw-r--r-- | core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java index 76688c442ce..bc2f1d5a5d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -154,6 +155,20 @@ public class InternalParserUtil extends ParserFactory { InputStream in; try { in= file.getContents(true); + if (!(in instanceof FileInputStream)) { + /* + * In general, non-local file-systems will not use FileInputStream. Instead make a + * cached copy of the file and open an input stream to that. + */ + IFileStore store = EFS.getStore(file.getLocationURI()); + File fileCache = store.toLocalFile(EFS.CACHE, null); + try { + in = new FileInputStream(fileCache); + } catch (FileNotFoundException e) { + CCorePlugin.log(e); + return null; + } + } try { return createFileContent(path, file.getCharset(), in); } finally { @@ -221,6 +236,9 @@ public class InternalParserUtil extends ParserFactory { private static InternalFileContent createFileContent(String path, String charset, InputStream in) { try { AbstractCharArray chars= FileCharArray.create(path, charset, in); + if (chars == null) + return null; + return new InternalFileContent(path, chars); } catch (IOException e) { CCorePlugin.log(e); |