diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java index 1a2a2c584a43..897044a5655e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java @@ -27,13 +27,14 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.magicConstant.MagicConstantInspection; -import com.intellij.openapi.application.PathManager; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.SdkModificator; import com.intellij.openapi.roots.AnnotationOrderRootType; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.InspectionTestCase; +import com.intellij.testFramework.PlatformTestUtil; public class MagicConstantInspectionTest extends InspectionTestCase { @Override @@ -46,7 +47,8 @@ public class MagicConstantInspectionTest extends InspectionTestCase { // add JDK annotations Sdk sdk = super.getTestProjectSdk(); SdkModificator sdkModificator = sdk.getSdkModificator(); - VirtualFile root = LocalFileSystem.getInstance().findFileByPath(PathManager.getHomePath() + "/jdkAnnotations"); + VirtualFile root = LocalFileSystem.getInstance().findFileByPath( + FileUtil.toSystemIndependentName(PlatformTestUtil.getCommunityPath()) + "/java/jdkAnnotations"); if (root != null) { sdkModificator.addRoot(root, AnnotationOrderRootType.getInstance()); sdkModificator.commitChanges(); diff --git a/java/jdkAnnotations/java/awt/annotations.xml b/java/jdkAnnotations/java/awt/annotations.xml new file mode 100644 index 000000000000..4bb636e6fc6d --- /dev/null +++ b/java/jdkAnnotations/java/awt/annotations.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/awt/datatransfer/annotations.xml b/java/jdkAnnotations/java/awt/datatransfer/annotations.xml new file mode 100644 index 000000000000..329dbd0b61bf --- /dev/null +++ b/java/jdkAnnotations/java/awt/datatransfer/annotations.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/java/jdkAnnotations/java/awt/event/annotations.xml b/java/jdkAnnotations/java/awt/event/annotations.xml new file mode 100644 index 000000000000..f6f7f66ddd0b --- /dev/null +++ b/java/jdkAnnotations/java/awt/event/annotations.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/awt/geom/annotations.xml b/java/jdkAnnotations/java/awt/geom/annotations.xml new file mode 100644 index 000000000000..eec0712ee356 --- /dev/null +++ b/java/jdkAnnotations/java/awt/geom/annotations.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/awt/im/annotations.xml b/java/jdkAnnotations/java/awt/im/annotations.xml new file mode 100644 index 000000000000..2e2406127776 --- /dev/null +++ b/java/jdkAnnotations/java/awt/im/annotations.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/io/annotations.xml b/java/jdkAnnotations/java/io/annotations.xml new file mode 100644 index 000000000000..72d3c50227cd --- /dev/null +++ b/java/jdkAnnotations/java/io/annotations.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/lang/annotations.xml b/java/jdkAnnotations/java/lang/annotations.xml new file mode 100644 index 000000000000..4e9191617257 --- /dev/null +++ b/java/jdkAnnotations/java/lang/annotations.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/lang/ref/annotations.xml b/java/jdkAnnotations/java/lang/ref/annotations.xml new file mode 100644 index 000000000000..4adb3db0ed82 --- /dev/null +++ b/java/jdkAnnotations/java/lang/ref/annotations.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/java/jdkAnnotations/java/lang/reflect/annotations.xml b/java/jdkAnnotations/java/lang/reflect/annotations.xml new file mode 100644 index 000000000000..43b583bbdd17 --- /dev/null +++ b/java/jdkAnnotations/java/lang/reflect/annotations.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/java/jdkAnnotations/java/net/annotations.xml b/java/jdkAnnotations/java/net/annotations.xml new file mode 100644 index 000000000000..ef979346b268 --- /dev/null +++ b/java/jdkAnnotations/java/net/annotations.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/nio/charset/annotations.xml b/java/jdkAnnotations/java/nio/charset/annotations.xml new file mode 100644 index 000000000000..e111541b5df5 --- /dev/null +++ b/java/jdkAnnotations/java/nio/charset/annotations.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/java/jdkAnnotations/java/security/annotations.xml b/java/jdkAnnotations/java/security/annotations.xml new file mode 100644 index 000000000000..96f7fd9febac --- /dev/null +++ b/java/jdkAnnotations/java/security/annotations.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/java/jdkAnnotations/java/text/annotations.xml b/java/jdkAnnotations/java/text/annotations.xml new file mode 100644 index 000000000000..3a1d14aa4e0a --- /dev/null +++ b/java/jdkAnnotations/java/text/annotations.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/java/jdkAnnotations/java/util/annotations.xml b/java/jdkAnnotations/java/util/annotations.xml new file mode 100644 index 000000000000..dc7b98e0ee35 --- /dev/null +++ b/java/jdkAnnotations/java/util/annotations.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/util/concurrent/annotations.xml b/java/jdkAnnotations/java/util/concurrent/annotations.xml new file mode 100644 index 000000000000..82cf07f8b228 --- /dev/null +++ b/java/jdkAnnotations/java/util/concurrent/annotations.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/util/regex/annotations.xml b/java/jdkAnnotations/java/util/regex/annotations.xml new file mode 100644 index 000000000000..b32556557e6a --- /dev/null +++ b/java/jdkAnnotations/java/util/regex/annotations.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/java/util/zip/annotations.xml b/java/jdkAnnotations/java/util/zip/annotations.xml new file mode 100644 index 000000000000..4df87a14ccf9 --- /dev/null +++ b/java/jdkAnnotations/java/util/zip/annotations.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/java/jdkAnnotations/javax/naming/event/annotations.xml b/java/jdkAnnotations/javax/naming/event/annotations.xml new file mode 100644 index 000000000000..a28577ad2b0b --- /dev/null +++ b/java/jdkAnnotations/javax/naming/event/annotations.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/java/jdkAnnotations/javax/swing/annotations.xml b/java/jdkAnnotations/javax/swing/annotations.xml new file mode 100644 index 000000000000..c398535c39f3 --- /dev/null +++ b/java/jdkAnnotations/javax/swing/annotations.xml @@ -0,0 +1,375 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/javax/swing/border/annotations.xml b/java/jdkAnnotations/javax/swing/border/annotations.xml new file mode 100644 index 000000000000..f6e56aeca94c --- /dev/null +++ b/java/jdkAnnotations/javax/swing/border/annotations.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/javax/swing/event/annotations.xml b/java/jdkAnnotations/javax/swing/event/annotations.xml new file mode 100644 index 000000000000..688014ee959b --- /dev/null +++ b/java/jdkAnnotations/javax/swing/event/annotations.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jdkAnnotations/javax/swing/tree/annotations.xml b/java/jdkAnnotations/javax/swing/tree/annotations.xml new file mode 100644 index 000000000000..c99ffda0bef1 --- /dev/null +++ b/java/jdkAnnotations/javax/swing/tree/annotations.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/java/jdkAnnotations/org/jdom/annotations.xml b/java/jdkAnnotations/org/jdom/annotations.xml new file mode 100644 index 000000000000..bf5707355e20 --- /dev/null +++ b/java/jdkAnnotations/org/jdom/annotations.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootContainerImpl.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootContainerImpl.java index 438e458d8e6b..56c778826ff7 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootContainerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootContainerImpl.java @@ -216,7 +216,8 @@ public class ProjectRootContainerImpl implements JDOMExternalizable, ProjectRoot List children = child.getChildren(); LOG.assertTrue(children.size() == 1); - myRoots.put(type, (CompositeProjectRoot)ProjectRootUtil.read((Element)children.get(0))); + CompositeProjectRoot root = (CompositeProjectRoot)ProjectRootUtil.read((Element)children.get(0)); + myRoots.put(type, root); } private void write(Element roots, PersistentOrderRootType type) throws WriteExternalException { diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java index 19a0c655acc7..d12a6828d5c9 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectRootUtil.java @@ -76,7 +76,7 @@ public class ProjectRootUtil { root.readExternal(element); return root; } - else if (type.equals(COMPOSITE_ROOT)) { + if (type.equals(COMPOSITE_ROOT)) { final CompositeProjectRoot root = new CompositeProjectRoot(); root.readExternal(element); return root; diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SimpleProjectRoot.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SimpleProjectRoot.java index 4d6b81236478..c09c8ac64580 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SimpleProjectRoot.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SimpleProjectRoot.java @@ -21,9 +21,11 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.ex.http.HttpFileSystem; +import com.intellij.util.PathUtil; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -36,9 +38,9 @@ import java.io.File; public class SimpleProjectRoot implements ProjectRoot, JDOMExternalizable { private String myUrl; private VirtualFile myFile; - private final VirtualFile[] myFileArrray = new VirtualFile[1]; + private final VirtualFile[] myFileArray = new VirtualFile[1]; private boolean myInitialized = false; - @NonNls public static final String ATTRIBUTE_URL = "url"; + @NonNls private static final String ATTRIBUTE_URL = "url"; SimpleProjectRoot(@NotNull VirtualFile file) { myFile = file; @@ -71,8 +73,8 @@ public class SimpleProjectRoot implements ProjectRoot, JDOMExternalizable { return VirtualFile.EMPTY_ARRAY; } - myFileArrray[0] = myFile; - return myFileArrray; + myFileArray[0] = myFile; + return myFileArray; } public String[] getUrls() { @@ -96,15 +98,14 @@ public class SimpleProjectRoot implements ProjectRoot, JDOMExternalizable { if (myFile == null || !myFile.isValid()) { myFile = VirtualFileManager.getInstance().findFileByUrl(myUrl); - if (myFile != null && cantHaveChildren()) { + if (myFile != null && !canHaveChildren()) { myFile = null; } } } - private boolean cantHaveChildren() { - if (myFile.getFileSystem() instanceof HttpFileSystem) return false; - return !myFile.isDirectory(); + private boolean canHaveChildren() { + return myFile.getFileSystem() instanceof HttpFileSystem || myFile.isDirectory(); } public String getUrl() { @@ -112,7 +113,20 @@ public class SimpleProjectRoot implements ProjectRoot, JDOMExternalizable { } public void readExternal(Element element) throws InvalidDataException { - myUrl = element.getAttributeValue(ATTRIBUTE_URL); + String url = element.getAttributeValue(ATTRIBUTE_URL); + myUrl = migrateJdkAnnotationsToCommunityForDevIdea(url); + } + + // hack to migrate internal IDEA jdk annos dir from IDEA_PROJECT_HOME/jdkAnnotations to IDEA_PROJECT_HOME/community/java/jdkAnnotations + private static String migrateJdkAnnotationsToCommunityForDevIdea(String url) { + File root = new File(VfsUtil.urlToPath(url) + "/.."); + boolean isOldJdkAnnotations = new File(root, "community/java/jdkAnnotations").exists() + && new File(root, "idea.iml").exists() + && new File(root, "testData").exists(); + if (isOldJdkAnnotations) { + return VfsUtil.pathToUrl(PathUtil.getCanonicalPath(VfsUtil.urlToPath(url + "/../community/java/jdkAnnotations"))); + } + return url; } public void writeExternal(Element element) throws WriteExternalException { @@ -122,5 +136,4 @@ public class SimpleProjectRoot implements ProjectRoot, JDOMExternalizable { element.setAttribute(ATTRIBUTE_URL, myUrl); } - } diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 7f4f4f5ee580..047ca2d0e755 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -206,7 +206,7 @@ public class PathManager { } public static File getIndexRoot() { - File file = new File(getSystemPath(), "index"); + File file = new File(getIndexRootDir()); try { file = file.getCanonicalFile(); } @@ -216,6 +216,11 @@ public class PathManager { return file; } + private static String getIndexRootDir() { + String dir = System.getProperty("index_root_path"); + return dir == null ? getSystemPath() + "/index" : dir; + } + private static class StringHolder { private static final String ourPreinstalledPluginsPath = getHomePath() + File.separatorChar + PLUGINS_DIRECTORY; } diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index f38741145ca7..8fc2349f3a23 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -24,6 +24,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Processor; import com.intellij.util.SystemProperties; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.Stack; import com.intellij.util.io.URLUtil; import org.intellij.lang.annotations.RegExp; import org.jetbrains.annotations.NonNls; @@ -761,7 +762,7 @@ public class FileUtil { @NotNull @NonNls final String aFilePrefix, @NotNull String aExtension) { int postfix = 0; - String ext = 0 == aExtension.length() ? "" : "." + aExtension; + String ext = aExtension.isEmpty() ? "" : "." + aExtension; File candidate = new File(aParentFolder, aFilePrefix + ext); while (candidate.exists()) { @@ -787,12 +788,12 @@ public class FileUtil { } public static String toCanonicalPath(String path) { - if (path == null || path.length() == 0) { + if (path == null || path.isEmpty()) { return path; } path = path.replace(File.separatorChar, '/'); final StringTokenizer tok = new StringTokenizer(path, "/"); - final com.intellij.util.containers.Stack stack = new com.intellij.util.containers.Stack(); + final Stack stack = new Stack(); while (tok.hasMoreTokens()) { final String token = tok.nextToken(); if ("..".equals(token)) { @@ -801,7 +802,7 @@ public class FileUtil { } stack.pop(); } - else if (token.length() != 0 && !".".equals(token)) { + else if (!token.isEmpty() && !".".equals(token)) { stack.push(token); } } @@ -1256,7 +1257,7 @@ public class FileUtil { String _path = path; - if ((SystemInfo.isLinux || SystemInfo.isMac)) { + if (SystemInfo.isLinux || SystemInfo.isMac) { final File projectDir = new File(path); final File userHomeDir = new File(SystemProperties.getUserHome()); if (isAncestor(userHomeDir, projectDir, true)) {