mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -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)
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -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);
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
private boolean myPerformBackgroundCommit = true;
|
||||
|
||||
private volatile boolean myIsCommitInProgress;
|
||||
private static final ThreadLocal<Boolean> ourIsFullReparseInProgress = new ThreadLocal<>();
|
||||
private static volatile boolean ourIsFullReparseInProgress;
|
||||
private final PsiToDocumentSynchronizer mySynchronizer;
|
||||
|
||||
private final List<Listener> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@ public class CodeEditUtil {
|
||||
private static final ThreadLocal<Boolean> ALLOW_NODES_REFORMATTING = ThreadLocal.withInitial(() -> Boolean.TRUE);
|
||||
private static final ThreadLocal<NotNullFunction<ASTNode, Boolean>> NODE_REFORMAT_STRATEGY = new ThreadLocal<>();
|
||||
|
||||
public static final Key<Boolean> OUTER_OK = new Key<>("OUTER_OK");
|
||||
|
||||
private CodeEditUtil() { }
|
||||
|
||||
public static void addChild(ASTNode parent, ASTNode child, ASTNode anchorBefore) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
+1
-1
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
+18
-9
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -273,6 +273,11 @@ public class LinkLabel<T> 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;
|
||||
|
||||
@@ -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<Pair<St
|
||||
.split(ALL_POSSIBLE_SEPARATORS)
|
||||
.filter { !StringUtil.isEmptyOrSpaces(it) }
|
||||
.map { it.trim() }
|
||||
.map { if (it.startsWith("#")) it else "#" + it }
|
||||
.map {
|
||||
if (it.endsWith(TRACE_SUFFIX, ignoreCase = true)) Pair(it.dropLast(TRACE_SUFFIX.length), DebugLogManager.DebugLogLevel.TRACE)
|
||||
else Pair(it, DebugLogManager.DebugLogLevel.DEBUG)
|
||||
|
||||
+10
-4
@@ -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<PsiFile> 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();
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -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<ActionLinkFixture, ActionLink> {
|
||||
|
||||
|
||||
@NotNull
|
||||
public static ActionLinkFixture findByActionId(@NotNull final String actionId,
|
||||
@NotNull final Robot robot,
|
||||
@@ -111,5 +115,61 @@ public class ActionLinkFixture extends JComponentFixture<ActionLinkFixture, Acti
|
||||
|
||||
private ActionLinkFixture(@NotNull Robot robot, @NotNull ActionLink target) {
|
||||
super(ActionLinkFixture.class, robot, target);
|
||||
replaceDriverWith(new ActionLinkDriver(robot));
|
||||
}
|
||||
|
||||
static class ActionLinkDriver extends JComponentDriver {
|
||||
|
||||
public ActionLinkDriver(Robot robot) {
|
||||
super(robot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(Component c) {
|
||||
clickActionLinkText(c, MouseButton.LEFT_BUTTON, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(Component c, MouseButton button) {
|
||||
clickActionLinkText(c, button, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(Component c, MouseClickInfo mouseClickInfo) {
|
||||
clickActionLinkText(c, mouseClickInfo.button(), mouseClickInfo.times());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doubleClick(Component c) {
|
||||
clickActionLinkText(c, MouseButton.LEFT_BUTTON, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rightClick(Component c) {
|
||||
clickActionLinkText(c, MouseButton.RIGHT_BUTTON, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(Component c, MouseButton button, int times) {
|
||||
clickActionLinkText(c, button, times);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(@NotNull Component c, @NotNull Point where) {
|
||||
click(c, where, MouseButton.LEFT_BUTTON, 1);
|
||||
}
|
||||
|
||||
private void clickActionLinkText(@NotNull Component c, @NotNull MouseButton mouseButton, int times) {
|
||||
assert c instanceof ActionLink;
|
||||
Point textRectangleCenter = ((ActionLink)c).getTextRectangleCenter();
|
||||
click(c, textRectangleCenter, mouseButton, times);
|
||||
}
|
||||
|
||||
private void click(@NotNull Component c, @NotNull Point where, MouseButton mouseButton, int times) {
|
||||
checkInEdtEnabledAndShowing(c);
|
||||
this.robot.click(c, where, mouseButton, times);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
.footer {
|
||||
position:fixed;
|
||||
line-height: 3.5em;
|
||||
bottom: 0;
|
||||
bottom: 5%;
|
||||
right: 1%;
|
||||
width: 95%;
|
||||
text-align: right;
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
Authorization succeeded.
|
||||
<br>
|
||||
|
||||
You may return to PyCharm
|
||||
You may return to %IDE_NAME
|
||||
</body>
|
||||
</html>
|
||||
+8
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
-3
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user