From 515d8bb816f6e59b9e8936e9be681a78d1f9de0a Mon Sep 17 00:00:00 2001 From: "Liana.Bakradze" Date: Wed, 9 Aug 2017 13:49:24 +0300 Subject: [PATCH 01/27] EDU-965 Placeholders displayed incorrectly in Show Preview on Windows VfsUtilCore.loadText(answerFile) returns text with \r\n, but offsets for placeholders are saved for \n --- .../src/com/jetbrains/edu/learning/core/EduUtils.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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; From 50c10dad20893bd50841167258ec34265382ec29 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 9 Aug 2017 07:51:28 +0200 Subject: [PATCH 02/27] mad testing FilePsiMutation: survive PSI invalidation --- .../java/propertyBased/AddNullArgument.java | 4 ++-- .../propertyBased/DeleteForeachInitializers.java | 2 +- .../java/propertyBased/DeleteSecondArgument.java | 2 +- .../java/propertyBased/MakeAllMethodsVoid.java | 5 +++-- .../propertyBased/FilePsiMutation.java | 14 ++++++++++---- 5 files changed, 17 insertions(+), 10 deletions(-) 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/testFramework/testSrc/com/intellij/testFramework/propertyBased/FilePsiMutation.java b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/FilePsiMutation.java index 74fa127f6533..afb26779f1fe 100644 --- a/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/FilePsiMutation.java +++ b/platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/FilePsiMutation.java @@ -18,16 +18,18 @@ package com.intellij.testFramework.propertyBased; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; +import com.intellij.psi.SmartPointerManager; +import com.intellij.psi.SmartPsiElementPointer; import com.intellij.testFramework.PsiTestUtil; /** * @author peter */ public abstract class FilePsiMutation implements MadTestingAction { - protected final PsiFile myFile; + private final SmartPsiElementPointer 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(); + } } From 884ebd0a335fb62fcd8166c4a2f57a46c0a637d0 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 9 Aug 2017 13:54:43 +0300 Subject: [PATCH 03/27] in case of canceled indicator make checkCanceled() throw immediately instead of sleeping and then throwing --- .../progress/util/AbstractProgressIndicatorBase.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); From c166c6035abe545072439913b0a435363dc174ca Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 9 Aug 2017 13:34:23 +0200 Subject: [PATCH 04/27] [platform] proper quoting/escaping @argfile contents (IDEA-177260) --- .../java/openapi/projectRoots/JdkUtilTest.kt | 4 ++ .../openapi/projectRoots/JdkUtil.java | 45 ++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) 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..4add6c3e3d40 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/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java index 1c2049468ee6..7da284cc7350 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java @@ -229,7 +229,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 +239,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 +274,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.trim().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, From a46d2a2a23035236f3d04d5df47785d5d910ce0f Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 9 Aug 2017 13:40:15 +0200 Subject: [PATCH 05/27] Cleanup (minor optimization; IDEA-CR-23688) --- .../com/intellij/java/openapi/projectRoots/JdkUtilTest.kt | 4 ++-- .../src/com/intellij/openapi/projectRoots/JdkUtil.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 4add6c3e3d40..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 @@ -111,10 +111,10 @@ class JdkUtilTest : BareTestFixtureTestCase() { parameters.setUseDynamicVMOptions(true) parameters.setUseDynamicParameters(true) parameters.programParametersList.clearAll() - parameters.programParametersList.addAll(" #1", "\"2\"", "line\n-", "C:\\", "D:\\work", "E:\\work space") + 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\"") + 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/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java index 7da284cc7350..8b0226b85237 100644 --- a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java @@ -276,7 +276,7 @@ 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.trim().startsWith("#")) { + if (StringUtil.containsAnyChar(arg, " \"\n\r\t\f") || arg.endsWith("\\") || arg.startsWith("#")) { StringBuilder sb = new StringBuilder(arg.length() * 2); sb.append('"'); From c3c54dea37138676dd70dba12f5fd503623f3ce3 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 9 Aug 2017 14:40:19 +0300 Subject: [PATCH 06/27] fix scrolling to active element in color settings preview page --- .../application/options/colors/SimpleEditorPreview.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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))); } From e97c8545f1ccbd23cb202c3b489e280c0600c459 Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Wed, 9 Aug 2017 14:38:26 +0300 Subject: [PATCH 07/27] [gui-test] make ActionLinkFixture click to the center of text --- .../ui/components/labels/LinkLabel.java | 5 ++ .../fixtures/ActionLinkFixture.java | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+) 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/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 Date: Wed, 9 Aug 2017 14:48:33 +0300 Subject: [PATCH 08/27] Revert "debug log configurable: prepend log categories with # if needed" This reverts commit efc0a43 --- .../src/com/intellij/ide/actions/DebugLogConfigureAction.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 Date: Wed, 9 Aug 2017 13:48:18 +0200 Subject: [PATCH 09/27] fix review remarks (IDEA-CR-23649 allow PSI operations with outer language elements) --- .../intellij/psi/impl/PsiDocumentManagerBase.java | 12 +++++++----- .../psi/impl/source/codeStyle/CodeEditUtil.java | 2 -- 2 files changed, 7 insertions(+), 7 deletions(-) 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) { From 2c67e90fc0d0882eb94dab093eecdcd8273d7b13 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 9 Aug 2017 13:51:29 +0200 Subject: [PATCH 10/27] Cleanup (formatting) --- .../src/com/intellij/openapi/projectRoots/JdkUtil.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 8b0226b85237..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); } From 9e7e78d1f7c5a00ac42276f5f29aae3c452c86a2 Mon Sep 17 00:00:00 2001 From: "Dmitry.Krasilschikov" Date: Wed, 9 Aug 2017 14:50:33 +0300 Subject: [PATCH 11/27] IDEA-CR-23668 kotlin-style `firstNotNull` refactoring --- .../src/com/intellij/openapi/project/ProjectUtil.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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) From ff4e37da07a4f4a265d245d660b4b626f2f022e4 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 9 Aug 2017 14:33:45 +0300 Subject: [PATCH 12/27] vcs: fix diff for removed files from "Update Info" tree It's OK to have invalid pointer here. (ex: files deleted as a part of an update, or files deleted after update notification was shown) "EA-99903 - assert: VirtualFilePointerImpl.checkDisposed" was caused by disposed pointer (but not because it was invalid), as diff viewer might have a longer life than update info tree. follow-up: bb67875b64fca8754f0d196eec6dfd0266948ab4 (bug introduced here) 376e1e988649e8170a33c711c5ae48be56f8c309 --- .../src/com/intellij/openapi/vcs/update/UpdateInfoTree.java | 2 -- 1 file changed, 2 deletions(-) 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; From a14b4488c19b1effc81ff6873615de56e9d85ec1 Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Tue, 8 Aug 2017 12:52:16 +0300 Subject: [PATCH 13/27] PY-25300 Do not set token for configuration if it's already set The problem was because we reset token when notebook was opened in browser. We parsed this line "[I 12:43:36.348 NotebookApp] 302 GET /?token=c806a0dc9861fd193c94b61eaa208bd6e55de3265b5cafcf (127.0.0.1) 0.65ms" and got wrong value for a token --- .../org/jetbrains/plugins/ipnb/run/IpnbCommandLineState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()); } } From 8d44f9550f2bd279ca32315876bf58a0fa9a9378 Mon Sep 17 00:00:00 2001 From: Alexey Utkin Date: Wed, 9 Aug 2017 15:24:47 +0300 Subject: [PATCH 14/27] IDEA-177314 transfer all PsiTree-related activity from EDT to pooled thread --- .../BraceHighlightingHandler.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) 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..d1a0929d5e5a 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 removeEditorFormProcessed = () -> 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(removeEditorFormProcessed); + 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(removeEditorFormProcessed); throw e; } ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> { @@ -140,15 +149,15 @@ public class BraceHighlightingHandler { } } finally { - PROCESSED_EDITORS.remove(editor); + removeEditorFormProcessed.run(); } - }, ModalityState.stateForComponent(editor.getComponent())); + }, modalityState); })) { // write action is queued in AWT. restart after it's finished ApplicationManager.getApplication().invokeLater(() -> { - PROCESSED_EDITORS.remove(editor); + removeEditorFormProcessed.run(); lookForInjectedAndMatchBracesInOtherThread(editor, alarm, processor); - }, ModalityState.stateForComponent(editor.getComponent())); + }, modalityState); } }); } From ef17a617717ad400867cf326b04fef1d679ad3f7 Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Wed, 9 Aug 2017 15:26:35 +0300 Subject: [PATCH 15/27] [gui-test] add waitForIdle to SmartWaitRobot#close --- .../com/intellij/testGuiFramework/impl/FirstStart.kt | 4 +++- .../src/org/fest/swing/core/SmartWaitRobot.kt | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/FirstStart.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/FirstStart.kt index dbca7c347016..e47c0d2d919b 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/FirstStart.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/FirstStart.kt @@ -77,7 +77,9 @@ abstract class FirstStart(val ideType: IdeType) { private val checkIsFrameFunction: (Frame) -> 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 From 2ccade488e7df16437b471cd00c993366d6536f9 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Wed, 9 Aug 2017 15:26:48 +0300 Subject: [PATCH 16/27] Unsuccessful "Attach to process" action leaves running process (PY-24732) "Attach to process" debug server shouldn't wait forever. It should connect with timeout and shouldn't wait for next connection. --- .../debugger/attach/PyAttachToProcessDebugRunner.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; From a6ca91134cffdd7aa3f0197a92380f87ddf77634 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 9 Aug 2017 15:37:40 +0300 Subject: [PATCH 17/27] build scripts: product-independent resources moved to platform/build-scripts --- .../build/impl/MacDistributionBuilder.groovy | 2 +- .../resources}/mac/Contents/Info.plist | 0 .../resources}/mac/Contents/MacOS/idea | Bin 3 files changed, 1 insertion(+), 1 deletion(-) rename {build/conf => platform/build-scripts/resources}/mac/Contents/Info.plist (100%) rename {build/conf => platform/build-scripts/resources}/mac/Contents/MacOS/idea (100%) 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..1a8761307ce9 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,7 +124,7 @@ 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 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/idea similarity index 100% rename from build/conf/mac/Contents/MacOS/idea rename to platform/build-scripts/resources/mac/Contents/MacOS/idea From 18eed760884332dd1732db946006a7aabc9842ef Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 9 Aug 2017 15:44:46 +0300 Subject: [PATCH 18/27] build scripts: rename MacOS/idea file to 'executable' for clarity ...because it is also used for other IDEs. --- .../build/impl/MacDistributionBuilder.groovy | 6 ++---- .../mac/Contents/MacOS/{idea => executable} | Bin 2 files changed, 2 insertions(+), 4 deletions(-) rename platform/build-scripts/resources/mac/Contents/MacOS/{idea => executable} (100%) 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 1a8761307ce9..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 @@ -128,6 +128,8 @@ class MacDistributionBuilder extends OsSpecificDistributionBuilder { } 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/resources/mac/Contents/MacOS/idea b/platform/build-scripts/resources/mac/Contents/MacOS/executable similarity index 100% rename from platform/build-scripts/resources/mac/Contents/MacOS/idea rename to platform/build-scripts/resources/mac/Contents/MacOS/executable From 402addbb7937c7a8b85b06f3d1802ffc3d8e7d17 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 9 Aug 2017 14:57:16 +0200 Subject: [PATCH 19/27] Cleanup (a comment; IDEA-CR-23188) --- .../intellij/build/impl/LinuxDistributionBuilder.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..efbabd581dd2 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 @@ -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 } } From 5739a5ce019cfb2c80ea623dd9da78a908ace00a Mon Sep 17 00:00:00 2001 From: Alexey Utkin Date: Wed, 9 Aug 2017 15:56:18 +0300 Subject: [PATCH 20/27] IDEA-177314 fix typo removeEditorFormProcessed -> removeEditorFromProcessed --- .../highlighting/BraceHighlightingHandler.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 d1a0929d5e5a..c5e30e45b343 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java @@ -114,12 +114,12 @@ public class BraceHighlightingHandler { // any request to the UI component need to be done from EDT final ModalityState modalityState = ModalityState.stateForComponent(editor.getComponent()); - final DumbAwareRunnable removeEditorFormProcessed = () -> PROCESSED_EDITORS.remove(editor); + final DumbAwareRunnable removeEditorFromProcessed = () -> PROCESSED_EDITORS.remove(editor); ApplicationManager.getApplication().executeOnPooledThread(() -> { if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() -> { if (!isValidEditor(editor)) { - ApplicationManager.getApplication().invokeLater(removeEditorFormProcessed); + ApplicationManager.getApplication().invokeLater(removeEditorFromProcessed); return; } @SuppressWarnings("ConstantConditions") // the `project` is valid after the `isValidEditor` call @@ -137,7 +137,7 @@ public class BraceHighlightingHandler { } catch (RuntimeException e) { // Reset processing flag in case of unexpected exception. - ApplicationManager.getApplication().invokeLater(removeEditorFormProcessed); + ApplicationManager.getApplication().invokeLater(removeEditorFromProcessed); throw e; } ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> { @@ -149,13 +149,13 @@ public class BraceHighlightingHandler { } } finally { - removeEditorFormProcessed.run(); + removeEditorFromProcessed.run(); } }, modalityState); })) { // write action is queued in AWT. restart after it's finished ApplicationManager.getApplication().invokeLater(() -> { - removeEditorFormProcessed.run(); + removeEditorFromProcessed.run(); lookForInjectedAndMatchBracesInOtherThread(editor, alarm, processor); }, modalityState); } From f8e5cb854c1983a84b9275fdec6884e05aadff37 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 9 Aug 2017 15:02:23 +0200 Subject: [PATCH 21/27] Cleanup (obsolete deprecations) --- platform/core-api/src/com/intellij/util/PlatformUtils.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 From 8c4906ac5e498d44d79267fabf6ecf99c8a9d1b5 Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Fri, 28 Jul 2017 16:47:22 +0300 Subject: [PATCH 22/27] EDU-1020 Use correct text in authorization message on Stepik --- .../resources/oauthResponsePages/okPage.html | 2 +- .../learning/builtInServer/EduStepikRestService.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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/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(); } } From f75ce440a931b809821eeca497468570e67dd029 Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Mon, 31 Jul 2017 16:14:35 +0300 Subject: [PATCH 23/27] EDU-1014 Adaptive Java: New Project wizard: Description textfield too narrow --- .../edu/coursecreator/intellij/EduCCModuleBuilder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; } From d9a7698ca92ad1cf80f0b65cced3a26e10492049 Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Wed, 2 Aug 2017 17:46:39 +0300 Subject: [PATCH 24/27] EDU-996 horizontal scrolling by mouse is not working The reason was that footer with Stepik link was placed too close to scroll bar --- python/educational-core/resources/code-mirror/template.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From ecde6554bdfaafffafb79a384b2261d3ec627e13 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 9 Aug 2017 16:26:25 +0300 Subject: [PATCH 25/27] build scripts: product-independent Linux script templates moved to platform/build-scripts At the end community/build is supposed to contain IDEA-specific files only. --- .../intellij/build/impl/LinuxDistributionBuilder.groovy | 2 +- .../build-scripts/resources/linux/scripts}/format.sh | 0 .../build-scripts/resources/linux/scripts}/idea.sh | 0 .../build-scripts/resources/linux/scripts}/inspect.sh | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {bin/scripts/unix => platform/build-scripts/resources/linux/scripts}/format.sh (100%) rename {bin/scripts/unix => platform/build-scripts/resources/linux/scripts}/idea.sh (100%) rename {bin/scripts/unix => platform/build-scripts/resources/linux/scripts}/inspect.sh (100%) 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 efbabd581dd2..004d78571790 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) 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 From 27accb23849f686bbe61c6009db5aecf02261b86 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 9 Aug 2017 16:26:50 +0300 Subject: [PATCH 26/27] build scripts: product-independent Windows batch templates moved to platform/build-scripts At the end community/build is supposed to contain IDEA-specific files only. --- .../intellij/build/impl/WindowsDistributionBuilder.groovy | 2 +- .../build-scripts/resources/win/scripts}/append.bat | 0 .../build-scripts/resources/win/scripts}/format.bat | 0 .../build-scripts/resources/win/scripts}/idea.bat | 0 .../build-scripts/resources/win/scripts}/inspect.bat | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename {bin/scripts/win => platform/build-scripts/resources/win/scripts}/append.bat (100%) rename {bin/scripts/win => platform/build-scripts/resources/win/scripts}/format.bat (100%) rename {bin/scripts/win => platform/build-scripts/resources/win/scripts}/idea.bat (100%) rename {bin/scripts/win => platform/build-scripts/resources/win/scripts}/inspect.bat (100%) 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/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 From 4533b6e282b9ca3775d3777203ab80b925513769 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 9 Aug 2017 16:31:10 +0300 Subject: [PATCH 27/27] build scripts: common Install-Linux-tar.txt template moved to platform/build-scripts At the end community/build is supposed to contain IDEA-specific files only. --- .../intellij/build/impl/LinuxDistributionBuilder.groovy | 2 +- .../build-scripts/resources/linux}/Install-Linux-tar.txt | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {build => platform/build-scripts/resources/linux}/Install-Linux-tar.txt (100%) 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 004d78571790..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 @@ -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], "@@") 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