# HG changeset patch # User Vladimir Kvashin # Date 1423172302 -10800 # Node ID f22b2d32dba71a3e1c6e448ad3a2d7ddf5c50398 # Parent f7dd9ddf59f7818d2ec230585a170803682b64fe fix for #249533 - Remote code model never gets notification when a header is created diff -r f7dd9ddf59f7 -r f22b2d32dba7 cnd.utils/nbproject/project.properties --- a/cnd.utils/nbproject/project.properties Thu Feb 05 19:00:02 2015 +0300 +++ b/cnd.utils/nbproject/project.properties Fri Feb 06 00:38:22 2015 +0300 @@ -1,6 +1,6 @@ javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.6 -spec.version.base=1.45.5 +spec.version.base=1.45.6 test.config.stableBTD.includes=**/*Test.class test.config.stableBTD.excludes=\ diff -r f7dd9ddf59f7 -r f22b2d32dba7 cnd.utils/src/org/netbeans/modules/cnd/utils/FSPath.java --- a/cnd.utils/src/org/netbeans/modules/cnd/utils/FSPath.java Thu Feb 05 19:00:02 2015 +0300 +++ b/cnd.utils/src/org/netbeans/modules/cnd/utils/FSPath.java Fri Feb 06 00:38:22 2015 +0300 @@ -44,6 +44,7 @@ import org.netbeans.modules.cnd.spi.utils.CndFileSystemProvider; import org.netbeans.modules.cnd.utils.cache.CndFileUtils; +import org.netbeans.modules.dlight.libs.common.PathUtilities; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileSystem; @@ -89,6 +90,15 @@ return fileSystem.findResource(path); } + public FSPath getParent() { + String parentPath = PathUtilities.getDirName(path); + return (parentPath == null) ? null : new FSPath(fileSystem, parentPath); + } + + public FSPath getChild(String childName) { + return new FSPath(fileSystem, path + CndFileUtils.getFileSeparatorChar(fileSystem) + childName); + } + public CharSequence getURL() { return CndFileSystemProvider.toUrl(this); } diff -r f7dd9ddf59f7 -r f22b2d32dba7 cnd.utils/src/org/netbeans/modules/cnd/utils/cache/CndFileUtils.java --- a/cnd.utils/src/org/netbeans/modules/cnd/utils/cache/CndFileUtils.java Thu Feb 05 19:00:02 2015 +0300 +++ b/cnd.utils/src/org/netbeans/modules/cnd/utils/cache/CndFileUtils.java Fri Feb 06 00:38:22 2015 +0300 @@ -138,7 +138,7 @@ caseSenstive = Utilities.isUnix() && !Utilities.isMac(); } TRUE_CASE_SENSITIVE_SYSTEM = caseSenstive; - FileUtil.addFileChangeListener(FSL); + CndFileSystemProvider.addFileChangeListener(FSL); } public static boolean isSystemCaseSensitive() { @@ -732,11 +732,10 @@ } @Override - public void fileFolderCreated(FileEvent fe) { - File file = CndFileUtils.toFile(fe.getFile()); - String path = file.getAbsolutePath(); - String absPath = preparePath(path); - if (getFilesMap(getLocalFileSystem()).put(absPath, Flags.DIRECTORY) != null) { + public void fileFolderCreated(FileEvent fe) { + String path = checkSeparators(fe.getFile()); + String absPath = changeStringCaseIfNeeded(getFileSystem(fe), path); + if (getFilesMap(getFileSystem(fe)).put(absPath, Flags.DIRECTORY) != null) { // If there was something in the map already - invalidate it invalidateFile(path, absPath); } @@ -744,10 +743,9 @@ @Override public void fileDataCreated(FileEvent fe) { - File file = CndFileUtils.toFile(fe.getFile()); - String path = file.getAbsolutePath(); - String absPath = preparePath(path); - if (getFilesMap(getLocalFileSystem()).put(absPath, Flags.FILE) != null) { + String path = checkSeparators(fe.getFile()); + String absPath = changeStringCaseIfNeeded(getFileSystem(fe), path); + if (getFilesMap(getFileSystem(fe)).put(absPath, Flags.FILE) != null) { // If there was something in the map already - invalidate it invalidateFile(path, absPath); } @@ -760,12 +758,12 @@ @Override public void fileRenamed(FileRenameEvent fe) { - final File parent = clearCachesAboutFile(fe); + final FSPath parent = clearCachesAboutFile(fe); // update info about old file as well if (parent != null) { final String ext = fe.getExt(); final String oldName = (ext.length() == 0) ? fe.getName() : (fe.getName() + "." + ext); // NOI18N - clearCachesAboutFile(new File(parent, oldName), false); + clearCachesAboutFile(parent.getChild(oldName), false); } } @@ -779,30 +777,46 @@ // no update } - private File clearCachesAboutFile(FileEvent fe) { - return clearCachesAboutFile(CndFileUtils.toFile(fe.getFile()), false); + private FSPath clearCachesAboutFile(FileEvent fe) { + return clearCachesAboutFile(FSPath.toFSPath(fe.getFile()), false); } - private File clearCachesAboutFile(File f, boolean withParent) { - cleanCachesImpl(f.getAbsolutePath()); + private FSPath clearCachesAboutFile(FSPath f, boolean withParent) { + cleanCachesImpl(f); if (withParent) { - File parent = f.getParentFile(); + FSPath parent = f.getParent(); if (parent != null) { - cleanCachesImpl(parent.getAbsolutePath()); + cleanCachesImpl(parent); } return parent; } return null; } - private String preparePath(String path) { - String absPath = changeStringCaseIfNeeded(getLocalFileSystem(), path); - if (isWindows) { + private String checkSeparators(FileObject fo) { + return checkSeparators(FSPath.toFSPath(fo)); + } + + private String checkSeparators(FSPath path) { + String absPath = path.getPath(); + if (isWindows && isLocalFileSystem(path.getFileSystem())) { absPath = absPath.replace('/', '\\'); } return absPath; } + private FileSystem getFileSystem(FileEvent fe) { + return getFileSystem(fe.getFile()); + } + + private FileSystem getFileSystem(FileObject fo) { + try { + return fo.getFileSystem(); + } catch (FileStateInvalidException ex) { + throw new IllegalStateException(ex); + } + } + private static void invalidateFile(String file, String absPath) { for (CndFileExistSensitiveCache cache : getCaches()) { cache.invalidateFile(file); @@ -810,8 +824,9 @@ } } - private void cleanCachesImpl(String file) { - String absPath = preparePath(file); + private void cleanCachesImpl(FSPath fsPath) { + String file = checkSeparators(fsPath); + String absPath = changeStringCaseIfNeeded(fsPath.getFileSystem(), file); Flags removed = getFilesMap(getLocalFileSystem()).remove(absPath); if (TRACE_EXTERNAL_CHANGES) { System.err.printf("clean cache for %s->%s\n", absPath, removed);