diff --git a/build/groovy/org/jetbrains/intellij/build/ApplicationInfoProperties.groovy b/build/groovy/org/jetbrains/intellij/build/ApplicationInfoProperties.groovy index ed1055dc6897..cb305c8a5eb0 100644 --- a/build/groovy/org/jetbrains/intellij/build/ApplicationInfoProperties.groovy +++ b/build/groovy/org/jetbrains/intellij/build/ApplicationInfoProperties.groovy @@ -15,6 +15,8 @@ */ package org.jetbrains.intellij.build +import com.intellij.openapi.util.text.StringUtil + import java.text.MessageFormat /** @@ -30,6 +32,7 @@ class ApplicationInfoProperties { final String minorVersionMainPart final String productName final String companyName + final String shortCompanyName final boolean isEAP @SuppressWarnings(["GrUnresolvedAccess", "GroovyAssignabilityCheck"]) @@ -45,6 +48,7 @@ class ApplicationInfoProperties { companyName = root.company.first().@name minorVersionMainPart = minorVersion.takeWhile { it != '.' } isEAP = Boolean.parseBoolean(root.version.first().@eap) + shortCompanyName = StringUtil.trimEnd(companyName, "s.r.o.").trim() } public String getUpperCaseProductName() { shortProductName.toUpperCase() } diff --git a/build/groovy/org/jetbrains/intellij/build/BuildContext.groovy b/build/groovy/org/jetbrains/intellij/build/BuildContext.groovy index 50fdfa225ddd..c4c20b20f765 100644 --- a/build/groovy/org/jetbrains/intellij/build/BuildContext.groovy +++ b/build/groovy/org/jetbrains/intellij/build/BuildContext.groovy @@ -64,12 +64,18 @@ abstract class BuildContext { */ List bootClassPathJarNames + abstract boolean includeBreakGenLibraries() + + abstract String getAdditionalJvmArguments() + abstract void notifyArtifactBuilt(String artifactPath) abstract File findApplicationInfoInSources() abstract JpsModule findApplicationInfoModule() + abstract JpsModule findRequiredModule(String name) + abstract JpsModule findModule(String name) abstract void signExeFile(String path) diff --git a/build/groovy/org/jetbrains/intellij/build/BuildTasks.groovy b/build/groovy/org/jetbrains/intellij/build/BuildTasks.groovy index 1882bc0a20c2..ca8510415a64 100644 --- a/build/groovy/org/jetbrains/intellij/build/BuildTasks.groovy +++ b/build/groovy/org/jetbrains/intellij/build/BuildTasks.groovy @@ -16,6 +16,7 @@ package org.jetbrains.intellij.build import org.jetbrains.intellij.build.impl.BuildTasksImpl +import org.jetbrains.intellij.build.impl.PluginLayout /** * @author nik @@ -53,10 +54,14 @@ abstract class BuildTasks { */ abstract void buildDistributions() + abstract void compileModulesAndBuildDistributions(List allPlugins) + abstract void cleanOutput() abstract void compileProjectAndTests(List includingTestsInModules) + abstract void compileModules(List moduleNames, List includingTestsInModules = []) + public static BuildTasks create(BuildContext context) { return new BuildTasksImpl(context) } diff --git a/build/groovy/org/jetbrains/intellij/build/CommunityRepositoryModules.groovy b/build/groovy/org/jetbrains/intellij/build/CommunityRepositoryModules.groovy new file mode 100644 index 000000000000..dab0cb97491a --- /dev/null +++ b/build/groovy/org/jetbrains/intellij/build/CommunityRepositoryModules.groovy @@ -0,0 +1,179 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +package org.jetbrains.intellij.build + +import org.jetbrains.intellij.build.impl.PluginLayout + +import static org.jetbrains.intellij.build.impl.PluginLayout.plugin + +/** + * @author nik + */ +class CommunityRepositoryModules { + static List PLATFORM_API_MODULES = [ + "analysis-api", + "built-in-server-api", + "core-api", + "diff-api", + "dvcs-api", + "editor-ui-api", + "external-system-api", + "indexing-api", + "jps-model-api", + "lang-api", + "lvcs-api", + "platform-api", + "projectModel-api", + "remote-servers-agent-rt", + "remote-servers-api", + "usageView", + "vcs-api-core", + "vcs-api", + "vcs-log-api", + "vcs-log-graph-api", + "xdebugger-api", + "xml-analysis-api", + "xml-openapi", + "xml-psi-api", + "xml-structure-view-api" + ] + + static List PLATFORM_IMPLEMENTATION_MODULES = [ + "analysis-impl", + "built-in-server", + "core-impl", + "diff-impl", + "dvcs-impl", + "editor-ui-ex", + "images", + "indexing-impl", + "jps-model-impl", + "jps-model-serialization", + "json", + "lang-impl", + "lvcs-impl", + "platform-impl", + "projectModel-impl", + "protocol-reader-runtime", + "RegExpSupport", + "relaxng", + "remote-servers-impl", + "script-debugger-backend", + "script-debugger-ui", + "smRunner", + "spellchecker", + "structure-view-impl", + "testRunner", + "vcs-impl", + "vcs-log-graph", + "vcs-log-impl", + "xdebugger-impl", + "xml-analysis-impl", + "xml-psi-impl", + "xml-structure-view-impl", + "xml", + "configuration-store-impl", + ] + + /** + * Specifies layout for all plugins which sources are located in 'community' and 'contrib' repositories + */ + static List COMMUNITY_REPOSITORY_PLUGINS = [ + plugin("copyright"), + plugin("java-i18n"), + plugin("hg4idea"), + plugin("github"), + plugin("ant") { + mainJarName = "antIntegration.jar" + withModule("ant-jps-plugin") + }, + plugin("ui-designer") { + directoryName = "uiDesigner" + mainJarName = "uiDesigner.jar" + withJpsModule("ui-designer-jps-plugin") + }, + plugin("properties") { + withModule("properties-psi-api", "properties.jar") + withModule("properties-psi-impl", "properties.jar") + }, + plugin("git4idea") { + withModule("git4idea-rt", "git4idea-rt.jar", false) + withOptionalModule("remote-servers-git") + withOptionalModule("remote-servers-git-java", "remote-servers-git.jar") + }, + plugin("svn4idea") { + withResource("lib/licenses", "lib/licenses") + withResource("lib/sqljetsrc.zip", "lib") + withResource("lib/svnkit-javahl16.zip", "lib") + withResource("lib/trileadsrc.zip", "lib") + }, + plugin("cvs-plugin") { + directoryName = "cvsIntegration" + mainJarName = "cvsIntegration.jar" + withModule("javacvs-src") + withModule("smartcvs-src") + withModule("cvs-core", "cvs_util.jar") + }, + plugin("xpath") { + withModule("xslt-rt", "rt/xslt-rt.jar") + }, + plugin("tasks-core") { + directoryName = "tasks" + withModule("tasks-api") + withModule("jira") + withOptionalModule("tasks-java") + doNotCreateSeperateJarForLocalizableResources() + }, + plugin("terminal") { + withResource("lib/jediterm.in", "lib") + }, + plugin("editorconfig"), + plugin("coverage"), + plugin("yaml"), + plugin("xslt-debugger") { + withModule("xslt-debugger-engine") + withModule("xslt-debugger-engine-impl", "rt/xslt-debugger-engine-impl.jar") + withModuleLibrary("Saxon-6.5.5", "xslt-debugger-engine-impl", "rt") + withModuleLibrary("Saxon-9HE", "xslt-debugger-engine-impl", "rt") + withModuleLibrary("Xalan-2.7.1", "xslt-debugger-engine-impl", "rt") + //todo[nik] unmark 'lib' directory as source root instead + excludeFromModule("xslt-debugger-engine-impl", "rmi-stubs.jar") + excludeFromModule("xslt-debugger-engine-impl", "saxon.jar") + excludeFromModule("xslt-debugger-engine-impl", "saxon9he.jar") + excludeFromModule("xslt-debugger-engine-impl", "serializer.jar") + excludeFromModule("xslt-debugger-engine-impl", "xalan.jar") + }, + plugin("settings-repository") + ] +} \ No newline at end of file diff --git a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy index 080e899b92fc..6e15ed2290c1 100644 --- a/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy +++ b/build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy @@ -29,11 +29,6 @@ class IdeaCommunityProperties extends ProductProperties { buildCrossPlatformDistribution = true } - @Override - String fullNameIncludingEdition(ApplicationInfoProperties applicationInfo) { - "IntelliJ IDEA Community Edition" - } - @Override void copyAdditionalFiles(BuildContext buildContext, String targetDirectory) { buildContext.ant.copy(todir: targetDirectory) { @@ -57,6 +52,12 @@ class IdeaCommunityProperties extends ProductProperties { @Override String rootDirectoryName(String buildNumber) { "" } + @Override + String fullNameIncludingEdition(ApplicationInfoProperties applicationInfo) { "IntelliJ IDEA Community Edition" } + + @Override + String fullNameIncludingEditionAndVendor(ApplicationInfoProperties applicationInfo) { "IntelliJ IDEA Community Edition" } + @Override String uninstallFeedbackPageUrl(ApplicationInfoProperties applicationInfo) { "https://www.jetbrains.com/idea/uninstall/?edition=IC-${applicationInfo.majorVersion}.${applicationInfo.minorVersion}" @@ -82,6 +83,7 @@ class IdeaCommunityProperties extends ProductProperties { { helpId = "IJ" urlSchemes = ["idea"] + associateIpr = true enableYourkitAgentInEAP = false bundleIdentifier = "com.jetbrains.intellij.ce" dmgImagePath = "$projectHome/build/conf/mac/communitydmg.png" diff --git a/build/groovy/org/jetbrains/intellij/build/MacDistributionCustomizer.groovy b/build/groovy/org/jetbrains/intellij/build/MacDistributionCustomizer.groovy index fea25a526f62..72f13f6e7123 100644 --- a/build/groovy/org/jetbrains/intellij/build/MacDistributionCustomizer.groovy +++ b/build/groovy/org/jetbrains/intellij/build/MacDistributionCustomizer.groovy @@ -29,10 +29,15 @@ abstract class MacDistributionCustomizer { */ String minOSXVersion = "10.8" String helpId = "" - String docTypes = null + String additionalDocTypes = "" List urlSchemes = [] List architectures = ["x86_64"] + /** + * If {@code true} *.ipr files will be associated with the product in Info.plist + */ + boolean associateIpr = false + /** * If {@code true} YourKit agent will be automatically attached when an EAP build of the product starts under Mac OS. This property is * taken into account only if {@link ProductProperties#enableYourkitAgentInEAP} is {@code true}. @@ -58,6 +63,8 @@ abstract class MacDistributionCustomizer { abstract String rootDirectoryName(ApplicationInfoProperties applicationInfo, String buildNumber) + Map customIdeaProperties(ApplicationInfoProperties applicationInfo) { [:] } + void copyAdditionalFiles(BuildContext context, String targetDirectory) { } } diff --git a/build/groovy/org/jetbrains/intellij/build/ProductModulesLayout.groovy b/build/groovy/org/jetbrains/intellij/build/ProductModulesLayout.groovy new file mode 100644 index 000000000000..b50770a0ce6f --- /dev/null +++ b/build/groovy/org/jetbrains/intellij/build/ProductModulesLayout.groovy @@ -0,0 +1,111 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +package org.jetbrains.intellij.build + +import org.jetbrains.intellij.build.impl.PluginLayout + +/** + * @author nik + */ +class ProductModulesLayout { + /** + * Name of the main product JAR file. Outputs of {@link #platformImplementationModules} will be packed into it. + */ + String mainJarName + + /** + * Names of the modules which need to be packed into openapi.jar in the product's 'lib' directory. + * @see CommunityRepositoryModules#PLATFORM_API_MODULES + */ + List platformApiModules = [] + + /** + * Names of the modules which need to be included into {@link #mainJarName} in the product's 'lib' directory + * @see CommunityRepositoryModules#PLATFORM_IMPLEMENTATION_MODULES + */ + List platformImplementationModules = [] + + /** + * Names of the main modules (containing META-INF/plugin.xml) of the plugins which need to be bundled with the product. It may also + * includes names of optional modules from these plugins which need to be included into the plugin distribution for this product. + */ + List bundledPluginModules = [] + + /** + * Names of the main modules (containing META-INF/plugin.xml) of the plugins which aren't bundled with the product but may be installed + * into it. Zip archives of these plugins will be built and placed under 'plugins' directory in the build artifacts. + */ + List pluginModulesToPublish = [] + + /** + * Paths to JAR files which contents should be extracted into {@link #mainJarName} JAR. + */ + List additionalJarsToUnpackIntoMainJar = [] + + /** + * Maps names of the modules to names of JARs; these modules will be packed into these JARs and copied to the product's 'lib' directory. + */ + Map additionalPlatformModules = [:] + + + /** + * Name of the module which classpath will be used to build searchable options index + */ + String mainModule + + /** + * Name of the module containing search/searchableOptions.xml file. + * //todo[nik] make this optional + */ + String searchableOptionsModule + + /** + * Paths to license files which are required to start IDE in headless mode to generate searchable options index + */ + List licenseFilesToBuildSearchableOptions = [] + + /** + * @param allPlugins descriptions of layout of all plugins which may be included into the product + * @return list of all modules which output is included into the product platform's JARs or the plugin's JARs + */ + List getIncludedModules(List allPlugins) { + Set enabledPluginModules = getEnabledPluginModules() + def allPluginModules = allPlugins.findAll { enabledPluginModules.contains(it.mainModule) }.collectMany { it.getActualModules(enabledPluginModules).values() } + ((allPluginModules + platformApiModules + platformImplementationModules + additionalPlatformModules.keySet()) as Set) as List + } + + Set getEnabledPluginModules() { + (bundledPluginModules + pluginModulesToPublish) as Set + } +} \ No newline at end of file diff --git a/build/groovy/org/jetbrains/intellij/build/ProductProperties.groovy b/build/groovy/org/jetbrains/intellij/build/ProductProperties.groovy index 0e282ab00355..d32f749a3be8 100644 --- a/build/groovy/org/jetbrains/intellij/build/ProductProperties.groovy +++ b/build/groovy/org/jetbrains/intellij/build/ProductProperties.groovy @@ -39,6 +39,8 @@ public abstract class ProductProperties { */ String applicationInfoModule + String brandingModule + /** * Name of the sh/bat script (without extension) which will contain the commands to run IDE in 'offline inspections' mode */ @@ -54,17 +56,39 @@ public abstract class ProductProperties { */ String additionalIdeJvmArguments = "" - /** - * @return name of the product which will be shown in Windows Installer - */ - String fullNameIncludingEdition(ApplicationInfoProperties applicationInfo) { applicationInfo.productName } - /** * An identifier which will be used to form names for directories where configuration and caches will be stored, usually a product name * without spaces with added version ('IntelliJIdea2016.1' for IntelliJ IDEA 2016.1) */ abstract String systemSelector(ApplicationInfoProperties applicationInfo) + /** + * If {@code true} Alt+Button1 shortcut will be removed from 'Quick Evaluate Expression' action and assigned to 'Add/Remove Caret' action + * (instead of Alt+Shift+Button1) in the default keymap + */ + boolean reassignAltClickToMultipleCarets = false + + /** + * If {@code true} a txt file containing information (in Atlassian Confluence format) about third-party libraries used in the product + * will be generated. + */ + boolean generateLibrariesLicensesTable = true + + /** + * List of licenses information about all libraries which can be used in the product modules + */ + List allLibraryLicenses = CommunityLibraryLicenses.LICENSES_LIST + + /** + * If {@code true} the main product JAR file will be scrambled using {@link BuildContext#scrambleTool} + */ + boolean scrambleMainJar = false + + /** + * Described which modules should be included into the product's platform and which plugins should be bundled with the product + */ + ProductModulesLayout productLayout = new ProductModulesLayout() + /** * If {@code true} cross-platform ZIP archive containing binaries for all OS will be built */ @@ -115,6 +139,12 @@ public abstract class ProductProperties { List excludedPlugins = [] + /** + * Prefix for names of environment variables used by Windows and Linux distributions to allow users customize location of the product JDK + * (<PRODUCT>_JDK variable), *.vmoptions file (<PRODUCT>_VM_OPTIONS variable), idea.properties file (<PRODUCT>_PROPERTIES variable) + */ + String environmentVariableBaseName(ApplicationInfoProperties applicationInfo) { applicationInfo.upperCaseProductName } + /** * Override this method to copy additional files to distributions of all operating systems. */ diff --git a/build/groovy/org/jetbrains/intellij/build/ScrambleTool.groovy b/build/groovy/org/jetbrains/intellij/build/ScrambleTool.groovy index 520ae6cdd276..a885565770f6 100644 --- a/build/groovy/org/jetbrains/intellij/build/ScrambleTool.groovy +++ b/build/groovy/org/jetbrains/intellij/build/ScrambleTool.groovy @@ -22,8 +22,18 @@ package org.jetbrains.intellij.build * @author nik */ interface ScrambleTool { + /** + * @return list of modules used by the tool which need to be compiled before {@link #scramble} method is invoked + */ + List getAdditionalModulesToCompile() + /** * Scramble {@code mainJarName} in {@code "$buildContext.paths.distAll/lib"} directory */ void scramble(String mainJarName, BuildContext buildContext) + + /** + * @return list of names of JAR files which cannot be included into the product 'lib' directory in plain form + */ + List getNamesOfJarsRequiredToBeScrambled() } \ No newline at end of file diff --git a/build/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy b/build/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy index ef315aaa7dfa..cfd30127d203 100644 --- a/build/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy +++ b/build/groovy/org/jetbrains/intellij/build/WindowsDistributionCustomizer.groovy @@ -61,6 +61,16 @@ abstract class WindowsDistributionCustomizer { */ void copyAdditionalFiles(BuildContext context, String targetDirectory) {} + /** + * The returned name will be shown in Windows Installer and used in Registry keys + */ + String fullNameIncludingEdition(ApplicationInfoProperties applicationInfo) { applicationInfo.productName } + + /** + * The returned name will be used to create links on Desktop + */ + String fullNameIncludingEditionAndVendor(ApplicationInfoProperties applicationInfo) { applicationInfo.shortCompanyName + " " + applicationInfo.productName } + String uninstallFeedbackPageUrl(ApplicationInfoProperties applicationInfo) { return null } diff --git a/build/groovy/org/jetbrains/intellij/build/impl/BuildContextImpl.groovy b/build/groovy/org/jetbrains/intellij/build/impl/BuildContextImpl.groovy index 0563de6aa82c..462928272916 100644 --- a/build/groovy/org/jetbrains/intellij/build/impl/BuildContextImpl.groovy +++ b/build/groovy/org/jetbrains/intellij/build/impl/BuildContextImpl.groovy @@ -163,9 +163,14 @@ class BuildContextImpl extends BuildContext { @Override JpsModule findApplicationInfoModule() { - def module = findModule(productProperties.applicationInfoModule) + return findRequiredModule(productProperties.applicationInfoModule) + } + + @Override + JpsModule findRequiredModule(String name) { + def module = findModule(name) if (module == null) { - messages.error("Cannot find module '$productProperties.applicationInfoModule' containing ApplicationInfo.xml file") + messages.error("Cannot find required module '$name' in the project") } return module } @@ -196,6 +201,31 @@ class BuildContextImpl extends BuildContext { } } + @Override + boolean includeBreakGenLibraries() { + def productLayout = productProperties.productLayout + return productLayout.mainJarName == null || //todo[nik] remove this condition later + productLayout.additionalPlatformModules.containsKey("java-runtime") + } + + @Override + String getAdditionalJvmArguments() { + String jvmArgs + if (productProperties.platformPrefix != null +//todo[nik] remove later. This is added to keep the current behavior (platform prefix for CE is set in MainImpl anyway) + && productProperties.platformPrefix != "Idea") { + jvmArgs = "-Didea.platform.prefix=${productProperties.platformPrefix}" + } + else { + jvmArgs = "" + } + jvmArgs += " $productProperties.additionalIdeJvmArguments".trim() + if (productProperties.toolsJarRequired) { + jvmArgs += " -Didea.jre.check=true" + } + return jvmArgs.trim() + } + @Override void notifyArtifactBuilt(String artifactPath) { if (!underTeamCity) return diff --git a/build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy b/build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy index 942370056642..ea9bfdf940e0 100644 --- a/build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy +++ b/build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy @@ -19,9 +19,6 @@ import com.intellij.openapi.util.io.FileUtil import org.jetbrains.intellij.build.BuildContext import org.jetbrains.intellij.build.BuildOptions import org.jetbrains.intellij.build.BuildTasks -import org.jetbrains.intellij.build.LinuxDistributionCustomizer -import org.jetbrains.intellij.build.MacDistributionCustomizer -import org.jetbrains.intellij.build.WindowsDistributionCustomizer import org.jetbrains.jps.model.java.JavaResourceRootType import org.jetbrains.jps.model.java.JavaSourceRootType import org.jetbrains.jps.model.module.JpsModule @@ -86,9 +83,13 @@ class BuildTasksImpl extends BuildTasks { } } -//todo[nik] do we need 'cp' and 'jvmArgs' parameters? @Override void buildSearchableOptions(String targetModuleName, List modulesToIndex, List pathsToLicenses) { + buildSearchableOptions(new File(buildContext.projectBuilder.moduleOutput(buildContext.findModule(targetModuleName))), modulesToIndex, pathsToLicenses) + } + +//todo[nik] do we need 'cp' and 'jvmArgs' parameters? + void buildSearchableOptions(File targetDirectory, List modulesToIndex, List pathsToLicenses) { //todo[nik] create searchableOptions.xml in a separate directory instead of modifying it in the module output buildContext.executeStep("Build searchable options index", BuildOptions.SEARCHABLE_OPTIONS_INDEX_STEP, { def javaRuntimeClasses = "${buildContext.projectBuilder.moduleOutput(buildContext.findModule("java-runtime"))}" @@ -98,8 +99,7 @@ class BuildTasksImpl extends BuildTasks { buildContext.messages.progress("Building searchable options for modules $modulesToIndex") - def targetModuleOutput = buildContext.projectBuilder.moduleOutput(buildContext.findModule(targetModuleName)) - String targetFile = "$targetModuleOutput/search/searchableOptions.xml" + String targetFile = "${targetDirectory.absolutePath}/search/searchableOptions.xml" FileUtil.delete(new File(targetFile)) def tempDir = "$buildContext.paths.temp/searchableOptions" @@ -123,6 +123,9 @@ class BuildTasksImpl extends BuildTasks { sysproperty(key: "idea.home.path", value: buildContext.paths.projectHome) sysproperty(key: "idea.system.path", value: systemPath) sysproperty(key: "idea.config.path", value: configPath) + if (buildContext.productProperties.platformPrefix != null) { + sysproperty(key: "idea.platform.prefix", value: buildContext.productProperties.platformPrefix) + } arg(value: "$classpathFile") arg(line: "com.intellij.idea.Main traverseUI") arg(value: targetFile) @@ -244,6 +247,26 @@ idea.fatal.error.notification=disabled } } + @Override + void compileModulesAndBuildDistributions(List allPlugins) { + def productLayout = buildContext.productProperties.productLayout + cleanOutput() + def includedModules = productLayout.getIncludedModules(allPlugins) + compileModules(includedModules) + buildContext.messages.block("Build platform and plugin JARs") { + new DistributionJARsBuilder(buildContext, includedModules, allPlugins).buildJARs() + } + if (buildContext.productProperties.scrambleMainJar) { + if (buildContext.scrambleTool != null) { + buildContext.scrambleTool.scramble(buildContext.productProperties.productLayout.mainJarName, buildContext) + } + else { + buildContext.messages.warning("Scrambling skipped: 'srambleTool' isn't defined") + } + } + buildDistributions() + } + @Override void cleanOutput() { buildContext.messages.block("Clean output") { @@ -262,6 +285,11 @@ idea.fatal.error.notification=disabled @Override void compileProjectAndTests(List includingTestsInModules = []) { + compileModules(null, includingTestsInModules) + } + + @Override + void compileModules(List moduleNames, List includingTestsInModules = []) { if (buildContext.options.useCompiledClassesFromProjectOutput) { buildContext.messages.info("Compilation skipped, the compiled classes from the project output will be used") return @@ -272,7 +300,18 @@ idea.fatal.error.notification=disabled } buildContext.projectBuilder.cleanOutput() - buildContext.projectBuilder.buildProduction() + if (moduleNames == null) { + buildContext.projectBuilder.buildProduction() + } + else { + List modulesToBuild = ((moduleNames as Set) + DistributionJARsBuilder.ADDITIONAL_MODULES_TO_COMPILE + + buildContext.scrambleTool?.additionalModulesToCompile ?: []) as List + List invalidModules = modulesToBuild.findAll {buildContext.findModule(it) == null} + if (!invalidModules.empty) { + buildContext.messages.warning("The following modules won't be compiled: $invalidModules") + } + buildContext.projectBuilder.buildModules(modulesToBuild.collect {buildContext.findModule(it)}.findAll {it != null}) + } for (String moduleName : includingTestsInModules) { buildContext.projectBuilder.makeModuleTests(buildContext.findModule(moduleName)) } diff --git a/build/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy new file mode 100644 index 000000000000..797f44f48da2 --- /dev/null +++ b/build/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy @@ -0,0 +1,405 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.intellij.build.impl + +import com.intellij.openapi.util.io.FileUtil +import com.intellij.util.PathUtilRt +import org.jetbrains.intellij.build.BuildContext +import org.jetbrains.intellij.build.BuildOptions +import org.jetbrains.jps.model.java.JpsJavaClasspathKind +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsLibraryDependency +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil + +/** + * @author nik + */ +class DistributionJARsBuilder { + public static final List ADDITIONAL_MODULES_TO_COMPILE = [ + "java-runtime",//required to build searchable options index + "colorSchemes", "platform-resources", "platform-resources-en", "boot", "icons", "forms_rt", "bootstrap" + ] + private static final boolean COMPRESS_JARS = false + private static final String RESOURCES_INCLUDED = "resources.included" + private static final String RESOURCES_EXCLUDED = "resources.excluded" + private final BuildContext buildContext + private final List allPlugins + private final Set usedModules = new LinkedHashSet<>() + private final List includedModules + + DistributionJARsBuilder(BuildContext buildContext, List includedModules, List allPlugins) { + this.includedModules = includedModules + this.buildContext = buildContext + this.allPlugins = allPlugins + buildContext.ant.patternset(id: RESOURCES_INCLUDED) { + include(name: "**/*.properties") + include(name: "fileTemplates/**/*") + include(name: "inspectionDescriptions/**/*") + include(name: "intentionDescriptions/**/*") + include(name: "tips/**/*") + include(name: "search/**/*") + } + + buildContext.ant.patternset(id: RESOURCES_EXCLUDED) { + exclude(name: "**/*.properties") + exclude(name: "fileTemplates/**/*") + exclude(name: "fileTemplates") + exclude(name: "inspectionDescriptions/**/*") + exclude(name: "inspectionDescriptions") + exclude(name: "intentionDescriptions/**/*") + exclude(name: "intentionDescriptions") + exclude(name: "tips/**/*") + exclude(name: "tips") + } + } + + void buildJARs() { + buildLib() + buildPlugins() + + def productProperties = buildContext.productProperties + if (productProperties.generateLibrariesLicensesTable) { + buildContext.messages.block("Generate table of licenses for used third-party libraries") { + def generator = new LibraryLicensesListGenerator(buildContext.projectBuilder, buildContext.project, productProperties.allLibraryLicenses) + generator.generateLicensesTable("$buildContext.paths.artifacts/${buildContext.applicationInfo.productName}-third-party-libraries.txt", usedModules) + } + } + + if (productProperties.scrambleMainJar) { + createLayoutBuilder().layout(buildContext.paths.artifacts) { + jar("internalUtilities.jar") { + module("internalUtilities") + } + } + } + } + + private void buildLib() { + def ant = buildContext.ant + def layoutBuilder = createLayoutBuilder() + def productLayout = buildContext.productProperties.productLayout + def searchableOptionsDir = new File(buildContext.paths.temp, "searchableOptions/result") + + //todo[nik] move buildSearchableOptions and patchedApplicationInfo methods to this class + def buildTasks = new BuildTasksImpl(buildContext) + buildTasks.buildSearchableOptions(searchableOptionsDir, [productLayout.mainModule], productLayout.licenseFilesToBuildSearchableOptions) + if (!buildContext.options.buildStepsToSkip.contains(BuildOptions.SEARCHABLE_OPTIONS_INDEX_STEP)) { + layoutBuilder.patchModuleOutput(productLayout.searchableOptionsModule, FileUtil.toSystemIndependentName(searchableOptionsDir.absolutePath)) + } + + def applicationInfoFile = FileUtil.toSystemIndependentName(buildTasks.patchApplicationInfo().absolutePath) + def applicationInfoDir = "$buildContext.paths.temp/applicationInfo" + ant.copy(file: applicationInfoFile, todir: "$applicationInfoDir/idea") + layoutBuilder.patchModuleOutput(buildContext.productProperties.applicationInfoModule, applicationInfoDir) + + if (buildContext.productProperties.reassignAltClickToMultipleCarets) { + def patchedKeyMapDir = createKeyMapWithAltClickReassignedToMultipleCarets() + layoutBuilder.patchModuleOutput("platform-resources", FileUtil.toSystemIndependentName(patchedKeyMapDir.absolutePath)) + } + + Set usedJars = collectUsedJars(includedModules, []) - productLayout.additionalJarsToUnpackIntoMainJar.collect {FileUtil.toSystemIndependentName(it)} + + if (buildContext.scrambleTool != null) { + def forbiddenJarNames = buildContext.scrambleTool.namesOfJarsRequiredToBeScrambled + def forbiddenJars = usedJars.findAll { forbiddenJarNames.contains(PathUtilRt.getFileName(it)) } + if (!forbiddenJars.empty) { + buildContext.messages.error("The following JARs cannot be included into the product 'lib' directory, they need to be scrambled with the main jar: ${forbiddenJars}") + } + } + + def communityHome = "$buildContext.paths.communityHome" + def resourcesIncluded = RESOURCES_INCLUDED + def resourcesExcluded = RESOURCES_EXCLUDED + + layoutBuilder.layout("$buildContext.paths.distAll/lib") { + jar("util.jar") { + module("util") + module("util-rt") + } + jar("openapi.jar") { + productLayout.platformApiModules.each { module it } + } + + jar("annotations.jar") { + module("annotations-common") + module("annotations") + } + jar("extensions.jar") { module("extensions") } + jar("bootstrap.jar") { module("bootstrap") } + jar("resources.jar", true) { + modulePatches(["platform-resources"]) + module("colorSchemes") + module("platform-resources") + } + + jar("forms_rt.jar") { module("forms_rt") } + + productLayout.additionalPlatformModules.entrySet().findAll { it.value != "resources_en.jar" }.each { + def moduleName = it.key + jar(it.value) { + module(moduleName) + } + } + + jar("resources_en.jar", true) { + productLayout.additionalPlatformModules.entrySet().findAll { it.value == "resources_en.jar"}.each { + modulePatches([it.key]) + module(it.key) + } + module("platform-resources-en") + module("coverage-common") { + ant.patternset(refid: resourcesIncluded) + } + } + + jar("icons.jar") { module("icons") } + jar("boot.jar") { module("boot") } + projectLibrary("KotlinJavaRuntime") + + jar(productLayout.mainJarName, true, false) { + modulePatches(productLayout.platformImplementationModules) + productLayout.platformImplementationModules.each { module it } + module("coverage-common") { + ant.patternset(refid: resourcesExcluded) + } + productLayout.additionalJarsToUnpackIntoMainJar.each { + ant.zipfileset(src: it) + } + } + + usedJars.each { + ant.fileset(file: it) + } + + dir("libpty") { + ant.fileset(dir: "$communityHome/lib/libpty") { + exclude(name: "*.txt") + } + } + dir("ext") {//why ext? + projectLibrary("CGLIB") + } + + dir("src") { + ant.fileset(dir: "$communityHome/lib/src") { + include(name: "trove4j_changes.txt") + include(name: "trove4j_src.jar") + } + } + } + usedModules.addAll(layoutBuilder.usedModules) + } + + private void buildPlugins() { + def ant = buildContext.ant + def productLayout = buildContext.productProperties.productLayout + def layoutBuilder = createLayoutBuilder() + + if (buildContext.productProperties.setPluginAndIDEVersionInPluginXml) { + def pluginsToBuild = getPluginsByModules(productLayout.pluginModulesToPublish) + pluginsToBuild.each { plugin -> + def moduleOutput = buildContext.projectBuilder.moduleOutput(buildContext.findRequiredModule(plugin.mainModule)) + def pluginXmlPath = "$moduleOutput/META-INF/plugin.xml" + if (!new File(pluginXmlPath)) { + buildContext.messages.error("plugin.xml not found in $plugin.mainModule module: $pluginXmlPath") + } + def patchedPluginXmlDir = "$buildContext.paths.temp/patched-plugin-xml/$plugin.mainModule" + ant.copy(file: pluginXmlPath, todir: "$patchedPluginXmlDir/META-INF") + setPluginVersionAndSince("$patchedPluginXmlDir/META-INF/plugin.xml", buildContext.buildNumber) + layoutBuilder.patchModuleOutput(plugin.mainModule, patchedPluginXmlDir) + } + } + + buildPlugins(layoutBuilder, getPluginsByModules(productLayout.bundledPluginModules), "$buildContext.paths.distAll/plugins") + usedModules.addAll(layoutBuilder.usedModules) + + def pluginsToPublishDir = "$buildContext.paths.temp/plugins-to-publish" + def pluginsToPublish = getPluginsByModules(productLayout.pluginModulesToPublish) + buildPlugins(layoutBuilder, pluginsToPublish, pluginsToPublishDir) + pluginsToPublish.each { plugin -> + def directory = plugin.directoryName + ant.zip(destfile: "$buildContext.paths.artifacts/plugins/$directory-${buildContext.buildNumber}.zip") { + zipfileset(dir: "$pluginsToPublishDir/$directory", prefix: directory) + } + } + } + + private List getPluginsByModules(List modules) { + def modulesToInclude = modules as Set + allPlugins.findAll { modulesToInclude.contains(it.mainModule) } + } + + private buildPlugins(LayoutBuilder layoutBuilder, List pluginsToInclude, String targetDirectory) { + def ant = buildContext.ant + def resourceExcluded = RESOURCES_EXCLUDED + def resourcesIncluded = RESOURCES_INCLUDED + def enabledModulesSet = buildContext.productProperties.productLayout.enabledPluginModules + layoutBuilder.layout(targetDirectory) { + pluginsToInclude.each { plugin -> + dir(plugin.directoryName) { + dir("lib") { + def actualModuleJars = plugin.getActualModules(enabledModulesSet) + actualModuleJars.entrySet().each { + def modules = it.value + def jarPath = it.key + jar(jarPath, true) { + modulePatches(modules) + modules.each { moduleName -> + module(moduleName) { + if (plugin.packLocalizableResourcesInCommonJar(moduleName)) { + ant.patternset(refid: resourceExcluded) + } + plugin.moduleExcludes.get(moduleName)?.each { + ant.exclude(name: "$it/**") + } + } + } + } + } + def modulesWithResources = actualModuleJars.values().findAll { plugin.packLocalizableResourcesInCommonJar(it) } + if (!modulesWithResources.empty) { + jar("resources_en.jar") { + modulesWithResources.each { + module(it) { + ant.patternset(refid: resourcesIncluded) + } + } + } + } + plugin.includedProjectLibraries.each { + projectLibrary(it) + } + + //include all module libraries from the plugin modules added to IDE classpath to layout + actualModuleJars.entrySet().findAll {!it.key.contains("/")}.collectMany {it.value}.each { moduleName -> + findModule(moduleName).dependenciesList.dependencies. + findAll { it instanceof JpsLibraryDependency && it?.libraryReference?.parentReference?.resolve() instanceof JpsModule}. + findAll { JpsJavaExtensionService.instance.getDependencyExtension(it)?.scope?.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME) ?: false}. + each { + jpsLibrary(((JpsLibraryDependency)it).library) + } + } + + plugin.includedModuleLibraries.each { data -> + dir(data.relativeOutputPath) { + moduleLibrary(data.moduleName, data.libraryName) + } + } + } + plugin.resourcePaths.entrySet().each { + def contentRoot = JpsPathUtil.urlToPath(findModule(plugin.mainModule).contentRootsList.urls.first()) + def path = "$contentRoot/$it.key" + dir(it.value) { + if (new File(path).isFile()) { + ant.fileset(file: path) + } + else { + ant.fileset(dir: path) + } + } + } + plugin.resourceArchivePaths.entrySet().each { + def contentRoot = JpsPathUtil.urlToPath(findModule(plugin.mainModule).contentRootsList.urls.first()) + def path = "$contentRoot/$it.key" + zip(it.value) { + ant.fileset(dir: path) + } + } + } + } + } + } + + private LayoutBuilder createLayoutBuilder() { + new LayoutBuilder(buildContext.ant, buildContext.project, COMPRESS_JARS) + } + + private void setPluginVersionAndSince(String pluginXmlPath, String buildNumber) { + buildContext.ant.replaceregexp(file: pluginXmlPath, + match: "[\\d.]*", + replace: "${buildNumber}") + buildContext.ant.replaceregexp(file: pluginXmlPath, + match: "\\s*<\\!\\[CDATA\\[\\s*Plugin version: \\\$\\{version\\}", + replace: "\n")) { + def dotIndex = buildNumber.indexOf('.') + def untilBuild = dotIndex > 0 ? Integer.parseInt(buildNumber.substring(0, dotIndex)) + ".*" : buildNumber + def anchor = text.contains("") ? "" : "" + file.text = text.replace(anchor, + "${anchor}\n ${buildNumber}\n \n") + } + } + + private Set collectUsedJars(List modules, List additionalLibFolders) { + def usedJars = new LinkedHashSet(); + List approvedJars = + (["$buildContext.paths.communityHome/lib", "$buildContext.paths.projectHome/lib", "$buildContext.paths.communityHome/xml/relaxng/lib"] as List) + + additionalLibFolders + + modules.each { + def module = buildContext.findModule(it) + if (module != null) { + buildContext.projectBuilder.moduleRuntimeClasspath(module, false).each { + File file = new File(it) + if (file.exists()) { + String path = FileUtil.toSystemIndependentName(file.canonicalPath) + if (path.endsWith(".jar") && approvedJars.any { FileUtil.startsWith(path, it) }) { + if (usedJars.add(path)) { + buildContext.messages.info("\tADDED: $path for $module.name") + } + } + } + } + } + } + + return usedJars + } + + private File createKeyMapWithAltClickReassignedToMultipleCarets() { + def sourceFile = new File("${buildContext.projectBuilder.moduleOutput(buildContext.findModule("platform-resources"))}/idea/Keymap_Default.xml") + String defaultKeymapContent = sourceFile.text + defaultKeymapContent = defaultKeymapContent.replace("", "") + defaultKeymapContent = defaultKeymapContent.replace("", + "") + def patchedKeyMapDir = new File(buildContext.paths.temp, "patched-keymap") + def targetFile = new File(patchedKeyMapDir, "idea/Keymap_Default.xml") + FileUtil.createParentDirs(targetFile) + targetFile.text = defaultKeymapContent + return patchedKeyMapDir + } +} diff --git a/build/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy new file mode 100644 index 000000000000..d51b5785472a --- /dev/null +++ b/build/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy @@ -0,0 +1,221 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.intellij.build.impl + +import com.intellij.openapi.util.MultiValuesMap +import com.intellij.util.PathUtilRt +import org.apache.tools.ant.AntClassLoader +import org.jetbrains.jps.model.JpsProject +import org.jetbrains.jps.model.library.JpsLibrary +import org.jetbrains.jps.model.library.JpsOrderRootType +import org.jetbrains.jps.model.module.JpsModule + +/** + * This is replacement for {@link org.jetbrains.jps.gant.JpsGantTool} which doesn't depend on Gant. It also allows us to patch a module + * output before packing it into JAR. + * + * @author nik + */ +class LayoutBuilder { + private final AntBuilder ant + private final boolean compressJars + final Set usedModules = new LinkedHashSet<>() + private final MultiValuesMap moduleOutputPatches = new MultiValuesMap<>(true) + private final JpsProject project + + LayoutBuilder(AntBuilder ant, JpsProject project, boolean compressJars) { + this.project = project + this.ant = ant + this.compressJars = compressJars + + def contextLoaderRef = "GANT_CONTEXT_CLASS_LOADER"; + if (!ant.project.hasReference(contextLoaderRef)) { + ClassLoader contextLoader = Thread.currentThread().contextClassLoader + if (!(contextLoader instanceof AntClassLoader)) { + contextLoader = new AntClassLoader(contextLoader, ant.project, null) + } + ant.project.addReference(contextLoaderRef, contextLoader) + ant.taskdef(name: "layout", loaderRef: contextLoaderRef, classname: "jetbrains.antlayout.tasks.LayoutTask") + } + } + + /** + * Contents of {@code pathToDirectoryWithPatchedFiles} will be used to patch the module output. Set 'preserveDuplicates' to {@code true} + * when calling {@link LayoutSpec#jar} and call {@link LayoutSpec#modulePatches} from its body to apply the patches to the JAR. + */ + void patchModuleOutput(String moduleName, String pathToDirectoryWithPatchedFiles) { + moduleOutputPatches.put(moduleName, pathToDirectoryWithPatchedFiles) + } + + /** + * Creates the output layout accordingly to {@code data} in {@code targetDirectory}. Please note that {@code data} may refer to local + * variables of its method only. It cannot refer to its fields or methods because data's 'owner' field is changed to support the internal DSL. + */ + void layout(String targetDirectory, @DelegatesTo(LayoutSpec) Closure data) { + def spec = new LayoutSpec() + //we cannot set 'spec' as delegate because 'delegate' will be overwritten by AntBuilder + def body = data.rehydrate(null, spec, data.thisObject) + body.resolveStrategy = Closure.OWNER_FIRST + ant.layout(toDir: targetDirectory, body) + } + + class LayoutSpec { + /** + * Create a JAR file with name {@code relativePath} (it may also include parent directories names for the JAR) into the current place + * in the layout. The content of the JAR is specified by {@code body}. + */ + def jar(String relativePath, boolean preserveDuplicates = false, boolean mergeManifests = true, Closure body) { + def directory = PathUtilRt.getParentPath(relativePath) + if (directory == "") { + ant.jar(name: relativePath, compress: compressJars, duplicate: preserveDuplicates ? "preserve" : "fail", + filesetmanifest: mergeManifests ? "merge" : "skip", body) + } + else { + dir(directory) { + jar(PathUtilRt.getFileName(relativePath), preserveDuplicates, mergeManifests, body) + } + } + } + + /** + * Create a Zip file with name {@code relativePath} (it may also include parent directories names for the JAR) into the current place + * in the layout. The content of the JAR is specified by {@code body}. + */ + def zip(String relativePath, Closure body) { + def directory = PathUtilRt.getParentPath(relativePath) + if (directory == "") { + ant.zip(name: relativePath, body) + } + else { + dir(directory) { + zip(PathUtilRt.getFileName(relativePath), body) + } + } + } + + /** + * Create a directory (or several nested directories) {@code relativePath} in the current place in the layout. The content of the + * directory is specified by {@code body}. + */ + def dir(String relativePath, Closure body) { + def parent = PathUtilRt.getParentPath(relativePath) + if (relativePath.empty) { + body() + } + else if (parent.empty) { + ant.dir(name: relativePath, body) + } + else { + dir(parent) { + dir(PathUtilRt.getFileName(relativePath), body) + } + } + } + + /** + * Include the patched outputs of {@code moduleNames} modules to the current place in the layout. This method is supposed to be called + * in the {@code body} of {@link #jar} with 'preserveDuplicates' set to {@code true} + */ + def modulePatches(Collection moduleNames) { + moduleNames.each { + moduleOutputPatches.get(it)?.each { + ant.fileset(dir: it) + } + } + } + + /** + * Include production output of {@code moduleName} to the current place in the layout + */ + def module(String moduleName, Closure body = {}) { + usedModules << moduleName + ant.module(name: moduleName, body) + } + + /** + * Include test output of {@code moduleName} to the current place in the layout + */ + def moduleTests(String moduleName, Closure body = {}) { + ant.moduleTests(name: moduleName, body) + } + + /** + * Include JARs added as classes roots of project library {@code libraryName} to the current place in the layout + */ + def projectLibrary(String libraryName) { + def library = project.libraryCollection.findLibrary(libraryName) + if (library == null) { + throw new IllegalArgumentException("Cannot find library $libraryName in the project") + } + jpsLibrary(library) + } + + /** + * Include JARs added as classes roots of a module library {@code libraryName} from module {@code moduleName} to the current place in the layout + */ + def moduleLibrary(String moduleName, String libraryName) { + def module = findModule(moduleName) + def library = module.libraryCollection.libraries.find {getLibraryName(it) == libraryName} + if (library == null) { + throw new IllegalArgumentException("Cannot find library $libraryName in '$moduleName' module") + } + jpsLibrary(library) + } + + def jpsLibrary(JpsLibrary library) { + library.getFiles(JpsOrderRootType.COMPILED).each { + ant.fileset(file: it.absolutePath) + } + } + + def JpsModule findModule(String name) { + def module = project.modules.find { it.name == name } + if (module == null) { + throw new IllegalArgumentException("Cannot find module '$name' in the project") + } + module + } + + private String getLibraryName(JpsLibrary lib) { + def name = lib.name + if (name.startsWith("#")) { + if (lib.getRoots(JpsOrderRootType.COMPILED).size() != 1) { + def urls = lib.getRoots(JpsOrderRootType.COMPILED).collect { it.url } + throw new IllegalStateException("Non-single entry module library $name: $urls"); + } + File file = lib.getFiles(JpsOrderRootType.COMPILED)[0] + return file.name + } + return name + } + } +} + diff --git a/build/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy index 1b6549a61c57..badd29c54816 100644 --- a/build/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy +++ b/build/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy @@ -36,7 +36,11 @@ class LinuxDistributionBuilder { //todo[nik] rename void layoutUnix(File ideaProperties) { buildContext.ant.copy(todir: "$unixDistPath/bin") { - fileset(dir: "$buildContext.paths.communityHome/bin/linux") + fileset(dir: "$buildContext.paths.communityHome/bin/linux") { + if (!buildContext.includeBreakGenLibraries()) { + exclude(name: "libbreakgen*") + } + } if (buildContext.productProperties.yourkitAgentBinariesDirectoryPath != null) { fileset(dir: buildContext.productProperties.yourkitAgentBinariesDirectoryPath) { include(name: "libyjpagent-linux*.so") @@ -47,7 +51,9 @@ class LinuxDistributionBuilder { //todo[nik] converting line separators to unix-style make sense only when building Linux distributions under Windows on a local machine; // for real installers we need to checkout all text files with 'lf' separators anyway buildContext.ant.fixcrlf(file: "$unixDistPath/bin/idea.properties", eol: "unix") - buildContext.ant.copy(file: customizer.iconPngPath, tofile: "$unixDistPath/bin/${buildContext.productProperties.baseFileName}.png") + if (customizer.iconPngPath != null) { + buildContext.ant.copy(file: customizer.iconPngPath, tofile: "$unixDistPath/bin/${buildContext.productProperties.baseFileName}.png") + } unixScripts() unixVMOptions() @@ -70,10 +76,8 @@ class LinuxDistributionBuilder { String classPath = "CLASSPATH=\"\$IDE_HOME/lib/${buildContext.bootClassPathJarNames[0]}\"\n" classPath += buildContext.bootClassPathJarNames[1..-1].collect { "CLASSPATH=\"\$CLASSPATH:\$IDE_HOME/lib/${it}\"" }.join("\n") - def jvmArgs = buildContext.productProperties.additionalIdeJvmArguments if (buildContext.productProperties.toolsJarRequired) { classPath += "\nCLASSPATH=\"\$CLASSPATH:\$JDK/lib/tools.jar\"" - jvmArgs = "$jvmArgs -Didea.jre.check=true".trim() } buildContext.ant.copy(todir: "${unixDistPath}/bin") { @@ -81,11 +85,11 @@ class LinuxDistributionBuilder { filterset(begintoken: "@@", endtoken: "@@") { filter(token: "product_full", value: fullName) - filter(token: "product_uc", value: buildContext.applicationInfo.upperCaseProductName) + filter(token: "product_uc", value: buildContext.productProperties.environmentVariableBaseName(buildContext.applicationInfo)) filter(token: "vm_options", value: vmOptionsFileName) filter(token: "isEap", value: buildContext.applicationInfo.isEAP) filter(token: "system_selector", value: buildContext.systemSelector) - filter(token: "ide_jvm_args", value: jvmArgs) + filter(token: "ide_jvm_args", value: buildContext.additionalJvmArguments) filter(token: "class_path", value: classPath) filter(token: "script_name", value: name) } diff --git a/build/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy index 172479fa1e6f..568c693c819d 100644 --- a/build/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy +++ b/build/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy @@ -15,12 +15,14 @@ */ package org.jetbrains.intellij.build.impl +import com.intellij.util.PathUtilRt import org.jetbrains.intellij.build.BuildContext import org.jetbrains.intellij.build.BuildOptions import org.jetbrains.intellij.build.JvmArchitecture import org.jetbrains.intellij.build.MacDistributionCustomizer import java.time.LocalDate + /** * @author nik */ @@ -36,21 +38,25 @@ class MacDistributionBuilder { } public layoutMac(File ideaPropertiesFile) { - def docTypes = customizer.docTypes ?: """ + def docTypes = (customizer.associateIpr ? """ CFBundleTypeExtensions ipr CFBundleTypeIconFile - ${buildContext.productProperties.baseFileName}.icns + ${PathUtilRt.getFileName(customizer.icnsPath ?: "idea.icns")} CFBundleTypeName ${buildContext.applicationInfo.productName} Project File CFBundleTypeRole Editor -""" - Map customIdeaProperties = ["idea.jre.check": "$buildContext.productProperties.toolsJarRequired"]; +""" : "") + customizer.additionalDocTypes + Map customIdeaProperties = [:] + if (buildContext.productProperties.toolsJarRequired) { + customIdeaProperties["idea.jre.check"] = "true" + } + customIdeaProperties.putAll(customizer.customIdeaProperties(buildContext.applicationInfo)) layoutMacApp(ideaPropertiesFile, customIdeaProperties, docTypes) customizer.copyAdditionalFiles(buildContext, macDistPath) def macZipPath = buildMacZip() diff --git a/build/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy b/build/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy new file mode 100644 index 000000000000..2ae33d4a4d73 --- /dev/null +++ b/build/groovy/org/jetbrains/intellij/build/impl/PluginLayout.groovy @@ -0,0 +1,200 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.intellij.build.impl + +import com.intellij.openapi.util.MultiValuesMap +import groovy.transform.Immutable + +/** + * @author nik + */ +class PluginLayout { + final String mainModule + String directoryName + /** JAR name (or path relative to 'lib' directory) to module name */ + final MultiValuesMap moduleJars = new MultiValuesMap<>(true) + /** source directory -> relative path to a target directory under the plugin directory */ + final Map resourcePaths = [:] + /** source directory -> relative path to a zip file under the plugin directory */ + final Map resourceArchivePaths = [:] + /** module name to entries which should be excluded from its output */ + final MultiValuesMap moduleExcludes = new MultiValuesMap<>(true) + final List includedProjectLibraries = [] + final List includedModuleLibraries = [] + private final Set optionalModules = new LinkedHashSet<>() + private final Set modulesWithLocalizableResourcesInCommonJar = new LinkedHashSet<>() + private boolean doNotCreateSeparateJarForLocalizableResources + + private PluginLayout(String mainModule) { + this.mainModule = mainModule + } + + /** + * Creates the plugin layout description. The default plugin layout is composed of a jar with name {@code mainModuleName}.jar containing output of + * {@code mainModuleName}, resources_en.jar containing translatable resources from {@code mainModuleName}, and the module libraries of + * {@code mainModuleName} with scopes 'Compile' and 'Runtime' placed under 'lib' directory in a directory with name {@code mainModuleName}. + * In you need to include additional resources or modules into the plugin layout specify them in {@code body} parameter. + * + * @param mainModuleName name of the module containing META-INF/plugin.xml file of the plugin + */ + static PluginLayout plugin(String mainModuleName, @DelegatesTo(PluginLayoutSpec) Closure body = {}) { + def layout = new PluginLayout(mainModuleName) + def spec = new PluginLayoutSpec(layout) + body.delegate = spec + body() + layout.directoryName = spec.directoryName + spec.withModule(mainModuleName, spec.mainJarName) + if (layout.doNotCreateSeparateJarForLocalizableResources) { + layout.modulesWithLocalizableResourcesInCommonJar.clear() + } + return layout + } + + MultiValuesMap getActualModules(Set enabledPluginModules) { + def result = new MultiValuesMap(true) + for (Map.Entry> entry : moduleJars.entrySet()) { + for (String moduleName : entry.getValue()) { + if (!optionalModules.contains(moduleName) || enabledPluginModules.contains(moduleName)) { + result.put(entry.key, moduleName) + } + } + } + return result + } + + boolean packLocalizableResourcesInCommonJar(String moduleName) { + return modulesWithLocalizableResourcesInCommonJar.contains(moduleName) + } + + static class PluginLayoutSpec { + private final PluginLayout layout + /** + * Name of the directory (under 'plugins' directory) where the plugin should be placed + */ + String directoryName + /** + * Name of the main plugin JAR file + */ + String mainJarName + + PluginLayoutSpec(PluginLayout layout) { + this.layout = layout + directoryName = layout.mainModule + mainJarName = "${layout.mainModule}.jar" + } + + /** + * Register an optional module which may be excluded from the plugin distribution in some products + */ + void withOptionalModule(String moduleName, String relativeJarPath = "${moduleName}.jar") { + layout.optionalModules << moduleName + withModule(moduleName, relativeJarPath) + } + + /** + * Register an additional module to be included into the plugin distribution. If {@code relativeJarPath} doesn't contain '/' (i.e. the + * JAR will be added to the plugin's classpath) this will also cause modules library from {@code moduleName} with scopes 'Compile' and + * 'Runtime' to be copied to the 'lib' directory of the plugin. + * + * @param relativeJarPath target JAR path relative to 'lib' directory of the plugin; different modules may be packed into the same JAR, + * but don't use this for new plugins; this parameter is temporary added to keep layout of old plugins. + * @param localizableResourcesInCommonJar if {@code true} the translatable resources from the module (messages, inspection descriptions, etc) will be + * placed into a separate 'resources_en.jar'. Do not use this for new plugins, this parameter is temporary added to keep layout of old plugins. + */ + void withModule(String moduleName, String relativeJarPath = "${moduleName}.jar", boolean localizableResourcesInCommonJar = true) { + if (localizableResourcesInCommonJar) { + layout.modulesWithLocalizableResourcesInCommonJar << moduleName + } + layout.moduleJars.put(relativeJarPath, moduleName) + } + + void withJpsModule(String moduleName) { + withModule(moduleName, "jps/${moduleName}.jar") + } + + /** + * @param resourcePath path to resource file or directory relative to the plugin's main module content root + * @param relativeOutputDirectory target path relative to the plugin root directory + */ + void withResource(String resourcePath, String relativeOutputDirectory) { + layout.resourcePaths[resourcePath] = relativeOutputDirectory + } + + /** + * @param resourcePath path to resource file or directory relative to the plugin's main module content root + * @param relativeOutputFile target path relative to the plugin root directory + */ + void withResourceArchive(String resourcePath, String relativeOutputFile) { + layout.resourceArchivePaths[resourcePath] = relativeOutputFile + } + + /** + * Include the project library to 'lib' directory of the plugin distribution + */ + void withProjectLibrary(String libraryName) { + layout.includedProjectLibraries << libraryName + } + + /** + * Include the module library to the plugin distribution. Please note that it makes sense to call this method only + * for additional modules which aren't copied directly to the 'lib' directory of the plugin distribution, because for ordinary modules + * their module libraries are included into the layout automatically. + */ + void withModuleLibrary(String libraryName, String moduleName = layout.mainModule, String relativeOutputPath) { + layout.includedModuleLibraries << new ModuleLibraryData(moduleName: moduleName, libraryName: libraryName, relativeOutputPath: relativeOutputPath) + } + + /** + * Exclude the specified directory when {@code moduleName} is packed into JAR file. + * This is a temporary method added to keep layout of some old plugins. If some directory from a module shouldn't be included into the + * module JAR it's strongly recommended to move that directory outside of the module source roots. + * @param excludedDirectory path to the directory to be exclude relatively to the module output root + */ + void excludeFromModule(String moduleName, String excludedDirectory) { + layout.moduleExcludes.put(moduleName, excludedDirectory) + } + + /** + * Do not create 'resources_en.jar' and pack all resources into corresponding module JARs. + * Do not use this for new plugins, this method is temporary added to keep layout of old plugins. + */ + void doNotCreateSeperateJarForLocalizableResources() { + layout.doNotCreateSeparateJarForLocalizableResources = true + } + } + + @Immutable + static class ModuleLibraryData { + String moduleName + String libraryName + String relativeOutputPath + } +} \ No newline at end of file diff --git a/build/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy index bf23841eab53..97f17d38ad82 100644 --- a/build/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy +++ b/build/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy @@ -122,13 +122,12 @@ class WinExeInstallerBuilder { !define PRODUCT_VM_OPTIONS_FILE "${toSystemDependentName("$winDistPath/bin/")}\${PRODUCT_VM_OPTIONS_NAME}" """ - String fullProductName = productProperties.fullNameIncludingEdition(buildContext.applicationInfo) def extensionsList = customizer.fileAssociations def fileAssociations = extensionsList.isEmpty() ? "NoAssociation" : extensionsList.join(",") new File(box, "nsiconf/strings.nsi").text = """ -!define MANUFACTURER "JetBrains" -!define MUI_PRODUCT "$fullProductName" -!define PRODUCT_FULL_NAME "$fullProductName" +!define MANUFACTURER "${buildContext.applicationInfo.shortCompanyName}" +!define MUI_PRODUCT "${customizer.fullNameIncludingEdition(buildContext.applicationInfo)}" +!define PRODUCT_FULL_NAME "${customizer.fullNameIncludingEditionAndVendor(buildContext.applicationInfo)}" !define PRODUCT_EXE_FILE "${productProperties.baseFileName}.exe" !define PRODUCT_EXE_FILE_64 "${productProperties.baseFileName}64.exe" !define PRODUCT_ICON_FILE "install.ico" @@ -138,7 +137,7 @@ class WinExeInstallerBuilder { !define ASSOCIATION "$fileAssociations" !define UNINSTALL_WEB_PAGE "${customizer.uninstallFeedbackPageUrl(buildContext.applicationInfo) ?: "feedback_web_page"}" -; if SHOULD_SET_DEFAULT_INSTDIR != 0 then default installation directory will be directory where highest-numbered IDEA build has been installed +; if SHOULD_SET_DEFAULT_INSTDIR != 0 then default installation directory will be directory where highest-numbered IDE build has been installed ; set to 1 for release build !define SHOULD_SET_DEFAULT_INSTDIR "0" diff --git a/build/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy b/build/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy index 6d0484b21956..774f54928f64 100644 --- a/build/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy +++ b/build/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy @@ -20,6 +20,7 @@ import org.jetbrains.intellij.build.BuildOptions import org.jetbrains.intellij.build.JvmArchitecture import org.jetbrains.intellij.build.WindowsDistributionCustomizer import org.jetbrains.jps.model.module.JpsModuleSourceRoot + /** * @author nik */ @@ -37,7 +38,11 @@ class WindowsDistributionBuilder { //todo[nik] rename void layoutWin(File ideaProperties) { buildContext.ant.copy(todir: "$winDistPath/bin") { - fileset(dir: "$buildContext.paths.communityHome/bin/win") + fileset(dir: "$buildContext.paths.communityHome/bin/win") { + if (!buildContext.includeBreakGenLibraries()) { + exclude(name: "breakgen*") + } + } if (buildContext.productProperties.yourkitAgentBinariesDirectoryPath != null) { fileset(dir: buildContext.productProperties.yourkitAgentBinariesDirectoryPath) { include(name: "yjpagent*.dll") @@ -47,7 +52,9 @@ class WindowsDistributionBuilder { buildContext.ant.copy(file: ideaProperties.path, todir: "$winDistPath/bin") buildContext.ant.fixcrlf(file: "$winDistPath/bin/idea.properties", eol: "dos") - buildContext.ant.copy(file: customizer.icoPath, tofile: "$winDistPath/bin/${buildContext.productProperties.baseFileName}.ico") + if (customizer.icoPath != null) { + buildContext.ant.copy(file: customizer.icoPath, tofile: "$winDistPath/bin/${buildContext.productProperties.baseFileName}.ico") + } if (customizer.includeBatchLaunchers) { winScripts() } @@ -58,7 +65,7 @@ class WindowsDistributionBuilder { def arch = customizer.bundledJreArchitecture def jreDirectoryPath = arch != null ? buildContext.bundledJreManager.extractWinJre(arch) : null - buildWinZip(jreDirectoryPath, ".win") + buildWinZip(jreDirectoryPath, buildContext.productProperties.buildCrossPlatformDistribution ? ".win" : "") if (arch != null && customizer.buildZipWithBundledOracleJre) { String oracleJrePath = buildContext.bundledJreManager.extractOracleWinJre(arch) if (oracleJrePath != null) { @@ -82,7 +89,6 @@ class WindowsDistributionBuilder { String classPath = "SET CLASS_PATH=%IDE_HOME%\\lib\\${buildContext.bootClassPathJarNames[0]}\n" classPath += buildContext.bootClassPathJarNames[1..-1].collect { "SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\\lib\\$it" }.join("\n") - def jvmArgs = getAdditionalJvmArguments() if (buildContext.productProperties.toolsJarRequired) { classPath += "\nSET CLASS_PATH=%CLASS_PATH%;%JDK%\\lib\\tools.jar" } @@ -93,11 +99,11 @@ class WindowsDistributionBuilder { filterset(begintoken: "@@", endtoken: "@@") { filter(token: "product_full", value: fullName) - filter(token: "product_uc", value: buildContext.applicationInfo.upperCaseProductName) + filter(token: "product_uc", value: buildContext.productProperties.environmentVariableBaseName(buildContext.applicationInfo)) filter(token: "vm_options", value: vmOptionsFileName) filter(token: "isEap", value: buildContext.applicationInfo.isEAP) filter(token: "system_selector", value: buildContext.systemSelector) - filter(token: "ide_jvm_args", value: jvmArgs) + filter(token: "ide_jvm_args", value: buildContext.additionalJvmArguments) filter(token: "class_path", value: classPath) filter(token: "script_name", value: batName) } @@ -116,14 +122,6 @@ class WindowsDistributionBuilder { buildContext.ant.fixcrlf(srcdir: "$winDistPath/bin", includes: "*.bat", eol: "dos") } - private String getAdditionalJvmArguments() { - def jvmArgs = buildContext.productProperties.additionalIdeJvmArguments - if (buildContext.productProperties.toolsJarRequired) { - return "$jvmArgs -Didea.jre.check=true".trim() - } - return jvmArgs - } - //todo[nik] rename private void winVMOptions() { JvmArchitecture.values().each { @@ -141,37 +139,32 @@ class WindowsDistributionBuilder { def launcherPropertiesPath = "${buildContext.paths.temp}/launcher${arch.fileSuffix}.properties" def upperCaseProductName = buildContext.applicationInfo.upperCaseProductName def lowerCaseProductName = buildContext.applicationInfo.shortProductName.toLowerCase() - String vmOptions - if (buildContext.productProperties.platformPrefix != null -//todo[nik] remove later. This is added to keep current behavior (platform prefix for CE is set in MainImpl anyway) - && buildContext.productProperties.platformPrefix != "Idea") { - vmOptions = "-Didea.platform.prefix=${buildContext.productProperties.platformPrefix}" - } - else { - vmOptions = "" - } - - vmOptions = "$vmOptions -Didea.paths.selector=${buildContext.systemSelector} ${getAdditionalJvmArguments()}".trim() + String vmOptions = "$buildContext.additionalJvmArguments -Didea.paths.selector=${buildContext.systemSelector}".trim() def productName = buildContext.applicationInfo.upperCaseProductName //todo[nik] use '.productName' instead String jdkEnvVarSuffix = arch == JvmArchitecture.x64 ? "_64" : ""; + def envVarBaseName = buildContext.productProperties.environmentVariableBaseName(buildContext.applicationInfo) new File(launcherPropertiesPath).text = """ IDS_JDK_ONLY=$buildContext.productProperties.toolsJarRequired -IDS_JDK_ENV_VAR=${upperCaseProductName}_JDK${jdkEnvVarSuffix} -IDS_APP_TITLE=${productName} Launcher +IDS_JDK_ENV_VAR=${envVarBaseName}_JDK$jdkEnvVarSuffix +IDS_APP_TITLE=$productName Launcher IDS_VM_OPTIONS_PATH=%USERPROFILE%\\\\.$buildContext.systemSelector IDS_VM_OPTION_ERRORFILE=-XX:ErrorFile=%USERPROFILE%\\\\java_error_in_${lowerCaseProductName}_%p.log IDS_VM_OPTION_HEAPDUMPPATH=-XX:HeapDumpPath=%USERPROFILE%\\\\java_error_in_${lowerCaseProductName}.hprof IDC_WINLAUNCHER=${upperCaseProductName}_LAUNCHER -IDS_PROPS_ENV_VAR=${upperCaseProductName}_PROPERTIES -IDS_VM_OPTIONS_ENV_VAR=${upperCaseProductName}${arch.fileSuffix}_VM_OPTIONS -IDS_ERROR_LAUNCHING_APP=Error launching ${productName} +IDS_PROPS_ENV_VAR=${envVarBaseName}_PROPERTIES +IDS_VM_OPTIONS_ENV_VAR=$envVarBaseName${arch.fileSuffix}_VM_OPTIONS +IDS_ERROR_LAUNCHING_APP=Error launching $productName IDS_VM_OPTIONS=$vmOptions """.trim() def communityHome = "$buildContext.paths.communityHome" String inputPath = "$communityHome/bin/WinLauncher/WinLauncher${arch.fileSuffix}.exe" def outputPath = "$winDistPath/bin/$exeFileName" + def resourceModules = [buildContext.findApplicationInfoModule(), buildContext.findModule("icons")] + if (buildContext.productProperties.brandingModule != null) { + resourceModules << buildContext.findRequiredModule(buildContext.productProperties.brandingModule) + } buildContext.ant.java(classname: "com.pme.launcher.LauncherGeneratorMain", fork: "true", failonerror: "true") { sysproperty(key: "java.awt.headless", value: "true") arg(value: inputPath) @@ -186,7 +179,7 @@ IDS_VM_OPTIONS=$vmOptions include(name: "jdom.jar") include(name: "sanselan*.jar") } - [buildContext.findApplicationInfoModule(), buildContext.findModule("icons")].collectMany { it.sourceRoots }.each { JpsModuleSourceRoot root -> + resourceModules.collectMany { it.sourceRoots }.each { JpsModuleSourceRoot root -> pathelement(location: root.file.absolutePath) } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java index fe68c1c00278..464abd6f8ca5 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java @@ -16,6 +16,7 @@ package com.intellij.codeInspection.dataFlow; import com.intellij.codeInsight.AnnotationUtil; +import com.intellij.codeInsight.ExceptionUtil; import com.intellij.codeInspection.dataFlow.instructions.*; import com.intellij.codeInspection.dataFlow.value.*; import com.intellij.openapi.diagnostic.Logger; @@ -1041,9 +1042,9 @@ public class ControlFlowAnalyzer extends JavaElementVisitor { ((PsiResourceExpression)resource).getExpression().accept(this); } - PsiMethod closer = PsiUtil.getResourceCloserMethod(resource); - if (closer != null) { - addMethodThrows(closer, null); + final List closerExceptions = ExceptionUtil.getCloserExceptions(resource); + if (!closerExceptions.isEmpty()) { + addThrows(null, findNextCatch(false), closerExceptions.toArray(new PsiClassType[closerExceptions.size()])); } } } @@ -1411,15 +1412,19 @@ public class ControlFlowAnalyzer extends JavaElementVisitor { CatchDescriptor cd = findNextCatch(false); if (method != null) { PsiClassType[] refs = method.getThrowsList().getReferencedTypes(); - for (PsiClassType ref : refs) { - pushUnknown(); - ConditionalGotoInstruction cond = new ConditionalGotoInstruction(null, false, null); - addInstruction(cond); - addInstruction(new EmptyStackInstruction()); - initException(ref, cd); - addThrowCode(cd, explicitCall); - cond.setOffset(myCurrentFlow.getInstructionCount()); - } + addThrows(explicitCall, cd, refs); + } + } + + private void addThrows(@Nullable PsiElement explicitCall, CatchDescriptor cd, PsiClassType[] refs) { + for (PsiClassType ref : refs) { + pushUnknown(); + ConditionalGotoInstruction cond = new ConditionalGotoInstruction(null, false, null); + addInstruction(cond); + addInstruction(new EmptyStackInstruction()); + initException(ref, cd); + addThrowCode(cd, explicitCall); + cond.setOffset(myCurrentFlow.getInstructionCount()); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java index 3b2ffe5a6832..e6b2e95de45a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/TryWithResourcesPostfixTemplate.java @@ -100,11 +100,6 @@ public class TryWithResourcesPostfixTemplate extends PostfixTemplate { @NotNull private static Collection getUnhandled(@NotNull PsiExpression expression) { assert expression.getType() != null; - PsiMethod methodCloser = PsiUtil.getResourceCloserMethodForType((PsiClassType)expression.getType()); - PsiSubstitutor substitutor = PsiUtil.resolveGenericsClassInType(expression.getType()).getSubstitutor(); - - return methodCloser != null - ? ExceptionUtil.getUnhandledExceptions(methodCloser, expression, null, substitutor) - : Collections.emptyList(); + return ExceptionUtil.getUnhandledCloserExceptions(expression, null, expression.getType()); } } diff --git a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java index c1864e69373e..7376042ef16e 100644 --- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java @@ -216,36 +216,46 @@ public class LambdaUtil { } @Nullable - public static List findFunctionCandidates(PsiClass psiClass) { + public static List findFunctionCandidates(final PsiClass psiClass) { if (psiClass != null && psiClass.isInterface() && !psiClass.isAnnotationType()) { - final List methods = new ArrayList(); - final Map> overrideEquivalents = PsiSuperMethodUtil.collectOverrideEquivalents(psiClass); - final Collection visibleSignatures = psiClass.getVisibleSignatures(); - for (HierarchicalMethodSignature signature : visibleSignatures) { - final PsiMethod psiMethod = signature.getMethod(); - if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue; - if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) continue; - final Set equivalentMethods = overrideEquivalents.get(signature); - if (equivalentMethods != null && equivalentMethods.size() > 1) { - boolean hasNonAbstractOverrideEquivalent = false; - for (PsiMethod method : equivalentMethods) { - if (!method.hasModifierProperty(PsiModifier.ABSTRACT) && !MethodSignatureUtil.isSuperMethod(method, psiMethod)) { - hasNonAbstractOverrideEquivalent = true; - break; - } - } - if (hasNonAbstractOverrideEquivalent) continue; + return CachedValuesManager.getCachedValue(psiClass, new CachedValueProvider>() { + @Nullable + @Override + public Result> compute() { + return Result.create(calcFunctionCandidates(psiClass), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT); } - if (!overridesPublicObjectMethod(signature)) { - methods.add(signature); - } - } - - return hasSubsignature(methods); + }); } return null; } + private static List calcFunctionCandidates(PsiClass psiClass) { + final List methods = new ArrayList(); + final Map> overrideEquivalents = PsiSuperMethodUtil.collectOverrideEquivalents(psiClass); + final Collection visibleSignatures = psiClass.getVisibleSignatures(); + for (HierarchicalMethodSignature signature : visibleSignatures) { + final PsiMethod psiMethod = signature.getMethod(); + if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue; + if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) continue; + final Set equivalentMethods = overrideEquivalents.get(signature); + if (equivalentMethods != null && equivalentMethods.size() > 1) { + boolean hasNonAbstractOverrideEquivalent = false; + for (PsiMethod method : equivalentMethods) { + if (!method.hasModifierProperty(PsiModifier.ABSTRACT) && !MethodSignatureUtil.isSuperMethod(method, psiMethod)) { + hasNonAbstractOverrideEquivalent = true; + break; + } + } + if (hasNonAbstractOverrideEquivalent) continue; + } + if (!overridesPublicObjectMethod(signature)) { + methods.add(signature); + } + } + + return hasSubsignature(methods); + } + @Nullable private static PsiType getReturnType(PsiClass psiClass, MethodSignature methodSignature) { diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java index 5360eb550f29..289154d7e930 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java @@ -1137,20 +1137,9 @@ public final class PsiUtil extends PsiUtilCore { return name != null && IGNORED_NAMES.contains(name); } - @Nullable - public static PsiMethod getResourceCloserMethod(@NotNull PsiResourceListElement resource) { - PsiType resourceType = resource.getType(); - return resourceType instanceof PsiClassType ? getResourceCloserMethodForType((PsiClassType)resourceType) : null; - } - - /** @deprecated use {@link #getResourceCloserMethod(PsiResourceListElement)} (to be removed in IDEA 17) */ - @SuppressWarnings("unused") - public static PsiMethod getResourceCloserMethod(@NotNull PsiResourceVariable resource) { - return getResourceCloserMethod((PsiResourceListElement)resource); - } @Nullable - public static PsiMethod getResourceCloserMethodForType(@NotNull final PsiClassType resourceType) { + public static PsiMethod[] getResourceCloserMethodsForType(@NotNull final PsiClassType resourceType) { final PsiClass resourceClass = resourceType.resolve(); if (resourceClass == null) return null; @@ -1162,7 +1151,10 @@ public final class PsiUtil extends PsiUtilCore { if (JavaClassSupers.getInstance().getSuperClassSubstitutor(autoCloseable, resourceClass, resourceType.getResolveScope(), PsiSubstitutor.EMPTY) == null) return null; final PsiMethod[] closes = autoCloseable.findMethodsByName("close", false); - return closes.length == 1 ? resourceClass.findMethodBySignature(closes[0], true) : null; + if (closes.length == 1) { + return resourceClass.findMethodsBySignature(closes[0], true); + } + return null; } @Nullable diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java index 7f9c6cc8194c..fc9083936d24 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java @@ -38,8 +38,6 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -import static com.intellij.openapi.util.Pair.pair; - /** * @author mike */ @@ -533,38 +531,66 @@ public class ExceptionUtil { if (psiType instanceof PsiClassType) { ex.add((PsiClassType)psiType); } + else if (psiType instanceof PsiCapturedWildcardType) { + final PsiCapturedWildcardType capturedWildcardType = (PsiCapturedWildcardType)psiType; + final PsiType upperBound = capturedWildcardType.getUpperBound(); + if (upperBound instanceof PsiClassType) { + ex.add((PsiClassType)upperBound); + } + } } return ex; } @NotNull public static List getCloserExceptions(@NotNull PsiResourceListElement resource) { - Pair closer = resolveCloser(resource); - return closer != null ? getExceptionsByMethod(closer.first, closer.second, resource) : Collections.emptyList(); + List ex = getExceptionsFromClose(resource); + return ex != null ? ex : Collections.emptyList(); } @NotNull public static List getUnhandledCloserExceptions(@NotNull PsiResourceListElement resource, @Nullable PsiElement topElement) { - Pair closer = resolveCloser(resource); - return closer != null ? getUnhandledExceptions(closer.first, resource, topElement, closer.second) : Collections.emptyList(); + final PsiType type = resource.getType(); + return getUnhandledCloserExceptions(resource, topElement, type); } - private static Pair resolveCloser(PsiResourceListElement resource) { - PsiMethod method = PsiUtil.getResourceCloserMethod(resource); - if (method != null) { - PsiClass closerClass = method.getContainingClass(); - if (closerClass != null) { - PsiClassType.ClassResolveResult resourceType = PsiUtil.resolveGenericsClassInType(resource.getType()); - if (resourceType != null) { - PsiClass resourceClass = resourceType.getElement(); - if (resourceClass != null) { - PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(closerClass, resourceClass, resourceType.getSubstitutor()); - if (substitutor != null) { - return pair(method, substitutor); + @NotNull + public static List getUnhandledCloserExceptions(PsiElement place, @Nullable PsiElement topElement, PsiType type) { + List ex = type instanceof PsiClassType ? getExceptionsFromClose(type, place.getResolveScope()) : null; + return ex != null ? getUnhandledExceptions(place, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()])) : Collections.emptyList(); + } + + private static List getExceptionsFromClose(PsiResourceListElement resource) { + final PsiType type = resource.getType(); + return type instanceof PsiClassType ? getExceptionsFromClose(type, resource.getResolveScope()) : null; + } + + private static List getExceptionsFromClose(PsiType type, GlobalSearchScope scope) { + PsiClassType.ClassResolveResult resourceType = PsiUtil.resolveGenericsClassInType(type); + PsiClass resourceClass = resourceType.getElement(); + if (resourceClass == null) return null; + + PsiMethod[] methods = PsiUtil.getResourceCloserMethodsForType((PsiClassType)type); + if (methods != null) { + List ex = null; + for (PsiMethod method : methods) { + PsiClass closerClass = method.getContainingClass(); + if (closerClass != null) { + PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(closerClass, resourceClass, resourceType.getSubstitutor()); + if (substitutor != null) { + final PsiClassType[] exceptionTypes = method.getThrowsList().getReferencedTypes(); + if (exceptionTypes.length == 0) return Collections.emptyList(); + + if (ex == null) { + ex = collectSubstituted(substitutor, exceptionTypes, scope); + } + else { + retainExceptions(ex, collectSubstituted(substitutor, exceptionTypes, scope)); } } } } + return ex; } return null; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java index 4de4dbeec1f5..68f20356704a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java @@ -20,6 +20,7 @@ import com.intellij.lang.LighterAST; import com.intellij.lang.LighterASTNode; import com.intellij.psi.JavaTokenType; import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiNameHelper; import com.intellij.psi.impl.cache.RecordUtil; import com.intellij.psi.impl.cache.TypeInfo; import com.intellij.psi.impl.java.stubs.impl.PsiMethodStubImpl; @@ -169,8 +170,7 @@ public abstract class JavaMethodElementType extends JavaStubElementType 0) continue; - String typeName = type.getShortTypeText(); + String typeName = PsiNameHelper.getShortClassName(type.text); if (TypeConversionUtil.isPrimitive(typeName) || TypeConversionUtil.isPrimitiveWrapper(typeName)) continue; sink.occurrence(JavaStubIndexKeys.METHOD_TYPES, typeName); if (methodTypeParams != null && methodTypeParams.contains(typeName)) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java index 85fbce060fb7..d6074403ef3e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java @@ -38,7 +38,7 @@ import java.io.IOException; * @author max */ public class JavaFileElementType extends ILightStubFileElementType { - public static final int STUB_VERSION = 27; + public static final int STUB_VERSION = 28; public JavaFileElementType() { super("java.FILE", JavaLanguage.INSTANCE); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java index 063242381fc3..1cf442943e97 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaSharedImplUtil.java @@ -28,6 +28,7 @@ import com.intellij.psi.util.PsiUtil; import com.intellij.util.CharTable; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.JBIterable; import com.intellij.util.containers.Stack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,7 +93,9 @@ public class JavaSharedImplUtil { if (modifierList != null) { PsiAnnotation[] annotations = modifierList.getAnnotations(); if (annotations.length > 0) { - TypeAnnotationProvider provider = new FilteringTypeAnnotationProvider(annotations); + TypeAnnotationProvider original = + modifierList.getParent() instanceof PsiMethod ? type.getAnnotationProvider() : TypeAnnotationProvider.EMPTY; + TypeAnnotationProvider provider = new FilteringTypeAnnotationProvider(annotations, original); if (type instanceof PsiArrayType) { Stack types = new Stack(); do { @@ -196,10 +199,12 @@ public class JavaSharedImplUtil { private static class FilteringTypeAnnotationProvider implements TypeAnnotationProvider { private final PsiAnnotation[] myCandidates; + private final TypeAnnotationProvider myOriginalProvider; private volatile PsiAnnotation[] myCache; - private FilteringTypeAnnotationProvider(PsiAnnotation[] candidates) { + private FilteringTypeAnnotationProvider(PsiAnnotation[] candidates, TypeAnnotationProvider originalProvider) { myCandidates = candidates; + myOriginalProvider = originalProvider; } @NotNull @@ -207,12 +212,15 @@ public class JavaSharedImplUtil { public PsiAnnotation[] getAnnotations() { PsiAnnotation[] result = myCache; if (result == null) { - List filtered = ContainerUtil.filter(myCandidates, new Condition() { - @Override - public boolean value(PsiAnnotation annotation) { - return AnnotationTargetUtil.isTypeAnnotation(annotation); - } - }); + List filtered = JBIterable.of(myCandidates) + .filter(new Condition() { + @Override + public boolean value(PsiAnnotation annotation) { + return AnnotationTargetUtil.isTypeAnnotation(annotation); + } + }) + .append(myOriginalProvider.getAnnotations()) + .toList(); myCache = result = filtered.isEmpty() ? PsiAnnotation.EMPTY_ARRAY : filtered.toArray(new PsiAnnotation[filtered.size()]); } return result; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResourcesWithMultipleCloseInterfaces.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResourcesWithMultipleCloseInterfaces.java new file mode 100644 index 000000000000..2ff36864df68 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResourcesWithMultipleCloseInterfaces.java @@ -0,0 +1,48 @@ +import java.io.IOException; + +class Ex extends Exception {} + +interface IOCloseable { + void close() throws IOException; +} + +interface ExCloseable { + void close() throws Ex; +} + +interface NoExCloseable { + void close(); +} + +interface TCloseable { + void close() throws T; +} + +interface I1 extends AutoCloseable, IOCloseable {} +interface I1R extends IOCloseable, AutoCloseable {} +interface I2 extends AutoCloseable, IOCloseable, ExCloseable {} +interface I3 extends AutoCloseable, NoExCloseable {} +interface I3R extends NoExCloseable, AutoCloseable {} + +interface IT extends AutoCloseable, TCloseable {} + +class Main { + { + try (I1 i1 = null) {} + try (I1 i11 = null) { + } catch (IOException e){} + try (I1R i11r = null) { + } catch (IOException e){} + + try (I2 i2 = null) {} + try (I2 i21 = null) { + } catch (IOException e) {} + try (I2 i22 = null) { + } catch (Ex e) {} + + try (I3 i3 = null) {} + try (I3R i3r = null) {} + + try (IT it = null) {} + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/findUsages/ConstructorReferences.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/findUsages/ConstructorReferences.java new file mode 100644 index 000000000000..e51e0df8af9b --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/findUsages/ConstructorReferences.java @@ -0,0 +1,9 @@ +class Foo { + Foo() { this(() -> 4); } + + Foo(I i) {} +} + +interface I { + int foo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/findUsages/VarargPosition.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/findUsages/VarargPosition.java new file mode 100644 index 000000000000..cc7662348b80 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/findUsages/VarargPosition.java @@ -0,0 +1,6 @@ +public interface I { + void m(); +} + +interface J extends I {} + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java index 12d72c9ed246..a717ecf9a9f1 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java @@ -237,7 +237,7 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase { } String qualifiedName = aClass.getQualifiedName(); if (qualifiedName.startsWith("java.lang.invoke")) continue; // java.lang.invoke.MethodHandle has weird access attributes in recent rt.jar which causes spurious highlighting errors - if ("Sink".equals(aClass.getName())) continue; + if (qualifiedName.contains(".Sink")) continue; // Sink has weird access in class files imports.append("import " + qualifiedName + ";\n"); usages.append("/**/ "+aClass.getName() + " var" + v + " = null; var" + v + ".toString();\n"); aClasses.add(aClass); @@ -248,7 +248,7 @@ public class HighlightStressTest extends LightDaemonAnalyzerTestCase { WriteCommandAction.runWriteCommandAction(null, () -> getEditor().getDocument().setText(text)); List errors = DaemonAnalyzerTestCase.filter(doHighlighting(), HighlightSeverity.WARNING); - assertEmpty(errors); + assertEmpty(text, errors); Random random = new Random(); int unused = 0; for (int i = 0; i < 100; i++) { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index c2062de4ca18..def1ddf09142 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -179,6 +179,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testUncheckedExtendedWarnings() { doTest(true, false); } public void testInaccessibleInferredTypeForVarargsArgument() { doTest(false, false);} public void testRuntimeClassCast() { doTest(true, false);} + public void testTryWithResourcesWithMultipleCloseInterfaces() { doTest(false, false);} public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk8Test.java index 4c1ab97d7bfd..20fc3af7e55c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk8Test.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon; import com.intellij.codeInspection.compiler.JavacQuirksInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; @@ -33,11 +32,6 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - private void doTest(boolean warnings, boolean weakWarnings) { doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, weakWarnings, false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java index 14d02606cc86..5a000129aae9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk9Test.java @@ -19,7 +19,6 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; @@ -34,11 +33,6 @@ public class LightAdvHighlightingJdk9Test extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, getModule(), getTestRootDisposable()); } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - private void doTest(boolean checkWarnings, boolean checkInfos) { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ChangeSignatureTouchLambdaTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ChangeSignatureTouchLambdaTest.java index cdfb5a39a4e1..b4f1d7b22dd5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ChangeSignatureTouchLambdaTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ChangeSignatureTouchLambdaTest.java @@ -15,12 +15,10 @@ */ package com.intellij.codeInsight.daemon.lambda; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.PsiType; import com.intellij.refactoring.ChangeSignatureBaseTest; import com.intellij.refactoring.changeSignature.ParameterInfoImpl; import com.intellij.refactoring.changeSignature.ThrownExceptionInfo; -import com.intellij.testFramework.IdeaTestUtil; public class ChangeSignatureTouchLambdaTest extends ChangeSignatureBaseTest { @@ -52,9 +50,4 @@ public class ChangeSignatureTouchLambdaTest extends ChangeSignatureBaseTest { protected String getRelativePath() { return "/codeInsight/daemonCodeAnalyzer/lambda/changeSignature/"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java index acacc42803d5..ef179f8155b3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java @@ -16,8 +16,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase { @@ -70,9 +68,4 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase { private void doTest(final boolean checkWarnings) { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java index a1f1046f56da..7a7898d76757 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java @@ -16,8 +16,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase { @@ -70,9 +68,4 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase { private void doTest() throws Exception { doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FindFunctionalInterfaceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FindFunctionalInterfaceTest.java index cc967135b311..7ab0bf361c20 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FindFunctionalInterfaceTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FindFunctionalInterfaceTest.java @@ -50,19 +50,25 @@ public class FindFunctionalInterfaceTest extends LightCodeInsightFixtureTestCase myFixture.addClass("public class A {" + " public I r;" + "}"); - for (int i = 0; i < JavaFunctionalExpressionSearcher.SMART_SEARCH_THRESHOLD + 1; i++) { - myFixture.addClass("class B" + i + " { {Runnable r = () -> {};}}"); //ensure common case is used - } + addManyLambdas(); + + doTestOneExpression(); + } + + public void testVarargPosition() throws Exception { + myFixture.addClass("\n" + + "class A { \n" + + " void foo(T... r) {}\n" + + " void bar(J i){foo(i, i, () -> {});}\n" + + "}"); + addManyLambdas(); doTestOneExpression(); } private void doTestOneExpression() { myFixture.configureByFile(getTestName(false) + ".java"); - final PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertNotNull(elementAtCaret); - final PsiClass psiClass = PsiTreeUtil.getParentOfType(elementAtCaret, PsiClass.class, false); - assertTrue(psiClass != null && psiClass.isInterface()); + final PsiClass psiClass = findClassAtCaret(); final Collection expressions = FunctionalExpressionSearch.search(psiClass).findAll(); int size = expressions.size(); assertEquals(1, size); @@ -71,6 +77,15 @@ public class FindFunctionalInterfaceTest extends LightCodeInsightFixtureTestCase assertEquals("() -> {}", next.getText()); } + @NotNull + private PsiClass findClassAtCaret() { + final PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertNotNull(elementAtCaret); + final PsiClass psiClass = PsiTreeUtil.getParentOfType(elementAtCaret, PsiClass.class, false); + assertTrue(psiClass != null && psiClass.isInterface()); + return psiClass; + } + public void testFieldFromAnonymousClassScope() throws Exception { myFixture.configureByFile(getTestName(false) + ".java"); final PsiElement elementAtCaret = myFixture.getElementAtCaret(); @@ -95,9 +110,7 @@ public class FindFunctionalInterfaceTest extends LightCodeInsightFixtureTestCase public void doTestIndexSearch(String expected) { myFixture.configureByFile(getTestName(false) + ".java"); - for (int i = 0; i < JavaFunctionalExpressionSearcher.SMART_SEARCH_THRESHOLD + 5; i++) { - myFixture.addFileToProject("a" + i + ".java", "class Goo {{ Runnable r = () -> {} }}"); - } + addManyLambdas(); PsiClass predicate = JavaPsiFacade.getInstance(getProject()).findClass(Predicate.class.getName(), GlobalSearchScope.allScope(getProject())); assert predicate != null; @@ -105,6 +118,28 @@ public class FindFunctionalInterfaceTest extends LightCodeInsightFixtureTestCase assertEquals(expected, next.getText()); } + public void testConstructorReferences() { + myFixture.configureByFile(getTestName(false) + ".java"); + + myFixture.addClass("class Bar extends Foo {\n" + + " public Bar() { super(() -> 1); }\n" + + "\n" + + " {\n" + + " new Foo(() -> 2) { };\n" + + " new Foo(() -> 3);\n" + + " }\n" + + "}"); + addManyLambdas(); + + assertSize(4, FunctionalExpressionSearch.search(findClassAtCaret()).findAll()); + } + + private void addManyLambdas() { + for (int i = 0; i < JavaFunctionalExpressionSearcher.SMART_SEARCH_THRESHOLD + 5; i++) { + myFixture.addFileToProject("a" + i + ".java", "class Goo {{ Runnable r = () -> {} }}"); + } + } + @Override protected String getBasePath() { return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/lambda/findUsages/"; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java index 66234ca38ca0..f0bbbbf0d74a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; public class FunctionalExpressionIncompleteHighlightingTest extends LightDaemonAnalyzerTestCase { @@ -45,9 +43,4 @@ public class FunctionalExpressionIncompleteHighlightingTest extends LightDaemonA private void doTest(final boolean checkWarnings) { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java index 507d4d181e50..bf246de5f308 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; @@ -48,9 +47,4 @@ public class FunctionalTypeWildcardParameterizationTest extends LightDaemonAnaly IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java index 6cf13ad22cb9..980e259b25f1 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java @@ -44,11 +44,6 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase { return new LocalInspectionTool[]{new UncheckedWarningLocalInspection(), new UnusedImportLocalInspection()}; } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - public void testReferenceTypeParams() { doTest(); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java index 020befac8ee1..19979bc7b905 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlightingGenerated8Test.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; @@ -26,11 +25,6 @@ import org.jetbrains.annotations.NonNls; public class GenericsHighlightingGenerated8Test extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/genericsHighlightingGenerated8"; - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - public void testEmptyTestT() throws Exception {} public void _testUnrelatedClasses() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index 2e8a7bd62059..939c6056f789 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -491,9 +491,4 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/InferencePerformanceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/InferencePerformanceTest.java index 5ba7c67c169f..a8ebd709c923 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/InferencePerformanceTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/InferencePerformanceTest.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PlatformTestUtil; import org.jetbrains.annotations.NonNls; @@ -37,9 +36,4 @@ public class InferencePerformanceTest extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8ExpressionsCheckTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8ExpressionsCheckTest.java index 0dc3e2f72109..279f26f2d1e9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8ExpressionsCheckTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8ExpressionsCheckTest.java @@ -18,13 +18,11 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.ExpectedTypeInfo; import com.intellij.codeInsight.ExpectedTypesProvider; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy; import com.intellij.psi.infos.CandidateInfo; import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import java.util.Collection; @@ -203,9 +201,4 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase { } } } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java index 26d9f6d81960..54ae883f2be0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; @@ -83,9 +82,4 @@ public class Java8RegressionTest extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java index 673a5cfaa44a..e6ebf6e2ab0d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { @@ -111,9 +109,4 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { private void doTest(final boolean checkWarnings) { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java index 5a821021f2ec..e7b0bcdba6f3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java @@ -18,8 +18,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -89,9 +87,4 @@ public class LambdaRedundantCastTest extends LightDaemonAnalyzerTestCase { private void doTest() { doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java index 97683fca3d57..96880e40835a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; @@ -118,9 +117,4 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java index 7f92628e506d..6e41ee8e6193 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.registry.Registry; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; @@ -142,9 +141,4 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewInferenceCollectingAdditionalConstraintsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewInferenceCollectingAdditionalConstraintsTest.java index 01a6573ebefb..3cfeaa32fc5e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewInferenceCollectingAdditionalConstraintsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewInferenceCollectingAdditionalConstraintsTest.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; @@ -40,9 +39,4 @@ public class NewInferenceCollectingAdditionalConstraintsTest extends LightDaemon IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index 7bd35c7b68a0..050113fd5ffe 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; @@ -337,11 +336,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } -/* + /* public static Test suite() { final TestSuite suite = new TestSuite(); for (int i = 0; i < 1000; i++) { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index 320557441481..fda6beefbc4d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -20,7 +20,6 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -530,9 +529,4 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java index 56ecc91be0a5..d9da817f04f8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PlatformTestUtil; import org.jetbrains.annotations.NonNls; @@ -237,9 +236,4 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase { IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionFromFieldInitializerToConstructorThrowsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionFromFieldInitializerToConstructorThrowsTest.java index aa50430c9664..75b498bdcac0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionFromFieldInitializerToConstructorThrowsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionFromFieldInitializerToConstructorThrowsTest.java @@ -15,9 +15,6 @@ */ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; - /** * @author Dmitry Batkovich */ @@ -30,9 +27,4 @@ public class AddExceptionFromFieldInitializerToConstructorThrowsTest extends Lig protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/addToConstructorThrows"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToCatchTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToCatchTest.java index e55cced09985..4ef4c493e09d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToCatchTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToCatchTest.java @@ -1,8 +1,5 @@ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; - public class AddExceptionToCatchTest extends LightQuickFixParameterizedTestCase { public void test() throws Exception { doAllTests(); @@ -12,9 +9,4 @@ public class AddExceptionToCatchTest extends LightQuickFixParameterizedTestCase protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/addCatchBlock"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java index 5fa9b96f574d..f25775fb962b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java @@ -1,8 +1,5 @@ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; - public class AddExceptionToThrowsTest extends LightQuickFixParameterizedTestCase { public void test() throws Exception { doAllTests(); @@ -12,9 +9,4 @@ public class AddExceptionToThrowsTest extends LightQuickFixParameterizedTestCase protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java index a129c3cbe21d..f496d6a3b3da 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.AnonymousCanBeLambdaInspection; import com.intellij.codeInspection.LocalInspectionTool; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class Anonymous2LambdaInspectionTest extends LightQuickFixParameterizedTe protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java index 37e0a4cfd4a8..86ad2edfaaf8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.AnonymousCanBeMethodReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class Anonymous2MethodReferenceInspectionTest extends LightQuickFixParame protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2methodReference"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeMethodSignatureFromUsage8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeMethodSignatureFromUsage8Test.java index 0a4f58ca8bbf..fbc121e1a2e2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeMethodSignatureFromUsage8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeMethodSignatureFromUsage8Test.java @@ -15,12 +15,7 @@ */ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; - -import java.util.ArrayList; -import java.util.LinkedList; public class ChangeMethodSignatureFromUsage8Test extends LightQuickFixParameterizedTestCase { @@ -35,9 +30,4 @@ public class ChangeMethodSignatureFromUsage8Test extends LightQuickFixParameteri protected LanguageLevel getLanguageLevel() { return LanguageLevel.JDK_1_8; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GeneralizeCatchTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GeneralizeCatchTest.java index 90299b35923c..ac0c5b4ae09e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GeneralizeCatchTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GeneralizeCatchTest.java @@ -1,8 +1,5 @@ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; - public class GeneralizeCatchTest extends LightQuickFixParameterizedTestCase { public void test() throws Exception { doAllTests(); @@ -12,9 +9,4 @@ public class GeneralizeCatchTest extends LightQuickFixParameterizedTestCase { protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/generalizeCatch"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java index 125aaf43ce44..6c6cda6147ae 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LambdaCanBeMethodReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class Lambda2MethodReferenceInspectionTest extends LightQuickFixParameter protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java index 1a34d12eb448..757b720c44c6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class RedundantLambdaCodeBlockInspectionTest extends LightQuickFixParamet protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantTypeArgsInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantTypeArgsInspectionTest.java index 67659c1af372..110d2deac42d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantTypeArgsInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantTypeArgsInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.miscGenerics.RedundantTypeArgsInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -35,9 +33,4 @@ public class RedundantTypeArgsInspectionTest extends LightQuickFixParameterizedT protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/redundantTypeArgs"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceFromOfNullableFixTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceFromOfNullableFixTest.groovy index 15ef5ff77f14..213258fa48ef 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceFromOfNullableFixTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceFromOfNullableFixTest.groovy @@ -15,14 +15,13 @@ */ package com.intellij.codeInsight.daemon.quickFix + import com.intellij.codeInspection.LocalInspectionTool import com.intellij.codeInspection.dataFlow.DataFlowInspection import com.intellij.openapi.Disposable import com.intellij.openapi.command.WriteCommandAction -import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.IdeaTestUtil import org.jetbrains.annotations.NotNull public class ReplaceFromOfNullableFixTest extends LightQuickFixParameterizedTestCase { @@ -82,8 +81,4 @@ public abstract class Optional { super.afterActionCompleted(testName, contents) } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithOfNullableFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithOfNullableFixTest.java index 8df4cf22e5c5..3b486baf08b3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithOfNullableFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithOfNullableFixTest.java @@ -22,8 +22,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; public class ReplaceWithOfNullableFixTest extends LightQuickFixParameterizedTestCase { @@ -55,9 +53,4 @@ public class ReplaceWithOfNullableFixTest extends LightQuickFixParameterizedTest ReplaceFromOfNullableFixTest.cleanupGuava(); super.afterActionCompleted(testName, contents); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java index eac9703e7ff0..b9c67141273f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java @@ -18,11 +18,9 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.lang.java.JavaLanguage; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -68,9 +66,4 @@ public class Simplify2DiamondInspectionsTest extends LightQuickFixParameterizedT protected LanguageLevel getLanguageLevel() { return LanguageLevel.JDK_1_8; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java index a112ddfa5045..4e6c407ec6f2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.StreamApiMigrationInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class StreamApiMigrationInspectionTest extends LightQuickFixParameterized protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialFunctionalExpressionUsageInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialFunctionalExpressionUsageInspectionTest.java index 5de09e455807..6069a3ff6475 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialFunctionalExpressionUsageInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialFunctionalExpressionUsageInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.TrivialFunctionalExpressionUsageInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class TrivialFunctionalExpressionUsageInspectionTest extends LightQuickFi protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/trivialFunctionalExpressionUsage"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialMethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialMethodReferenceInspectionTest.java index 00263f77aab1..320e749c4475 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialMethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/TrivialMethodReferenceInspectionTest.java @@ -17,8 +17,6 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.TrivialMethodReferenceInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; @@ -37,9 +35,4 @@ public class TrivialMethodReferenceInspectionTest extends LightQuickFixParameter protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/trivialMethodReference"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapLongWithMathToIntExactFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapLongWithMathToIntExactFixTest.java index a32d1f339ff3..caa712f13340 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapLongWithMathToIntExactFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapLongWithMathToIntExactFixTest.java @@ -15,9 +15,6 @@ */ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; - /** * @author Dmitry Batkovich */ @@ -30,9 +27,4 @@ public class WrapLongWithMathToIntExactFixTest extends LightQuickFixParameterize protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/wrapLongWithMathToIntExact"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapObjectWithOptionalFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapObjectWithOptionalFixTest.java index 401fcdc1a61e..993a3347e221 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapObjectWithOptionalFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/WrapObjectWithOptionalFixTest.java @@ -15,9 +15,6 @@ */ package com.intellij.codeInsight.daemon.quickFix; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; - /** * @author Dmitry Batkovich */ @@ -30,9 +27,4 @@ public class WrapObjectWithOptionalFixTest extends LightQuickFixParameterizedTes protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/wrapObjectWithOptional"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/MergeFilterChainActionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/MergeFilterChainActionTest.java index bcfbeb79b701..b1aa1985cdba 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/MergeFilterChainActionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/MergeFilterChainActionTest.java @@ -16,8 +16,6 @@ package com.intellij.codeInsight.intention; import com.intellij.codeInsight.daemon.LightIntentionActionTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; public class MergeFilterChainActionTest extends LightIntentionActionTestCase { @@ -27,9 +25,4 @@ public class MergeFilterChainActionTest extends LightIntentionActionTestCase { protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/mergeFilter"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitFilterActionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitFilterActionTest.java index efe14b0a2055..02f1a5967709 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitFilterActionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitFilterActionTest.java @@ -16,8 +16,6 @@ package com.intellij.codeInsight.intention; import com.intellij.codeInsight.daemon.LightIntentionActionTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; public class SplitFilterActionTest extends LightIntentionActionTestCase { @@ -27,9 +25,4 @@ public class SplitFilterActionTest extends LightIntentionActionTestCase { protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/splitFilter"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/psi/AnnotatedTypeTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/psi/AnnotatedTypeTest.groovy index bb2e2ba20a0b..ec5ab5fcd0c5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/psi/AnnotatedTypeTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/psi/AnnotatedTypeTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -36,9 +36,7 @@ class AnnotatedTypeTest extends LightCodeInsightFixtureTestCase { @interface A { } @Target(ElementType.TYPE_USE) @interface TA { int value() default 42; } - class O { - class I { } - } + class O { class I { } } @SuppressWarnings("ExceptionClassNameDoesntEndWithException") class E1 extends Exception { } @SuppressWarnings("ExceptionClassNameDoesntEndWithException") class E2 extends Exception { }""".stripIndent()) @@ -101,9 +99,9 @@ class AnnotatedTypeTest extends LightCodeInsightFixtureTestCase { } public void testMethodReturnType() { - def psi = factory.createMethodFromText("@A @TA(1) String m() { return null; }", context) - assertTypeText psi.returnType, "java.lang.@pkg.TA(1) String", "java.lang.String" - assertAnnotations psi.returnType, "@TA(1)" + def psi = factory.createMethodFromText("@A @TA(1) @TA(2) String m() { return null; }", context) + assertTypeText psi.returnType, "java.lang.@pkg.TA(1) @pkg.TA(2) String", "java.lang.String" + assertAnnotations psi.returnType, "@TA(1)", "@TA(2)" } private void doTest(String text, String annotated, String canonical) { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java index 981fb7fe67eb..0e651d1a6199 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java @@ -23,7 +23,6 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.java15api.Java15APIUsageInspection; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.InspectionTestCase; @@ -63,11 +62,6 @@ public class JavaAPIUsagesInspectionTest extends InspectionTestCase { IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, JavaAPIUsagesInspectionTest.this::doTest); } - @Override - protected Sdk getTestProjectSdk() { - return IdeaTestUtil.getMockJdk18(); - } - //generate apiXXX.txt /* //todo exclude inheritors of ConcurrentMap#putIfAbsent diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java index 8588e37d1fbf..3c28371a74c2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java @@ -38,6 +38,7 @@ import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.impl.source.PsiClassImpl; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.FileTreeAccessFilter; +import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.InspectionTestCase; import com.intellij.testFramework.PsiTestUtil; import org.jetbrains.annotations.NotNull; @@ -62,7 +63,8 @@ public class MagicConstantInspectionTest extends InspectionTestCase { @Override protected Sdk getTestProjectSdk() { - return PsiTestUtil.addJdkAnnotations(super.getTestProjectSdk()); + // has to have JFrame and sources + return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17()); } private void doTest() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java index a8b27ab21089..d6c194fd1f92 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java @@ -3,6 +3,7 @@ package com.intellij.codeInspection; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.pom.java.LanguageLevel; @@ -17,6 +18,12 @@ public class RedundantCast15Test extends InspectionTestCase { ModuleRootModificationUtil.setModuleSdk(getModule(), getTestProjectSdk()); } + @Override + protected Sdk getTestProjectSdk() { + // in jdk 8 some casts are unnecessary + return IdeaTestUtil.getMockJdk17(); + } + private void doTest() throws Exception { final LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(new RedundantCastInspection()); doTest("redundantCast/generics/" + getTestName(false), toolWrapper, "java 1.5"); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java index fe187a68940d..7e9bcf8e18e4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java @@ -17,10 +17,6 @@ package com.intellij.codeInspection; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.InspectionTestCase; public class RedundantCast18Test extends InspectionTestCase { @@ -35,11 +31,4 @@ public class RedundantCast18Test extends InspectionTestCase { public void testForeachValue() throws Exception { doTest(); } public void testConditional() throws Exception { doTest(); } public void testInferApplicabilityError() throws Exception { doTest(); } - - @Override - protected Sdk getTestProjectSdk() { - Sdk sdk = IdeaTestUtil.getMockJdk17(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8); - return sdk; - } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java index 61dc1d9a5600..4a7d7d1f35ab 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java @@ -17,10 +17,6 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.unneededThrows.RedundantThrows; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.InspectionTestCase; public class RedundantThrowTest extends InspectionTestCase { @@ -68,11 +64,4 @@ public class RedundantThrowTest extends InspectionTestCase { public void testThrownClausesInFunctionalExpressions() throws Exception { doTest(); } - - @Override - protected Sdk getTestProjectSdk() { - Sdk sdk = IdeaTestUtil.getMockJdk17(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8); - return sdk; - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspectionTest.java index c79fb02d6c61..87ab36223390 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspectionTest.java @@ -16,8 +16,6 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; /** @@ -35,11 +33,6 @@ public class SimplifyStreamApiCallChainsInspectionTest extends LightQuickFixPara doAllTests(); } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - @Override protected String getBasePath() { return "/inspection/streamApiCallChains"; diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/StringTokenizerDelimiterInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/StringTokenizerDelimiterInspectionTest.java index ddac3879885c..c51611905489 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/StringTokenizerDelimiterInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/StringTokenizerDelimiterInspectionTest.java @@ -16,8 +16,6 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; /** @@ -39,9 +37,4 @@ public class StringTokenizerDelimiterInspectionTest extends LightQuickFixParamet protected String getBasePath() { return "/inspection/stringTokenizerDelimiter"; } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java index 74f27e0b0c11..c72432532ad6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java @@ -12,10 +12,6 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.InspectionTestCase; public class UnusedReturnValueTest extends InspectionTestCase { @@ -47,13 +43,6 @@ public class UnusedReturnValueTest extends InspectionTestCase { doTest(); } - @Override - protected Sdk getTestProjectSdk() { - Sdk sdk = IdeaTestUtil.getMockJdk18(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8); - return sdk; - } - public void testSimpleSetter() throws Exception { try { myTool.IGNORE_BUILDER_PATTERN = true; diff --git a/java/java-tests/testSrc/com/intellij/ide/util/JavaSuperMethodTest.java b/java/java-tests/testSrc/com/intellij/ide/util/JavaSuperMethodTest.java index 3b241630e76f..cd4e7b3afc32 100644 --- a/java/java-tests/testSrc/com/intellij/ide/util/JavaSuperMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/ide/util/JavaSuperMethodTest.java @@ -17,11 +17,9 @@ package com.intellij.ide.util; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMethod; import com.intellij.psi.impl.FindSuperElementsHelper; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -38,11 +36,6 @@ public class JavaSuperMethodTest extends LightDaemonAnalyzerTestCase { return "/codeInsight/gotosuper/"; } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - public void testDoNotGoToSiblingInheritanceIfInLibrary() throws Throwable { configureByFile(getBasePath() + "OverridingLibrary.java"); diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java index 94d4a659674b..d4c3e9980fbd 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java @@ -36,7 +36,6 @@ import com.intellij.testFramework.LightIdeaTestCase; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.LineReader; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -147,11 +146,11 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase { doTest(getTestName(false) + ".java", getTestName(false) + "_after.java"); } - public void doTest(@NonNls String fileNameBefore, @NonNls String fileNameAfter) { + public void doTest(@NotNull String fileNameBefore, @NotNull String fileNameAfter) { doTextTest(Action.REFORMAT, loadFile(fileNameBefore), loadFile(fileNameAfter)); } - public void doTestWithDetectableIndentOptions(@NonNls String text, @NonNls String textAfter) { + public void doTestWithDetectableIndentOptions(@NotNull String text, @NotNull String textAfter) { DetectableIndentOptionsProvider provider = DetectableIndentOptionsProvider.getInstance(); assertNotNull("DetectableIndentOptionsProvider not found", provider); provider.setEnabledInTest(true); @@ -163,11 +162,11 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase { } } - public void doTextTest(@NonNls final String text, @NonNls String textAfter) throws IncorrectOperationException { + public void doTextTest(@NotNull String text, @NotNull String textAfter) throws IncorrectOperationException { doTextTest(Action.REFORMAT, text, textAfter); } - public void doTextTest(@NotNull final Action action, @NotNull String text, @NotNull String textAfter) throws IncorrectOperationException { + public void doTextTest(@NotNull Action action, @NotNull String text, @NotNull String textAfter) throws IncorrectOperationException { final PsiFile file = createFile("A.java", text); final PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject()); final Document document = manager.getDocument(file); @@ -226,7 +225,7 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase { return document.getText(); } - public void doMethodTest(@NonNls final String before, @NonNls final String after) { + public void doMethodTest(@NotNull String before, @NotNull String after) { doTextTest( Action.REFORMAT, "class Foo{\n" + " void foo() {\n" + before + '\n' + " }\n" + "}", @@ -234,7 +233,7 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase { ); } - public void doClassTest(@NonNls final String before, @NonNls final String after) { + public void doClassTest(@NotNull String before, @NotNull String after) { doTextTest( Action.REFORMAT, "class Foo{\n" + before + '\n' + "}", diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java index 9e60b9a5fc4c..63668f03d60c 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -150,6 +150,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { doTextTest(initial, formatted); // Expect spaces to be inserted after unary operators } + @SuppressWarnings("unused") public void _testJavadocMethodParams() { // Inspired by IDEA-42167 // Disabled because the contents of the {@code tag} is not necessarily Java code and @@ -591,7 +592,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { "};" ); } - + public void testCommentBetweenAnnotationAndModifierList() { getSettings().KEEP_LINE_BREAKS = false; getSettings().KEEP_FIRST_COLUMN_COMMENT = false; @@ -607,7 +608,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { " int a = 2;\n" + "}"); } - + public void testSpace_BeforeSemicolon_InsideFor() { getSettings().SPACE_BEFORE_SEMICOLON = true; doMethodTest( @@ -619,7 +620,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { "}\n" ); } - + public void testSpace_BeforeSemicolon_InsideFor_IfSpacesWithinForIsOn() { getSettings().SPACE_WITHIN_FOR_PARENTHESES = true; doMethodTest( @@ -631,7 +632,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { "}\n" ); } - + public void testSpaceBeforeTypeArgumentList() { getSettings().SPACE_BEFORE_TYPE_PARAMETER_LIST = true; doMethodTest( @@ -643,7 +644,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { "Bar. call();" ); } - + public void testKeepLineBreaksWorks_InsidePolyExpression() { getSettings().KEEP_LINE_BREAKS = false; doMethodTest( @@ -652,5 +653,4 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest { "int x = (1 + 2 + 3) * (1 + 2 + 2) * (1 + 2);" ); } - -} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaIndenterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaIndenterTest.java index 6961877d7bae..625dce1c0c43 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaIndenterTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaIndenterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -17,6 +17,7 @@ package com.intellij.psi.formatter.java; import com.intellij.openapi.util.TextRange; import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; /** * @author Denis Zhdanov @@ -43,7 +44,7 @@ public class JavaIndenterTest extends AbstractJavaFormatterTest { int end = initial.indexOf("\n", start); myTextRange = new TextRange(start, end); - doTextTest(initial, + doTextTest(initial, "class BrokenAlignment {\n" + " public\n" + "\tstatic int foo(String a, String b, String c,\n" + @@ -64,7 +65,7 @@ public class JavaIndenterTest extends AbstractJavaFormatterTest { "\n" + " }" + "}", - + "class Test {\n" + " // some comment\n" + " public void doSmth(int[] p) {\n" + @@ -74,7 +75,7 @@ public class JavaIndenterTest extends AbstractJavaFormatterTest { } @Override - public void doTextTest(String text, String textAfter) throws IncorrectOperationException { + public void doTextTest(@NotNull String text, @NotNull String textAfter) throws IncorrectOperationException { doTextTest(Action.INDENT, adjustTextIfNecessary(text), textAfter); } @@ -91,4 +92,4 @@ public class JavaIndenterTest extends AbstractJavaFormatterTest { myTextRange = new TextRange(caretIndex, caretIndex); return text.substring(0, caretIndex) + text.substring(caretIndex + CARET_TOKEN.length()); } -} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java index b5ee7c877183..a6102422f724 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java @@ -21,13 +21,11 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.JavaCodeFragment; import com.intellij.psi.JavaCodeFragmentFactory; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase { @@ -314,9 +312,4 @@ public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase { " }\n" + " }"); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java index deb8f12c3839..c51c4ae2bbc4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java @@ -22,13 +22,10 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtil; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler; import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; public class ExtractMethodObjectTest extends LightRefactoringTestCase { @@ -145,9 +142,4 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase { public void testWithPrivateMethodWhichCantBeMoved() throws Exception { doTest(); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceFunctionalParameterTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceFunctionalParameterTest.java index e6f177806752..dbac0ff8100c 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceFunctionalParameterTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceFunctionalParameterTest.java @@ -17,12 +17,10 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.openapi.editor.SelectionModel; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.refactoring.extractMethod.ExtractMethodHandler; import com.intellij.refactoring.introduceParameter.IntroduceParameterHandler; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.TestDataPath; import org.jetbrains.annotations.NotNull; @@ -83,11 +81,6 @@ public class IntroduceFunctionalParameterTest extends LightRefactoringTestCase return LanguageLevel.JDK_1_8; } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } - private void doTest() { doTest(null); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java index 56034a69ca86..4ab61941c063 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java @@ -18,7 +18,6 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.CommonClassNames; import com.intellij.psi.PsiElement; @@ -29,7 +28,6 @@ import com.intellij.refactoring.introduceVariable.InputValidator; import com.intellij.refactoring.introduceVariable.IntroduceVariableBase; import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings; import com.intellij.refactoring.ui.TypeSelectorManagerImpl; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.LightCodeInsightTestCase; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; @@ -562,9 +560,4 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { testMe.invoke(getProject(), getEditor(), getFile(), null); checkResultByFile(baseName + ".after.java"); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java b/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java index c74e41a21383..699d338a410a 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/PullUpTest.java @@ -16,7 +16,6 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; @@ -26,7 +25,6 @@ import com.intellij.refactoring.memberPullUp.PullUpConflictsUtil; import com.intellij.refactoring.memberPullUp.PullUpProcessor; import com.intellij.refactoring.util.DocCommentPolicy; import com.intellij.refactoring.util.classMembers.MemberInfo; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -281,9 +279,4 @@ public class PullUpTest extends LightRefactoringTestCase { protected String getTestDataPath() { return JavaTestUtil.getJavaTestDataPath(); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java b/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java index 84648a70edbc..6271f4dc96fe 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java @@ -16,14 +16,12 @@ package com.intellij.refactoring; import com.intellij.codeInsight.TargetElementUtil; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.memberPushDown.PushDownProcessor; import com.intellij.refactoring.util.DocCommentPolicy; import com.intellij.refactoring.util.classMembers.MemberInfo; import com.intellij.refactoring.util.classMembers.MemberInfoStorage; -import com.intellij.testFramework.IdeaTestUtil; import com.intellij.usageView.UsageInfo; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; @@ -183,9 +181,4 @@ public class PushDownTest extends LightRefactoringTestCase { checkResultByFile(BASE_PATH + getTestName(false) + "_after.java"); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/RenameSuggestionsTest.groovy b/java/java-tests/testSrc/com/intellij/refactoring/RenameSuggestionsTest.groovy index ba23b91162c1..6b979db4f82a 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/RenameSuggestionsTest.groovy +++ b/java/java-tests/testSrc/com/intellij/refactoring/RenameSuggestionsTest.groovy @@ -14,15 +14,14 @@ * limitations under the License. */ package com.intellij.refactoring + import com.intellij.codeInsight.TargetElementUtil import com.intellij.codeInsight.lookup.LookupEx import com.intellij.codeInsight.lookup.LookupManager import com.intellij.codeInsight.template.impl.TemplateManagerImpl import com.intellij.codeInsight.template.impl.TemplateState -import com.intellij.openapi.projectRoots.Sdk import com.intellij.psi.PsiElement import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler -import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.LightCodeInsightTestCase /** * User: anna @@ -71,10 +70,6 @@ class RenameSuggestionsTest extends LightCodeInsightTestCase { doTestSuggestionAvailable(text, "foo") } - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18() - } public void "test by Optional_of initializer"() { def suggestions = getNameSuggestions(""" diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java index 60e48283bda6..30c32410e834 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -17,7 +17,6 @@ package com.intellij.refactoring.inline; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtil; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; @@ -27,7 +26,6 @@ import com.intellij.refactoring.BaseRefactoringProcessor; import com.intellij.refactoring.LightRefactoringTestCase; import com.intellij.refactoring.MockInlineMethodOptions; import com.intellij.refactoring.util.InlineUtil; -import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -369,9 +367,4 @@ public class InlineMethodTest extends LightRefactoringTestCase { new InlineMethodProcessor(getProject(), method, refExpr, myEditor, options.isInlineThisOnly(), nonCode, nonCode); processor.run(); } - - @Override - protected Sdk getProjectJDK() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/java/mockJDK-1.8/jre/lib/rt.jar b/java/mockJDK-1.8/jre/lib/rt.jar index f3a4f893f3d4..6885606d2964 100644 Binary files a/java/mockJDK-1.8/jre/lib/rt.jar and b/java/mockJDK-1.8/jre/lib/rt.jar differ diff --git a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java index 92e3a7d2c6ad..3538efac6322 100644 --- a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java @@ -241,8 +241,8 @@ public abstract class InspectionTestCase extends PsiTestCase { } protected Sdk getTestProjectSdk() { - Sdk sdk = IdeaTestUtil.getMockJdk17(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); + Sdk sdk = IdeaTestUtil.getMockJdk18(); + LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8); return sdk; } diff --git a/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaFileProvider.java b/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaFileProvider.java index 96b7ce7bdd2d..d2e88f1ea066 100644 --- a/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaFileProvider.java +++ b/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaFileProvider.java @@ -16,4 +16,12 @@ public interface JsonSchemaFileProvider { SchemaType getSchemaType(); int getOrder(); + + interface Orders { + int CORE = -1000; + int EMBEDDED_BASE = 1; + int PACKAGE_JSON = 2; + int TEST = 10; + int USER = 1000; + } } diff --git a/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaImportedProviderFactory.java b/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaImportedProviderFactory.java index 7883df39f83e..d520f021fc18 100644 --- a/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaImportedProviderFactory.java +++ b/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaImportedProviderFactory.java @@ -77,7 +77,7 @@ public class JsonSchemaImportedProviderFactory implements JsonSchemaProviderFact @Override public int getOrder() { - return 1000; + return Orders.USER; } @NotNull diff --git a/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaProjectSelfProviderFactory.java b/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaProjectSelfProviderFactory.java index a4366664e4d1..49a353de5043 100644 --- a/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaProjectSelfProviderFactory.java +++ b/json/src/com/jetbrains/jsonSchema/extension/JsonSchemaProjectSelfProviderFactory.java @@ -70,7 +70,7 @@ public class JsonSchemaProjectSelfProviderFactory implements JsonSchemaProviderF @Override public int getOrder() { - return -1000; + return Orders.CORE; } } } diff --git a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaTestProvider.java b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaTestProvider.java index e598f876b197..b4e8b661daed 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaTestProvider.java +++ b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaTestProvider.java @@ -39,6 +39,6 @@ public class JsonSchemaTestProvider implements JsonSchemaFileProvider { @Override public int getOrder() { - return 10; + return Orders.TEST; } } diff --git a/lib/annotations/jdk/java/math/annotations.xml b/lib/annotations/jdk/java/math/annotations.xml new file mode 100644 index 000000000000..e24dbcf105c1 --- /dev/null +++ b/lib/annotations/jdk/java/math/annotations.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/platform/boot/src/com/intellij/concurrency/IdeaForkJoinWorkerThreadFactory.java b/platform/boot/src/com/intellij/concurrency/IdeaForkJoinWorkerThreadFactory.java index 13c040f79e71..cc536f329982 100644 --- a/platform/boot/src/com/intellij/concurrency/IdeaForkJoinWorkerThreadFactory.java +++ b/platform/boot/src/com/intellij/concurrency/IdeaForkJoinWorkerThreadFactory.java @@ -41,6 +41,7 @@ public class IdeaForkJoinWorkerThreadFactory implements ForkJoinPool.ForkJoinWor } }; thread.setName("JobScheduler FJ pool " + n + "/" + PARALLELISM); + thread.setPriority(Thread.NORM_PRIORITY - 1); return thread; } diff --git a/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt b/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt index e8d95620fac7..372e2c8af7c9 100644 --- a/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt +++ b/platform/built-in-server/src/org/jetbrains/builtInWebServer/BuiltInWebServer.kt @@ -32,6 +32,7 @@ import com.intellij.openapi.ui.Messages import com.intellij.openapi.util.SystemInfoRt import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.endsWithName +import com.intellij.openapi.util.io.setOwnerPermissions import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.VirtualFile @@ -52,11 +53,8 @@ import java.awt.datatransfer.StringSelection import java.io.IOException import java.math.BigInteger import java.net.InetAddress -import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths -import java.nio.file.attribute.PosixFileAttributeView -import java.nio.file.attribute.PosixFilePermission import java.security.SecureRandom import java.util.* import java.util.concurrent.TimeUnit @@ -127,15 +125,7 @@ private val STANDARD_COOKIE by lazy { if (token == null) { token = UUID.randomUUID().toString() file.write(token!!) - val view = Files.getFileAttributeView(file, PosixFileAttributeView::class.java) - if (view != null) { - try { - view.setPermissions(setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)) - } - catch (e: IOException) { - LOG.warn(e) - } - } + file.setOwnerPermissions() } // explicit setting domain cookie on localhost doesn't work for chrome diff --git a/platform/diff-api/src/com/intellij/diff/DiffContentFactory.java b/platform/diff-api/src/com/intellij/diff/DiffContentFactory.java index 270150b7103c..95f2bd14b528 100644 --- a/platform/diff-api/src/com/intellij/diff/DiffContentFactory.java +++ b/platform/diff-api/src/com/intellij/diff/DiffContentFactory.java @@ -23,6 +23,7 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -77,6 +78,12 @@ public abstract class DiffContentFactory { @Nullable public abstract FileContent createFile(@Nullable Project project, @NotNull VirtualFile file); + @NotNull + public abstract DocumentContent createFragment(@Nullable Project project, @NotNull Document document, @NotNull TextRange range); + + @NotNull + public abstract DocumentContent createFragment(@Nullable Project project, @NotNull DocumentContent content, @NotNull TextRange range); + @NotNull public abstract DiffContent createClipboardContent(); diff --git a/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java b/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java index b33b4b0e54f9..b2ff4f6ac40d 100644 --- a/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java +++ b/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java @@ -15,17 +15,20 @@ */ package com.intellij.diff; +import com.intellij.diff.actions.DocumentFragmentContent; import com.intellij.diff.contents.*; import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorFactory; +import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.ide.CopyPasteManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; @@ -143,6 +146,19 @@ public class DiffContentFactoryImpl extends DiffContentFactory { return (FileContent)create(project, file); } + @NotNull + @Override + public DocumentContent createFragment(@Nullable Project project, @NotNull Document document, @NotNull TextRange range) { + DocumentContent content = create(project, document); + return new DocumentFragmentContent(project, content, range); + } + + @NotNull + @Override + public DocumentContent createFragment(@Nullable Project project, @NotNull DocumentContent content, @NotNull TextRange range) { + return new DocumentFragmentContent(project, content, range); + } + @Override @NotNull public DiffContent createClipboardContent() { @@ -225,10 +241,10 @@ public class DiffContentFactoryImpl extends DiffContentFactory { } @NotNull - public static VirtualFile createTemporalFile(@Nullable Project project, - @NotNull String prefix, - @NotNull String suffix, - @NotNull byte[] content) throws IOException { + private static VirtualFile createTemporalFile(@Nullable Project project, + @NotNull String prefix, + @NotNull String suffix, + @NotNull byte[] content) throws IOException { File tempFile = FileUtil.createTempFile(PathUtil.suggestFileName(prefix + "_", true, false), PathUtil.suggestFileName("_" + suffix, true, false), true); if (content.length != 0) { diff --git a/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java b/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java index 6594d1786778..db6c656d0eb0 100644 --- a/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java +++ b/platform/diff-impl/src/com/intellij/diff/actions/CompareClipboardWithSelectionAction.java @@ -106,7 +106,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction { SelectionModel selectionModel = editor.getSelectionModel(); if (selectionModel.hasSelection()) { TextRange range = new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()); - content = new DocumentFragmentContent(project, content, range); + content = DiffContentFactory.getInstance().createFragment(project, content, range); } return content; diff --git a/platform/diff-impl/src/com/intellij/diff/actions/DocumentFragmentContent.java b/platform/diff-impl/src/com/intellij/diff/actions/DocumentFragmentContent.java index fad819b10401..0bd09104f464 100644 --- a/platform/diff-impl/src/com/intellij/diff/actions/DocumentFragmentContent.java +++ b/platform/diff-impl/src/com/intellij/diff/actions/DocumentFragmentContent.java @@ -41,30 +41,40 @@ public class DocumentFragmentContent extends DiffContentBase implements Document // TODO: reuse DocumentWindow ? @NotNull private final DocumentContent myOriginal; + @NotNull private final RangeMarker myRangeMarker; - @NotNull private final MyDocumentsSynchronizer mySynchonizer; + @NotNull private final MyDocumentsSynchronizer mySynchronizer; private int myAssignments = 0; public DocumentFragmentContent(@Nullable Project project, @NotNull DocumentContent original, @NotNull TextRange range) { + this(project, original, createRangeMarker(original.getDocument(), range)); + } + + public DocumentFragmentContent(@Nullable Project project, @NotNull DocumentContent original, @NotNull RangeMarker rangeMarker) { myOriginal = original; + myRangeMarker = rangeMarker; Document document1 = myOriginal.getDocument(); Document document2 = EditorFactory.getInstance().createDocument(""); document2.putUserData(UndoManager.ORIGINAL_DOCUMENT, document1); - RangeMarker rangeMarker = document1.createRangeMarker(range.getStartOffset(), range.getEndOffset(), true); + mySynchronizer = new MyDocumentsSynchronizer(project, myRangeMarker, document1, document2); + } + + @NotNull + private static RangeMarker createRangeMarker(@NotNull Document document, @NotNull TextRange range) { + RangeMarker rangeMarker = document.createRangeMarker(range.getStartOffset(), range.getEndOffset(), true); rangeMarker.setGreedyToLeft(true); rangeMarker.setGreedyToRight(true); - - mySynchonizer = new MyDocumentsSynchronizer(project, rangeMarker, document1, document2); + return rangeMarker; } @NotNull @Override public Document getDocument() { - return mySynchonizer.getDocument2(); + return mySynchronizer.getDocument2(); } @Nullable @@ -76,8 +86,9 @@ public class DocumentFragmentContent extends DiffContentBase implements Document @Nullable @Override public Navigatable getNavigatable(@NotNull LineCol position) { + if (!myRangeMarker.isValid()) return null; int offset = position.toOffset(getDocument()); - int originalOffset = offset + mySynchonizer.getStartOffset(); + int originalOffset = offset + myRangeMarker.getStartOffset(); LineCol originalPosition = LineCol.fromOffset(myOriginal.getDocument(), originalOffset); return myOriginal.getNavigatable(originalPosition); } @@ -109,12 +120,12 @@ public class DocumentFragmentContent extends DiffContentBase implements Document @Override public void onAssigned(boolean isAssigned) { if (isAssigned) { - if (myAssignments == 0) mySynchonizer.startListen(); + if (myAssignments == 0) mySynchronizer.startListen(); myAssignments++; } else { myAssignments--; - if (myAssignments == 0) mySynchonizer.stopListen(); + if (myAssignments == 0) mySynchronizer.stopListen(); } assert myAssignments >= 0; } @@ -130,14 +141,6 @@ public class DocumentFragmentContent extends DiffContentBase implements Document myRangeMarker = range; } - public int getStartOffset() { - return myRangeMarker.getStartOffset(); - } - - public int getEndOffset() { - return myRangeMarker.getEndOffset(); - } - @Override protected void onDocumentChanged1(@NotNull DocumentEvent event) { if (!myRangeMarker.isValid()) { @@ -152,9 +155,7 @@ public class DocumentFragmentContent extends DiffContentBase implements Document @Override protected void onDocumentChanged2(@NotNull DocumentEvent event) { - if (!myRangeMarker.isValid()) { - return; - } + if (!myRangeMarker.isValid()) return; if (!myDocument1.isWritable()) return; CharSequence newText = event.getNewFragment(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java index 038a85eb921f..37f655cec865 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java @@ -155,8 +155,6 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { String text = ""; PsiElement[] impls = PsiElement.EMPTY_ARRAY; if (element != null) { - //if (element instanceof PsiPackage) return; - impls = getSelfAndImplementations(editor, element, createImplementationsSearcher()); text = SymbolPresentationUtil.getSymbolPresentableText(element); } @@ -176,7 +174,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { } if (!implsList.isEmpty()) { - implsList.toArray( impls = new PsiElement[implsList.size()] ); + impls = implsList.toArray(new PsiElement[implsList.size()]); } } @@ -455,7 +453,8 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { }; if (!myIncludeSelf) { myElements = getSelfAndImplementations(myEditor, myElement, implementationSearcher, false); - } else { + } + else { myElements = getSelfAndImplementations(myEditor, myElement, implementationSearcher); } } diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java index 34299445c9ef..d88bb7ed9732 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java @@ -35,10 +35,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.Trinity; +import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; @@ -63,9 +60,9 @@ import java.util.List; ) public class BookmarkManager extends AbstractProjectComponent implements PersistentStateComponent { private static final int MAX_AUTO_DESCRIPTION_SIZE = 50; + public static Key> BOOKMARKS_KEY = Key.create("bookmarks"); private final List myBookmarks = new ArrayList(); - private final Map> myDocumentsMap = new WeakHashMap<>(); private final Map, Bookmark> myDeletedDocumentBookmarks = new HashMap, Bookmark>(); private final Map>> myBeforeChangeData = new HashMap<>(); @@ -127,21 +124,21 @@ public class BookmarkManager extends AbstractProjectComponent implements Persist }, project); } - private void map(Document document, Bookmark bookmark) { + private static void map(Document document, Bookmark bookmark) { if (document == null || bookmark == null) return; - List list = myDocumentsMap.get(document); + List list = document.getUserData(BOOKMARKS_KEY); if (list == null) { - myDocumentsMap.put(document, list = new ArrayList()); + document.putUserData(BOOKMARKS_KEY, list = Collections.synchronizedList(new ArrayList())); } list.add(bookmark); } - private void unmap(Document document, Bookmark bookmark) { + private static void unmap(Document document, Bookmark bookmark) { if (document == null || bookmark == null) return; - List list = myDocumentsMap.get(document); + List list = document.getUserData(BOOKMARKS_KEY); if (list != null && list.remove(bookmark) && list.isEmpty()) { - myDocumentsMap.remove(document); + document.putUserData(BOOKMARKS_KEY, null); } } @@ -232,7 +229,7 @@ public class BookmarkManager extends AbstractProjectComponent implements Persist @Nullable public Bookmark findEditorBookmark(@NotNull Document document, int line) { - List bookmarks = myDocumentsMap.get(document); + List bookmarks = document.getUserData(BOOKMARKS_KEY); if (bookmarks != null) { for (Bookmark bookmark : bookmarks) { if (bookmark.getLine() == line) { @@ -294,8 +291,8 @@ public class BookmarkManager extends AbstractProjectComponent implements Persist for (Bookmark bookmark : myBookmarks) { bookmark.release(); publisher.bookmarkRemoved(bookmark); + unmap(bookmark.getDocument(), bookmark); } - myDocumentsMap.clear(); myBookmarks.clear(); readExternal(state); @@ -406,7 +403,7 @@ public class BookmarkManager extends AbstractProjectComponent implements Persist @Nullable public Bookmark findLineBookmark(@NotNull Editor editor, boolean isWrapped, boolean next) { - List bookmarksForDocument = myDocumentsMap.get(editor.getDocument()); + List bookmarksForDocument = editor.getDocument().getUserData(BOOKMARKS_KEY); if (bookmarksForDocument == null) return null; int sign = next ? 1 : -1; Collections.sort(bookmarksForDocument, (o1, o2) -> sign * (o1.getLine() - o2.getLine())); diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java index 051f42c3ebe9..67fc45cc4613 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java @@ -438,7 +438,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl String subId = subPane.getAttributeValue(ATTRIBUTE_SUBID); TreeState treeState = new TreeState(); treeState.readExternal(subPane); - myReadTreeState.put(subId, treeState); + if (!treeState.isEmpty()) myReadTreeState.put(subId, treeState); } } @@ -458,15 +458,13 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl protected void saveExpandedPaths() { if (myTree != null) { TreeState treeState = TreeState.createOn(myTree); - myReadTreeState.put(getSubId(), treeState); + if (!treeState.isEmpty()) myReadTreeState.put(getSubId(), treeState); } } public final void restoreExpandedPaths(){ TreeState treeState = myReadTreeState.get(getSubId()); - if (treeState != null) { - treeState.applyTo(myTree); - } + if (treeState != null && !treeState.isEmpty()) treeState.applyTo(myTree); } public void installComparator() { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index d382bc983298..c0e83f53255a 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -63,6 +63,8 @@ import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import com.intellij.util.containers.Queue; +import com.intellij.util.ui.JBInsets; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import gnu.trove.THashSet; @@ -674,6 +676,7 @@ public class SingleInspectionProfilePanel extends JPanel { final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTreeTable); myTreeTable.getTree().setShowsRootHandles(true); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM + SideBorder.LEFT + SideBorder.TOP)); TreeUtil.collapseAll(myTreeTable.getTree(), 1); myTreeTable.getTree().addTreeExpansionListener(new TreeExpansionListener() { @@ -893,21 +896,21 @@ public class SingleInspectionProfilePanel extends JPanel { severityPanel.add(new JLabel(InspectionsBundle.message("inspection.severity")), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, - new Insets(10, 0, 10, 0), 0, 0)); + JBUI.insets(10, 0), 0, 0)); final JComponent severityLevelChooserComponent = severityLevelChooser.createCustomComponent(severityLevelChooser.getTemplatePresentation()); severityPanel.add(severityLevelChooserComponent, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, - new Insets(10, 0, 10, 0), 0, 0)); + JBUI.insets(10, 0), 0, 0)); final JComponent scopesChooserComponent = scopesChooser.createCustomComponent(scopesChooser.getTemplatePresentation()); severityPanel.add(scopesChooserComponent, new GridBagConstraints(2, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, - new Insets(10, 0, 10, 0), 0, 0)); + JBUI.insets(10, 0), 0, 0)); final JLabel label = new JLabel("", SwingConstants.RIGHT); severityPanel.add(label, new GridBagConstraints(3, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH, - new Insets(2, 0, 2, 0), 0, 0)); + JBUI.insets(2, 0), 0, 0)); severityPanelWeightY = 0.0; if (singleNode != null) { setConfigPanel(configPanelAnchor, mySelectedProfile.getToolDefaultState(singleNode.getDefaultDescriptor().getKey().toString(), @@ -983,19 +986,20 @@ public class SingleInspectionProfilePanel extends JPanel { panel.setMinimumSize(new Dimension(getMinimumSize().width, 3 * scopesAndScopesAndSeveritiesTable.getRowHeight())); severityPanel.add(new JBLabel("Severity by Scope"), new GridBagConstraints(0, 0, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, - new Insets(5, 0, 2, 10), 0, 0)); + JBUI.insets(5, 0, 2, 10), 0, 0)); severityPanel.add(panel, new GridBagConstraints(0, 1, 1, 1, 0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, - new Insets(0, 0, 0, 0), 0, 0)); + JBUI.insets(0, 0, 0, 0), 0, 0)); severityPanelWeightY = 0.3; } - myOptionsPanel.add(severityPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, severityPanelWeightY, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + myOptionsPanel.add(severityPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, severityPanelWeightY, GridBagConstraints.WEST, GridBagConstraints.BOTH, + JBUI.insets(0, 2, 0, 0), 0, 0)); if (configPanelAnchor.getComponentCount() != 0) { - configPanelAnchor.setBorder(IdeBorderFactory.createTitledBorder("Options", false, new Insets(7, 0, 0, 0))); + configPanelAnchor.setBorder(IdeBorderFactory.createTitledBorder("Options", false, new JBInsets(7, 0, 0, 0))); } GuiUtils.enableChildren(myOptionsPanel, isThoughOneNodeEnabled(nodes)); if (configPanelAnchor.getComponentCount() != 0 || scopesNames.isEmpty()) { myOptionsPanel.add(configPanelAnchor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, - new Insets(0, 0, 0, 0), 0, 0)); + JBUI.insets(0, 2, 0, 0), 0, 0)); } myOptionsPanel.revalidate(); } @@ -1084,7 +1088,7 @@ public class SingleInspectionProfilePanel extends JPanel { JPanel descriptionPanel = new JPanel(new BorderLayout()); descriptionPanel.setBorder(IdeBorderFactory.createTitledBorder(InspectionsBundle.message("inspection.description.title"), false, - new Insets(2, 0, 0, 0))); + new JBInsets(2, 2, 0, 0))); descriptionPanel.add(ScrollPaneFactory.createScrollPane(myBrowser), BorderLayout.CENTER); myRightSplitter = new JBSplitter(true, "SingleInspectionProfilePanel.HORIZONTAL_DIVIDER_PROPORTION", DIVIDER_PROPORTION_DEFAULT); @@ -1100,10 +1104,12 @@ public class SingleInspectionProfilePanel extends JPanel { final JPanel northPanel = new JPanel(new GridBagLayout()); northPanel.setBorder(IdeBorderFactory.createEmptyBorder(2, 0, 2, 0)); myProfileFilter.setPreferredSize(new Dimension(20, myProfileFilter.getPreferredSize().height)); - northPanel.add(myProfileFilter, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - northPanel.add(createTreeToolbarPanel().getComponent(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + northPanel.add(myProfileFilter, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.HORIZONTAL, + JBUI.emptyInsets(), 0, 0)); + northPanel.add(createTreeToolbarPanel().getComponent(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, + JBUI.emptyInsets(), 0, 0)); - myMainSplitter = new JBSplitter(false, DIVIDER_PROPORTION_DEFAULT, 0.01f, 0.99f); + myMainSplitter = new OnePixelSplitter(false, DIVIDER_PROPORTION_DEFAULT, 0.01f, 0.99f); myMainSplitter.setSplitterProportionKey("SingleInspectionProfilePanel.VERTICAL_DIVIDER_PROPORTION"); myMainSplitter.setFirstComponent(tree); myMainSplitter.setSecondComponent(myRightSplitter); diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java index ba412e965c8e..4eae11fa4f8b 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java @@ -15,6 +15,7 @@ */ package com.intellij.refactoring.copy; +import com.intellij.ide.scratch.ScratchUtil; import com.intellij.ide.util.DirectoryUtil; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.ActionManager; @@ -23,6 +24,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.ex.FileTypeChooser; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.keymap.KeymapUtil; @@ -43,6 +45,7 @@ import com.intellij.ui.TextFieldWithHistoryWithBrowseButton; import com.intellij.ui.components.JBLabelDecorator; import com.intellij.ui.components.JBTextField; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.ObjectUtils; import com.intellij.util.PathUtil; import com.intellij.util.PathUtilRt; import com.intellij.util.ui.FormBuilder; @@ -111,6 +114,10 @@ public class CopyFilesOrDirectoriesDialog extends DialogWrapper { VirtualFile vFile = file.getVirtualFile(); text = RefactoringBundle.message(doClone ? "copy.files.clone.file.0" : "copy.files.copy.file.0", shortenPath(vFile)); String fileName = vFile.isInLocalFileSystem() ? vFile.getName() : PathUtil.suggestFileName(file.getName(), true, true); + if (StringUtil.isEmpty(vFile.getExtension()) && ScratchUtil.isScratch(vFile)) { + FileType type = ObjectUtils.notNull(file.getLanguage().getAssociatedFileType(), file.getFileType()); + fileName = PathUtil.makeFileName(fileName, type.getDefaultExtension()); + } myNewNameField.setText(fileName); int dotIdx = fileName.lastIndexOf('.'); if (dotIdx > 0) { diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/ui/models/SelectionDifferenceModel.java b/platform/lvcs-impl/src/com/intellij/history/integration/ui/models/SelectionDifferenceModel.java index a98f2dd27168..20f04f3726fa 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/ui/models/SelectionDifferenceModel.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/ui/models/SelectionDifferenceModel.java @@ -17,7 +17,6 @@ package com.intellij.history.integration.ui.models; import com.intellij.diff.DiffContentFactory; -import com.intellij.diff.actions.DocumentFragmentContent; import com.intellij.diff.contents.DiffContent; import com.intellij.diff.contents.DocumentContent; import com.intellij.history.core.revisions.Revision; @@ -98,8 +97,7 @@ public class SelectionDifferenceModel extends FileDifferenceModel { int fromOffset = d.getLineStartOffset(myFrom); int toOffset = d.getLineEndOffset(myTo); - DocumentContent documentContent = DiffContentFactory.getInstance().create(myProject, d); - return new DocumentFragmentContent(myProject, documentContent, new TextRange(fromOffset, toOffset)); + return DiffContentFactory.getInstance().createFragment(myProject, d, new TextRange(fromOffset, toOffset)); } private DocumentContent getDiffContent(Revision r, RevisionProcessingProgress p) { diff --git a/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java b/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java index 50d503b76411..5e64427a7829 100644 --- a/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java +++ b/platform/platform-api/src/com/intellij/ide/passwordSafe/PasswordSafe.java @@ -16,21 +16,10 @@ package com.intellij.ide.passwordSafe; import com.intellij.openapi.components.ServiceManager; +import org.jetbrains.annotations.NotNull; -/** - * The password safe component. It allows storing, removing, and retrieving the passwords. - * Note that on the first access to the password safe functions, the dialog asking for the - * master password might have to be shown. So the access should be either done from UI thread, - * or it should be possible to invoke {@link java.awt.EventQueue#invokeAndWait(Runnable)} - * method when password access methods are invoked. - * - * @see com.intellij.ide.passwordSafe.ui.PasswordSafePromptDialog - */ public abstract class PasswordSafe implements PasswordStorage { - - /** - * @return the instance of password safe service - */ + @NotNull public static PasswordSafe getInstance() { return ServiceManager.getService(PasswordSafe.class); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java b/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java index 1411eaa4439e..538916f6aefd 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/TreeState.java @@ -110,6 +110,10 @@ public class TreeState implements JDOMExternalizable { this(new ArrayList>(), new ArrayList>()); } + public boolean isEmpty() { + return myExpandedPaths.isEmpty() && mySelectedPaths.isEmpty(); + } + @Override public void readExternal(Element element) throws InvalidDataException { readExternal(element, myExpandedPaths, PATH); @@ -492,5 +496,39 @@ public class TreeState implements JDOMExternalizable { public void setScrollToSelection(boolean scrollToSelection) { myScrollToSelection = scrollToSelection; } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TreeState(").append(myScrollToSelection).append(")"); + append(sb, " expanded:", myExpandedPaths); + append(sb, " selected:", mySelectedPaths); + return sb.toString(); + } + + private static void append(StringBuilder sb, String prefix, Object object) { + if (prefix != null) { + sb.append(prefix); + } + if (object instanceof List) { + appendList(sb, (List)object); + } + else { + sb.append(object); + } + } + + private static void appendList(StringBuilder sb, List list) { + if (list.isEmpty()) { + sb.append("{}"); + } + else { + String prefix = "{"; + for (Object object : list) { + append(sb, prefix, object); + prefix = ", "; + } + sb.append("}"); + } + } } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/DropAnOutOfMemoryErrorAction.java b/platform/platform-impl/src/com/intellij/diagnostic/DropAnOutOfMemoryErrorAction.java index f8a7a790fc96..d2d83ac31261 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/DropAnOutOfMemoryErrorAction.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/DropAnOutOfMemoryErrorAction.java @@ -15,7 +15,6 @@ */ package com.intellij.diagnostic; -import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAwareAction; @@ -26,6 +25,10 @@ public class DropAnOutOfMemoryErrorAction extends DumbAwareAction { } public void actionPerformed(AnActionEvent e) { + Object[] array = new Object[Integer.MAX_VALUE]; + for (int i = 0; i < array.length; i++) { + array[i] = new Object[Integer.MAX_VALUE]; + } throw new OutOfMemoryError(); } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/CharToVKeyMap.java b/platform/platform-impl/src/com/intellij/ide/CharToVKeyMap.java index 3d15ec4ca98f..92e85cab47d0 100644 --- a/platform/platform-impl/src/com/intellij/ide/CharToVKeyMap.java +++ b/platform/platform-impl/src/com/intellij/ide/CharToVKeyMap.java @@ -29,7 +29,7 @@ class CharToVKeyMap { new HashMap(); public static Integer get (Character ch) { - return charToVKeyMap.get(ch); + return charToVKeyMap.containsKey(ch) ? charToVKeyMap.get(ch) : KeyEvent.VK_UNDEFINED; } static { diff --git a/platform/platform-impl/src/com/intellij/ide/GeneralSettingsPanel.form b/platform/platform-impl/src/com/intellij/ide/GeneralSettingsPanel.form index 8e590d041972..ff3aeb175b05 100644 --- a/platform/platform-impl/src/com/intellij/ide/GeneralSettingsPanel.form +++ b/platform/platform-impl/src/com/intellij/ide/GeneralSettingsPanel.form @@ -224,7 +224,7 @@ - + diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index ce09b77acbe0..9b4dfaa3e9b2 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -439,83 +439,49 @@ public class IdeEventQueue extends EventQueue { // Try to get it from editor Component sourceComponent = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow(); - if (ke.getID() == KeyEvent.KEY_PRESSED) { - switch (ke.getKeyCode()) { - case KeyEvent.VK_CONTROL: - if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) { - ctrlIsPressedCount++; - } - break; - case KeyEvent.VK_ALT: - if (ke.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { - if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) { - leftAltIsPressed = true; - } - } - break; - } - } - else if (ke.getID() == KeyEvent.KEY_RELEASED) { - switch (ke.getKeyCode()) { - case KeyEvent.VK_CONTROL: - ctrlIsPressedCount = 0; - break; - case KeyEvent.VK_ALT: - if (ke.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) { - leftAltIsPressed = false; - } - break; - } + switch (ke.getID()) { + case KeyEvent.KEY_PRESSED: + break; + case KeyEvent.KEY_RELEASED: + break; } - if (!leftAltIsPressed && KeyboardSettingsExternalizable.getInstance().isUkrainianKeyboard(sourceComponent)) { - if ('Ò‘' == ke.getKeyChar() || ke.getKeyCode() == KeyEvent.VK_U) { - ke = new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), 0, - KeyEvent.VK_UNDEFINED, 'Ò‘', ke.getKeyLocation()); - ke.setKeyCode(KeyEvent.VK_U); - ke.setKeyChar('Ò‘'); - return ke; - } - } + //if (!leftAltIsPressed && KeyboardSettingsExternalizable.getInstance().isUkrainianKeyboard(sourceComponent)) { + // if ('Ò‘' == ke.getKeyChar() || ke.getKeyCode() == KeyEvent.VK_U) { + // ke = new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), 0, + // KeyEvent.VK_UNDEFINED, 'Ò‘', ke.getKeyLocation()); + // ke.setKeyCode(KeyEvent.VK_U); + // ke.setKeyChar('Ò‘'); + // return ke; + // } + //} + + // NB: Standard keyboard layout is an English keyboard layout. If such + // layout is active every KeyEvent that is received has + // a @{code KeyEvent.getKeyCode} key code corresponding to + // the @{code KeyEvent.getKeyChar} key char in the event. + // For example, VK_MINUS key code and '-' character + // + // We have a key char. On some non standard layouts it does not correspond to + // key code in the event. Integer keyCodeFromChar = CharToVKeyMap.get(ke.getKeyChar()); + + // Now we have a correct key code as if we'd gotten a KeyEvent for + // standard English layout + + if (keyCodeFromChar == ke.getKeyCode() || keyCodeFromChar == KeyEvent.VK_UNDEFINED) { + return e; + } + + // Farther we handle a non standard layout + if (keyCodeFromChar != null) { if (keyCodeFromChar != ke.getKeyCode()) { // non-english layout ke.setKeyCode(keyCodeFromChar); } - - //for (int i = 0; sourceComponent == null && i < WindowManagerEx.getInstanceEx().getAllProjectFrames().length; i++) { - // sourceComponent = WindowManagerEx.getInstanceEx().getAllProjectFrames()[i].getComponent(); - //} - - if (sourceComponent != null) { - if (KeyboardSettingsExternalizable.isSupportedKeyboardLayout(sourceComponent)) { - if ((ke.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != 0 /*&& ke.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT*/) { - // On German keyboard layout on Windows we are getting on key press - // ctrl + alt instead of AltGr - - int modifiers = ke.getModifiers() ^ InputEvent.ALT_DOWN_MASK ^ InputEvent.CTRL_DOWN_MASK; - - if (ctrlIsPressedCount > 1) { - modifiers |= InputEvent.CTRL_DOWN_MASK; - } - - if (leftAltIsPressed) { - modifiers |= InputEvent.ALT_MASK; - } - - int oldKeyCode = ke.getKeyCode(); - - //noinspection MagicConstant - ke = new KeyEvent(ke.getComponent(), ke.getID(), ke.getWhen(), modifiers, - KeyEvent.VK_UNDEFINED, ke.getKeyChar(), KeyEvent.KEY_LOCATION_UNKNOWN); - - ke.setKeyCode(oldKeyCode); - } - } } - } return ke; } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java index 669b99de4955..f1edc303a264 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/config/PasswordSafeSettings.java @@ -22,7 +22,6 @@ import com.intellij.openapi.components.Storage; /** * The password safe settings - * The password database. The internal component for {@link com.intellij.ide.passwordSafe.impl.providers.masterKey.MasterKeyPasswordSafe}. */ @State( name = "PasswordSafe", diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java index 0b7c5e00e83a..cffa1c8d2c8d 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java @@ -23,6 +23,7 @@ import com.sun.jna.Structure; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIFunctionMapper; import com.sun.jna.win32.W32APITypeMapper; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -51,7 +52,8 @@ public class WindowsCryptUtils { * @param data the data to protect * @return the the protected form the data */ - public static byte[] protect(byte[] data) { + @NotNull + public static byte[] protect(@NotNull byte[] data) { if(data.length == 0) { return data; } @@ -74,6 +76,7 @@ public class WindowsCryptUtils { * @param data the data to protect * @return the the protected form the data */ + @NotNull public static byte[] unprotect(byte[] data) { if(data.length == 0) { return data; diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java index a33d4277f0f9..d7c886513f00 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java @@ -25,6 +25,7 @@ import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.BrowserHyperlinkListener; import com.intellij.ui.JBColor; @@ -45,6 +46,8 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import static com.intellij.openapi.util.Pair.pair; + /** * @author pti */ @@ -55,9 +58,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog { private final BuildInfo myNewBuild; private final PatchInfo myPatch; private final boolean myWriteProtected; - - private String myLicenseInfo = null; - private Color myLicenseInfoColor = null; + private final Pair myLicenseInfo; UpdateInfoDialog(@NotNull UpdateChannel channel, @NotNull BuildInfo newBuild, @@ -74,7 +75,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog { myPatch = patch; myWriteProtected = myPatch != null && !new File(PathManager.getHomePath()).canWrite(); getCancelAction().putValue(DEFAULT_ACTION, Boolean.TRUE); - initLicensingInfo(myUpdatedChannel, myNewBuild); + myLicenseInfo = initLicensingInfo(myUpdatedChannel, myNewBuild); init(); if (incompatiblePlugins != null && !incompatiblePlugins.isEmpty()) { @@ -83,33 +84,32 @@ class UpdateInfoDialog extends AbstractUpdateDialog { } } - private void initLicensingInfo(@NotNull UpdateChannel channel, @NotNull BuildInfo build) { + private static Pair initLicensingInfo(UpdateChannel channel, BuildInfo build) { LicensingFacade facade = LicensingFacade.getInstance(); - if (facade != null) { - if (channel.getLicensing().equals(UpdateChannel.LICENSING_EAP)) { - myLicenseInfo = IdeBundle.message("updates.channel.bundled.key"); - } - else { - Date buildDate = build.getReleaseDate(); - if (buildDate != null) { - Boolean applicable = facade.isApplicableForProduct(buildDate); - if (applicable != null) { - if (applicable == Boolean.FALSE) { - myLicenseInfo = IdeBundle.message("updates.paid.upgrade", channel.getEvalDays()); - myLicenseInfoColor = JBColor.RED; - } - else if (facade.isPerpetualForProduct(buildDate) == Boolean.TRUE) { - myLicenseInfo = IdeBundle.message("updates.fallback.build"); - } - else { - Date expiration = facade.getLicenseExpirationDate(); - if (expiration != null) { - myLicenseInfo = IdeBundle.message("updates.interim.build", DateFormatUtil.formatAboutDialogDate(expiration)); - } - } - } - } - } + if (facade == null) return null; + + if (channel.getLicensing().equals(UpdateChannel.LICENSING_EAP)) { + return pair(IdeBundle.message("updates.channel.bundled.key"), null); + } + + Date releaseDate = build.getReleaseDate(); + Boolean applicable = releaseDate == null ? null : facade.isApplicableForProduct(releaseDate); + if (applicable == null) { + return null; + } + if (applicable == Boolean.FALSE) { + return pair(IdeBundle.message("updates.paid.upgrade", channel.getEvalDays()), JBColor.RED); + } + if (facade.isPerpetualForProduct(releaseDate) == Boolean.TRUE) { + return pair(IdeBundle.message("updates.fallback.build"), null); + } + + Date expiration = facade.getLicenseExpirationDate(); + if (expiration != null) { + return pair(IdeBundle.message("updates.interim.build", DateFormatUtil.formatAboutDialogDate(expiration)), null); + } + else { + return null; } } @@ -269,7 +269,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog { } if (myLicenseInfo != null) { - configureMessageArea(myLicenseArea, myLicenseInfo, myLicenseInfoColor, null); + configureMessageArea(myLicenseArea, myLicenseInfo.first, myLicenseInfo.second, null); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt b/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt index eeb97cb8c019..fc752370b3c0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt +++ b/platform/platform-impl/src/com/intellij/openapi/util/io/fileUtil.kt @@ -15,9 +15,17 @@ */ package com.intellij.openapi.util.io +import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.text.StringUtil import com.intellij.util.PathUtilRt import java.io.File +import java.io.IOException +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.attribute.PosixFileAttributeView +import java.nio.file.attribute.PosixFilePermission + +private val LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileUtil") val File.systemIndependentPath: String get() = path.replace(File.separatorChar, '/') @@ -30,4 +38,15 @@ fun getParentPath(path: String) = StringUtil.nullize(PathUtilRt.getParentPath(pa fun endsWithSlash(path: String) = path.getOrNull(path.length - 1) == '/' -fun endsWithName(path: String, name: String) = path.endsWith(name) && (path.length == name.length || path.getOrNull(path.length - name.length - 1) == '/') \ No newline at end of file +fun endsWithName(path: String, name: String) = path.endsWith(name) && (path.length == name.length || path.getOrNull(path.length - name.length - 1) == '/') + +fun Path.setOwnerPermissions() { + Files.getFileAttributeView(this, PosixFileAttributeView::class.java)?.let { + try { + it.setPermissions(setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)) + } + catch (e: IOException) { + LOG.warn(e) + } + } +} \ No newline at end of file diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index c8cd453903a9..92e9c6bfc1ae 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -38,6 +38,7 @@ checkbox.save.files.on.frame.deactivation=Save files on frame deactivation checkbox.synchronize.files.on.frame.activation=Synchronize files on frame or editor tab activation checkbox.reopen.last.project.on.startup=Reopen last project on startup checkbox.support.screen.readers=Support screen readers (requires restart) +group.settings.process.tab.close=On Closing Tool Window with Running Process radio.process.close.terminate=Terminate process radio.process.close.disaconnect=Disconnect (if available) radio.process.close.ask=Ask diff --git a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java index faa1d31b724a..c428b8bb0416 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtilTest.java @@ -1,7 +1,21 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.ide.passwordSafe.impl.providers.masterKey.windows; import com.intellij.openapi.util.SystemInfo; -import com.intellij.ide.passwordSafe.MasterPasswordUnavailableException; import org.junit.Assert; import org.junit.Test; @@ -12,7 +26,7 @@ import java.security.SecureRandom; */ public class WindowsCryptUtilTest { @Test - public void testProtect() throws MasterPasswordUnavailableException { + public void testProtect() { if(SystemInfo.isWindows) { SecureRandom t = new SecureRandom(); byte[] data = new byte[256]; diff --git a/platform/script-debugger/backend/src/SuspendContextManager.kt b/platform/script-debugger/backend/src/SuspendContextManager.kt index fb13b95f15f5..a9d1c6413e15 100644 --- a/platform/script-debugger/backend/src/SuspendContextManager.kt +++ b/platform/script-debugger/backend/src/SuspendContextManager.kt @@ -68,12 +68,6 @@ enum class StepAction { */ IN, - /** - * Step into first scheduled async handler. - * @see Chrome debugger suggestion - */ - IN_ASYNC, - /** * Step over the current statement. */ diff --git a/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt b/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt index a50e2397a791..8104b203fceb 100644 --- a/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt +++ b/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt @@ -137,7 +137,7 @@ abstract class DebugProcessImpl>(session: XDebugSession, override final fun startStepInto(context: XSuspendContext?) { val vm = context.vm updateLastCallFrame(vm) - continueVm(vm, if (vm.captureAsyncStackTraces) StepAction.IN_ASYNC else StepAction.IN) + continueVm(vm, StepAction.IN) } override final fun startStepOut(context: XSuspendContext?) { diff --git a/platform/script-debugger/protocol/protocol-model-generator/src/TypeMap.kt b/platform/script-debugger/protocol/protocol-model-generator/src/TypeMap.kt index 74e0977c91b0..48834773f002 100644 --- a/platform/script-debugger/protocol/protocol-model-generator/src/TypeMap.kt +++ b/platform/script-debugger/protocol/protocol-model-generator/src/TypeMap.kt @@ -18,7 +18,9 @@ internal class TypeMap { val domainGenerator = domainGeneratorMap!!.get(domainName) if (domainGenerator == null) { val qName = "$domainName.$typeName"; - if (qName == "IO.StreamHandle" || qName == "Security.SecurityState") return BoxableType.ANY_STRING // ignore + if (qName == "IO.StreamHandle" || qName == "Security.SecurityState" || qName == "Emulation.ScreenOrientation") { + return BoxableType.ANY_STRING // ignore + } throw RuntimeException("Failed to find domain generator: $domainName for type $typeName") } return direction.get(getTypeData(domainName, typeName)).resolve(this, domainGenerator) diff --git a/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt b/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt index 63a17b083aa4..31f8c204d278 100644 --- a/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt +++ b/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt @@ -153,7 +153,8 @@ open class OutMessage() { writer.endArray() } - fun writeStringList(name: String, value: Collection) { + fun writeStringList(name: String, value: Collection?) { + if (value == null) return beginArguments() JsonWriters.writeStringList(writer, name, value) } diff --git a/platform/usageView/src/com/intellij/usages/impl/GroupNode.java b/platform/usageView/src/com/intellij/usages/impl/GroupNode.java index 4592f0f06702..616aaea0d961 100644 --- a/platform/usageView/src/com/intellij/usages/impl/GroupNode.java +++ b/platform/usageView/src/com/intellij/usages/impl/GroupNode.java @@ -41,8 +41,8 @@ public class GroupNode extends Node implements Navigatable, Comparable mySubgroupNodes = new THashMap(); - private final List myUsageNodes = new SmartList(); + private final Map mySubgroupNodes = new THashMap<>(); + private final List myUsageNodes = new SmartList<>(); @NotNull private final UsageViewTreeModelBuilder myUsageTreeModel; private volatile int myRecursiveUsageCount; @@ -67,7 +67,7 @@ public class GroupNode extends Node implements Navigatable, Comparable edtQueue) { @@ -85,7 +85,7 @@ public class GroupNode extends Node implements Navigatable, Comparable edtQueue) { if (!getBuilder().isDetachedMode()) { - edtQueue.consume(() -> myTreeModel.insertNodeInto(node, GroupNode.this, getNodeInsertionIndex(node))); + edtQueue.consume(() -> myTreeModel.insertNodeInto(node, this, getNodeInsertionIndex(node))); } } @@ -105,7 +105,8 @@ public class GroupNode extends Node implements Navigatable, Comparable groupNodes = mySubgroupNodes.values(); for(Iterator iterator = groupNodes.iterator();iterator.hasNext();) { @@ -151,7 +152,7 @@ public class GroupNode extends Node implements Navigatable, Comparable usages) { + boolean removeUsagesBulk(@NotNull Set usages) { boolean removed; synchronized (lock) { removed = myUsageNodes.removeAll(usages); @@ -201,7 +202,7 @@ public class GroupNode extends Node implements Navigatable, Comparable { - myTreeModel.insertNodeInto(node, GroupNode.this, getNodeIndex(node)); + myTreeModel.insertNodeInto(node, this, getNodeIndex(node)); incrementUsageCount(); }); } @@ -247,7 +248,7 @@ public class GroupNode extends Node implements Navigatable, Comparable myTreeModel.nodeChanged(Node.this)); + edtQueue.consume(() -> myTreeModel.nodeChanged(this)); } setFlag(UPDATED_MASK, true); } diff --git a/platform/usageView/src/com/intellij/usages/impl/SyntaxHighlighterOverEditorHighlighter.java b/platform/usageView/src/com/intellij/usages/impl/SyntaxHighlighterOverEditorHighlighter.java index 04690cc6fa20..9d9e4bde67bd 100644 --- a/platform/usageView/src/com/intellij/usages/impl/SyntaxHighlighterOverEditorHighlighter.java +++ b/platform/usageView/src/com/intellij/usages/impl/SyntaxHighlighterOverEditorHighlighter.java @@ -37,7 +37,7 @@ import org.jetbrains.annotations.NotNull; */ public class SyntaxHighlighterOverEditorHighlighter implements SyntaxHighlighter { private final Lexer lexer; - private LayeredHighlighterIterator layeredHighlighterIterator = null; + private LayeredHighlighterIterator layeredHighlighterIterator; private final SyntaxHighlighter highlighter; public SyntaxHighlighterOverEditorHighlighter(SyntaxHighlighter _highlighter, VirtualFile file, Project project) { diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java index 7c2d235ec58b..f10e65091860 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageFilteringRuleProviderImpl.java @@ -45,7 +45,7 @@ public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvide @Override @NotNull public UsageFilteringRule[] getActiveRules(@NotNull Project project) { - final List rules = new ArrayList(); + final List rules = new ArrayList<>(); if (!myReadWriteState.isShowReadAccess()) { rules.add(new ReadAccessFilteringRule()); @@ -77,22 +77,22 @@ public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvide private boolean myShowReadAccess = true; private boolean myShowWriteAccess = true; - public boolean isShowReadAccess() { + boolean isShowReadAccess() { return myShowReadAccess; } - public void setShowReadAccess(final boolean showReadAccess) { + void setShowReadAccess(final boolean showReadAccess) { myShowReadAccess = showReadAccess; if (!showReadAccess) { myShowWriteAccess = true; } } - public boolean isShowWriteAccess() { + boolean isShowWriteAccess() { return myShowWriteAccess; } - public void setShowWriteAccess(final boolean showWriteAccess) { + void setShowWriteAccess(final boolean showWriteAccess) { myShowWriteAccess = showWriteAccess; if (!showWriteAccess) { myShowReadAccess = true; diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java index 11713b812523..af472d1b3cb4 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java @@ -55,7 +55,7 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider @Override @NotNull public UsageGroupingRule[] getActiveRules(Project project) { - List rules = new ArrayList(); + List rules = new ArrayList<>(); if (supportsNonCodeRule()) { rules.add(new NonCodeUsageGroupingRule(project)); } diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageNode.java b/platform/usageView/src/com/intellij/usages/impl/UsageNode.java index fc09c2939ab6..4060c9de1533 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageNode.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageNode.java @@ -98,7 +98,7 @@ public class UsageNode extends Node implements Comparable, Navigatabl } } - public void setUsageExcluded(boolean usageExcluded) { + void setUsageExcluded(boolean usageExcluded) { myUsageExcluded = usageExcluded; } } diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageNodeTreeBuilder.java b/platform/usageView/src/com/intellij/usages/impl/UsageNodeTreeBuilder.java index 55211390e0ac..d073f277b6d0 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageNodeTreeBuilder.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageNodeTreeBuilder.java @@ -54,7 +54,7 @@ class UsageNodeTreeBuilder { myGroupingRules = rules; } - public void setFilteringRules(@NotNull UsageFilteringRule[] rules) { + void setFilteringRules(@NotNull UsageFilteringRule[] rules) { myFilteringRules = rules; } diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index 64f0286a6290..537f40e33475 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -61,7 +61,6 @@ import com.intellij.usages.*; import com.intellij.usages.rules.*; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.Convertor; import com.intellij.util.containers.TransferToEDTQueue; import com.intellij.util.enumeration.EmptyEnumeration; import com.intellij.util.messages.MessageBusConnection; @@ -74,7 +73,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.event.*; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; import javax.swing.plaf.TreeUI; import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.tree.*; @@ -108,7 +110,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra private final ExclusionHandler myExclusionHandler; private final UsageModelTracker myModelTracker; - private final Map myUsageNodes = new ConcurrentHashMap(); + private final Map myUsageNodes = new ConcurrentHashMap<>(); public static final UsageNode NULL_NODE = new UsageNode(NullUsage.INSTANCE, new UsageViewTreeModelBuilder(new UsageViewPresentation(), UsageTarget.EMPTY_ARRAY)); private final ButtonPanel myButtonPanel = new ButtonPanel(); private final JComponent myAdditionalComponent = new JPanel(new BorderLayout()); @@ -189,7 +191,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra // hack to avoid quadratic expandAll() @Override public Enumeration getExpandedDescendants(TreePath parent) { - return expandingAll ? EmptyEnumeration.getInstance() : super.getExpandedDescendants(parent); + return expandingAll ? EmptyEnumeration.getInstance() : super.getExpandedDescendants(parent); } }; myRootPanel = new MyPanel(myTree); @@ -202,7 +204,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra myBuilder = new UsageNodeTreeBuilder(myTargets, getActiveGroupingRules(project), getActiveFilteringRules(project), myRoot, myProject); final MessageBusConnection messageBusConnection = myProject.getMessageBus().connect(this); - messageBusConnection.subscribe(UsageFilteringRuleProvider.RULES_CHANGED, () -> rulesChanged()); + messageBusConnection.subscribe(UsageFilteringRuleProvider.RULES_CHANGED, this::rulesChanged); myUsageViewTreeCellRenderer = new UsageViewTreeCellRenderer(this); if (!myPresentation.isDetachedMode()) { @@ -231,10 +233,10 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra myTree.setCellRenderer(myUsageViewTreeCellRenderer); collapseAll(); - myModelTracker.addListener(UsageViewImpl.this); + myModelTracker.addListener(this); if (myPresentation.isShowCancelButton()) { - addButtonToLowerPane(() -> close(), UsageViewBundle.message("usage.view.cancel.button")); + addButtonToLowerPane(this::close, UsageViewBundle.message("usage.view.cancel.button")); } myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @@ -249,7 +251,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra } }); } - myTransferToEDTQueue = new TransferToEDTQueue("Insert usages", runnable -> { + myTransferToEDTQueue = new TransferToEDTQueue<>("Insert usages", runnable -> { runnable.run(); return true; }, o -> isDisposed || project.isDisposed(), 200); @@ -336,12 +338,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra // add reaction to scrolling: // since the UsageViewTreeCellRenderer ignores invisible nodes (outside the viewport), their preferred size is incorrect // and we need to recalculate them when the node scrolled into the visible rectangle - treePane.getViewport().addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - clearRendererCache(); - } - }); + treePane.getViewport().addChangeListener(e -> clearRendererCache()); myTree.addTreeExpansionListener(new TreeExpansionListener() { @Override public void treeExpanded(TreeExpansionEvent event) { @@ -370,7 +367,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra }; UsageContextPanel.Provider[] extensions = Extensions.getExtensions(UsageContextPanel.Provider.EP_NAME, myProject); - myUsageContextPanelProviders = ContainerUtil.filter(extensions, provider -> provider.isAvailableFor(UsageViewImpl.this)); + myUsageContextPanelProviders = ContainerUtil.filter(extensions, provider -> provider.isAvailableFor(this)); for (UsageContextPanel.Provider provider : myUsageContextPanelProviders) { JComponent component; if (myCurrentUsageContextProvider == null || myCurrentUsageContextProvider == provider) { @@ -386,14 +383,11 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra } int index = myUsageContextPanelProviders.indexOf(myCurrentUsageContextProvider); tabbedPane.setSelectedIndex(index); - tabbedPane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - int currentIndex = tabbedPane.getSelectedIndex(); - UsageContextPanel.Provider selectedProvider = myUsageContextPanelProviders.get(currentIndex); - if (selectedProvider != myCurrentUsageContextProvider) { - tabSelected(selectedProvider); - } + tabbedPane.addChangeListener(e -> { + int currentIndex = tabbedPane.getSelectedIndex(); + UsageContextPanel.Provider selectedProvider = myUsageContextPanelProviders.get(currentIndex); + if (selectedProvider != myCurrentUsageContextProvider) { + tabSelected(selectedProvider); } }); tabbedPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); @@ -426,7 +420,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra private static UsageFilteringRule[] getActiveFilteringRules(final Project project) { final UsageFilteringRuleProvider[] providers = Extensions.getExtensions(UsageFilteringRuleProvider.EP_NAME); - List list = new ArrayList(providers.length); + List list = new ArrayList<>(providers.length); for (UsageFilteringRuleProvider provider : providers) { ContainerUtil.addAll(list, provider.getActiveRules(project)); } @@ -435,7 +429,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra private static UsageGroupingRule[] getActiveGroupingRules(@NotNull final Project project) { final UsageGroupingRuleProvider[] providers = Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME); - List list = new ArrayList(providers.length); + List list = new ArrayList<>(providers.length); for (UsageGroupingRuleProvider provider : providers) { ContainerUtil.addAll(list, provider.getActiveRules(project)); } @@ -515,17 +509,14 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra } }); - TreeUIHelper.getInstance().installTreeSpeedSearch(myTree, new Convertor() { - @Override - public String convert(TreePath o) { - Object value = o.getLastPathComponent(); - TreeCellRenderer renderer = myTree.getCellRenderer(); - if (renderer instanceof UsageViewTreeCellRenderer) { - UsageViewTreeCellRenderer coloredRenderer = (UsageViewTreeCellRenderer)renderer; - return coloredRenderer.getPlainTextForNode(value); - } - return value == null ? null : value.toString(); + TreeUIHelper.getInstance().installTreeSpeedSearch(myTree, o -> { + Object value = o.getLastPathComponent(); + TreeCellRenderer renderer = myTree.getCellRenderer(); + if (renderer instanceof UsageViewTreeCellRenderer) { + UsageViewTreeCellRenderer coloredRenderer = (UsageViewTreeCellRenderer)renderer; + return coloredRenderer.getPlainTextForNode(value); } + return value == null ? null : value.toString(); }, true); } @@ -594,7 +585,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra } } - public void scheduleDisposeOnClose(@NotNull Disposable disposable) { + private void scheduleDisposeOnClose(@NotNull Disposable disposable) { Disposer.register(this, disposable); } @@ -631,12 +622,9 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra final AnAction expandAllAction = actionsManager.createExpandAllAction(treeExpander, component); final AnAction collapseAllAction = actionsManager.createCollapseAllAction(treeExpander, component); - scheduleDisposeOnClose(new Disposable() { - @Override - public void dispose() { - expandAllAction.unregisterCustomShortcutSet(component); - collapseAllAction.unregisterCustomShortcutSet(component); - } + scheduleDisposeOnClose(() -> { + expandAllAction.unregisterCustomShortcutSet(component); + collapseAllAction.unregisterCustomShortcutSet(component); }); @@ -709,7 +697,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @NotNull private AnAction[] createGroupingActions() { final UsageGroupingRuleProvider[] providers = Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME); - List list = new ArrayList(providers.length); + List list = new ArrayList<>(providers.length); for (UsageGroupingRuleProvider provider : providers) { ContainerUtil.addAll(list, provider.createGroupingActions(this)); } @@ -718,9 +706,9 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra private void rulesChanged() { ApplicationManager.getApplication().assertIsDispatchThread(); - final List states = new ArrayList(); + final List states = new ArrayList<>(); captureUsagesExpandState(new TreePath(myTree.getModel().getRoot()), states); - final List allUsages = new ArrayList(myUsageNodes.keySet()); + final List allUsages = new ArrayList<>(myUsageNodes.keySet()); Collections.sort(allUsages, USAGE_COMPARATOR); final Set excludedUsages = getExcludedUsages(); reset(); @@ -974,7 +962,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @Override public void removeUsagesBulk(@NotNull Collection usages) { - final Set nodes = new THashSet(usages.size()); + final Set nodes = new THashSet<>(usages.size()); for (Usage usage : usages) { UsageNode node = myUsageNodes.remove(usage); if (node != null && node != NULL_NODE) { @@ -1001,7 +989,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @Override public void includeUsages(@NotNull Usage[] usages) { - List nodes = new ArrayList(usages.length); + List nodes = new ArrayList<>(usages.length); for (Usage usage : usages) { final UsageNode node = myUsageNodes.get(usage); if (node != NULL_NODE && node != null) { @@ -1014,7 +1002,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @Override public void excludeUsages(@NotNull Usage[] usages) { - List nodes = new ArrayList(usages.length); + List nodes = new ArrayList<>(usages.length); for (Usage usage : usages) { final UsageNode node = myUsageNodes.get(usage); if (node != NULL_NODE && node != null) { @@ -1027,7 +1015,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @Override public void selectUsages(@NotNull Usage[] usages) { - List paths = new LinkedList(); + List paths = new LinkedList<>(); for (Usage usage : usages) { final UsageNode node = myUsageNodes.get(usage); @@ -1128,7 +1116,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra myUpdateAlarm.addRequest(() -> { if (myProject.isDisposed()) return; PsiDocumentManagerBase documentManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(myProject); - documentManager.cancelAndRunWhenAllCommitted("UpdateUsageView", () -> updateImmediately()); + documentManager.cancelAndRunWhenAllCommitted("UpdateUsageView", this::updateImmediately); }, 300); } @@ -1280,7 +1268,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @NotNull private Set getReadOnlyUsages() { - final Set result = new THashSet(); + final Set result = new THashSet<>(); final Set> usages = myUsageNodes.entrySet(); for (Map.Entry entry : usages) { Usage usage = entry.getKey(); @@ -1295,7 +1283,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @NotNull private Set getReadOnlyUsagesFiles() { Set usages = getReadOnlyUsages(); - Set result = new THashSet(); + Set result = new THashSet<>(); for (Usage usage : usages) { if (usage instanceof UsageInFile) { UsageInFile usageInFile = (UsageInFile)usage; @@ -1319,7 +1307,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @Override @NotNull public Set getExcludedUsages() { - Set result = new THashSet(); + Set result = new THashSet<>(); for (Map.Entry entry : myUsageNodes.entrySet()) { UsageNode node = entry.getValue(); Usage usage = entry.getKey(); @@ -1349,7 +1337,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra TreePath[] leadSelectionPath = myTree.getSelectionPaths(); if (leadSelectionPath == null || leadSelectionPath.length == 0) return null; - final List result = new ArrayList(); + final List result = new ArrayList<>(); for (TreePath comp : leadSelectionPath) { final Object lastPathComponent = comp.getLastPathComponent(); if (lastPathComponent instanceof Node) { @@ -1368,7 +1356,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra return null; } - Set usages = new THashSet(); + Set usages = new THashSet<>(); for (TreePath selectionPath : selectionPaths) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)selectionPath.getLastPathComponent(); collectUsages(node, usages); @@ -1386,7 +1374,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @Override @NotNull public List getSortedUsages() { - List usages = new ArrayList(getUsages()); + List usages = new ArrayList<>(getUsages()); Collections.sort(usages, USAGE_COMPARATOR); return usages; } @@ -1410,7 +1398,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra TreePath[] selectionPaths = myTree.getSelectionPaths(); if (selectionPaths == null) return null; - Set targets = new THashSet(); + Set targets = new THashSet<>(); for (TreePath selectionPath : selectionPaths) { Object lastPathComponent = selectionPath.getLastPathComponent(); if (lastPathComponent instanceof UsageTargetNode) { @@ -1440,7 +1428,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra if (nodes == null) { return null; } - final List result = new ArrayList(); + final List result = new ArrayList<>(); for (final Node node : nodes) { /* if (!node.isDataValid()) { @@ -1461,7 +1449,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra private class MyPanel extends JPanel implements TypeSafeDataProvider, OccurenceNavigator,Disposable{ @Nullable private OccurenceNavigatorSupport mySupport; - private CopyProvider myCopyProvider; + private final CopyProvider myCopyProvider; private MyPanel(@NotNull JTree tree) { mySupport = new OccurenceNavigatorSupport(tree) { @@ -1618,12 +1606,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra DumbService.getInstance(myProject).makeDumbAware(button, UsageViewImpl.this); button.setFocusable(false); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - runnable.run(); - } - }); + button.addActionListener(e -> runnable.run()); add(button, index); diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java index f5ac066cf8b4..08f12fbdd601 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java @@ -122,7 +122,7 @@ public class UsageViewManagerImpl extends UsageViewManager { @NotNull final FindUsagesProcessPresentation processPresentation, @Nullable final UsageViewStateListener listener) { final SearchScope searchScopeToWarnOfFallingOutOf = getMaxSearchScopeToWarnOfFallingOutOf(searchFor); - final AtomicReference usageViewRef = new AtomicReference(); + final AtomicReference usageViewRef = new AtomicReference<>(); Task.Backgroundable task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) { @Override @@ -243,7 +243,7 @@ public class UsageViewManagerImpl extends UsageViewManager { if (file != null) { return isFileInScope(file, searchScope); } - else if(element != null) { + if (element != null) { return searchScope instanceof EverythingGlobalScope || searchScope instanceof ProjectScopeImpl || searchScope instanceof ProjectAndLibrariesScope; @@ -258,9 +258,7 @@ public class UsageViewManagerImpl extends UsageViewManager { if (searchScope instanceof LocalSearchScope) { return ((LocalSearchScope)searchScope).isInScope(file); } - else { - return ((GlobalSearchScope)searchScope).contains(file); - } + return ((GlobalSearchScope)searchScope).contains(file); } @NotNull diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java index 7408e9b69f6b..5d05d7f8a0fc 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java @@ -49,7 +49,7 @@ class UsageViewTreeCellRenderer extends ColoredTreeCellRenderer { private static final SimpleTextAttributes ourNumberOfUsagesAttribute = SimpleTextAttributes.fromTextAttributes(ourColorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)); private static final SimpleTextAttributes ourInvalidAttributesDarcula = new SimpleTextAttributes(null, DarculaColors.RED, null, ourInvalidAttributes.getStyle()); private static final Insets STANDARD_IPAD_NOWIFI = new Insets(1, 2, 1, 2); - private boolean myRowBoundsCalled = false; + private boolean myRowBoundsCalled; private final UsageViewPresentation myPresentation; private final UsageView myView; diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeModelBuilder.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeModelBuilder.java index 321690e41082..5631564c4d86 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeModelBuilder.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeModelBuilder.java @@ -18,7 +18,6 @@ package com.intellij.usages.impl; import com.intellij.usages.UsageTarget; import com.intellij.usages.UsageViewPresentation; import com.intellij.usages.UsageViewSettings; -import com.intellij.util.Consumer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; @@ -55,8 +54,8 @@ public class UsageViewTreeModelBuilder extends DefaultTreeModel { myDetachedMode = presentation.isDetachedMode(); } - public static class TargetsRootNode extends DefaultMutableTreeNode { - public TargetsRootNode(String name) { + static class TargetsRootNode extends DefaultMutableTreeNode { + TargetsRootNode(String name) { super(name); } } @@ -71,10 +70,10 @@ public class UsageViewTreeModelBuilder extends DefaultTreeModel { myTargetsNode.add(targetNode); myTargetNodes[i] = targetNode; } - myRootNode.addNode(myTargetsNode, runnable -> UIUtil.invokeLaterIfNeeded(runnable)); + myRootNode.addNode(myTargetsNode, UIUtil::invokeLaterIfNeeded); } - public UsageNode getFirstUsageNode() { + UsageNode getFirstUsageNode() { return (UsageNode)getFirstChildOfType(myRootNode, UsageNode.class); } @@ -93,7 +92,7 @@ public class UsageViewTreeModelBuilder extends DefaultTreeModel { return null; } - public boolean areTargetsValid() { + boolean areTargetsValid() { if (myTargetNodes == null) return true; for (UsageTargetNode targetNode : myTargetNodes) { if (!targetNode.isValid()) return false; @@ -119,11 +118,11 @@ public class UsageViewTreeModelBuilder extends DefaultTreeModel { } } - public boolean isDetachedMode() { + boolean isDetachedMode() { return myDetachedMode; } - public boolean isFilterDuplicatedLine() { + boolean isFilterDuplicatedLine() { return myPresentation.isMergeDupLinesAvailable() && UsageViewSettings.getInstance().isFilterDuplicatedLine(); } } diff --git a/platform/util/src/com/intellij/util/containers/SmartHashSet.java b/platform/util/src/com/intellij/util/containers/SmartHashSet.java index dc68fc0ac14a..974b2e862af7 100644 --- a/platform/util/src/com/intellij/util/containers/SmartHashSet.java +++ b/platform/util/src/com/intellij/util/containers/SmartHashSet.java @@ -19,6 +19,7 @@ import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; import gnu.trove.TObjectProcedure; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.lang.reflect.Array; import java.util.Collection; @@ -95,7 +96,7 @@ public class SmartHashSet extends THashSet { } @Override - public boolean equals(@NotNull Object other) { + public boolean equals(@Nullable Object other) { T theElement = this.theElement; if (theElement != null) { return other instanceof Set && ((Set)other).size() == 1 && eq(theElement, (T)((Set)other).iterator().next()); diff --git a/platform/util/src/com/intellij/util/containers/WeakHashMap.java b/platform/util/src/com/intellij/util/containers/WeakHashMap.java index 14f44e10e7a0..56f878b1d919 100644 --- a/platform/util/src/com/intellij/util/containers/WeakHashMap.java +++ b/platform/util/src/com/intellij/util/containers/WeakHashMap.java @@ -25,8 +25,13 @@ import java.util.Map; /** * Weak keys hash map. + * Custom TObjectHashingStrategy is supported. * Null keys are NOT allowed * Null values are allowed + * + * Use this class if you need custom TObjectHashingStrategy. + * Do not use this class if you have null keys (shame on you). + * Otherwise it's the same as java.util.WeakHashMap, you are free to use either. */ public final class WeakHashMap extends RefHashMap { public WeakHashMap(int initialCapacity, float loadFactor) { diff --git a/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java b/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java index 826ddaf9bff6..83306ca3114a 100644 --- a/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java +++ b/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java @@ -22,6 +22,7 @@ package com.intellij.util.io.storage; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.registry.Registry; import com.intellij.util.EventDispatcher; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; @@ -141,6 +142,10 @@ public class HeavyProcessLatch { public void prioritizeUiActivity() { LOG.assertTrue(SwingUtilities.isEventDispatchThread()); + if (!Registry.is("ide.prioritize.ui.thread", false)) { + return; + } + // don't wait forever in case someone forgot to stop prioritizing before waiting for other threads to complete // wait just for 12 seconds; this will be noticeable (and we'll get 2 thread dumps) but not fatal myPrioritizingDeadLine = System.currentTimeMillis() + 12 * 1000; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java index a2fec889aed5..15f376cb9bca 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java @@ -17,7 +17,6 @@ package com.intellij.openapi.vcs.ex; import com.intellij.diff.DiffContentFactory; import com.intellij.diff.DiffManager; -import com.intellij.diff.actions.DocumentFragmentContent; import com.intellij.diff.contents.DiffContent; import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.requests.DiffRequest; @@ -70,7 +69,7 @@ public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction { private DiffContent createDiffContent(@NotNull Document document, @NotNull TextRange textRange, @Nullable VirtualFile file) { final Project project = myLineStatusTracker.getProject(); DocumentContent content = DiffContentFactory.getInstance().create(project, document, file); - return new DocumentFragmentContent(project, content, textRange); + return DiffContentFactory.getInstance().createFragment(project, content, textRange); } @NotNull diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExceptionUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExceptionUtils.java index 4bd074c13634..a4a392190344 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExceptionUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExceptionUtils.java @@ -15,8 +15,8 @@ */ package com.siyeh.ig.psiutils; +import com.intellij.codeInsight.ExceptionUtil; import com.intellij.psi.*; -import com.intellij.psi.util.PsiUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,8 +48,7 @@ public class ExceptionUtils { if (element instanceof PsiResourceList) { final PsiResourceList resourceList = (PsiResourceList)element; for (PsiResourceListElement resource : resourceList) { - final PsiMethod method = PsiUtil.getResourceCloserMethod(resource); - collectExceptionsThrown(method, PsiSubstitutor.EMPTY, out); + out.addAll(ExceptionUtil.getCloserExceptions(resource)); } } final ExceptionsThrownVisitor visitor = new ExceptionsThrownVisitor(out); @@ -202,26 +201,6 @@ public class ExceptionUtils { return false; } - private static void collectExceptionsThrown(@Nullable PsiMethod method, @NotNull PsiSubstitutor substitutor, - @NotNull Set out) { - if (method == null) { - return; - } - for (PsiClassType type : method.getThrowsList().getReferencedTypes()) { - final PsiType substitute = substitutor.substitute(type); - if (substitute instanceof PsiClassType) { - out.add((PsiClassType)substitute); - } - else if (substitute instanceof PsiCapturedWildcardType) { - final PsiCapturedWildcardType capturedWildcardType = (PsiCapturedWildcardType)substitute; - final PsiType upperBound = capturedWildcardType.getUpperBound(); - if (upperBound instanceof PsiClassType) { - out.add((PsiClassType)upperBound); - } - } - } - } - public static Set getExceptionTypesHandled(PsiTryStatement statement) { final Set out = new HashSet<>(5); for (PsiParameter parameter : statement.getCatchBlockParameters()) { @@ -258,7 +237,8 @@ public class ExceptionUtils { if (!(target instanceof PsiMethod)) { return; } - collectExceptionsThrown((PsiMethod)target, resolveResult.getSubstitutor(), m_exceptionsThrown); + final PsiClassType[] referencedTypes = ((PsiMethod)target).getThrowsList().getReferencedTypes(); + m_exceptionsThrown.addAll(ExceptionUtil.collectSubstituted(resolveResult.getSubstitutor(), referencedTypes, callExpression.getResolveScope())); } @Override diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/SingleStatementInBlockInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/SingleStatementInBlockInspection.java index 5205a4e29a2c..a3b88a9d362d 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/SingleStatementInBlockInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/SingleStatementInBlockInspection.java @@ -161,14 +161,21 @@ public class SingleStatementInBlockInspection extends BaseInspection { else if (startParent instanceof PsiLoopStatement) { body = ((PsiLoopStatement)startParent).getBody(); } - else { - assert startElement instanceof PsiKeyword; + else if (startElement instanceof PsiKeyword) { assert startParent instanceof PsiIfStatement; PsiIfStatement ifStatement = (PsiIfStatement)startParent; body = ((PsiKeyword)startElement).getTokenType() == JavaTokenType.IF_KEYWORD ? ifStatement.getThenBranch() : ifStatement.getElseBranch(); } + else if (startElement instanceof PsiJavaToken && + ((PsiJavaToken)startElement).getTokenType() == JavaTokenType.RBRACE) { // at the end of the omitted body + assert startParent instanceof PsiCodeBlock; + body = startParent.getParent(); + } + else { + return; + } assert body instanceof PsiBlockStatement; doFixImpl((PsiBlockStatement)body); } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/ElseWithLoop.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/ElseWithLoop.after.java new file mode 100644 index 000000000000..1f7d66bfcd0c --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/ElseWithLoop.after.java @@ -0,0 +1,8 @@ +class X { + void f(int[] a) { + if (a.length != 0) { + System.out.println(a.length); + } else for (int i = 0; i < 3; i++) + System.out.print(i); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/ElseWithLoop.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/ElseWithLoop.java new file mode 100644 index 000000000000..4fbe1800de64 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/ElseWithLoop.java @@ -0,0 +1,10 @@ +class X { + void f(int[] a) { + if (a.length != 0) { + System.out.println(a.length); + } else { + for (int i = 0; i < 3; i++) + System.out.print(i); + } + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfElse3.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfElse3.after.java new file mode 100644 index 000000000000..b3cd166c8dec --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfElse3.after.java @@ -0,0 +1,8 @@ +class X { + { + if (true) { + System.out.println(1); + } + else System.out.println(2); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfElse3.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfElse3.java new file mode 100644 index 000000000000..275772dad861 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfElse3.java @@ -0,0 +1,10 @@ +class X { + { + if (true) { + System.out.println(1); + } + else { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfWithLoop.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfWithLoop.after.java new file mode 100644 index 000000000000..945ed9eb0ac6 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfWithLoop.after.java @@ -0,0 +1,9 @@ +class X { + void f(int[] a) { + if (a.length != 0) for (int i : a) + System.out.println(i); + else { + System.out.println("no"); + } + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfWithLoop.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfWithLoop.java new file mode 100644 index 000000000000..b07658ba6ff5 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/single_statement_block/IfWithLoop.java @@ -0,0 +1,10 @@ +class X { + void f(int[] a) { + if (a.length != 0) { + for (int i : a) + System.out.println(i); + } else { + System.out.println("no"); + } + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java index 5bfc39c12c7f..60e62a243aa9 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java @@ -1,5 +1,5 @@ package com.siyeh.igtest.naming.standard_variable_names; - +import java.io.*; public class StandardVariableNames { void bad() { @@ -21,9 +21,13 @@ public class StandardVariableNames { long l; String s, str; - new java.io.OutputStream() { + new MyOutputStream() { + // same as super public void write(int b) throws IOException {} - } + }; } +} +interface MyOutputStream { + void write(int b) throws IOException; } \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml index aa28723a840c..52999e682cc8 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml @@ -84,4 +84,11 @@ Standard variable names Variable named <code>str</code> doesn't have type 'java.lang.String' #loc + + + StandardVariableNames.java + 32 + Standard variable names + Variable named <code>b</code> doesn't have type 'byte' or 'java.lang.Byte' #loc + \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java index b1106554548f..d0b21a7960a7 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java @@ -1,8 +1,15 @@ package com.siyeh.ig.bugs; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; public class AssertWithSideEffectsInspectionTest extends IGInspectionTestCase { + @Override + protected Sdk getTestProjectSdk() { + // uses SQL + return IdeaTestUtil.getMockJdk17(); + } public void test() throws Exception { doTest("com/siyeh/igtest/bugs/assert_with_side_effects", diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java index cc10fbc46415..7d51d61c834b 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java @@ -15,24 +15,12 @@ */ package com.siyeh.ig.classlayout; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; /** * @author Bas Leijdekkers */ public class FinalPrivateMethodInspectionTest extends IGInspectionTestCase { - - @Override - protected Sdk getTestProjectSdk() { - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7); - return IdeaTestUtil.getMockJdk17(); - } - public void test() throws Exception { doTest("com/siyeh/igtest/classlayout/final_private_method", new FinalPrivateMethodInspection()); } diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/braces/SingleStatementInBlockFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/braces/SingleStatementInBlockFixTest.java index c72c24ac6c50..d9ebda08bae7 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/braces/SingleStatementInBlockFixTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/braces/SingleStatementInBlockFixTest.java @@ -29,10 +29,13 @@ public class SingleStatementInBlockFixTest extends IGQuickFixesTestCase { public void testBetweenIfAndElse() { assertQuickfixNotAvailable(getMessagePrefix());} public void testIfElse() { doTest("if"); } public void testIfElse2() { doTest("if"); } + public void testIfElse3() { doTest("else"); } public void testWhile() { doTest("while"); } public void testForEach() { doTest("for"); } public void testForIndex() { doTest("for"); } public void testDoWhile() { doTest("do"); } + public void testIfWithLoop() { doTest("if"); } + public void testElseWithLoop() { doTest("else"); } @Override protected void setUp() throws Exception { diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java index 753c2f76f53a..5e6ed0b25c88 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java @@ -1,9 +1,5 @@ package com.siyeh.ig.inheritance; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspectionTestCase { @@ -14,11 +10,4 @@ public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspe tool.ignoreJavaDoc = true; doTest("com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method", tool); } - - @Override - protected Sdk getTestProjectSdk() { - Sdk sdk = IdeaTestUtil.getMockJdk17(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST); - return sdk; - } } diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java index d0bbbac1b820..1ebeb5519194 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java @@ -1,14 +1,11 @@ package com.siyeh.ig.inheritance; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCase { - public void test() throws Exception { final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject()); final LanguageLevel level = levelProjectExtension.getLanguageLevel(); @@ -21,9 +18,4 @@ public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCas levelProjectExtension.setLanguageLevel(level); } } - - @Override - protected Sdk getTestProjectSdk() { - return IdeaTestUtil.getMockJdk18(); - } } diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java index c813c05d7879..dcc4a5206b68 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java @@ -27,6 +27,7 @@ import com.siyeh.ig.LightInspectionTestCase; /** * @author Bas Leijdekkers */ +@SuppressWarnings("InfiniteRecursion") public class ProblematicWhitespaceInspectionTest extends LightInspectionTestCase { public void testHtml() { @@ -113,7 +114,7 @@ public class ProblematicWhitespaceInspectionTest extends LightInspectionTestCase final CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(JavaFileType.INSTANCE); options.USE_TAB_CHARACTER = true; options.SMART_TABS = true; - doTest("class X {{\n" + + doTest("class X {static{\n" + "\tSystem.out.println(\"asdf\" +\n" + "\t\t\t \"asdf\");\n" + "}}"); diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java index a78fff6c492a..2dcbf3dfe287 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java @@ -15,9 +15,16 @@ */ package com.siyeh.ig.style; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; public class UnnecessaryFinalOnLocalVariableOrParameterInspectionTest extends IGInspectionTestCase { + @Override + protected Sdk getTestProjectSdk() { + // effectively final rules are different in jdk 8 + return IdeaTestUtil.getMockJdk17(); + } public void test() throws Exception { doTest("com/siyeh/igtest/style/unnecessary_final_on_local_variable_or_parameter", diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java index 1856fc662a46..144eac9359b9 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java @@ -1,14 +1,21 @@ package com.siyeh.ig.style; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.JavaCodeStyleSettings; +import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; public class UnnecessaryFullyQualifiedNameInspectionTest extends IGInspectionTestCase { - private static final String BASE_DIR = "com/siyeh/igtest/style/"; + @Override + protected Sdk getTestProjectSdk() { + // uses awt + return IdeaTestUtil.getMockJdk17(); + } + public void testFqnInJavadoc_Unnecessary_WhenFullyQualifyIfNotImported() throws Exception { doTestWithFqnInJavadocSetting(BASE_DIR + "unnecessary_fqn_javadoc_fully_qualify_if_not_imported", JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED); } diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java index 0fe9f5d4c1c1..d187b16cb6ba 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java @@ -1,22 +1,9 @@ package com.siyeh.ig.visibility; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; import com.siyeh.ig.IGInspectionTestCase; public class MethodOverloadsParentMethodInspectionTest extends IGInspectionTestCase { - public void test() throws Exception { doTest("com/siyeh/igtest/visibility/method_overloads_parent_method", new MethodOverloadsParentMethodInspection()); } - - @Override - protected Sdk getTestProjectSdk() { - final Sdk sdk = IdeaTestUtil.getMockJdk17(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST); - return sdk; - } - } \ No newline at end of file diff --git a/plugins/commander/src/com/intellij/ide/commander/PsiDiffContentFactory.java b/plugins/commander/src/com/intellij/ide/commander/PsiDiffContentFactory.java index e841d19f0214..8184a9c7a04c 100644 --- a/plugins/commander/src/com/intellij/ide/commander/PsiDiffContentFactory.java +++ b/plugins/commander/src/com/intellij/ide/commander/PsiDiffContentFactory.java @@ -16,7 +16,6 @@ package com.intellij.ide.commander; import com.intellij.diff.DiffContentFactory; -import com.intellij.diff.actions.DocumentFragmentContent; import com.intellij.diff.contents.DiffContent; import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.requests.DiffRequest; @@ -42,21 +41,22 @@ public class PsiDiffContentFactory { @Nullable private static DiffContent fromPsiElement(@NotNull PsiElement psiElement) { + DiffContentFactory factory = DiffContentFactory.getInstance(); if (psiElement instanceof PsiFile) { - return DiffContentFactory.getInstance().create(psiElement.getProject(), ((PsiFile)psiElement).getVirtualFile()); + return factory.create(psiElement.getProject(), ((PsiFile)psiElement).getVirtualFile()); } else if (psiElement instanceof PsiDirectory) { - return DiffContentFactory.getInstance().create(psiElement.getProject(), ((PsiDirectory)psiElement).getVirtualFile()); + return factory.create(psiElement.getProject(), ((PsiDirectory)psiElement).getVirtualFile()); } PsiFile containingFile = psiElement.getContainingFile(); if (containingFile == null) { String text = psiElement.getText(); if (text == null) return null; - return DiffContentFactory.getInstance().create(text, psiElement.getLanguage().getAssociatedFileType(), false); + return factory.create(text, psiElement.getLanguage().getAssociatedFileType(), false); } - DocumentContent wholeFileContent = DiffContentFactory.getInstance().createDocument(psiElement.getProject(), containingFile.getVirtualFile()); + DocumentContent wholeFileContent = factory.createDocument(psiElement.getProject(), containingFile.getVirtualFile()); if (wholeFileContent == null) return null; - return new DocumentFragmentContent(psiElement.getProject(), wholeFileContent, psiElement.getTextRange()); + return factory.createFragment(psiElement.getProject(), wholeFileContent, psiElement.getTextRange()); } @Nullable diff --git a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java index 315273769180..dd4e9eca0546 100644 --- a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java +++ b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java @@ -40,26 +40,27 @@ import java.util.regex.Pattern; * @author cdr */ public class PropertiesUtil { - public final static Pattern LOCALE_PATTERN = Pattern.compile("(_[a-zA-Z]{2,8}(_[a-zA-Z]{2}|[0-9]{3})?(_[\\w\\-]+)?)\\.[^_]+$"); - public final static Set BASE_NAME_BORDER_CHAR = ContainerUtil.newHashSet('-', '_', '.'); - public final static Locale DEFAULT_LOCALE = new Locale("", "", ""); + private static final Pattern LOCALE_PATTERN = Pattern.compile("(_[a-zA-Z]{2,8}(_[a-zA-Z]{2}|[0-9]{3})?(_[\\w\\-]+)?)\\.[^_]+$"); + public static final Set BASE_NAME_BORDER_CHAR = ContainerUtil.newHashSet('-', '_', '.'); + public static final Locale DEFAULT_LOCALE = new Locale("", "", ""); private static final SoftLazyValue> LOCALES_LANGUAGE_CODES = new SoftLazyValue>() { @NotNull @Override protected Set compute() { final HashSet locales = - new HashSet(ContainerUtil.flatten(ContainerUtil.map(Locale.getAvailableLocales(), - (Function>)locale -> { - final ArrayList languages = ContainerUtil.newArrayList(locale.getLanguage()); - try { - languages.add(locale.getISO3Language()); - } - catch (MissingResourceException ignored) { - // if ISO3 language is not found for existed locale then exception is thrown anyway - } - return languages; - }))); + new HashSet<>(ContainerUtil.flatten(ContainerUtil.map(Locale.getAvailableLocales(), + (Function>)locale -> { + final ArrayList languages = + ContainerUtil.newArrayList(locale.getLanguage()); + try { + languages.add(locale.getISO3Language()); + } + catch (MissingResourceException ignored) { + // if ISO3 language is not found for existed locale then exception is thrown anyway + } + return languages; + }))); locales.addAll(ContainerUtil.newArrayList(Locale.getISOLanguages())); return locales; } @@ -97,7 +98,7 @@ public class PropertiesUtil { } @NotNull - public static String getDefaultBaseName(@NotNull final VirtualFile file) { + static String getDefaultBaseName(@NotNull final VirtualFile file) { final String name = file.getName(); if (!StringUtil.containsChar(name, '_')) { @@ -126,7 +127,7 @@ public class PropertiesUtil { } @NotNull - public static Locale getLocale(final @NotNull PropertiesFile propertiesFile) { + public static Locale getLocale(@NotNull final PropertiesFile propertiesFile) { String name = propertiesFile.getName(); if (!StringUtil.containsChar(name, '_')) return DEFAULT_LOCALE; final String containingResourceBundleBaseName = propertiesFile.getResourceBundle().getBaseName(); @@ -153,7 +154,7 @@ public class PropertiesUtil { * messages_en.properties is a parent of the messages_en_US.properties */ @Nullable - public static PropertiesFile getParent(PropertiesFile file, Collection candidates) { + public static PropertiesFile getParent(@NotNull PropertiesFile file, @NotNull Collection candidates) { VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return null; String name = virtualFile.getNameWithoutExtension(); @@ -175,7 +176,7 @@ public class PropertiesUtil { @NotNull @Deprecated public static List findAllProperties(Project project, @NotNull ResourceBundle resourceBundle, String key) { - List result = new SmartList(); + List result = new SmartList<>(); List propertiesFiles = resourceBundle.getPropertiesFiles(); for (PropertiesFile propertiesFile : propertiesFiles) { result.addAll(propertiesFile.findPropertiesByKey(key)); @@ -184,7 +185,7 @@ public class PropertiesUtil { } public static List findAllProperties(@NotNull ResourceBundle resourceBundle, String key) { - List result = new SmartList(); + List result = new SmartList<>(); List propertiesFiles = resourceBundle.getPropertiesFiles(); for (PropertiesFile propertiesFile : propertiesFiles) { result.addAll(propertiesFile.findPropertiesByKey(key)); @@ -206,13 +207,13 @@ public class PropertiesUtil { } @Nullable - public static String getPackageQualifiedName(@NotNull PsiDirectory directory) { + static String getPackageQualifiedName(@NotNull PsiDirectory directory) { return ProjectRootManager.getInstance(directory.getProject()).getFileIndex().getPackageNameByDirectory(directory.getVirtualFile()); } @NotNull public static String getPresentableLocale(@NotNull Locale locale) { - List names = new ArrayList(); + List names = new ArrayList<>(); if (!Comparing.strEqual(locale.getDisplayLanguage(), null)) { names.add(locale.getDisplayLanguage()); } @@ -222,7 +223,7 @@ public class PropertiesUtil { if (!Comparing.strEqual(locale.getDisplayVariant(), null)) { names.add(locale.getDisplayVariant()); } - return names.isEmpty() ? "" : (" (" + StringUtil.join(names, "/") + ")"); + return names.isEmpty() ? "" : " (" + StringUtil.join(names, "/") + ")"; } public static boolean hasDefaultLanguage(Locale locale) { diff --git a/plugins/terminal/terminal.iml b/plugins/terminal/terminal.iml index b173ddc26343..875cb81a97bb 100644 --- a/plugins/terminal/terminal.iml +++ b/plugins/terminal/terminal.iml @@ -10,7 +10,7 @@ - + @@ -26,4 +26,4 @@ - \ No newline at end of file + diff --git a/python/testData/testRunner/env/pytest/test1.py b/python/testData/testRunner/env/pytest/test1.py index 1b57c5fd7d9b..9a064ecd9199 100644 --- a/python/testData/testRunner/env/pytest/test1.py +++ b/python/testData/testRunner/env/pytest/test1.py @@ -1,7 +1,7 @@ from time import sleep class TestPyTest: def testOne(self): - sleep(1) # To check duration + sleep(1.5) # To check duration assert 4 == 2*2 def testTwo(self):