import com.intellij.ide.caches.CacheUpdater;
import com.intellij.ide.startup.StartupManagerEx;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.startup.StartupActivity;
+import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.LocalFileSystem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
+import java.io.FileNotFoundException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Application app = ApplicationManager.getApplication();
if (!app.isHeadlessEnvironment()) {
+ checkFsSanity();
checkProjectRoots();
final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
final MessageBusConnection connection = app.getMessageBus().connect();
});
}
+ private void checkFsSanity() {
+ try {
+ String path = myProject.getProjectFilePath();
+ boolean actual = FileUtil.isFileSystemCaseSensitive(path);
+ LOG.info(path + " case-sensitivity: " + actual);
+ if (actual != SystemInfo.isFileSystemCaseSensitive) {
+ int prefix = SystemInfo.isFileSystemCaseSensitive ? 1 : 0; // IDE=true -> FS=false -> prefix='in'
+ String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title");
+ String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix);
+ Notifications.Bus.notify(
+ new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, title, text, NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER),
+ myProject);
+ }
+ }
+ catch (FileNotFoundException e) {
+ LOG.warn(e);
+ }
+ }
+
private void checkProjectRoots() {
LocalFileSystem fs = LocalFileSystem.getInstance();
if (!(fs instanceof LocalFileSystemImpl)) return;
watcher.gave.up=File watcher gave up to operate
watcher.non.watchable.project=Project files cannot be watched (are they under network mount?)
+fs.case.sensitivity.mismatch.title=Filesystem Case-Sensitivity Mismatch
+fs.case.sensitivity.mismatch.message=\
+ The project seems to be located on a case-{0,choice,0#|1#in}sensitive file system.<br> \
+ This doesn't match IDE settings. \
+ <a href="https://confluence.jetbrains.com/display/IDEADEV/Filesystem+Case-Sensitivity+Mismatch">More details.</a>
+
arrangement.title.settings.tab=Arrangement
arrangement.text.empty.rule=<empty rule>
arrangement.text.type=Type
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
/**
- * Like {@link Properties#load(java.io.Reader)}, but preserves the order of key/value pairs.
+ * Like {@link Properties#load(Reader)}, but preserves the order of key/value pairs.
*/
@NotNull
public static Map<String, String> loadProperties(@NotNull Reader reader) throws IOException {
boolean success = file.renameTo(tempFileNameForDeletion);
return delete(success ? tempFileNameForDeletion:file);
}
+
+ public static boolean isFileSystemCaseSensitive(@NotNull String path) throws FileNotFoundException {
+ FileAttributes attributes = FileSystemUtil.getAttributes(path);
+ if (attributes == null) {
+ throw new FileNotFoundException(path);
+ }
+
+ FileAttributes upper = FileSystemUtil.getAttributes(path.toUpperCase(Locale.ENGLISH));
+ FileAttributes lower = FileSystemUtil.getAttributes(path.toLowerCase(Locale.ENGLISH));
+ return !(attributes.equals(upper) && attributes.equals(lower));
+ }
}
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
FileUtil.delete(linkDir);
assertEquals(1, targetDir.list().length);
}
+
+ @Test
+ public void testCaseSensitivityDetection() throws IOException {
+ String path = myFindTestFirstFile.getPath();
+ assertEquals(SystemInfo.isFileSystemCaseSensitive, FileUtil.isFileSystemCaseSensitive(path));
+ }
}