diff --git a/java/java-tests/testSrc/com/intellij/java/openapi/projectRoots/JdkUtilTest.kt b/java/java-tests/testSrc/com/intellij/java/openapi/projectRoots/JdkUtilTest.kt index 324be6a6fa35..c6084107627e 100644 --- a/java/java-tests/testSrc/com/intellij/java/openapi/projectRoots/JdkUtilTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/openapi/projectRoots/JdkUtilTest.kt @@ -110,7 +110,11 @@ class JdkUtilTest : BareTestFixtureTestCase() { setModuleMode() parameters.setUseDynamicVMOptions(true) parameters.setUseDynamicParameters(true) + parameters.programParametersList.clearAll() + parameters.programParametersList.addAll("#1", "\"2\"", "line\n-", "C:\\", "D:\\work", "E:\\work space") doTest("#arg_file#") + val args = filesToDelete?.find { it.name.contains("idea_arg_file") }?.readLines()?.dropWhile { !it.contains("hello.Main") } + assertThat(args).containsExactly("hello/hello.Main", "\"#1\"", "\"\\\"2\\\"\"", "\"line\\n-\"", "\"C:\\\\\"", "D:\\work", "\"E:\\\\work space\"") } private fun doTest(vararg expected: String) { diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/AddNullArgument.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/AddNullArgument.java index 1349b7180a0d..e5165efc9ae9 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/AddNullArgument.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/AddNullArgument.java @@ -30,10 +30,10 @@ class AddNullArgument extends FilePsiMutation { @Override protected void performMutation() { - PsiTreeUtil.findChildrenOfType(myFile, PsiMethodCallExpression.class).stream() + PsiTreeUtil.findChildrenOfType(getFile(), PsiMethodCallExpression.class).stream() .filter(PsiElement::isValid) .filter(call -> call.getArgumentList().getExpressions().length > 1) .forEach(call -> call.getArgumentList().add( - JavaPsiFacade.getElementFactory(myFile.getProject()).createExpressionFromText("null", call))); + JavaPsiFacade.getElementFactory(getFile().getProject()).createExpressionFromText("null", call))); } } diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteForeachInitializers.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteForeachInitializers.java index 527715483294..ffc8a9635729 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteForeachInitializers.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteForeachInitializers.java @@ -30,7 +30,7 @@ class DeleteForeachInitializers extends FilePsiMutation { @Override protected void performMutation() { - PsiTreeUtil.findChildrenOfType(myFile, PsiForStatement.class).stream() + PsiTreeUtil.findChildrenOfType(getFile(), PsiForStatement.class).stream() .limit(20) .map(stmt -> stmt.getInitialization()) .filter(Objects::nonNull) diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteSecondArgument.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteSecondArgument.java index d123ff8a30d4..3eb1dc072a6f 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteSecondArgument.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/DeleteSecondArgument.java @@ -28,7 +28,7 @@ class DeleteSecondArgument extends FilePsiMutation { @Override protected void performMutation() { - PsiTreeUtil.findChildrenOfType(myFile, PsiCallExpression.class) + PsiTreeUtil.findChildrenOfType(getFile(), PsiCallExpression.class) .stream() .filter(PsiElement::isValid) .map(PsiCall::getArgumentList) diff --git a/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeAllMethodsVoid.java b/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeAllMethodsVoid.java index 96b8e194803c..20c6080744ff 100644 --- a/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeAllMethodsVoid.java +++ b/java/java-tests/testSrc/com/intellij/java/propertyBased/MakeAllMethodsVoid.java @@ -30,8 +30,9 @@ class MakeAllMethodsVoid extends FilePsiMutation { @Override protected void performMutation() { - PsiTreeUtil.findChildrenOfType(myFile, PsiMethod.class).stream() + PsiTreeUtil.findChildrenOfType(getFile(), PsiMethod.class).stream() .filter(method -> method.getReturnTypeElement() != null) - .forEach(method -> method.getReturnTypeElement().replace(JavaPsiFacade.getElementFactory(myFile.getProject()).createTypeElement(PsiType.VOID))); + .forEach(method -> method.getReturnTypeElement().replace(JavaPsiFacade.getElementFactory( + getFile().getProject()).createTypeElement(PsiType.VOID))); } } diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy index 9bbf900decb9..c89e13d88c70 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy @@ -93,7 +93,7 @@ class LinuxDistributionBuilder extends OsSpecificDistributionBuilder { } buildContext.ant.copy(todir: "${unixDistPath}/bin") { - fileset(dir: "$buildContext.paths.communityHome/bin/scripts/unix") + fileset(dir: "$buildContext.paths.communityHome/platform/build-scripts/resources/linux/scripts") filterset(begintoken: "@@", endtoken: "@@") { filter(token: "product_full", value: fullName) @@ -133,7 +133,7 @@ class LinuxDistributionBuilder extends OsSpecificDistributionBuilder { private void generateReadme(String unixDistPath) { String fullName = buildContext.applicationInfo.productName - BuildUtils.copyAndPatchFile("$buildContext.paths.communityHome/build/Install-Linux-tar.txt", "$unixDistPath/Install-Linux-tar.txt", + BuildUtils.copyAndPatchFile("$buildContext.paths.communityHome/platform/build-scripts/resources/linux/Install-Linux-tar.txt", "$unixDistPath/Install-Linux-tar.txt", ["product_full" : fullName, "product" : buildContext.productProperties.baseFileName, "system_selector": buildContext.systemSelector], "@@") @@ -207,7 +207,7 @@ class LinuxDistributionBuilder extends OsSpecificDistributionBuilder { filter(token: "NAME", value: productName) filter(token: "ICON", value: "/bin/${buildContext.productProperties.baseFileName}.png") filter(token: "SCRIPT", value: "/bin/${buildContext.productProperties.baseFileName}.sh") - filter(token: "WM_CLASS", value: "jetbrains-${buildContext.applicationInfo.shortProductName.toLowerCase()}${ce ? "-ce" : ""}") + filter(token: "WM_CLASS", value: "jetbrains-${buildContext.applicationInfo.shortProductName.toLowerCase()}${ce ? "-ce" : ""}") // AppUIUtil#getFrameClass } } diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy index bd00ee0721d9..05c854b469c4 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy @@ -124,10 +124,12 @@ class MacDistributionBuilder extends OsSpecificDistributionBuilder { } buildContext.ant.copy(todir: target) { - fileset(dir: "$buildContext.paths.communityHome/build/conf/mac/Contents") + fileset(dir: "$buildContext.paths.communityHome/platform/build-scripts/resources/mac/Contents") } String executable = buildContext.productProperties.baseFileName + buildContext.ant.move(file: "$target/MacOS/executable", tofile: "$target/MacOS/$executable") + buildContext.ant.copy(file: icnsPath, todir: "$target/Resources") String helpId = macCustomizer.helpId if (helpId != null) { @@ -233,10 +235,6 @@ class MacDistributionBuilder extends OsSpecificDistributionBuilder { replacefilter(token: "@@bundled_help_attributes@@", value: bundledHelpAttributes) } - if (executable != "idea") { - buildContext.ant.move(file: "$target/MacOS/idea", tofile: "$target/MacOS/$executable") - } - buildContext.ant.replace(dir: "$target/bin", includes: "inspect.sh,format.sh") { replacefilter(token: "@@product_full@@", value: fullName) replacefilter(token: "@@script_name@@", value: executable) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy index df85abd7b929..2ffadcd45900 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy @@ -129,7 +129,7 @@ class WindowsDistributionBuilder extends OsSpecificDistributionBuilder { def batName = "${buildContext.productProperties.baseFileName}.bat" buildContext.ant.copy(todir: "$winDistPath/bin") { - fileset(dir: "$buildContext.paths.communityHome/bin/scripts/win") + fileset(dir: "$buildContext.paths.communityHome/platform/build-scripts/resources/win/scripts") filterset(begintoken: "@@", endtoken: "@@") { filter(token: "product_full", value: fullName) diff --git a/build/Install-Linux-tar.txt b/platform/build-scripts/resources/linux/Install-Linux-tar.txt similarity index 100% rename from build/Install-Linux-tar.txt rename to platform/build-scripts/resources/linux/Install-Linux-tar.txt diff --git a/bin/scripts/unix/format.sh b/platform/build-scripts/resources/linux/scripts/format.sh similarity index 100% rename from bin/scripts/unix/format.sh rename to platform/build-scripts/resources/linux/scripts/format.sh diff --git a/bin/scripts/unix/idea.sh b/platform/build-scripts/resources/linux/scripts/idea.sh similarity index 100% rename from bin/scripts/unix/idea.sh rename to platform/build-scripts/resources/linux/scripts/idea.sh diff --git a/bin/scripts/unix/inspect.sh b/platform/build-scripts/resources/linux/scripts/inspect.sh similarity index 100% rename from bin/scripts/unix/inspect.sh rename to platform/build-scripts/resources/linux/scripts/inspect.sh diff --git a/build/conf/mac/Contents/Info.plist b/platform/build-scripts/resources/mac/Contents/Info.plist similarity index 100% rename from build/conf/mac/Contents/Info.plist rename to platform/build-scripts/resources/mac/Contents/Info.plist diff --git a/build/conf/mac/Contents/MacOS/idea b/platform/build-scripts/resources/mac/Contents/MacOS/executable similarity index 100% rename from build/conf/mac/Contents/MacOS/idea rename to platform/build-scripts/resources/mac/Contents/MacOS/executable diff --git a/bin/scripts/win/append.bat b/platform/build-scripts/resources/win/scripts/append.bat similarity index 100% rename from bin/scripts/win/append.bat rename to platform/build-scripts/resources/win/scripts/append.bat diff --git a/bin/scripts/win/format.bat b/platform/build-scripts/resources/win/scripts/format.bat similarity index 100% rename from bin/scripts/win/format.bat rename to platform/build-scripts/resources/win/scripts/format.bat diff --git a/bin/scripts/win/idea.bat b/platform/build-scripts/resources/win/scripts/idea.bat similarity index 100% rename from bin/scripts/win/idea.bat rename to platform/build-scripts/resources/win/scripts/idea.bat diff --git a/bin/scripts/win/inspect.bat b/platform/build-scripts/resources/win/scripts/inspect.bat similarity index 100% rename from bin/scripts/win/inspect.bat rename to platform/build-scripts/resources/win/scripts/inspect.bat diff --git a/platform/core-api/src/com/intellij/util/PlatformUtils.java b/platform/core-api/src/com/intellij/util/PlatformUtils.java index 19d9e0805508..d00859dc9ef7 100644 --- a/platform/core-api/src/com/intellij/util/PlatformUtils.java +++ b/platform/core-api/src/com/intellij/util/PlatformUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -20,7 +20,6 @@ import com.intellij.openapi.application.ApplicationInfo; /** * @author Konstantin Bulenkov */ -@SuppressWarnings({"deprecation", "UnusedDeclaration"}) public class PlatformUtils { public static final String PLATFORM_PREFIX_KEY = "idea.platform.prefix"; @@ -123,4 +122,4 @@ public class PlatformUtils { private static boolean is(String idePrefix) { return idePrefix.equals(getPlatformPrefix()); } -} +} \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java index 087ef55f6c58..dd48ba2888a9 100644 --- a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java +++ b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java @@ -130,7 +130,13 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements @Override public void checkCanceled() { - CoreProgressManager.runCheckCanceledHooks(this); + throwIfCanceled(); + if (CoreProgressManager.runCheckCanceledHooks(this)) { + throwIfCanceled(); + } + } + + private void throwIfCanceled() { if (isCanceled() && isCancelable()) { Throwable trace = getCancellationTrace(); throw trace instanceof ProcessCanceledException ? (ProcessCanceledException)trace : new ProcessCanceledException(trace); diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java index 69071e11d306..bda73232969c 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java @@ -81,7 +81,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen private boolean myPerformBackgroundCommit = true; private volatile boolean myIsCommitInProgress; - private static final ThreadLocal ourIsFullReparseInProgress = new ThreadLocal<>(); + private static volatile boolean ourIsFullReparseInProgress; private final PsiToDocumentSynchronizer mySynchronizer; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); @@ -486,7 +486,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen } public static boolean isFullReparseInProgress() { - return Boolean.TRUE.equals(ourIsFullReparseInProgress.get()); + return ourIsFullReparseInProgress; } @Override @@ -1030,12 +1030,14 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen return mySynchronizer; } + @SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") public void reparseFileFromText(PsiFileImpl file) { - if (myIsCommitInProgress) throw new IllegalStateException("Re-entrant commit is not allowed"); + ApplicationManager.getApplication().assertIsDispatchThread(); + if (isCommitInProgress()) throw new IllegalStateException("Re-entrant commit is not allowed"); FileElement node = file.calcTreeElement(); CharSequence text = node.getChars(); - ourIsFullReparseInProgress.set(true); + ourIsFullReparseInProgress = true; try { WriteAction.run(() -> { ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator(); @@ -1046,7 +1048,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen }); } finally { - ourIsFullReparseInProgress.remove(); + ourIsFullReparseInProgress = false; } } diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java b/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java index cdcc89a37a47..ad7a491ee3e3 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/codeStyle/CodeEditUtil.java @@ -39,8 +39,6 @@ public class CodeEditUtil { private static final ThreadLocal ALLOW_NODES_REFORMATTING = ThreadLocal.withInitial(() -> Boolean.TRUE); private static final ThreadLocal> NODE_REFORMAT_STRATEGY = new ThreadLocal<>(); - public static final Key OUTER_OK = new Key<>("OUTER_OK"); - private CodeEditUtil() { } public static void addChild(ASTNode parent, ASTNode child, ASTNode anchorBefore) { diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java index 1c2049468ee6..00f6e1cfc8df 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java @@ -178,8 +178,7 @@ public class JdkUtil { setArgFileParams(commandLine, javaParameters, vmParameters, dynamicVMOptions, dynamicParameters); dynamicMainClass = dynamicParameters; } - else if (!explicitClassPath(vmParameters) && javaParameters.getJarPath() == null - && (commandLineWrapper = getCommandLineWrapperClass()) != null) { + else if (!explicitClassPath(vmParameters) && javaParameters.getJarPath() == null && (commandLineWrapper = getCommandLineWrapperClass()) != null) { if (canUseClasspathJar(javaParameters)) { setClasspathJarParams(commandLine, javaParameters, vmParameters, commandLineWrapper, dynamicVMOptions, dynamicParameters); } @@ -229,7 +228,8 @@ public class JdkUtil { try (PrintWriter writer = new PrintWriter(argFile)) { if (dynamicVMOptions) { for (String param : vmParameters.getList()) { - writer.println(param); + writer.print(quoteArg(param)); + writer.print('\n'); } } else { @@ -238,22 +238,26 @@ public class JdkUtil { PathsList classPath = javaParameters.getClassPath(); if (!classPath.isEmpty() && !explicitClassPath(vmParameters)) { - writer.println("-classpath"); - writer.println(classPath.getPathsString()); + writer.print("-classpath\n"); + writer.print(quoteArg(classPath.getPathsString())); + writer.print('\n'); } PathsList modulePath = javaParameters.getModulePath(); if (!modulePath.isEmpty() && !explicitModulePath(vmParameters)) { - writer.println("-p"); - writer.println(modulePath.getPathsString()); + writer.print("-p\n"); + writer.print(quoteArg(modulePath.getPathsString())); + writer.print('\n'); } if (dynamicParameters) { for (String parameter : getMainClassParams(javaParameters)) { - writer.println(parameter); + writer.print(quoteArg(parameter)); + writer.print('\n'); } for (String parameter : javaParameters.getProgramParametersList().getList()) { - writer.println(parameter); + writer.print(quoteArg(parameter)); + writer.print('\n'); } } } @@ -269,6 +273,32 @@ public class JdkUtil { } } + /* https://docs.oracle.com/javase/9/tools/java.htm, "java Command-Line Argument Files" */ + private static String quoteArg(String arg) { + if (StringUtil.containsAnyChar(arg, " \"\n\r\t\f") || arg.endsWith("\\") || arg.startsWith("#")) { + StringBuilder sb = new StringBuilder(arg.length() * 2); + sb.append('"'); + + for (int i = 0; i < arg.length(); i++) { + char c = arg.charAt(i); + switch (c) { + case '\n': sb.append("\\n"); break; + case '\r': sb.append("\\r"); break; + case '\t': sb.append("\\t"); break; + case '\f': sb.append("\\f"); break; + case '\"': sb.append("\\\""); break; + case '\\': sb.append("\\\\"); break; + default: sb.append(c); + } + } + + sb.append('"'); + return sb.toString(); + } + + return arg; + } + private static void setCommandLineWrapperParams(GeneralCommandLine commandLine, SimpleJavaParameters javaParameters, ParametersList vmParameters, diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java b/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java index 171cc5164936..2a8bc7c97370 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java @@ -245,7 +245,7 @@ public class SimpleEditorPreview implements PreviewPanel { private boolean isOffsetVisible(final int startOffset) { return myEditor .getScrollingModel() - .getVisibleArea() + .getVisibleAreaOnScrollingFinished() .contains(myEditor.logicalPositionToXY(myEditor.offsetToLogicalPosition(startOffset))); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java index 8a1ee21cb46b..c5e30e45b343 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java @@ -111,15 +111,24 @@ public class BraceHighlightingHandler { return; } final int offset = editor.getCaretModel().getOffset(); - final Project project = editor.getProject(); + + // any request to the UI component need to be done from EDT + final ModalityState modalityState = ModalityState.stateForComponent(editor.getComponent()); + final DumbAwareRunnable removeEditorFromProcessed = () -> PROCESSED_EDITORS.remove(editor); + ApplicationManager.getApplication().executeOnPooledThread(() -> { if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() -> { - final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project); - if (!isValidFile(psiFile)) return; + if (!isValidEditor(editor)) { + ApplicationManager.getApplication().invokeLater(removeEditorFromProcessed); + return; + } + @SuppressWarnings("ConstantConditions") // the `project` is valid after the `isValidEditor` call + @NotNull final Project project = editor.getProject(); + final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project); final PsiFile injected; try { - if (psiFile instanceof PsiBinaryFile || !isValidEditor(editor) || !isValidFile(psiFile)) { + if (psiFile instanceof PsiBinaryFile || !isValidFile(psiFile)) { injected = null; } else { @@ -128,7 +137,7 @@ public class BraceHighlightingHandler { } catch (RuntimeException e) { // Reset processing flag in case of unexpected exception. - ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> PROCESSED_EDITORS.remove(editor)); + ApplicationManager.getApplication().invokeLater(removeEditorFromProcessed); throw e; } ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> { @@ -140,15 +149,15 @@ public class BraceHighlightingHandler { } } finally { - PROCESSED_EDITORS.remove(editor); + removeEditorFromProcessed.run(); } - }, ModalityState.stateForComponent(editor.getComponent())); + }, modalityState); })) { // write action is queued in AWT. restart after it's finished ApplicationManager.getApplication().invokeLater(() -> { - PROCESSED_EDITORS.remove(editor); + removeEditorFromProcessed.run(); lookForInjectedAndMatchBracesInOtherThread(editor, alarm, processor); - }, ModalityState.stateForComponent(editor.getComponent())); + }, modalityState); } }); } diff --git a/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt b/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt index 83d75c6b584c..df9178a692e7 100644 --- a/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt +++ b/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt @@ -83,10 +83,8 @@ fun guessProjectForContentFile(file: VirtualFile, fileType: FileType = FileTypeM val list = ProjectManager.getInstance().openProjects.filter { !it.isDefault && it.isInitialized && !it.isDisposed && ProjectRootManager.getInstance(it).fileIndex.isInContent(file) } - - if (list.isEmpty()) return null - - return list.firstOrNull { WindowManager.getInstance().getFrame(it)?.isActive ?: false } ?: list[0] + + return list.firstOrNull { WindowManager.getInstance().getFrame(it)?.isActive ?: false } ?: list.firstOrNull() } fun isProjectOrWorkspaceFile(file: VirtualFile): Boolean = ProjectCoreUtil.isProjectOrWorkspaceFile(file) diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java index d6f116895dc7..db494df74d9b 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java @@ -273,6 +273,11 @@ public class LinkLabel extends JLabel { return textR.contains(pt); } + //for GUI tests + public Point getTextRectangleCenter() { + return new Point(textR.x + textR.width / 2, textR.y + textR.height / 2); + } + private void enableUnderline() { UIUtil.setCursor(this, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); myUnderline = true; diff --git a/platform/platform-impl/src/com/intellij/ide/actions/DebugLogConfigureAction.kt b/platform/platform-impl/src/com/intellij/ide/actions/DebugLogConfigureAction.kt index 5040be57bacf..b8e6efacdce0 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/DebugLogConfigureAction.kt +++ b/platform/platform-impl/src/com/intellij/ide/actions/DebugLogConfigureAction.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,6 @@ private class DebugLogConfigureDialog(project: Project, categories: List myFile; public FilePsiMutation(PsiFile file) { - myFile = file; + myFile = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(file); } @Override @@ -37,10 +39,14 @@ public abstract class FilePsiMutation implements MadTestingAction { @Override public void performAction() { - PsiDocumentManager.getInstance(myFile.getProject()).commitDocument(myFile.getViewProvider().getDocument()); + PsiDocumentManager.getInstance(myFile.getProject()).commitDocument(getFile().getViewProvider().getDocument()); WriteCommandAction.runWriteCommandAction(myFile.getProject(), this::performMutation); - PsiTestUtil.checkPsiStructureWithCommit(myFile, PsiTestUtil::checkStubsMatchText); + PsiTestUtil.checkPsiStructureWithCommit(getFile(), PsiTestUtil::checkStubsMatchText); } protected abstract void performMutation(); + + public PsiFile getFile() { + return myFile.getElement(); + } } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ActionLinkFixture.java b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ActionLinkFixture.java index 662c045f3137..cc8088529194 100755 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ActionLinkFixture.java +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/ActionLinkFixture.java @@ -20,7 +20,10 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.util.Ref; import com.intellij.ui.components.labels.ActionLink; import org.fest.swing.core.GenericTypeMatcher; +import org.fest.swing.core.MouseButton; +import org.fest.swing.core.MouseClickInfo; import org.fest.swing.core.Robot; +import org.fest.swing.driver.JComponentDriver; import org.fest.swing.exception.ComponentLookupException; import org.fest.swing.timing.Condition; import org.fest.swing.timing.Timeout; @@ -35,6 +38,7 @@ import static org.fest.swing.timing.Pause.pause; public class ActionLinkFixture extends JComponentFixture { + @NotNull public static ActionLinkFixture findByActionId(@NotNull final String actionId, @NotNull final Robot robot, @@ -111,5 +115,61 @@ public class ActionLinkFixture extends JComponentFixture Boolean get() { - val checkIsFrame: (Frame) -> Boolean = { frame -> frame.javaClass.simpleName == "FlatWelcomeFrame" && frame.isShowing } + val checkIsFrame: (Frame) -> Boolean = { frame -> frame.javaClass.simpleName == "FlatWelcomeFrame" + && frame.isShowing + && frame.isEnabled } return checkIsFrame } diff --git a/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt b/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt index 4b704fd6be0d..cdc49d33929e 100644 --- a/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt +++ b/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt @@ -25,6 +25,7 @@ import org.fest.util.Preconditions import java.awt.Component import java.awt.MouseInfo import java.awt.Point +import java.awt.Window import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit import javax.swing.SwingUtilities @@ -50,6 +51,15 @@ class SmartWaitRobot() : BasicRobot(null, ExistingHierarchy()) { } } + override fun close(w: Window) { + super.close(w) + superWaitForIdle() + } + + fun superWaitForIdle() { + super.waitForIdle() + } + //smooth mouse move override fun moveMouse(x: Int, y: Int) { val n = 20 diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java index d90070f7e5e3..f636a730373c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java @@ -177,7 +177,6 @@ public class UpdateInfoTree extends PanelWithActionsAndCloseButton { VirtualFilePointer pointer = null; if (treeNode instanceof FileTreeNode) { pointer = ((FileTreeNode)treeNode).getFilePointer(); - if (!pointer.isValid()) pointer = null; } if (pointer != null) { mySelectedUrl = getFilePath(pointer); @@ -292,7 +291,6 @@ public class UpdateInfoTree extends PanelWithActionsAndCloseButton { if (o instanceof FileTreeNode) { final FileTreeNode treeNode = (FileTreeNode)o; VirtualFilePointer filePointer = treeNode.getFilePointer(); - if (!filePointer.isValid()) continue; myNext = getFilePath(filePointer); myStatus = FileStatus.MODIFIED; diff --git a/python/educational-core/resources/code-mirror/template.html b/python/educational-core/resources/code-mirror/template.html index 3946b230c913..671b80471fa4 100644 --- a/python/educational-core/resources/code-mirror/template.html +++ b/python/educational-core/resources/code-mirror/template.html @@ -36,7 +36,7 @@ .footer { position:fixed; line-height: 3.5em; - bottom: 0; + bottom: 5%; right: 1%; width: 95%; text-align: right; diff --git a/python/educational-core/resources/oauthResponsePages/okPage.html b/python/educational-core/resources/oauthResponsePages/okPage.html index c7f89153df2b..a56a5a7791a6 100644 --- a/python/educational-core/resources/oauthResponsePages/okPage.html +++ b/python/educational-core/resources/oauthResponsePages/okPage.html @@ -20,6 +20,6 @@ Authorization succeeded.
-You may return to PyCharm +You may return to %IDE_NAME \ No newline at end of file diff --git a/python/educational-core/src/com/jetbrains/edu/coursecreator/intellij/EduCCModuleBuilder.java b/python/educational-core/src/com/jetbrains/edu/coursecreator/intellij/EduCCModuleBuilder.java index b8fc3e83c486..c27c3ce622c8 100644 --- a/python/educational-core/src/com/jetbrains/edu/coursecreator/intellij/EduCCModuleBuilder.java +++ b/python/educational-core/src/com/jetbrains/edu/coursecreator/intellij/EduCCModuleBuilder.java @@ -21,6 +21,7 @@ import com.intellij.openapi.util.Conditions; import com.intellij.openapi.util.InvalidDataException; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiManager; +import com.intellij.ui.components.JBScrollPane; import com.jetbrains.edu.coursecreator.CCUtils; import com.jetbrains.edu.coursecreator.actions.CCCreateLesson; import com.jetbrains.edu.coursecreator.actions.CCCreateTask; @@ -65,7 +66,13 @@ class EduCCModuleBuilder extends EduCourseModuleBuilder { } getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem()) .addToSettings(settingsStep); - getWizardInputField("ccdescr", "", "Description:", myPanel.getDescriptionField(), JTextArea::getText).addToSettings(settingsStep); + JTextArea descriptionField = myPanel.getDescriptionField(); + descriptionField.setRows(4); + descriptionField.setBorder(null); + descriptionField.invalidate(); + JBScrollPane scrollPane = new JBScrollPane(descriptionField); + scrollPane.setMinimumSize(scrollPane.getUI().getPreferredSize(descriptionField)); + getWizardInputField("ccdescr", "", "Description:", scrollPane, pane -> descriptionField.getText()).addToSettings(settingsStep); return javaSettingsStep; } diff --git a/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java b/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java index 237ea49177f9..cf3737eda564 100644 --- a/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java +++ b/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduStepikRestService.java @@ -18,6 +18,7 @@ package com.jetbrains.edu.learning.builtInServer; import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.StreamUtil; @@ -39,9 +40,11 @@ import org.jetbrains.ide.RestService; import org.jetbrains.io.Responses; import javax.swing.*; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; +import java.nio.charset.Charset; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -199,9 +202,11 @@ public class EduStepikRestService extends RestService { private void sendHtmlResponse(@NotNull HttpRequest request, @NotNull ChannelHandlerContext context, String pagePath) throws IOException { BufferExposingByteArrayOutputStream byteOut = new BufferExposingByteArrayOutputStream(); - InputStream pageStream = getClass().getResourceAsStream(pagePath); + InputStream pageTemplateStream = getClass().getResourceAsStream(pagePath); + String pageTemplate = StreamUtil.readText(pageTemplateStream, Charset.forName("UTF-8")); try { - byteOut.write(StreamUtil.loadFromStream(pageStream)); + String pageWithProductName = pageTemplate.replaceAll("%IDE_NAME", ApplicationNamesInfo.getInstance().getFullProductName()); + byteOut.write(StreamUtil.loadFromStream(new ByteArrayInputStream(pageWithProductName.getBytes(Charset.forName("UTF-8"))))); HttpResponse response = Responses.response("text/html", Unpooled.wrappedBuffer(byteOut.getInternalBuffer(), 0, byteOut.size())); Responses.addNoCache(response); response.headers().set("X-Frame-Options", "Deny"); @@ -209,7 +214,7 @@ public class EduStepikRestService extends RestService { } finally { byteOut.close(); - pageStream.close(); + pageTemplateStream.close(); } } diff --git a/python/educational-core/src/com/jetbrains/edu/learning/core/EduUtils.java b/python/educational-core/src/com/jetbrains/edu/learning/core/EduUtils.java index 11012dffdd7b..7d5aded30d26 100644 --- a/python/educational-core/src/com/jetbrains/edu/learning/core/EduUtils.java +++ b/python/educational-core/src/com/jetbrains/edu/learning/core/EduUtils.java @@ -16,7 +16,6 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.PlainTextFileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiDirectory; @@ -141,11 +140,11 @@ public class EduUtils { return taskFile; } Document document = FileDocumentManager.getInstance().getDocument(answerFile); - if (document != null) { - FileDocumentManager.getInstance().saveDocument(document); + if (document == null) { + return null; } - final LightVirtualFile studentFile = new LightVirtualFile("student_task", PlainTextFileType.INSTANCE, - VfsUtilCore.loadText(answerFile)); + FileDocumentManager.getInstance().saveDocument(document); + final LightVirtualFile studentFile = new LightVirtualFile("student_task", PlainTextFileType.INSTANCE, document.getText()); Document studentDocument = FileDocumentManager.getInstance().getDocument(studentFile); if (studentDocument == null) { return null; diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/run/IpnbCommandLineState.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/run/IpnbCommandLineState.java index 7cc549ea2ebe..436cd7bea670 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/run/IpnbCommandLineState.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/run/IpnbCommandLineState.java @@ -133,7 +133,7 @@ public class IpnbCommandLineState extends PythonCommandLineState { serverStarted.set(true); } final String token = "?token="; - if (text.toLowerCase().contains(token)) { + if (text.toLowerCase().contains(token) && StringUtil.isEmpty(myConfiguration.getToken())) { myConfiguration.setToken(text.substring(text.indexOf(token) + token.length()).trim()); } } diff --git a/python/src/com/jetbrains/python/debugger/attach/PyAttachToProcessDebugRunner.java b/python/src/com/jetbrains/python/debugger/attach/PyAttachToProcessDebugRunner.java index 6e6c321e9005..5b3d8a8fbae0 100644 --- a/python/src/com/jetbrains/python/debugger/attach/PyAttachToProcessDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/attach/PyAttachToProcessDebugRunner.java @@ -38,6 +38,7 @@ public class PyAttachToProcessDebugRunner extends PyDebugRunner { private Project myProject; private final int myPid; private String mySdkPath; + private static final int CONNECTION_TIMEOUT = 20000; public PyAttachToProcessDebugRunner(@NotNull Project project, int pid, String sdkPath) { @@ -79,6 +80,16 @@ public class PyAttachToProcessDebugRunner extends PyDebugRunner { protected void printConsoleInfo() { } + @Override + public int getConnectTimeout() { + return CONNECTION_TIMEOUT; + } + + @Override + protected void detachDebuggedProcess() { + handleStop(); + } + @Override protected String getConnectionMessage() { return "Attaching to a process with PID=" + myPid;