diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 92ef5de51cb3..b94649c9a1c1 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -71,6 +71,8 @@ target('default': 'The default target') { // load ApplicationInfo.xml properties ant.xmlproperty(file: appInfoFile(), collapseAttributes: "true") + zipSources(home, paths.artifacts) + layoutAll([buildNumber: "IC-$snapshot", system_selector: "IdeaIC${p("component.version.major")}", tools_jar: true], diff --git a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java index b35cf712a3c6..e6ed3ce7245c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java @@ -397,7 +397,7 @@ public class CompileServerManager implements ApplicationComponent{ // commandLine.add((launcherUsed? "-J" : "") + "-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + CharsetToolkit.getDefaultSystemCharset().name()); //} - private Process launchServer(int port) throws ExecutionException { + private Process launchServer(final int port) throws ExecutionException { // validate tools.jar presence final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); if (systemCompiler == null) { @@ -406,7 +406,8 @@ public class CompileServerManager implements ApplicationComponent{ final Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk(); final GeneralCommandLine cmdLine = new GeneralCommandLine(); - cmdLine.setExePath(((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk)); + final String vmExecutablePath = ((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk); + cmdLine.setExePath(vmExecutablePath); cmdLine.addParameter("-server"); cmdLine.addParameter("-ea"); cmdLine.addParameter("-XX:MaxPermSize=150m"); @@ -416,12 +417,21 @@ public class CompileServerManager implements ApplicationComponent{ cmdLine.addParameter("-Xmx" + Registry.intValue("compiler.server.heap.size") + "m"); // debugging - cmdLine.addParameter("-XX:+HeapDumpOnOutOfMemoryError"); - //cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5008"); - - if (Registry.is("compiler.server.use.memory.temp.cache")) { - cmdLine.addParameter("-D"+Server.USE_MEMORY_TEMP_CACHE_OPTION + "=true"); + final int debugPort = Registry.intValue("compiler.server.debug.port"); + if (debugPort > 0) { + cmdLine.addParameter("-XX:+HeapDumpOnOutOfMemoryError"); + cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort); } + + if (Registry.is("compiler.server.use.memory.temp.cache")) { + cmdLine.addParameter("-D"+ GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION + "=true"); + } + if (Registry.is("compiler.server.use.external.javac.process")) { + cmdLine.addParameter("-D"+ GlobalOptions.USE_EXTERNAL_JAVAC_OPTION + "=true"); + } + cmdLine.addParameter("-D"+ GlobalOptions.HOSTNAME_OPTION + "=" + NetUtils.getLocalHostString()); + cmdLine.addParameter("-D"+ GlobalOptions.VM_EXE_PATH_OPTION + "=" + FileUtil.toSystemIndependentName(vmExecutablePath)); + // javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language final String lang = System.getProperty("user.language"); if (lang != null) { diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java index 1139e1613e59..f2e52e81a203 100644 --- a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java @@ -23,8 +23,10 @@ import com.intellij.codeInspection.reference.RefClass; import com.intellij.codeInspection.reference.RefElement; import com.intellij.codeInspection.reference.RefJavaVisitor; import com.intellij.codeInspection.reference.RefManagerImpl; +import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; @@ -32,10 +34,12 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.containers.BidirectionalMap; import gnu.trove.THashMap; import gnu.trove.THashSet; +import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -47,6 +51,8 @@ import java.util.Map; public class RedundantSuppressInspection extends GlobalInspectionTool{ private BidirectionalMap myQuickFixes = null; private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.RedundantSuppressInspection"); + + public boolean IGNORE_ALL = false; @NotNull public String getGroupDisplayName() { @@ -64,6 +70,17 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{ return "RedundantSuppression"; } + @Override + public JComponent createOptionsPanel() { + return new SingleCheckboxOptionsPanel("Ignore @SuppressWarning(\"ALL\")", this, "IGNORE_ALL"); + } + + @Override + public void writeSettings(Element node) throws WriteExternalException { + if (IGNORE_ALL) { + super.writeSettings(node); + } + } public void runInspection(final AnalysisScope scope, final InspectionManager manager, @@ -123,6 +140,7 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{ String idsString = SuppressManager.getInstance().getSuppressedInspectionIdsIn(owner); if (idsString != null && idsString.length() != 0) { List ids = StringUtil.split(idsString, ","); + if (IGNORE_ALL && ids.contains(SuppressionUtil.ALL)) return; Collection suppressed = suppressedScopes.get(owner); if (suppressed == null) { suppressed = ids; diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java index bbabfc85fc85..5e079580c74a 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ReferenceAdjuster.java @@ -221,7 +221,13 @@ public class ReferenceAdjuster { private static boolean isSafeToShortenReference(final String referenceText, final PsiElement psiReference, final PsiClass refClass) { final PsiManager manager = refClass.getManager(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); - return manager.areElementsEquivalent(refClass, facade.getResolveHelper().resolveReferencedClass(referenceText, psiReference)); + final PsiResolveHelper helper = facade.getResolveHelper(); + if (manager.areElementsEquivalent(refClass, helper.resolveReferencedClass(referenceText, psiReference))) { + PsiElement parent = psiReference.getParent(); + if (parent instanceof PsiJavaCodeReferenceElement && parent.getParent() instanceof PsiNewExpression) return true; + return helper.resolveReferencedVariable(referenceText, psiReference) == null; + } + return false; } @NotNull diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java index 8925fca42e3c..a3672df32892 100644 --- a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java +++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java @@ -116,13 +116,18 @@ public class CoreJavaFileManager extends PackageIndex implements JavaFileManager @Nullable private PsiClass findClassInClasspathEntry(String qName, File file) { - String fileName = qName.replace(".", "/") + ".class"; + // TODO handle inner classes correctly + String fileName = qName.replace(".", "/") + ".java"; VirtualFile classFile = findUnderClasspathEntry(file, fileName); - + if (classFile == null) { + fileName = qName.replace(".", "/") + ".class"; + classFile = findUnderClasspathEntry(file, fileName); + } + if (classFile != null) { PsiFile psiFile = myPsiManager.findFile(classFile); if (!(psiFile instanceof PsiJavaFile)) { - throw new UnsupportedOperationException("no java file for .class"); + throw new UnsupportedOperationException("no java file for " + fileName); } final PsiClass[] classes = ((PsiJavaFile)psiFile).getClasses(); if (classes.length == 1) { diff --git a/java/java-tests/testData/inspection/redundantSuppress/defaultFile/expected.xml b/java/java-tests/testData/inspection/redundantSuppress/defaultFile/expected.xml new file mode 100644 index 000000000000..6fd7f7a2d7d7 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantSuppress/defaultFile/expected.xml @@ -0,0 +1,63 @@ + + + + + X.java + 4 + Redundant suppression + Redundant suppression + + + + + X.java + 42 + Redundant suppression + Redundant suppression + + + + + X.java + 53 + Redundant suppression + Redundant suppression + + + + + + X.java + 19 + Redundant suppression + Redundant suppression + + + + + + X.java + 30 + Redundant suppression + Redundant suppression + + + + + + X.java + 11 + Redundant suppression + Redundant suppression + + + + + X.java + 67 + Redundant suppression + Redundant suppression + + + + \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantSuppress/defaultFile/src/x/X.java b/java/java-tests/testData/inspection/redundantSuppress/defaultFile/src/x/X.java new file mode 100644 index 000000000000..95e1a638850d --- /dev/null +++ b/java/java-tests/testData/inspection/redundantSuppress/defaultFile/src/x/X.java @@ -0,0 +1,69 @@ +package x; + +class S { + public void f() { + //noinspection HardCodedStringLiteral + String s=null; + //noinspection HardCodedStringLiteral + String s2="sssssss"; + } + @SuppressWarnings({"HardCodedStringLiteral"}) + void g() { + String s = null; + } + @SuppressWarnings({"HardCodedStringLiteral"}) + void g2() { + String s = "sssssss"; + } + + void h() { + @SuppressWarnings({"HardCodedStringLiteral"}) + String s = null; + } + void h2() { + @SuppressWarnings({"HardCodedStringLiteral"}) + String s = "sssssss"; + } + + void i() { + @SuppressWarnings({"HardCodedStringLiteral"}) + class ss { + String s = null; + } + } + void i2() { + @SuppressWarnings({"HardCodedStringLiteral"}) + class ss { + String s = "sssssss"; + } + } + + /** @noinspection HardCodedStringLiteral */ + void j() { + String s = null; + } + /** @noinspection HardCodedStringLiteral */ + void j2() { + String s = "sssssss"; + } + + void k() { + class ss { + /** @noinspection HardCodedStringLiteral */ + String s = null; + } + } + void k2() { + class ss { + /** @noinspection HardCodedStringLiteral */ + String s = "sssssss"; + } + } + + @SuppressWarnings({"EmptyMethod"}) + void foo() {} + + @SuppressWarnings({"EmptyMethod"}) + void foo1() {String f;} + +} diff --git a/java/java-tests/testData/inspection/redundantSuppress/suppressAll/expected.xml b/java/java-tests/testData/inspection/redundantSuppress/suppressAll/expected.xml new file mode 100644 index 000000000000..5e933496b9cf --- /dev/null +++ b/java/java-tests/testData/inspection/redundantSuppress/suppressAll/expected.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/java/java-tests/testData/inspection/redundantSuppress/suppressAll/src/x/X.java b/java/java-tests/testData/inspection/redundantSuppress/suppressAll/src/x/X.java new file mode 100644 index 000000000000..7645e60d0360 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantSuppress/suppressAll/src/x/X.java @@ -0,0 +1,8 @@ +package x; + +public class S { + @SuppressWarnings("ALL") + public static void main(String[] args) { + System.out.println(args[0]); + } +} diff --git a/java/java-tests/testData/refactoring/inlineLocal/Qualified.java b/java/java-tests/testData/refactoring/inlineLocal/Qualified.java new file mode 100644 index 000000000000..dc626e01c64f --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineLocal/Qualified.java @@ -0,0 +1,17 @@ +public class A { + int f = 23; + + static class B { + static int f = 42; + } + + int foo() { + int r = B.f; + A B = this; + return r; + } + + public static void main(String[] args) { + System.out.println(new A().foo()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/inlineLocal/Qualified.java.after b/java/java-tests/testData/refactoring/inlineLocal/Qualified.java.after new file mode 100644 index 000000000000..102be05d5e9a --- /dev/null +++ b/java/java-tests/testData/refactoring/inlineLocal/Qualified.java.after @@ -0,0 +1,16 @@ +public class A { + int f = 23; + + static class B { + static int f = 42; + } + + int foo() { + A B = this; + return A.B.f; + } + + public static void main(String[] args) { + System.out.println(new A().foo()); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java new file mode 100644 index 000000000000..148a9a8522b4 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java @@ -0,0 +1,39 @@ +package com.intellij.codeInspection; + +import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper; +import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.codeInspection.ex.InspectionToolRegistrar; +import com.intellij.testFramework.InspectionTestCase; + +public class RedundantSuppressTest extends InspectionTestCase { + private GlobalInspectionToolWrapper myWrapper; + + @Override + protected void setUp() throws Exception { + super.setUp(); + InspectionToolRegistrar.getInstance().ensureInitialized(); + myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection()); + } + + public void testDefaultFile() throws Exception { + InspectionProfileImpl.INIT_INSPECTIONS = true; + doTest(); + InspectionProfileImpl.INIT_INSPECTIONS = false; + } + + public void testSuppressAll() throws Exception { + InspectionProfileImpl.INIT_INSPECTIONS = true; + try { + ((RedundantSuppressInspection)myWrapper.getTool()).IGNORE_ALL = true; + doTest(); + } + finally { + ((RedundantSuppressInspection)myWrapper.getTool()).IGNORE_ALL = false; + InspectionProfileImpl.INIT_INSPECTIONS = false; + } + } + + private void doTest() throws Exception { + doTest("redundantSuppress/" + getTestName(true), myWrapper,"java 1.5",true); + } +} diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java index c0e4cb1784b3..e4bde4df16c0 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java @@ -4,8 +4,6 @@ import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLocalVariable; import com.intellij.psi.PsiReference; @@ -130,6 +128,11 @@ public class InlineLocalTest extends LightCodeInsightTestCase { doTest(true); } + public void testQualified() throws Exception { + doTest(true); + } + + private void doTest(final boolean inlineDef, String conflictMessage) throws Exception { try { doTest(inlineDef); diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java b/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java new file mode 100644 index 000000000000..ee4e99bd02bc --- /dev/null +++ b/jps/jps-builders/src/org/jetbrains/jps/api/GlobalOptions.java @@ -0,0 +1,13 @@ +package org.jetbrains.jps.api; + +/** + * @author Eugene Zhuravlev + * Date: 1/24/12 + */ +public interface GlobalOptions { + + String USE_MEMORY_TEMP_CACHE_OPTION = "use.memory.temp.cache"; + String USE_EXTERNAL_JAVAC_OPTION = "use.external.javac.process"; + String HOSTNAME_OPTION = "localhost.name"; + String VM_EXE_PATH_OPTION = "vm.executable.path"; +} diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index 66446954646c..55382b5c6139 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -18,6 +18,7 @@ import org.jetbrains.jps.Module; import org.jetbrains.jps.ModuleChunk; import org.jetbrains.jps.Project; import org.jetbrains.jps.ProjectPaths; +import org.jetbrains.jps.api.GlobalOptions; import org.jetbrains.jps.api.RequestFuture; import org.jetbrains.jps.incremental.*; import org.jetbrains.jps.incremental.messages.BuildMessage; @@ -36,6 +37,7 @@ import javax.tools.Diagnostic; import javax.tools.JavaFileObject; import java.io.*; import java.net.MalformedURLException; +import java.net.ServerSocket; import java.net.URL; import java.net.URLClassLoader; import java.util.*; @@ -48,9 +50,9 @@ import java.util.concurrent.ExecutorService; */ public class JavaBuilder extends Builder{ public static final String BUILDER_NAME = "java"; - private static final String JAVA_EXTENSION = ".java"; private static final String FORM_EXTENSION = ".form"; + private static final boolean USE_EMBEDDED_JAVAC = System.getProperty(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION) == null; private static final FileFilter JAVA_SOURCES_FILTER = new FileFilter() { public boolean accept(File file) { @@ -222,7 +224,6 @@ public class JavaBuilder extends Builder{ final Collection classpath = paths.getCompilationClasspath(chunk, context.isCompilingTests(), false/*context.isProjectRebuild()*/); final Collection platformCp = paths.getPlatformCompilationClasspath(chunk, context.isCompilingTests(), false/*context.isProjectRebuild()*/); final Map> outs = buildOutputDirectoriesMap(context, chunk); - final List options = getCompilationOptions(context, chunk); // begin compilation round final DiagnosticSink diagnosticSink = new DiagnosticSink(context); @@ -234,7 +235,7 @@ public class JavaBuilder extends Builder{ final Set sourcePath = TEMPORARY_SOURCE_ROOTS_KEY.get(context,Collections.emptySet()); final boolean compiledOk = compileJava( - options, files, classpath, platformCp, sourcePath, outs, context, diagnosticSink, outputSink + files, classpath, platformCp, sourcePath, outs, context, diagnosticSink, outputSink ); final Map chunkSourcePath = ProjectPaths.getSourceRootsWithDependents(chunk, context.isCompilingTests()); @@ -291,12 +292,12 @@ public class JavaBuilder extends Builder{ return exitCode; } - private boolean compileJava(List options, Collection files, Collection classpath, Collection platformCp, Collection sourcePath, Map> outs, CompileContext context, DiagnosticOutputConsumer diagnosticSink, final OutputFileConsumer outputSink) throws Exception { - final boolean useEmbeddedJavac = true; // todo: make configurable + private boolean compileJava(Collection files, Collection classpath, Collection platformCp, Collection sourcePath, Map> outs, CompileContext context, DiagnosticOutputConsumer diagnosticSink, final OutputFileConsumer outputSink) throws Exception { + final List options = getCompilationOptions(context); final ClassProcessingConsumer classesConsumer = new ClassProcessingConsumer(context, outputSink); try { final boolean rc; - if (useEmbeddedJavac) { + if (USE_EMBEDDED_JAVAC) { rc = JavacMain.compile(options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer, context.getCancelStatus()); } else { @@ -326,13 +327,12 @@ public class JavaBuilder extends Builder{ return descriptor.client; } // start server here - final String javaHome = System.getProperty("java.home"); + final String vmExecPath = System.getProperty(GlobalOptions.VM_EXE_PATH_OPTION, System.getProperty("java.home") + "/bin/java"); + final String hostString = System.getProperty(GlobalOptions.HOSTNAME_OPTION, "localhost"); + final int port = findFreePort(); + final int heapSize = getJavacServerHeapSize(context); - final String hostString = "localhost"; // todo: obtain from IDEA - final int port = 9999; // todo: obtain from IDEA - final int heapSize = 512; // todo: make configurable; either obtain from IDEA or calculate - - final BaseOSProcessHandler processHandler = JavacServerBootstrap.launchJavacServer(javaHome + "/bin/java", heapSize, port, Paths.getSystemRoot()); + final BaseOSProcessHandler processHandler = JavacServerBootstrap.launchJavacServer(vmExecPath, heapSize, port, Paths.getSystemRoot()); final JavacServerClient client = new JavacServerClient(); try { client.connect(hostString, port); @@ -345,6 +345,46 @@ public class JavaBuilder extends Builder{ return client; } + private static int findFreePort() { + try { + final ServerSocket serverSocket = new ServerSocket(0); + try { + return serverSocket.getLocalPort(); + } + finally { + //workaround for linux : calling close() immediately after opening socket + //may result that socket is not closed + synchronized(serverSocket) { + try { + serverSocket.wait(1); + } + catch (Throwable ignored) { + } + } + serverSocket.close(); + } + } + catch (IOException e) { + e.printStackTrace(System.err); + return JavacServer.DEFAULT_SERVER_PORT; + } + } + + private static int getJavacServerHeapSize(CompileContext context) { + int heapSize = 512; + final Project project = context.getProject(); + final Map javacOpts = project.getCompilerConfiguration().getJavacOptions(); + final String hSize = javacOpts.get("MAXIMUM_HEAP_SIZE"); + if (hSize != null) { + try { + heapSize = Integer.parseInt(hSize); + } + catch (NumberFormatException ignored) { + } + } + return heapSize; + } + private static ClassLoader createInstrumentationClassLoader(Collection classpath, Collection platformCp, Map chunkSourcePath, OutputFilesSink outputSink) throws MalformedURLException { final List urls = new ArrayList(); @@ -361,7 +401,7 @@ public class JavaBuilder extends Builder{ return new CompiledClassesLoader(outputSink, urls.toArray(new URL[urls.size()])); } - private static List getCompilationOptions(CompileContext context, ModuleChunk chunk) { + private static List getCompilationOptions(CompileContext context) { final List options = new ArrayList(); options.add("-verbose"); diff --git a/jps/jps-builders/src/org/jetbrains/jps/server/Server.java b/jps/jps-builders/src/org/jetbrains/jps/server/Server.java index c1ddd4d58b12..8403017c21ae 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/server/Server.java +++ b/jps/jps-builders/src/org/jetbrains/jps/server/Server.java @@ -10,6 +10,7 @@ import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder; import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender; +import org.jetbrains.jps.api.GlobalOptions; import org.jetbrains.jps.api.JpsRemoteProto; import org.jetbrains.jps.incremental.Paths; @@ -27,7 +28,6 @@ public class Server { private static final int MAX_SIMULTANEOUS_BUILD_SESSIONS = Math.max(2, Runtime.getRuntime().availableProcessors()); public static final String SERVER_SUCCESS_START_MESSAGE = "Compile Server started successfully. Listening on port: "; public static final String SERVER_ERROR_START_MESSAGE = "Error starting Compile Server: "; - public static final String USE_MEMORY_TEMP_CACHE_OPTION = "use.memory.temp.cache"; private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("compile-server"); private final ChannelFactory myChannelFactory; @@ -99,7 +99,7 @@ public class Server { } }); - ServerState.getInstance().setKeepTempCachesInMemory(System.getProperty(USE_MEMORY_TEMP_CACHE_OPTION) != null); + ServerState.getInstance().setKeepTempCachesInMemory(System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null); System.out.println("Server classpath: " + System.getProperty("java.class.path")); System.err.println(SERVER_SUCCESS_START_MESSAGE + port); diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/SourceTreeToPsiMap.java b/platform/core-impl/src/com/intellij/psi/impl/source/SourceTreeToPsiMap.java index 01054a656a17..9ebb20533225 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/SourceTreeToPsiMap.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/SourceTreeToPsiMap.java @@ -27,8 +27,7 @@ public class SourceTreeToPsiMap { @Nullable public static PsiElement treeElementToPsi(@Nullable final ASTNode element) { - if (element == null) return null; - return element.getPsi(); + return element == null ? null : element.getPsi(); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index fd2e12e5f23a..1339a2c9fc76 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -233,27 +233,31 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass private static MultiMap getToolsForElements(List toolWrappers, boolean checkDumbAwareness, List inside, List outside) { - Set languages = new HashSet(); + Set languages = new THashSet(); + Map langIds = new THashMap(); + Set dialects = new THashSet(); for (PsiElement element : inside) { - languages.add(element.getLanguage()); + Language language = element.getLanguage(); + if (languages.add(language)) { + langIds.put(language.getID(), language); + for (Language dialect : language.getDialects()) { + dialects.add(dialect.getID()); + } + } } for (PsiElement element : outside) { - languages.add(element.getLanguage()); - } - Map langIds = new HashMap(); - for (Language language : languages) { - langIds.put(language.getID(), language); - } - Set dialects = new HashSet(); - for (Language language : languages) { - for (Language dialect : language.getDialects()) { - dialects.add(dialect.getID()); + Language language = element.getLanguage(); + if (languages.add(language)) { + langIds.put(language.getID(), language); + for (Language dialect : language.getDialects()) { + dialects.add(dialect.getID()); + } } } MultiMap map = new MultiMap() { @Override protected Collection createCollection() { - return new HashSet(); + return new THashSet(); } @Override @@ -319,11 +323,11 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass } } }; - PsiElementVisitor visitor = createVisitorAndAcceptElements(tool, holder, isOnTheFly, session, elements, - (Set)pair.getValue()); + Set languages = (Set)pair.getValue(); + PsiElementVisitor visitor = createVisitorAndAcceptElements(tool, holder, isOnTheFly, session, elements, languages); synchronized (init) { - init.add(new InspectionContext(tool, holder, visitor, (Set)pair.getValue())); + init.add(new InspectionContext(tool, holder, visitor, languages)); } advanceProgress(1); @@ -477,7 +481,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass } }, myProject.getDisposed(), 200); - private final Set emptyActionRegistered = Collections.synchronizedSet(new HashSet()); + private final Set emptyActionRegistered = Collections.synchronizedSet(new THashSet()); private void addDescriptorIncrementally(@NotNull final ProblemDescriptor descriptor, @NotNull final LocalInspectionTool tool, @@ -777,7 +781,6 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass } private static class InspectionContext { - private InspectionContext(LocalInspectionTool tool, ProblemsHolder holder, PsiElementVisitor visitor, Set languageIds) { this.tool = tool; this.holder = holder; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java index 06dd0747e39b..e36bd7207cd0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java @@ -130,6 +130,8 @@ public class IncrementalSearchHandler { final DocumentListener[] documentListener = new DocumentListener[1]; final CaretListener[] caretListener = new CaretListener[1]; + final Document document = editor.getDocument(); + final LightweightHint hint = new LightweightHint(panel) { public void hide() { PerHintSearchData data = getUserData(SEARCH_DATA_IN_HINT_KEY); @@ -146,7 +148,7 @@ public class IncrementalSearchHandler { editorData.lastSearch = prefix; if (documentListener[0] != null){ - editor.getDocument().removeDocumentListener(documentListener[0]); + document.removeDocumentListener(documentListener[0]); } if (caretListener[0] != null){ @@ -162,7 +164,7 @@ public class IncrementalSearchHandler { hint.hide(); } }; - editor.getDocument().addDocumentListener(documentListener[0]); + document.addDocumentListener(documentListener[0]); caretListener[0] = new CaretListener() { public void caretPositionChanged(CaretEvent e) { diff --git a/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java b/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java index 3cb289656276..b221a829268b 100644 --- a/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java +++ b/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java @@ -77,7 +77,7 @@ public abstract class RunManagerEx extends RunManager { public abstract Collection getSortedConfigurations(); - public abstract void removeConfiguration(RunnerAndConfigurationSettings settings); + public abstract void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings); public abstract void addRunManagerListener(RunManagerListener listener); public abstract void removeRunManagerListener(RunManagerListener listener); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 32cdb8a5835b..f0e6a15f6206 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -311,7 +311,9 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, } @Override - public void removeConfiguration(RunnerAndConfigurationSettings settings) { + public void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings) { + if (settings == null) return; + for (Iterator it = getSortedConfigurations().iterator(); it.hasNext(); ) { final RunnerAndConfigurationSettings configuration = it.next(); if (configuration.equals(settings)) { @@ -728,6 +730,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, if (settings != null) { invalidateConfigurationIcon(settings); settings.setTemporary(false); + fireRunConfigurationChanged(settings); } } @@ -870,11 +873,13 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, } public void shareConfiguration(final RunConfiguration runConfiguration, final boolean shareConfiguration) { + RunnerAndConfigurationSettings settings = getSettings(runConfiguration); + boolean shouldFire = settings != null && isConfigurationShared(settings) != shareConfiguration; + if (shareConfiguration && isTemporary(runConfiguration)) makeStable(runConfiguration); mySharedConfigurations.put(runConfiguration.getUniqueID(), shareConfiguration); - RunnerAndConfigurationSettings settings = getSettings(runConfiguration); - if (settings != null) fireRunConfigurationChanged(settings); + if (shouldFire) fireRunConfigurationChanged(settings); } public final void setBeforeRunTasks(final RunConfiguration runConfiguration, Map, BeforeRunTask> tasks) { diff --git a/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java b/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java index ff8f2b8913e0..de885e7a2b33 100644 --- a/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java +++ b/platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java @@ -69,6 +69,7 @@ public class EditorSearchComponent extends JPanel implements DataProvider, Selec private final Project myProject; private ActionToolbar myActionsToolbar; + public Editor getEditor() { return myEditor; } 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 1bf7e1578eb9..daa29aefff5c 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 @@ -671,7 +671,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl @Override public ActionCallback getReady(@NotNull Object requestor) { - if (myTreeBuilder.isDisposed()) return new ActionCallback.Rejected(); + if (myTreeBuilder == null || myTreeBuilder.isDisposed()) return new ActionCallback.Rejected(); return myTreeBuilder.getUi().getReady(requestor); } } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java index 21cde88973b3..d92469b19c1c 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java @@ -8,6 +8,7 @@ import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.IconLoader; +import com.intellij.util.PlatformUtils; /** * Created by IntelliJ IDEA. @@ -40,6 +41,12 @@ public abstract class ShowModulesAction extends ToggleAction { super.update(e); final Presentation presentation = e.getPresentation(); final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject); - presentation.setVisible(Comparing.strEqual(projectView.getCurrentViewId(), getId())); + presentation.setVisible(hasModules() && Comparing.strEqual(projectView.getCurrentViewId(), getId())); + } + + private static boolean hasModules() { + return PlatformUtils.isIdea() || + PlatformUtils.isCommunity() || + PlatformUtils.isFlexIde(); } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 5b290af55fc4..256452a8a04a 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -227,6 +227,8 @@ public class FileStructurePopup implements Disposable { if (size > max) { max = size; cur = p.node; + } else if (size == max && size == parents.size()) { + cur = p.node; } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java index b11f59dc1b8e..db21ded54762 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java @@ -58,7 +58,9 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModel @Override public boolean process(ChooseByNameContributor contributor) { try { - ContainerUtil.addAll(names, contributor.getNames(myProject, checkBoxState)); + if (!myProject.isDisposed()) { + ContainerUtil.addAll(names, contributor.getNames(myProject, checkBoxState)); + } } catch (ProcessCanceledException ex) { // index corruption detected, ignore diff --git a/platform/lang-impl/src/com/intellij/psi/PsiAnchor.java b/platform/lang-impl/src/com/intellij/psi/PsiAnchor.java index 042dbf6bd1fc..6529269590fd 100644 --- a/platform/lang-impl/src/com/intellij/psi/PsiAnchor.java +++ b/platform/lang-impl/src/com/intellij/psi/PsiAnchor.java @@ -182,7 +182,7 @@ public abstract class PsiAnchor { @Override @Nullable public PsiFile getFile() { - return SelfElementInfo.restoreFileFromVirtual(myVirtualFile, myProject, myLanguage); + return SelfElementInfo.restoreFileFromVirtual(myVirtualFile, myProject, myFileLanguage); } @Override @@ -274,6 +274,7 @@ public abstract class PsiAnchor { } @Override + @Nullable public PsiFile getFile() { return SelfElementInfo.restoreFileFromVirtual(myFile, myProject); } @@ -323,6 +324,7 @@ public abstract class PsiAnchor { } } + @Nullable public static PsiElement restoreFromStubIndex(PsiFileWithStubSupport fileImpl, int index, IStubElementType elementType) { diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java index 3a17904953fa..8dbb23bb4ae4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java @@ -73,7 +73,7 @@ public class ConfigurableExtensionPointUtil { @NotNull private static T findConfigurable(ConfigurableEP[] extensions, Class configurableClass) { for (ConfigurableEP extension : extensions) { - if (extension.implementationClass != null) { + if (extension.providerClass != null || extension.instanceClass != null || extension.implementationClass != null) { final Configurable configurable = extension.createConfigurable(); if (configurableClass.isInstance(configurable)) { return configurableClass.cast(configurable); diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWrapper.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWrapper.java index 0b37d4b23b84..296443cb6e47 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWrapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWrapper.java @@ -43,11 +43,11 @@ public class ProgressWrapper extends ProgressIndicatorBase { @Nullable public static ProgressWrapper wrap(@Nullable ProgressIndicator indicator) { - return indicator == null ? null : new ProgressWrapper(indicator); + return indicator == null || indicator instanceof ProgressWrapper ? (ProgressWrapper)indicator : new ProgressWrapper(indicator); } public static ProgressIndicator unwrap(ProgressIndicator indicator) { return indicator instanceof ProgressWrapper ? - ((ProgressWrapper)indicator).getOriginalProgressIndicator():indicator; + ((ProgressWrapper)indicator).getOriginalProgressIndicator() : indicator; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index 2b4c5217936f..2967be12aeee 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -508,9 +508,10 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements final String[] ids = getToolWindowIds(); // Remove ToolWindowsPane - - ((IdeRootPane)myFrame.getRootPane()).setToolWindowsPane(null); - myWindowManager.releaseFrame(myFrame); + if (myFrame != null) { + ((IdeRootPane)myFrame.getRootPane()).setToolWindowsPane(null); + myWindowManager.releaseFrame(myFrame); + } appendUpdateToolWindowsPaneCmd(commandsList); // Hide all tool windows diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java index 5d1cb37b4220..dd51b8e69b95 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java @@ -25,7 +25,6 @@ import java.awt.image.BufferedImage; class ComboContentLayout extends ContentLayout { - BaseLabel myIdLabel; ContentComboLabel myComboLabel; private BufferedImage myImage; @@ -112,7 +111,6 @@ class ComboContentLayout extends ContentLayout { @Override public void update() { updateIdLabel(myIdLabel); - myIdLabel.setVisible(!"true".equals(myUi.myWindow.getComponent().getClientProperty(ToolWindowContentUi.HIDE_ID_LABEL))); myComboLabel.update(); } @@ -131,10 +129,6 @@ class ComboContentLayout extends ContentLayout { return myUi.myManager.getContentCount() > 1; } - boolean isIdVisible() { - return myIdLabel.isVisible(); - } - @Override public void contentAdded(ContentManagerEvent event) { } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentLayout.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentLayout.java index a25e12360b52..b903e3878fa2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentLayout.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentLayout.java @@ -21,6 +21,7 @@ import com.intellij.ui.awt.RelativeRectangle; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManagerEvent; +import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; @@ -40,6 +41,7 @@ abstract class ContentLayout { static final int TAB_SHIFT = 2; ToolWindowContentUi myUi; + BaseLabel myIdLabel; ContentLayout(ToolWindowContentUi ui) { myUi = ui; @@ -76,6 +78,8 @@ abstract class ContentLayout { label.setBorder(new EmptyBorder(0, 2, 0, 0)); } } + + label.setVisible(shouldShowId()); } protected void fillTabShape(Graphics2D g2d, Shape shape, boolean isSelected, Rectangle bounds) { @@ -106,4 +110,12 @@ abstract class ContentLayout { public abstract String getPreviousContentActionName(); public abstract String getNextContentActionName(); + protected boolean shouldShowId() { + final JComponent component = myUi.myWindow.getComponent(); + return component != null && !"true".equals(component.getClientProperty(ToolWindowContentUi.HIDE_ID_LABEL)); + } + + boolean isIdVisible() { + return myIdLabel.isVisible(); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabContentLayout.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabContentLayout.java index 1a23b457c4ac..ae785f953295 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabContentLayout.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/TabContentLayout.java @@ -50,8 +50,6 @@ class TabContentLayout extends ContentLayout { private Map myCached = new com.intellij.util.containers.HashMap(); - BaseLabel myIdLabel; - private final MoreIcon myMoreIcon = new MoreIcon() { protected Rectangle getIconRec() { return myLastLayout.moreRect; @@ -153,8 +151,10 @@ class TabContentLayout extends ContentLayout { data.eachX = 2; data.eachY = 0; - myIdLabel.setBounds(data.eachX, data.eachY, myIdLabel.getPreferredSize().width, bounds.height); - data.eachX += myIdLabel.getPreferredSize().width; + if (isIdVisible()) { + myIdLabel.setBounds(data.eachX, data.eachY, myIdLabel.getPreferredSize().width, bounds.height); + data.eachX += myIdLabel.getPreferredSize().width; + } int tabsStart = data.eachX; if (manager.getContentCount() == 0) return; @@ -310,7 +310,7 @@ class TabContentLayout extends ContentLayout { } if (image != null) { - g.drawImage(image, r.x, r.y, null); + g.drawImage(image, isIdVisible() ? r.x : r.x - 2, r.y, null); } prevSelected = each.isSelected(); diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java index a3d2b28dc1d6..7f29f725af9f 100644 --- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java +++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java @@ -176,7 +176,7 @@ public abstract class SpeedSearchBase extends SpeedSear final Object element = it.next(); if (isMatchingElement(element, _s)) return element; } - return isMatchingElement(current, _s) ? current : null; + return ( current != null && isMatchingElement(current, _s) ) ? current : null; } @Nullable diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 998e01a5aa92..f27367c763ef 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -125,12 +125,18 @@ compiler.perform.outputs.refresh.on.start.description=Whether to perform initial compiler.max.static.constants.searches=10000 compiler.max.static.constants.searches.description=If the number of changed compile time constants exceeds this value, make will start full-project rebuild -compiler.server.heap.size=600 +compiler.server.heap.size=300 compiler.server.heap.size.description=Heap size value in MB for the compile server process -compiler.server.use.memory.temp.cache=false +compiler.server.use.memory.temp.cache=true compiler.server.use.memory.temp.cache.description=Store temporary data in memory for faster compilation; requires larger server heap size +compiler.server.use.external.javac.process=true +compiler.server.use.external.javac.process.description=Run javac compiler in external process (allows to run compile server with smaller heap size) + +compiler.server.debug.port=-1 +#compiler.server.javac.debug.port=-1 + vcs.show.colored.annotations=true vcs.showConsole=true diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java index 1a4bbac2867d..a018f4dd6000 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilTest.java @@ -282,6 +282,11 @@ public class NameUtilTest extends UsefulTestCase { assertOrderedEquals(new NameUtil.MinusculeMatcher("doge*st", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample), TextRange.from(0, 4), TextRange.from(22, 2)); + sample = "_test"; + assertOrderedEquals(new NameUtil.MinusculeMatcher("_", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample), + TextRange.from(0, 1)); + assertOrderedEquals(new NameUtil.MinusculeMatcher("_t", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample), + TextRange.from(0, 2)); } public void testMatchingDegree() { diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java index a8f9a8366b8d..8de61cf45014 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java @@ -11,6 +11,7 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.impl.PsiAwareFileEditorManagerImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.content.Content; @@ -24,6 +25,7 @@ import java.util.Collection; */ public class AutoTestManager { private final Project myProject; + private final PsiAwareFileEditorManagerImpl myManager; private final Alarm myAutoTestAlarm; private static final int AUTOTEST_DELAY = 2000; @@ -37,8 +39,11 @@ public class AutoTestManager { private final Collection myEnabledDescriptors = new WeakList(); - public AutoTestManager(Project project) { + public AutoTestManager(Project project, FileEditorManager manager) { myProject = project; + myManager = manager instanceof PsiAwareFileEditorManagerImpl ? + (PsiAwareFileEditorManagerImpl)manager : + null; myAutoTestAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, project); myRunTestsRunnable = new Runnable() { public void run() { @@ -73,6 +78,14 @@ public class AutoTestManager { } public void runAutoTests() { + if (myManager != null) { + for (FileEditor editor : myManager.getAllEditors()) { + final VirtualFile file = myManager.getFile(editor); + if (file != null && myManager.isProblem(file)) { + return; + } + } + } for (Content content : myEnabledDescriptors) { runAutoTest(content); } diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index 8fc2349f3a23..a47df50805c8 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -131,7 +131,8 @@ public class FileUtil { if (parent == null) { return false; } - if (parent.equals(ancestor)) { + // Do not user file.equals as it incorrectly works on MacOS + if (pathsEqual(parent.getPath(), ancestor.getPath())) { return true; } parent = getParentFile(parent); diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index b765c62fae48..767ed7679ee7 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -570,6 +570,7 @@ public class StringUtil { @Nullable String additionalChars, boolean escapeSlash, @NotNull @NonNls StringBuilder buffer) { + char prev = 0; for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); switch (ch) { @@ -597,7 +598,7 @@ public class StringUtil { if (escapeSlash && ch == '\\') { buffer.append("\\\\"); } - else if (additionalChars != null && additionalChars.indexOf(ch) > -1) { + else if (additionalChars != null && additionalChars.indexOf(ch) > -1 && (escapeSlash || prev != '\\')) { buffer.append("\\").append(ch); } else if (Character.isISOControl(ch)) { @@ -613,6 +614,7 @@ public class StringUtil { buffer.append(ch); } } + prev = ch; } return buffer; } diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java index c20e0b586745..ba75281f1063 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java +++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java @@ -486,17 +486,21 @@ public class NameUtil { while (i > 0) { FList ranges = matchName(name, patternIndex + i, nextStart); if (ranges != null) { - TextRange head = ranges.getHead(); - if (head != null && head.getStartOffset() == nameIndex + i) { - return ranges.getTail().prepend(new TextRange(nameIndex, head.getEndOffset())); - } - return ranges.prepend(TextRange.from(nameIndex, i)); + return prependRange(ranges, nameIndex, i); } i--; } return null; } + private static FList prependRange(FList ranges, int from, int length) { + TextRange head = ranges.getHead(); + if (head != null && head.getStartOffset() == from + length) { + return ranges.getTail().prepend(new TextRange(from, head.getEndOffset())); + } + return ranges.prepend(TextRange.from(from, length)); + } + private boolean isWordSeparator(char c) { return mySeparatorFunction.fun(c); } @@ -513,7 +517,12 @@ public class NameUtil { return null; } - return matchName(name, patternIndex + 1, nextStart); + final FList ranges = matchName(name, patternIndex + 1, nextStart); + if (ranges != null) { + return prependRange(ranges, nameIndex, 1); + } + + return null; } return matchName(name, patternIndex, nextStart); diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index 01916d3e999c..0fe8eaa0f314 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -217,6 +217,17 @@ public class ContainerUtil { return true; } + public static boolean process(@NotNull List list, @NotNull Processor processor) { + //noinspection ForLoopReplaceableByForEach + for (int i = 0, size = list.size(); i < size; i++) { + T t = list.get(i); + if (!processor.process(t)) { + return false; + } + } + return true; + } + public static boolean process(@NotNull T[] iterable, @NotNull Processor processor) { for (final T t : iterable) { if (!processor.process(t)) { diff --git a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java index 84d5b70d8d47..3179e96c3768 100644 --- a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java +++ b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java @@ -111,4 +111,10 @@ public class StringUtilTest extends TestCase { public void testTitleCase() { assertEquals("Couldn't Connect to Debugger", StringUtil.wordsToBeginFromUpperCase("Couldn't connect to debugger")); } + + public void testEscapeStringCharacters() { + assertEquals("\\\"\\n", StringUtil.escapeStringCharacters(3, "\\\"\n", "\"", false, new StringBuilder()).toString()); + assertEquals("\\\"\\n", StringUtil.escapeStringCharacters(2, "\"\n", "\"", false, new StringBuilder()).toString()); + assertEquals("\\\\\\\"\\n", StringUtil.escapeStringCharacters(3, "\\\"\n", "\"", true, new StringBuilder()).toString()); + } } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java index 3cfdfc066ad9..dbf307d0134e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java @@ -223,6 +223,9 @@ public abstract class VcsVFSListener implements Disposable { getSingleFileDeletePromptTemplate(), myRemoveOption); } + protected void beforeContentsChange(VirtualFile file) { + } + private void addFileToMove(final VirtualFile file, final String newParentPath, final String newName) { if (file.isDirectory() && !isDirectoryVersioningSupported()) { VirtualFile[] children = file.getChildren(); @@ -372,6 +375,14 @@ public abstract class VcsVFSListener implements Disposable { } } } + + @Override + public void beforeContentsChange(VirtualFileEvent event) { + if (!isEventIgnored(event, false)) { + assert !event.getFile().isDirectory(); + VcsVFSListener.this.beforeContentsChange(event.getFile()); + } + } } private class MyCommandAdapter extends CommandAdapter { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java index a1e02e799576..253e56e2d505 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java @@ -449,12 +449,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec } }); - for (VcsDirtyScope scope : scopes) { - if (scope.getVcs().needsLastUnchangedContent()) { - updateLastUnchangedContents(scope); - } - } - myChangesViewManager.scheduleRefresh(); } catch (DisposedException e) { @@ -628,55 +622,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec } } - private void updateLastUnchangedContents(VcsDirtyScope scope) { - scope.iterateExistingInsideScope(new Processor() { - @Override - public boolean process(VirtualFile file) { - if (!file.isDirectory() && getStatus(file) == FileStatus.NOT_CHANGED) { - LastUnchangedContentTracker.updateLastUnchangedContent(file); - } - - return true; - } - }); - } - - public void collectUnchangedFileContents(@Nullable ProgressIndicator indicator) { - final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); - for (VcsDirectoryMapping mapping : vcsManager.getDirectoryMappings()) { - final AbstractVcs vcs = vcsManager.findVcsByName(mapping.getVcs()); - final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(mapping.getDirectory()); - if (vcs != null && file != null && vcs.needsLastUnchangedContent()) { - if (indicator != null) { - indicator.setText(mapping.getDirectory()); - } - - final VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(vcs, myProject); - scope.addDirtyDirRecursively(new FilePathImpl(file)); - updateLastUnchangedContents(scope); - } - } - - for (LocalChangeList list : getChangeListsCopy()) { - for (Change change : list.getChanges()) { - final VirtualFile file = change.getVirtualFile(); - final ContentRevision before = change.getBeforeRevision(); - if (file != null && before != null && !LastUnchangedContentTracker.hasSavedContent(file)) { - try { - final String content = before.getContent(); - if (content != null) { - LastUnchangedContentTracker.forceSavedContent(file, content); - } - } - catch (VcsException e) { - LOG.info(e); - } - } - - } - } - } - private void checkIfDisposed() { if (myUpdater.isStopped()) throw new DisposedException(); } diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java index 49ff51dea24c..10f7da0ad4f4 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java +++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java @@ -15,7 +15,10 @@ */ package com.intellij.junit4; -import com.intellij.rt.execution.junit.*; +import com.intellij.rt.execution.junit.IDEAJUnitListener; +import com.intellij.rt.execution.junit.IdeaTestRunner; +import com.intellij.rt.execution.junit.TimeSender; +import com.intellij.rt.execution.junit.TreeSender; import com.intellij.rt.execution.junit.segments.OutputObjectRegistry; import com.intellij.rt.execution.junit.segments.SegmentedOutputStream; import org.junit.internal.requests.ClassRequest; @@ -25,7 +28,9 @@ import org.junit.runner.manipulation.Filter; import org.junit.runner.notification.RunListener; import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; /** @noinspection UnusedDeclaration*/ public class JUnit4IdeaTestRunner implements IdeaTestRunner { @@ -93,17 +98,20 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner { field.setAccessible(true); final Filter filter = (Filter)field.get(request); final String filterDescription = filter.describe(); - if (filterDescription != null && (filterDescription.startsWith("Failed tests") || filterDescription.startsWith("Ignored"))) { + if (filterDescription != null) { + boolean isMethodFilter = filterDescription.startsWith("Method"); + if (isMethodFilter && canCompress(description)) return (Description)description.getChildren().get(0); try { final Description failedTestsDescription = Description.createSuiteDescription(filterDescription, null); - for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext();) { - final Description childDescription = (Description)iterator.next(); - if (filter.shouldRun(childDescription)) { - failedTestsDescription.addChild(childDescription); + if (filterDescription.startsWith("Tests") || filterDescription.startsWith("Ignored")) { + for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) { + final Description childDescription = (Description)iterator.next(); + if (filter.shouldRun(childDescription)) { + failedTestsDescription.addChild(childDescription); + } } - } - description = failedTestsDescription; - if (!failedTestsDescription.isTest() && failedTestsDescription.testCount() == 1 && filterDescription.startsWith("Method")) { + description = failedTestsDescription; + } else if (isMethodFilter && canCompress(failedTestsDescription)) { description = (Description)failedTestsDescription.getChildren().get(0); } } @@ -114,6 +122,10 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner { return description; } + private static boolean canCompress(Description description) { + return !description.isTest() && description.testCount() == 1; + } + private static Description getSuiteMethodDescription(Request request, Description description) throws NoSuchFieldException, IllegalAccessException { final Field field = ClassRequest.class.getDeclaredField("fTestClass"); field.setAccessible(true); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java index a8f1db45a43e..16be043e6cf9 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java @@ -6,13 +6,13 @@ import com.intellij.find.impl.FindInProjectUtil; import com.intellij.find.replaceInProject.ReplaceInProjectManager; import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -40,7 +40,7 @@ import org.jetbrains.idea.maven.dom.MavenDomUtil; import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel; import org.jetbrains.idea.maven.dom.model.MavenDomProperties; -import java.util.Set; +import java.util.*; public class IntroducePropertyAction extends BaseRefactoringAction { private static String PREFIX = "${"; @@ -126,7 +126,7 @@ public class IntroducePropertyAction extends BaseRefactoringAction { final MavenDomProjectModel model = MavenDomUtil.getMavenDomModel(file, MavenDomProjectModel.class); final String selectedString = editor.getDocument().getText(range); - Set ranges = getPropertiesTextRanges(stringValue); + List ranges = getPropertiesTextRanges(stringValue); int offsetInElement = range.getStartOffset() - selectedElement.getTextOffset(); if (model == null || @@ -251,78 +251,88 @@ public class IntroducePropertyAction extends BaseRefactoringAction { Set usages = new HashSet(); public void generate(final Processor processor) { + AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); - ApplicationManager.getApplication().runReadAction(new Runnable() { - public void run() { - collectUsages(myModel); - for (MavenDomProjectModel model : MavenDomProjectProcessorUtils.getChildrenProjects(myModel)) { - collectUsages(model); - } - - for (UsageInfo2UsageAdapter adapter : UsageInfo2UsageAdapter.convert(usages.toArray(new UsageInfo[usages.size()]))) { - processor.process(adapter); - } + try { + collectUsages(myModel); + for (MavenDomProjectModel model : MavenDomProjectProcessorUtils.getChildrenProjects(myModel)) { + collectUsages(model); } - private void collectUsages(@NotNull MavenDomProjectModel model) { - if (model.isValid()) { - final XmlElement root = model.getXmlElement(); - if (root != null) { - root.acceptChildren(new XmlElementVisitor() { + for (UsageInfo usage : usages) { + processor.process(UsageInfo2UsageAdapter.CONVERTER.fun(usage)); + } + } + finally { + accessToken.finish(); + } + } - @Override - public void visitXmlText(XmlText text) { - XmlTag xmlTag = PsiTreeUtil.getParentOfType(text, XmlTag.class); - if (xmlTag != null && !xmlTag.getName().equals(myPropertyName)) { - usages.addAll(getUsages(text)); - } - } + private void collectUsages(@NotNull MavenDomProjectModel model) { + if (model.isValid()) { + final XmlElement root = model.getXmlElement(); + if (root != null) { + root.acceptChildren(new XmlElementVisitor() { - @Override - public void visitXmlAttributeValue(XmlAttributeValue value) { - XmlTag xmlTag = PsiTreeUtil.getParentOfType(value, XmlTag.class); - if (xmlTag != null && !xmlTag.equals(root)) { - usages.addAll(getUsages(value)); - } - } - - @Override - public void visitXmlElement(XmlElement element) { - element.acceptChildren(this); - } - }); + @Override + public void visitXmlText(XmlText text) { + XmlTag xmlTag = PsiTreeUtil.getParentOfType(text, XmlTag.class); + if (xmlTag != null && !xmlTag.getName().equals(myPropertyName)) { + usages.addAll(getUsages(text)); + } } - } + + @Override + public void visitXmlAttributeValue(XmlAttributeValue value) { + XmlTag xmlTag = PsiTreeUtil.getParentOfType(value, XmlTag.class); + if (xmlTag != null && !xmlTag.equals(root)) { + usages.addAll(getUsages(value)); + } + } + + @Override + public void visitXmlElement(XmlElement element) { + element.acceptChildren(this); + } + }); } - }); + } + } + + @NotNull + private Set getUsages(@NotNull XmlElement xmlElement) { + String s = xmlElement.getText(); + if (StringUtil.isEmptyOrSpaces(s)) return Collections.emptySet(); + + int start = s.indexOf(mySelectedString); + if (start == -1) return Collections.emptySet(); + + Set usages = new HashSet(); + + List ranges = getPropertiesTextRanges(s); + TextRange elementTextRange = xmlElement.getTextRange(); + PsiFile containingFile = xmlElement.getContainingFile(); + + do { + int end = start + mySelectedString.length(); + boolean isInsideProperty = isInsideTextRanges(ranges, start, end); + if (!isInsideProperty) { + usages + .add(new UsageInfo(containingFile, elementTextRange.getStartOffset() + start, elementTextRange.getStartOffset() + end)); + } + start = s.indexOf(mySelectedString, end); + } + while (start != -1); + + return usages; } }; } - - @NotNull - private Set getUsages(@NotNull XmlElement xmlElement) { - String s = xmlElement.getText(); - Set usages = new HashSet(); - if (!StringUtil.isEmptyOrSpaces(s)) { - Set ranges = getPropertiesTextRanges(s); - - int start = s.indexOf(mySelectedString); - while (start >= 0) { - int end = start + mySelectedString.length(); - boolean isInsideProperty = isInsideTextRanges(ranges, start, end); - if (!isInsideProperty) { - usages.add(new UsageInfo(xmlElement, start, end)); - } - start = s.indexOf(mySelectedString, end); - } - } - return usages; - } } } - private static Set getPropertiesTextRanges(String s) { - Set ranges = new HashSet(); + private static List getPropertiesTextRanges(String s) { + List ranges = new ArrayList(); int startOffset = s.indexOf(PREFIX); while (startOffset >= 0) { int endOffset = s.indexOf(SUFFIX, startOffset); @@ -343,15 +353,13 @@ public class IntroducePropertyAction extends BaseRefactoringAction { return ranges; } - private static boolean isInsideTextRanges(@NotNull Set ranges, int start, int end) { - boolean isInsideProperty = false; + private static boolean isInsideTextRanges(@NotNull Collection ranges, int start, int end) { for (TextRange range : ranges) { if ((start >= range.getStartOffset() && (end <= range.getEndOffset() || start <= range.getEndOffset())) || (end <= range.getEndOffset() && (end > range.getStartOffset()))) { - isInsideProperty = true; - break; + return true; } } - return isInsideProperty; + return false; } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/IncreaseIndentAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/IncreaseIndentAction.java index 0953098904f8..e4de3b8e9a7d 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/IncreaseIndentAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/IncreaseIndentAction.java @@ -31,16 +31,15 @@ import java.util.List; * @author yole */ public class IncreaseIndentAction extends AbstractGuiEditorAction { - private final IndentProperty myIndentProperty = new IndentProperty(); - public IncreaseIndentAction() { super(true); } protected void actionPerformed(final GuiEditor editor, final List selection, final AnActionEvent e) { + IndentProperty indentProperty = IndentProperty.getInstance(editor.getProject()); for(RadComponent c: selection) { - int indent = myIndentProperty.getValue(c).intValue(); - myIndentProperty.setValueEx(c, adjustIndent(indent)); + int indent = indentProperty.getValue(c).intValue(); + indentProperty.setValueEx(c, adjustIndent(indent)); } } diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java b/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java index f3a4b07bd5b7..fb3329487988 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java @@ -172,6 +172,7 @@ class XmlMover extends LineMover { if (offset + 1 < document.getTextLength()) { final int line = document.getLineNumber(offset + 1); final LineRange toMove2 = info.toMove2; + if (toMove2 == null) return; info.toMove2 = new LineRange(toMove2.startLine, Math.min(Math.max(line, toMove2.endLine), document.getLineCount() - 1)); } }