diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java index 43c9d630045a..cff331654e10 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java @@ -12,7 +12,6 @@ import com.intellij.util.indexing.FileContent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Comparator; import java.util.function.Supplier; import java.util.stream.Stream; @@ -55,9 +54,10 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder.CompositeBina VirtualFile file = fileContent.getFile(); try { if (decompiler instanceof Full) { - return ((Full) decompiler).getStubBuilder().buildFileStub(fileContent); + return ((Full)decompiler).getStubBuilder().buildFileStub(fileContent); } - } catch (ClsFormatException e) { + } + catch (ClsFormatException e) { if (LOG.isDebugEnabled()) LOG.debug(file.getPath(), e); else LOG.info(file.getPath() + ": " + e.getMessage()); } @@ -68,7 +68,8 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder.CompositeBina LOG.info("No stub built for the file " + fileContent); } return stub; - } catch (ClsFormatException e) { + } + catch (ClsFormatException e) { if (LOG.isDebugEnabled()) LOG.debug(file.getPath(), e); else LOG.info(file.getPath() + ": " + e.getMessage()); } @@ -77,11 +78,8 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder.CompositeBina }); } - private static final Comparator CLASS_NAME_COMPARATOR = Comparator.comparing(o -> o.getClass().getName()); - @Override public int getStubVersion() { - // composite indexer return STUB_VERSION; } @@ -89,7 +87,8 @@ public class ClassFileStubBuilder implements BinaryFileStubBuilder.CompositeBina try { content.getFile().setPreloadedContentHint(content.getContent()); return computation.get(); - } finally { + } + finally { content.getFile().setPreloadedContentHint(null); } } diff --git a/platform/core-impl/src/com/intellij/psi/AbstractFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/AbstractFileViewProvider.java index a7c414d86f13..6b51e004173d 100644 --- a/platform/core-impl/src/com/intellij/psi/AbstractFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/AbstractFileViewProvider.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi; import com.intellij.injected.editor.DocumentWindow; @@ -55,10 +55,9 @@ public abstract class AbstractFileViewProvider extends UserDataHolderBase implem private static final Logger LOG = Logger.getInstance(AbstractFileViewProvider.class); public static final Key FREE_THREADED = Key.create("FREE_THREADED"); private static final Key> KNOWN_COPIES = Key.create("KNOWN_COPIES"); - @NotNull - private final PsiManagerEx myManager; - @NotNull - private final VirtualFile myVirtualFile; + + private final @NotNull PsiManagerEx myManager; + private final @NotNull VirtualFile myVirtualFile; private final boolean myEventSystemEnabled; private final boolean myPhysical; private volatile Content myContent; @@ -536,4 +535,4 @@ public abstract class AbstractFileViewProvider extends UserDataHolderBase implem public final FileType getFileType() { return myVirtualFile.getFileType(); } -} +} \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt index ef109c10cd00..618691d6678c 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.kt @@ -8,6 +8,8 @@ import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.IoTestUtil +import com.intellij.openapi.util.io.IoTestUtil.assumeSymLinkCreationIsSupported +import com.intellij.openapi.util.io.IoTestUtil.assumeWindows import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtilCore @@ -248,7 +250,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { // ensure that flat roots set via symbolic paths behave correctly and do not report dirty files returned from other recursive roots @Test fun testSymbolicLinkIntoFlatRoot() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val root = tempDir.newFolder("root") val cDir = tempDir.newFolder("root/A/B/C") @@ -265,7 +267,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testMultipleSymbolicLinkPathsToFile() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val root = tempDir.newFolder("root") val file = tempDir.newFile("root/A/B/C/test.txt") @@ -285,7 +287,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testSymbolicLinkWatchRoot() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -300,7 +302,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testSymbolicLinkAboveWatchRoot() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -316,7 +318,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testJunctionWatchRoot() { - IoTestUtil.assumeWindows() + assumeWindows() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -337,7 +339,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testJunctionAboveWatchRoot() { - IoTestUtil.assumeWindows() + assumeWindows() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -360,7 +362,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testSymlinkBelowWatchRoot() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -375,7 +377,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testCircularSymlinkBelowWatchRoot() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val top = tempDir.newFolder("top") val topA = tempDir.newFolder("top/a") @@ -399,7 +401,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testSymlinkBelowWatchRootCreation() { - IoTestUtil.assumeSymLinkCreationIsSupported() + assumeSymLinkCreationIsSupported() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -417,7 +419,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testJunctionBelowWatchRoot() { - IoTestUtil.assumeWindows() + assumeWindows() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -432,7 +434,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testJunctionBelowWatchRootCreation() { - IoTestUtil.assumeWindows() + assumeWindows() val top = tempDir.newFolder("top") val file = tempDir.newFile("top/dir1/dir2/dir3/test.txt") @@ -450,7 +452,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testSubst() { - IoTestUtil.assumeWindows() + assumeWindows() val target = tempDir.newFolder("top") val file = tempDir.newFile("top/sub/test.txt") @@ -573,7 +575,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testHiddenFiles() { - IoTestUtil.assumeWindows() + assumeWindows() val root = tempDir.newFolder("root") val file = tempDir.newFile("root/dir/file") @@ -674,7 +676,7 @@ class FileWatcherTest : BareTestFixtureTestCase() { } @Test fun testUncRoot() { - IoTestUtil.assumeWindows() + assumeWindows() watch(File("\\\\SRV\\share\\path"), checkRoots = false) } @@ -722,4 +724,4 @@ class FileWatcherTest : BareTestFixtureTestCase() { assertEquals(expected, actual) } // -} +} \ No newline at end of file diff --git a/platform/util-class-loader/src/com/intellij/util/lang/ClassPath.java b/platform/util-class-loader/src/com/intellij/util/lang/ClassPath.java index b1039c1bfb13..662795e76ab9 100644 --- a/platform/util-class-loader/src/com/intellij/util/lang/ClassPath.java +++ b/platform/util-class-loader/src/com/intellij/util/lang/ClassPath.java @@ -37,11 +37,10 @@ public final class ClassPath { final boolean myPreloadJarContents; final boolean myCanHavePersistentIndex; final boolean myLazyClassloadingCaches; - @Nullable private final CachePoolImpl myCachePool; - @Nullable private final UrlClassLoader.CachingCondition myCachingCondition; + private final @Nullable CachePoolImpl myCachePool; + private final @Nullable UrlClassLoader.CachingCondition myCachingCondition; final boolean myLogErrorOnMissingJar; - @Nullable - private final LinkedHashSet myJarAccessLog; + private final @Nullable LinkedHashSet myJarAccessLog; public ClassPath(List urls, boolean canLockJars, @@ -69,10 +68,9 @@ public final class ClassPath { push(urls); } - /** - * @deprecated Adding additional urls to classpath at runtime could lead to hard-to-debug errors - */ + /** @deprecated adding URLs to classpath at runtime could lead to hard-to-debug errors */ @Deprecated + @SuppressWarnings("DeprecatedIsStillUsed") void addURL(URL url) { push(Collections.singletonList(url)); } diff --git a/platform/util-class-loader/src/com/intellij/util/lang/JarLoader.java b/platform/util-class-loader/src/com/intellij/util/lang/JarLoader.java index 186cb0fbbe45..ad4fe8658dc6 100644 --- a/platform/util-class-loader/src/com/intellij/util/lang/JarLoader.java +++ b/platform/util-class-loader/src/com/intellij/util/lang/JarLoader.java @@ -33,16 +33,15 @@ class JarLoader extends Loader { pair(Resource.Attribute.IMPL_VERSION, Attributes.Name.IMPLEMENTATION_VERSION), pair(Resource.Attribute.IMPL_VENDOR, Attributes.Name.IMPLEMENTATION_VENDOR)); - @NotNull + private static final String NULL_STRING = ""; + private final String myFilePath; private final ClassPath myConfiguration; - @NotNull private final URL myUrl; private SoftReference myMemoryLoader; private volatile SoftReference myZipFileSoftReference; // Used only when myConfiguration.myCanLockJars==true private volatile Map myAttributes; private volatile String myClassPathManifestAttribute; - private static final String NULL_STRING = ""; JarLoader(@NotNull URL url, @NotNull File file, int index, @NotNull ClassPath configuration) throws IOException { super(new URL("jar", "", -1, url + "!/"), index); @@ -105,8 +104,7 @@ class JarLoader extends Loader { Attributes manifestAttributes = myConfiguration.getManifestData(myUrl); if (manifestAttributes == null) { ZipEntry entry = zipFile.getEntry(JarFile.MANIFEST_NAME); - InputStream zipEntryStream = entry != null ? zipFile.getInputStream(entry) : null; - manifestAttributes = loadManifestAttributes(zipFile, zipEntryStream); + if (entry != null) manifestAttributes = loadManifestAttributes(zipFile.getInputStream(entry)); if (manifestAttributes == null) manifestAttributes = new Attributes(0); myConfiguration.cacheManifestData(myUrl, manifestAttributes); } @@ -126,8 +124,7 @@ class JarLoader extends Loader { } @Nullable - protected Attributes loadManifestAttributes(@NotNull ZipFile zipFile, @Nullable InputStream stream) { - if (stream == null) return null; + private static Attributes loadManifestAttributes(InputStream stream) { try { try { return new Manifest(stream).getMainAttributes(); @@ -333,4 +330,4 @@ class JarLoader extends Loader { public String toString() { return "JarLoader [" + myFilePath + "]"; } -} +} \ No newline at end of file diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 807e842bf077..bac6dbb7817f 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -8,7 +8,6 @@ import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.util.SystemProperties; import com.intellij.util.io.URLUtil; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,8 +40,8 @@ public final class PathManager { public static final String DEFAULT_EXT = ".xml"; public static final String DEFAULT_OPTIONS_FILE = "other" + DEFAULT_EXT; - @NonNls private static final String KOTLIN_IDE_IML_RELATIVE_PATH = "kotlin/idea/kotlin.idea.iml"; - @NonNls private static final String INTELLIJ_SUB_REPO_NAME = "intellij"; + private static final String KOTLIN_IDE_IML_RELATIVE_PATH = "kotlin/idea/kotlin.idea.iml"; + private static final String INTELLIJ_SUB_REPO_NAME = "intellij"; private static final String PROPERTY_HOME = "idea.home"; // reduced variant of PROPERTY_HOME_PATH, now deprecated diff --git a/platform/util/testSrc/com/intellij/util/lang/UrlClassLoaderTest.java b/platform/util/testSrc/com/intellij/util/lang/UrlClassLoaderTest.java index cc4b3345ac91..e058bebacefc 100644 --- a/platform/util/testSrc/com/intellij/util/lang/UrlClassLoaderTest.java +++ b/platform/util/testSrc/com/intellij/util/lang/UrlClassLoaderTest.java @@ -37,6 +37,7 @@ public class UrlClassLoaderTest { @Test public void testBootstrapResources() { + //noinspection SpellCheckingInspection String name = JavaVersion.current().feature > 8 ? "META-INF/services/java.nio.file.spi.FileSystemProvider" : "com/sun/xml/internal/messaging/saaj/soap/LocalStrings.properties"; assertNotNull(ClassLoader.getSystemResourceAsStream(name)); @@ -104,7 +105,7 @@ public class UrlClassLoaderTest { namesToLoad.add(resourceNames.get(random.nextInt(resourceNames.size()))); } - List futures = new ArrayList<>(); + List> futures = new ArrayList<>(); for (int i = 0; i < threadCount; i++) { futures.add(executor.submit(() -> { for (String name : namesToLoad) { @@ -119,7 +120,7 @@ public class UrlClassLoaderTest { })); } - for (Future future : futures) { + for (Future future : futures) { future.get(); } } @@ -133,17 +134,17 @@ public class UrlClassLoaderTest { @Test public void testInvalidJarsInClassPath() throws IOException { String entryName = "test_res_dir/test_res.txt"; - File theGood = createTestJar(createTestFile(tempDir.getRoot(), "1_normal.jar"), entryName, "-"); - File theBad = createTestFile(tempDir.getRoot(), "2_broken.jar", new String(new char[1024])); + File theGood = createTestJar(tempDir.newFile("1_normal.jar"), entryName, "-"); + File theBad = tempDir.newFile("2_broken.jar", new byte[1024]); - UrlClassLoader flat = UrlClassLoader.build().urls(theBad.toURI().toURL(), theGood.toURI().toURL()).useLazyClassloadingCaches(false).get(); + UrlClassLoader flat = UrlClassLoader.build().urls(theBad.toURI().toURL(), theGood.toURI().toURL()).get(); assertNotNull(findResource(flat, entryName, false)); String content = Attributes.Name.MANIFEST_VERSION + ": 1.0\n" + Attributes.Name.CLASS_PATH + ": " + theBad.toURI().toURL() + " " + theGood.toURI().toURL() + "\n\n"; - File theUgly = createTestJar(createTestFile(tempDir.getRoot(), ClassPath.CLASSPATH_JAR_FILE_NAME_PREFIX + "_3.jar"), JarFile.MANIFEST_NAME, content); + File theUgly = createTestJar(tempDir.newFile(ClassPath.CLASSPATH_JAR_FILE_NAME_PREFIX + "_3.jar"), JarFile.MANIFEST_NAME, content); - UrlClassLoader recursive = UrlClassLoader.build().urls(theUgly.toURI().toURL()).useLazyClassloadingCaches(false).get(); + UrlClassLoader recursive = UrlClassLoader.build().urls(theUgly.toURI().toURL()).get(); assertNotNull(findResource(recursive, entryName, false)); } @@ -151,7 +152,7 @@ public class UrlClassLoaderTest { public void testDirEntry() throws IOException { String resourceDirName = "test_res_dir"; String resourceDirName2 = "test_res_dir2"; - File theGood = createTestJar(createTestFile(tempDir.getRoot(), "1_normal.jar"), resourceDirName + "/test_res.txt", "-", resourceDirName2 + "/", null); + File theGood = createTestJar(tempDir.newFile("1_normal.jar"), resourceDirName + "/test_res.txt", "-", resourceDirName2 + "/", null); UrlClassLoader flat = UrlClassLoader.build().urls(theGood.toURI().toURL()).get(); String resourceDirNameWithSlash = resourceDirName + "/";