| author | Greg Watson | 2013-02-01 16:13:24 (EST) |
|---|---|---|
| committer | Sergey Prigogin | 2013-02-01 16:35:39 (EST) |
| commit | f63c877df9e068f2088bbd7ca9ea4b2e8e7f1a42 (patch) (side-by-side diff) | |
| tree | b41c250ffe48efe24748526ddb34bdd04a733450 | |
| parent | 2bc9035f8c9f52455f923e0f7a16a6e41842b067 (diff) | |
| download | org.eclipse.cdt-f63c877df9e068f2088bbd7ca9ea4b2e8e7f1a42.zip org.eclipse.cdt-f63c877df9e068f2088bbd7ca9ea4b2e8e7f1a42.tar.gz org.eclipse.cdt-f63c877df9e068f2088bbd7ca9ea4b2e8e7f1a42.tar.bz2 | |
Change-Id: If8ff6c840c82d1174c8cec79f9b038bd30267cb7
Reviewed-on: https://git.eclipse.org/r/9982
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
4 files changed, 39 insertions, 26 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java index 4682d18..bb1c9b5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java @@ -38,6 +38,7 @@ import org.eclipse.cdt.core.model.IPathEntryContainer; import org.eclipse.cdt.core.model.IProjectEntry; import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.resources.IPathEntryVariableManager; +import org.eclipse.cdt.utils.UNCPathConverter; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -513,6 +514,9 @@ public class PathEntryUtil { private static boolean isValidExternalPath(IPath path) { if (path != null) { + if (path.isUNC()) { + return true; + } File file = path.toFile(); if (file != null) { return file.exists(); 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 a9de019..456eec9 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,7 +13,6 @@ 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; @@ -159,26 +158,15 @@ public class InternalParserUtil extends ParserFactory { IFileStore store = EFS.getStore(file.getLocationURI()); IFileInfo fileInfo = store.fetchInfo(); input= file.getContents(true); - if (!(input 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. - */ - File fileCache = store.toLocalFile(EFS.CACHE, null); + if (input instanceof FileInputStream) { try { - input = new FileInputStream(fileCache); - } catch (FileNotFoundException e) { - CCorePlugin.log(e); - return null; - } - } - try { - return createFileContent(path, file.getCharset(), input, - fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime); - } finally { - try { - input.close(); - } catch (IOException e) { + return createFileContent(path, null, file.getCharset(), input, + fileInfo.getLastModified(), fileInfo.getLength(), fileReadTime); + } finally { + try { + input.close(); + } catch (IOException e) { + } } } } catch (CoreException e) { @@ -193,18 +181,19 @@ public class InternalParserUtil extends ParserFactory { CCorePlugin.log(e); break; } - return null; } + return null; } /** * Creates a code reader for an external location, normalizing path to * canonical path. */ - public static InternalFileContent createExternalFileContent(String externalLocation, String encoding) { + public static InternalFileContent createExternalFileContent(final String externalLocation, String encoding) { long fileReadTime = System.currentTimeMillis(); File includeFile = null; String path = null; + String localPath = null; if (!UNCPathConverter.isUNC(externalLocation)) { includeFile = new File(externalLocation); // Use the canonical path so that in case of non-case-sensitive OSs @@ -216,6 +205,7 @@ public class InternalParserUtil extends ParserFactory { IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(externalLocation)); includeFile = store.toLocalFile(EFS.CACHE, null); path = externalLocation; + localPath = includeFile.getAbsolutePath(); } catch (CoreException e) { } } @@ -230,7 +220,7 @@ public class InternalParserUtil extends ParserFactory { return null; } try { - return createFileContent(path, encoding, in, timestamp, fileSize, fileReadTime); + return createFileContent(path, localPath, encoding, in, timestamp, fileSize, fileReadTime); } finally { try { in.close(); @@ -241,10 +231,13 @@ public class InternalParserUtil extends ParserFactory { return null; } - private static InternalFileContent createFileContent(String path, String charset, InputStream in, + private static InternalFileContent createFileContent(String path, String localPath, String charset, InputStream in, long fileTimestamp, long fileSize, long fileReadTime) { + if (localPath == null) { + localPath = path; + } try { - AbstractCharArray chars= FileCharArray.create(path, charset, in); + AbstractCharArray chars= FileCharArray.create(localPath, charset, in); if (chars == null) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java index 1899ef3..ff79a12 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java @@ -28,6 +28,10 @@ import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; +import org.eclipse.cdt.utils.UNCPathConverter; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.runtime.CoreException; /** * Internal implementation of the file content providers @@ -49,7 +53,16 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv /** * Checks whether the specified inclusion exists. */ - public boolean getInclusionExists(String path) { + public boolean getInclusionExists(final String path) { + if (UNCPathConverter.isUNC(path)) { + try { + IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(path)); + return store.fetchInfo().exists(); + } catch (CoreException e) { + return false; + } + } + return new File(path).exists(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java index 7e26e3a..92044bf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/LanguageSettingsImages.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.UNCPathConverter;
/**
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
@@ -168,6 +169,8 @@ public class LanguageSettingsImages { IPath path = new Path(entry.getValue());
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
exists = (rc !=null) && rc.isAccessible();
+ } else if (UNCPathConverter.isUNC(entry.getName())) {
+ return true;
} else {
String pathname = entry.getName();
java.io.File file = new java.io.File(pathname);
|

