From 52fa0f73f6859ead4f8539ce811a5637b7eae932 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 17 Aug 2015 13:48:18 +0200 Subject: [PATCH 01/11] [java] diagnostic for EA-71784 --- .../src/com/intellij/lang/java/lexer/JavaLexer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java b/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java index d2f30c332e03..653a304b469b 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/lexer/JavaLexer.java @@ -182,7 +182,7 @@ public class JavaLexer extends LexerBase { } catch (IOException e) { /* impossible */ } catch (Error e) { - throw new IllegalArgumentException("Non-parsable text `" + myBuffer + "`"); + throw new IllegalArgumentException("Non-parsable text `" + myBuffer + "`", e); } } From f862a762a60e35ec08bad3f079ce98e227dcd1e1 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 17 Aug 2015 15:33:25 +0200 Subject: [PATCH 02/11] max header size 16 KB --- platform/platform-impl/src/org/jetbrains/io/NettyUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java index 30eba6497f9b..258fca6bdceb 100644 --- a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java +++ b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java @@ -235,7 +235,8 @@ public final class NettyUtil { public static void addHttpServerCodec(@NotNull ChannelPipeline pipeline) { pipeline.addLast("httpRequestEncoder", new HttpResponseEncoder()); - pipeline.addLast("httpRequestDecoder", new HttpRequestDecoder(16 * 1024, 8192, 8192)); + // https://jetbrains.zendesk.com/agent/tickets/68315 + pipeline.addLast("httpRequestDecoder", new HttpRequestDecoder(16 * 1024, 16 * 1024, 8192)); pipeline.addLast("httpObjectAggregator", new HttpObjectAggregator(MAX_CONTENT_LENGTH)); // could be added earlier if HTTPS if (pipeline.get(ChunkedWriteHandler.class) == null) { From 4fabd30a42b60d036df26554bad95bcf0bb7cfe6 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 17 Aug 2015 15:42:52 +0200 Subject: [PATCH 03/11] attempt to fix incremental compilation --- .../testSrc/SchemeManagerTest.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/configuration-store-impl/testSrc/SchemeManagerTest.kt b/platform/configuration-store-impl/testSrc/SchemeManagerTest.kt index f3d4a8898a93..f7d7de7e462a 100644 --- a/platform/configuration-store-impl/testSrc/SchemeManagerTest.kt +++ b/platform/configuration-store-impl/testSrc/SchemeManagerTest.kt @@ -27,11 +27,12 @@ import com.intellij.testFramework.ProjectRule import com.intellij.testFramework.TemporaryDirectory import com.intellij.util.SmartList import com.intellij.util.lang.CompoundRuntimeException +import com.intellij.util.xmlb.SerializationFilter +import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters import com.intellij.util.xmlb.XmlSerializer import com.intellij.util.xmlb.annotations.Attribute import com.intellij.util.xmlb.annotations.Tag import com.intellij.util.xmlb.annotations.Transient -import com.intellij.util.xmlb.serialize import com.intellij.util.xmlb.toByteArray import gnu.trove.THashMap import org.assertj.core.api.Assertions.assertThat @@ -146,7 +147,7 @@ class SchemeManagerTest { } fun TestScheme.save(file: File) { - FileUtil.writeToFile(file, serialize().toByteArray()) + FileUtil.writeToFile(file, _serialize().toByteArray()) } public Test fun `different extensions`() { @@ -389,11 +390,13 @@ public data class TestScheme(@Attribute private var name: String = "", @Attribut public open class TestSchemesProcessor : BaseSchemeProcessor() { override fun readScheme(element: Element) = XmlSerializer.deserialize(element, javaClass()) - override fun writeScheme(scheme: TestScheme) = scheme.serialize() + override fun writeScheme(scheme: TestScheme) = scheme._serialize() } fun SchemeManagerImpl<*, *>.save() { val errors = SmartList() save(errors) CompoundRuntimeException.doThrow(errors) -} \ No newline at end of file +} + +public fun T._serialize(filter: SerializationFilter? = SkipDefaultValuesSerializationFilters()): Element = XmlSerializer.serialize(this, filter) \ No newline at end of file From 7472a0446fb3738d1cf1c22b6c0586c4f72ffef9 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 17 Aug 2015 15:55:54 +0200 Subject: [PATCH 04/11] [java] diagnostic for EA-70891 --- .../refactoring/util/CanonicalTypes.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java b/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java index 131750f17179..bb303ccdea64 100644 --- a/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java +++ b/java/java-psi-impl/src/com/intellij/refactoring/util/CanonicalTypes.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Map; @@ -51,7 +52,7 @@ public class CanonicalTypes { private abstract static class AnnotatedType extends Type { protected final PsiAnnotation[] myAnnotations; - protected AnnotatedType(PsiAnnotation[] annotations) { + protected AnnotatedType(@NotNull PsiAnnotation[] annotations) { myAnnotations = annotations; } } @@ -59,7 +60,7 @@ public class CanonicalTypes { private static class Primitive extends AnnotatedType { private final PsiPrimitiveType myType; - private Primitive(PsiPrimitiveType type) { + private Primitive(@NotNull PsiPrimitiveType type) { super(type.getAnnotations()); myType = type; } @@ -79,7 +80,7 @@ public class CanonicalTypes { private static class Array extends AnnotatedType { protected final Type myComponentType; - private Array(PsiType original, Type componentType) { + private Array(@NotNull PsiType original, @NotNull Type componentType) { super(original.getAnnotations()); myComponentType = componentType; } @@ -107,7 +108,7 @@ public class CanonicalTypes { } private static class Ellipsis extends Array { - private Ellipsis(PsiType original, Type componentType) { + private Ellipsis(@NotNull PsiType original, @NotNull Type componentType) { super(original, componentType); } @@ -127,7 +128,7 @@ public class CanonicalTypes { private final boolean myIsExtending; private final Type myBound; - private WildcardType(PsiType original, boolean isExtending, Type bound) { + private WildcardType(@NotNull PsiType original, boolean isExtending, @Nullable Type bound) { super(original.getAnnotations()); myIsExtending = isExtending; myBound = bound; @@ -176,7 +177,7 @@ public class CanonicalTypes { private final String myPresentableText; private final String myCanonicalText; - private UnresolvedType(PsiType original) { + private UnresolvedType(@NotNull PsiType original) { myPresentableText = original.getPresentableText(); myCanonicalText = original.getCanonicalText(true); } @@ -203,7 +204,7 @@ public class CanonicalTypes { private final String myClassQName; private final Map mySubstitutor; - private ClassType(PsiType original, String classQName, Map substitutor) { + private ClassType(@NotNull PsiType original, @NotNull String classQName, @NotNull Map substitutor) { super(original.getAnnotations()); myPresentableText = original.getPresentableText(); myClassQName = classQName; From 89f7272fa935bc186192349dd95b62fcaf42ece6 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Mon, 17 Aug 2015 14:29:11 +0300 Subject: [PATCH 05/11] enable escape entities --- xml/impl/src/com/intellij/xml/actions/EscapeEntitiesAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/impl/src/com/intellij/xml/actions/EscapeEntitiesAction.java b/xml/impl/src/com/intellij/xml/actions/EscapeEntitiesAction.java index 3c3cb45c7321..22234e1b1cdd 100644 --- a/xml/impl/src/com/intellij/xml/actions/EscapeEntitiesAction.java +++ b/xml/impl/src/com/intellij/xml/actions/EscapeEntitiesAction.java @@ -110,7 +110,7 @@ public class EscapeEntitiesAction extends BaseCodeInsightAction implements CodeI @Override protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { - return ApplicationManager.getApplication().isInternal() && file instanceof XmlFile; + return file instanceof XmlFile; } @NotNull From 3d2373ae285749bb98cf0360487b0d77e6f5b2b6 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Mon, 17 Aug 2015 17:12:24 +0300 Subject: [PATCH 06/11] IDEA-97324 Maven support cannot handle skinny wars for EAR deployments --- ...enManifestGenerationBuildTaskProvider.java | 94 +++++++++++++++++++ .../MavenModuleResourceConfiguration.java | 5 + .../maven/importing/ManifestImporter.java | 2 +- .../idea/maven/importing/MavenImporter.java | 6 ++ .../maven/importing/MavenModuleImporter.java | 25 +++++ .../maven/importing/MavenProjectImporter.java | 8 +- ...esourceCompilerConfigurationGenerator.java | 9 ++ .../idea/maven/utils/ManifestBuilder.java | 39 +++++--- 8 files changed, 173 insertions(+), 15 deletions(-) diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java index e5aa3003c36e..f65ee59c26c2 100644 --- a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java +++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java @@ -16,26 +16,43 @@ package org.jetbrains.jps.maven.compiler; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Base64; +import com.intellij.util.Function; +import com.intellij.util.Processor; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.builders.BuildRootDescriptor; import org.jetbrains.jps.builders.artifacts.ArtifactBuildTaskProvider; import org.jetbrains.jps.builders.storage.BuildDataPaths; +import org.jetbrains.jps.cmdline.ProjectDescriptor; import org.jetbrains.jps.incremental.BuildTask; import org.jetbrains.jps.incremental.CompileContext; import org.jetbrains.jps.incremental.ProjectBuildException; +import org.jetbrains.jps.incremental.artifacts.impl.JpsArtifactUtil; import org.jetbrains.jps.maven.model.JpsMavenExtensionService; import org.jetbrains.jps.maven.model.impl.MavenModuleResourceConfiguration; import org.jetbrains.jps.maven.model.impl.MavenProjectConfiguration; import org.jetbrains.jps.model.artifact.JpsArtifact; import org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement; +import org.jetbrains.jps.model.artifact.elements.JpsFileCopyPackagingElement; +import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement; +import java.io.ByteArrayInputStream; import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.jar.Attributes; import java.util.jar.JarFile; +import java.util.jar.Manifest; /** * @author nik @@ -72,6 +89,7 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP try { File output = new File(myArtifact.getOutputPath(), JarFile.MANIFEST_NAME); FileUtil.writeToFile(output, Base64.decode(moduleResourceConfiguration.manifest)); + handleSkinnyWars(context, projectConfiguration, moduleResourceConfiguration); } // do not fail the whole 'Make' if there is an invalid manifest cached (e.g. non encoded string generated by previous IDEA version) catch (Exception e) { @@ -80,6 +98,82 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP } } + private void handleSkinnyWars(final CompileContext context, + final MavenProjectConfiguration projectConfiguration, + MavenModuleResourceConfiguration moduleResourceConfiguration) { + if (!"ear".equals(moduleResourceConfiguration.modelMap.get("packaging"))) return; + if (!Boolean.parseBoolean(moduleResourceConfiguration.modelMap.get("build.plugin.maven-ear-plugin.skinnyWars"))) return; + + final String earClasspath = moduleResourceConfiguration.classpath; + if (earClasspath == null) return; + + final Map earClasspathMap = ContainerUtil.map2Map( + StringUtil.split(earClasspath, " "), new Function>() { + @Override + public Pair fun(String s) { + final int idx = s.lastIndexOf("/"); + return Pair.create(s.substring(idx == -1 ? 0 : idx + 1), s); + } + }); + + JpsArtifactUtil.processPackagingElements(myArtifact.getRootElement(), new Processor() { + @Override + public boolean process(JpsPackagingElement element) { + if (!(element instanceof JpsFileCopyPackagingElement)) return true; + + final String filePath = ((JpsFileCopyPackagingElement)element).getFilePath(); + final File skinnyManifest = new File(filePath); + if (!"SKINNY_MANIFEST.MF".equals(skinnyManifest.getName())) return true; + + final String skinnyWarModuleName = skinnyManifest.getParentFile().getParentFile().getName(); + final MavenModuleResourceConfiguration warConfiguration = projectConfiguration.moduleConfigurations.get(skinnyWarModuleName); + if (warConfiguration == null || warConfiguration.classpath == null) return true; + + try { + final byte[] warManifestData = Base64.decode(warConfiguration.manifest); + Manifest warManifest = new Manifest(new ByteArrayInputStream(warManifestData)); + + List skinnyWarClasspath = ContainerUtil.newArrayList(); + for (String entry : StringUtil.split(warConfiguration.classpath, " ")) { + final int idx = entry.lastIndexOf("/"); + final String entryName = entry.substring(idx == -1 ? 0 : idx + 1); + final String earEntryPath = earClasspathMap.get(entryName); + skinnyWarClasspath.add(earEntryPath == null ? entry : earEntryPath); + } + + final Attributes warManifestMainAttributes = warManifest.getMainAttributes(); + warManifestMainAttributes.putValue("Class-Path", StringUtil.join(skinnyWarClasspath, " ")); + + FileUtil.createParentDirs(skinnyManifest); + FileOutputStream outputStream = new FileOutputStream(skinnyManifest); + try { + warManifest.write(outputStream); + + final ProjectDescriptor projectDescriptor = context.getProjectDescriptor(); + final Collection descriptors = + projectDescriptor.getBuildRootIndex().findAllParentDescriptors(skinnyManifest, context); + for (BuildRootDescriptor descriptor : descriptors) { + try { + projectDescriptor.fsState.markDirty(context, skinnyManifest, descriptor, projectDescriptor.timestamps.getStorage()); + } + catch (IOException e) { + LOG.debug(e); + } + } + } + finally { + StreamUtil.closeStream(outputStream); + } + } + catch (IOException e) { + LOG.debug(e); + } + + return true; + } + }); + } + @Nullable private static String getModuleName(@NotNull String artifactName) { return StringUtil.substringBefore(artifactName, ":"); diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java index a6bf8b1e1e91..20cc5ed17b44 100644 --- a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java +++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java @@ -45,6 +45,10 @@ public class MavenModuleResourceConfiguration { @Tag("manifest") public String manifest; + @Nullable + @Tag("classpath") + public String classpath; + @NotNull @Tag("delimiters-pattern") public String delimitersPattern; @@ -110,6 +114,7 @@ public class MavenModuleResourceConfiguration { result = 31 * result + (parentId != null ? parentId.hashCode() : 0); result = 31 * result + directory.hashCode(); result = 31 * result + (manifest != null ? manifest.hashCode() : 0); + result = 31 * result + (classpath != null ? classpath.hashCode() : 0); result = 31 * result + delimitersPattern.hashCode(); result = 31 * result + modelMap.hashCode(); result = 31 * result + properties.hashCode(); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ManifestImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ManifestImporter.java index 65fb06cebfce..210f8013ee7e 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ManifestImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/ManifestImporter.java @@ -50,7 +50,7 @@ public abstract class ManifestImporter { String classpathPrefix = getClasspathPrefix(manifestConfiguration); for (MavenArtifact mavenArtifact : mavenProject.getDependencies()) { final DependencyScope scope = MavenModuleImporter.selectScope(mavenArtifact.getScope()); - if (scope.isForProductionRuntime()) { + if (scope.isForProductionCompile() || scope.isForProductionRuntime()) { if (classpath.length() > 0) { classpath.append(" "); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenImporter.java index f2e55d189ad1..7732bd15d3a7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenImporter.java @@ -149,6 +149,12 @@ public abstract class MavenImporter { Map mavenProjectToModuleName, List postTasks); + public void postProcess(Module module, + MavenProject mavenProject, + MavenProjectChanges changes, + MavenModifiableModelsProvider modifiableModelsProvider) { + } + public boolean processChangedModulesOnly() { return true; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java index cb7396dfb85b..954706999ba3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java @@ -159,6 +159,31 @@ public class MavenModuleImporter { }); } + public void postConfigFacets() { + MavenUtil.invokeAndWaitWriteAction(myModule.getProject(), new Runnable() { + public void run() { + if (myModule.isDisposed()) return; + + final ModuleType moduleType = ModuleType.get(myModule); + + for (final MavenImporter importer : getSuitableImporters()) { + final MavenProjectChanges changes; + if (myMavenProjectChanges == null) { + if (importer.processChangedModulesOnly()) continue; + changes = MavenProjectChanges.NONE; + } + else { + changes = myMavenProjectChanges; + } + + if (importer.getModuleType() == moduleType) { + importer.postProcess(myModule, myMavenProject, changes, myModifiableModelsProvider); + } + } + } + }); + } + private List getSuitableImporters() { return myMavenProject.getSuitableImporters(); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java index 9ee85b83fcc5..a7b5a600516d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java @@ -431,7 +431,7 @@ public class MavenProjectImporter { javacOptions.ADDITIONAL_OPTIONS_STRING = options; } - private void importModules(final List postTasks) { + private void importModules(final List tasks) { Map projectsWithChanges = myProjectsToImportWithChanges; Set projectsWithNewlyCreatedModules = new THashSet(); @@ -471,7 +471,11 @@ public class MavenProjectImporter { } for (MavenModuleImporter importer : importers) { - importer.configFacets(postTasks); + importer.configFacets(tasks); + } + + for (MavenModuleImporter importer : importers) { + importer.postConfigFacets(); } setMavenizedModules(modulesToMavenize, true); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java index 274ee5a16193..5c4ad86a84c9 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java @@ -129,6 +129,8 @@ public class MavenResourceCompilerConfigurationGenerator { } } + addEarModelMapEntries(mavenProject, resourceConfig.modelMap); + Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin"); resourceConfig.outputDirectory = getResourcesPluginGoalOutputDirectory(mavenProject, pluginConfiguration, "resources"); @@ -190,6 +192,12 @@ public class MavenResourceCompilerConfigurationGenerator { }); } + private static void addEarModelMapEntries(@NotNull MavenProject mavenProject, @NotNull Map modelMap) { + Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-ear-plugin"); + final String skinnyWars = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "skinnyWars", "false"); + modelMap.put("build.plugin.maven-ear-plugin.skinnyWars", skinnyWars); + } + @Nullable private static String getResourcesPluginGoalOutputDirectory(@NotNull MavenProject mavenProject, @Nullable Element pluginConfiguration, @@ -234,6 +242,7 @@ public class MavenResourceCompilerConfigurationGenerator { finally { StreamUtil.closeStream(outputStream); } + resourceConfig.classpath = ManifestBuilder.getClasspath(mavenProject); } catch (ManifestBuilder.ManifestBuilderException e) { LOG.warn("Unable to generate artifact manifest", e); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java index dbedc4a88675..bf6bf48abe1b 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java @@ -67,18 +67,7 @@ public class ManifestBuilder { @NotNull public java.util.jar.Manifest build() throws ManifestBuilderException { try { - Element mavenPackagingPluginConfiguration = null; - final String packaging = myMavenProject.getPackaging(); - if (StringUtil.isEmpty(packaging)) { - mavenPackagingPluginConfiguration = myMavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-jar-plugin"); - } - else { - final String pluginArtifactId = PACKAGING_PLUGINS.get(StringUtil.toLowerCase(packaging)); - if (pluginArtifactId != null) { - mavenPackagingPluginConfiguration = myMavenProject.getPluginConfiguration("org.apache.maven.plugins", pluginArtifactId); - } - } - + Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(myMavenProject); final Element mavenArchiveConfiguration = mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null; @@ -110,6 +99,16 @@ public class ManifestBuilder { } } + @NotNull + public static String getClasspath(@NotNull MavenProject mavenProject) { + Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(mavenProject); + final Element mavenArchiveConfiguration = + mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null; + final Element manifestConfiguration = mavenArchiveConfiguration != null ? mavenArchiveConfiguration.getChild("manifest") : null; + final ManifestImporter manifestImporter = ManifestImporter.getManifestImporter(mavenProject.getPackaging()); + return manifestImporter.getClasspath(mavenProject, manifestConfiguration); + } + @NotNull public static String getClasspathPrefix(@Nullable Element manifestConfiguration) { String classpathPrefix = MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "classpathPrefix", "").replaceAll("\\\\", "/"); @@ -119,6 +118,22 @@ public class ManifestBuilder { return classpathPrefix; } + @Nullable + private static Element getMavenPackagingPluginConfiguration(@NotNull MavenProject mavenProject) { + Element mavenPackagingPluginConfiguration = null; + final String packaging = mavenProject.getPackaging(); + if (StringUtil.isEmpty(packaging)) { + mavenPackagingPluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-jar-plugin"); + } + else { + final String pluginArtifactId = PACKAGING_PLUGINS.get(StringUtil.toLowerCase(packaging)); + if (pluginArtifactId != null) { + mavenPackagingPluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", pluginArtifactId); + } + } + return mavenPackagingPluginConfiguration; + } + private static Map getManifestEntries(Element manifestEntries) { boolean hasManifestEntries = manifestEntries != null && manifestEntries.getContentSize() > 0; From f4672e27777c82b7e751c8154b3218d68b1ef805 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Mon, 17 Aug 2015 17:30:20 +0300 Subject: [PATCH 07/11] OC-11982 Navigate from Objective-C to Swift derived methods and classes (review 2) --- .../com/intellij/codeInsight/navigation/GotoTargetHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java index 562b6ad544a8..f2069874326f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/GotoTargetHandler.java @@ -242,7 +242,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler { }; } - protected static PsiElementListCellRenderer createRenderer(GotoData gotoData, PsiElement eachTarget) { + public static PsiElementListCellRenderer createRenderer(GotoData gotoData, PsiElement eachTarget) { PsiElementListCellRenderer renderer = null; for (GotoTargetRendererProvider eachProvider : Extensions.getExtensions(GotoTargetRendererProvider.EP_NAME)) { renderer = eachProvider.getRenderer(eachTarget, gotoData); From b00e5ea35e03484a2c8cd82677fa8050d7fd2e76 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 17 Aug 2015 16:59:29 +0200 Subject: [PATCH 08/11] To avoid memory leak from AWT implementation, unregister action with custom shortcut attached to root pane (IDEA-143990) --- .../src/com/intellij/find/impl/FindDialog.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java index 1b55e7771da8..4fb51e73df83 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java @@ -24,6 +24,7 @@ import com.intellij.find.FindSettings; import com.intellij.find.actions.ShowUsagesAction; import com.intellij.ide.util.scopeChooser.ScopeChooserCombo; import com.intellij.lang.Language; +import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -647,7 +648,7 @@ public class FindDialog extends DialogWrapper { pane.insertTab("Options", null, optionsPanel, null, 0); pane.insertTab(PREVIEW_TITLE, null, myPreviewSplitter, null, RESULTS_PREVIEW_TAB_INDEX); myContent = pane; - AnAction anAction = new AnAction() { + final AnAction anAction = new AnAction() { @Override public void actionPerformed(AnActionEvent e) { int selectedIndex = myContent.getSelectedIndex(); @@ -656,7 +657,16 @@ public class FindDialog extends DialogWrapper { }; final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_SWITCHER).getShortcutSet(); - anAction.registerCustomShortcutSet(shortcutSet, getRootPane()); + final JRootPane rootPane = getRootPane(); + + anAction.registerCustomShortcutSet(shortcutSet, rootPane); + Disposer.register(myDisposable, new Disposable() { + @Override + public void dispose() { + anAction.unregisterCustomShortcutSet(rootPane); + } + }); + if (myPreviewResultsTabWasSelected) myContent.setSelectedIndex(RESULTS_PREVIEW_TAB_INDEX); return pane.getComponent(); From 1a9e331018ae9a919cf8a2bcc9aa45e8863d3b33 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 17 Aug 2015 17:34:38 +0200 Subject: [PATCH 09/11] IDEA-143911 (quick fix produces uncompilable code (StringBuffer can be replaced with String)) --- .../StringBufferReplaceableByStringInspection.java | 2 +- .../style/replace_with_string/Linebreaks.after.java | 9 +++++++++ .../igfixes/style/replace_with_string/Linebreaks.java | 10 ++++++++++ .../style/StringBufferReplaceableByStringFixTest.java | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.after.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.java diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java index db90214433e8..589d8d8b50d1 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java @@ -209,7 +209,7 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection { } if (element instanceof PsiWhiteSpace) { - if (element.getText().contains("\n")) { + if (element.getText().contains("\n") && result.length() > 0) { result.append('\n'); // keep line break structure } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.after.java new file mode 100644 index 000000000000..748f16c6b43d --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.after.java @@ -0,0 +1,9 @@ +class Linebreaks { + + void m(String code) { + String controlDigit = String.valueOf(code.charAt(5)) + + code.charAt(7) + + code.charAt(9) + + code.charAt(11); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.java new file mode 100644 index 000000000000..29bc796680e8 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Linebreaks.java @@ -0,0 +1,10 @@ +class Linebreaks { + + void m(String code) { + String controlDigit = new StringBuilder() + .append(code.charAt(5)) + .append(code.charAt(7)) + .append(code.charAt(9)) + .append(code.charAt(11)).toString(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableByStringFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableByStringFixTest.java index bf5ffba39ae1..7ce51e5e5860 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableByStringFixTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableByStringFixTest.java @@ -35,4 +35,5 @@ public class StringBufferReplaceableByStringFixTest extends IGQuickFixesTestCase public void testMethodCallOnString() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } public void testComplex1() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } public void testComplex2() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } + public void testLinebreaks() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); } } From cc772f3242295e5fbfe308adb42ab7896dae5122 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 17 Aug 2015 18:55:40 +0300 Subject: [PATCH 10/11] test history fixed --- .../testframework/sm/runner/ui/SMTestRunnerResultsForm.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java index 0ab67c1325d5..671255c19b78 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java @@ -41,6 +41,7 @@ import com.intellij.openapi.progress.util.ColorProgressBar; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pass; +import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; @@ -808,6 +809,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel new SimpleDateFormat(HISTORY_DATE_FORMAT).format(new Date()); myOutputFile = new File(AbstractImportTestsAction.getTestHistoryRoot(myProject), configurationNameIncludedDate + ".xml"); + FileUtilRt.createParentDirs(myOutputFile); handler.setResult(new StreamResult(new FileWriter(myOutputFile))); final SMTestProxy.SMRootTestProxy root = myRoot; final RunConfiguration configuration = myConfiguration; From 1e0891dac5ffe45de476e7ad29e27df730f0f42f Mon Sep 17 00:00:00 2001 From: Pavel Fatin Date: Mon, 17 Aug 2015 18:43:37 +0200 Subject: [PATCH 11/11] Zero-latency typing: skip undo / redo and PSI synchronization changes --- .../com/intellij/openapi/editor/impl/DocumentImpl.java | 7 +++++++ .../com/intellij/openapi/editor/impl/EditorImpl.java | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index a92586c8e110..ea5974deb2fb 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -624,6 +624,13 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { myGuardsSuppressed = true; } + // This data is used during the immediate editor painting to detect whether PSI synchronization is in progress. + // PsiToDocumentSynchronizer.doCommitTransaction should probably perform bulk document updates. + // TODO Remove this getter later + public boolean isGuardsSuppressed() { + return myGuardsSuppressed; + } + @Override public void unSuppressGuardedExceptions() { myGuardsSuppressed = false; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index fe17f8680acf..a327c8c10af6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -37,6 +37,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.UndoConfirmationPolicy; +import com.intellij.openapi.command.undo.UndoManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.*; @@ -2174,8 +2175,13 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi print(g, newText, point, ascent, font, color); } - private static boolean canPaintImmediately(@NotNull DocumentEvent e) { - return !contains(e.getOldFragment(), '\n') && + private boolean canPaintImmediately(@NotNull DocumentEvent e) { + UndoManager undoManager = UndoManager.getInstance(myProject); + return !undoManager.isUndoInProgress() && // Undo / Redo actions might start multiple write actions and make multiple document changes. + !undoManager.isRedoInProgress() && // Can we optimize the subsystem to start only one write action and do a single update? + myDocument instanceof DocumentImpl && + !((DocumentImpl)myDocument).isGuardsSuppressed() && // Heuristics. Can PsiToDocumentSynchronizer perform bulk document updates? + !contains(e.getOldFragment(), '\n') && !contains(e.getNewFragment(), '\n') && !(e.getNewLength() == 1 && DOCUMENT_CHARS_TO_SKIP.contains(e.getNewFragment().charAt(0))); }