mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
merge LanguageConsole & LanguageConsoleView: part 2
This commit is contained in:
@@ -66,6 +66,9 @@ public class RunContentDescriptor implements Disposable {
|
||||
myIcon = icon;
|
||||
myHelpId = myExecutionConsole instanceof HelpIdProvider ? ((HelpIdProvider)myExecutionConsole).getHelpId() : null;
|
||||
myActivationCallback = activationCallback;
|
||||
if (myExecutionConsole != null) {
|
||||
Disposer.register(this, myExecutionConsole);
|
||||
}
|
||||
}
|
||||
|
||||
public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
|
||||
@@ -110,10 +113,7 @@ public class RunContentDescriptor implements Disposable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myExecutionConsole != null) {
|
||||
Disposer.dispose(myExecutionConsole);
|
||||
myExecutionConsole = null;
|
||||
}
|
||||
myExecutionConsole = null;
|
||||
myComponent = null;
|
||||
myRestarter = null;
|
||||
myProcessHandler = null;
|
||||
|
||||
@@ -39,39 +39,39 @@ public class ConsoleExecuteAction extends DumbAwareAction {
|
||||
|
||||
private final LanguageConsoleView myConsoleView;
|
||||
final ConsoleExecuteActionHandler myExecuteActionHandler;
|
||||
private final Condition<LanguageConsole> myEnabledCondition;
|
||||
private final Condition<LanguageConsoleView> myEnabledCondition;
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public ConsoleExecuteAction(@NotNull LanguageConsoleView console, @NotNull BaseConsoleExecuteActionHandler executeActionHandler) {
|
||||
this(console, executeActionHandler, CONSOLE_EXECUTE_ACTION_ID, Conditions.<LanguageConsole>alwaysTrue());
|
||||
this(console, executeActionHandler, CONSOLE_EXECUTE_ACTION_ID, Conditions.<LanguageConsoleView>alwaysTrue());
|
||||
}
|
||||
|
||||
ConsoleExecuteAction(@NotNull LanguageConsoleView console, final @NotNull ConsoleExecuteActionHandler executeActionHandler, @Nullable Condition<LanguageConsole> enabledCondition) {
|
||||
ConsoleExecuteAction(@NotNull LanguageConsoleView console, final @NotNull ConsoleExecuteActionHandler executeActionHandler, @Nullable Condition<LanguageConsoleView> enabledCondition) {
|
||||
this(console, executeActionHandler, CONSOLE_EXECUTE_ACTION_ID, enabledCondition);
|
||||
}
|
||||
|
||||
public ConsoleExecuteAction(@NotNull LanguageConsoleView console,
|
||||
@NotNull BaseConsoleExecuteActionHandler executeActionHandler,
|
||||
@Nullable Condition<LanguageConsole> enabledCondition) {
|
||||
@Nullable Condition<LanguageConsoleView> enabledCondition) {
|
||||
this(console, executeActionHandler, CONSOLE_EXECUTE_ACTION_ID, enabledCondition);
|
||||
}
|
||||
|
||||
public ConsoleExecuteAction(@NotNull LanguageConsoleView consoleView,
|
||||
@NotNull ConsoleExecuteActionHandler executeActionHandler,
|
||||
@NotNull String emptyExecuteActionId,
|
||||
@Nullable Condition<LanguageConsole> enabledCondition) {
|
||||
@Nullable Condition<LanguageConsoleView> enabledCondition) {
|
||||
super(null, null, AllIcons.Actions.Execute);
|
||||
|
||||
myConsoleView = consoleView;
|
||||
myExecuteActionHandler = executeActionHandler;
|
||||
myEnabledCondition = enabledCondition == null ? Conditions.<LanguageConsole>alwaysTrue() : enabledCondition;
|
||||
myEnabledCondition = enabledCondition == null ? Conditions.<LanguageConsoleView>alwaysTrue() : enabledCondition;
|
||||
|
||||
EmptyAction.setupAction(this, emptyExecuteActionId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void update(@NotNull AnActionEvent e) {
|
||||
EditorEx editor = myConsoleView.getConsole().getConsoleEditor();
|
||||
EditorEx editor = myConsoleView.getConsoleEditor();
|
||||
boolean enabled = !editor.isRendererMode() && isEnabled() &&
|
||||
(myExecuteActionHandler.isEmptyCommandExecutionAllowed() || !StringUtil.isEmptyOrSpaces(editor.getDocument().getCharsSequence()));
|
||||
if (enabled) {
|
||||
@@ -89,12 +89,12 @@ public class ConsoleExecuteAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return myEnabledCondition.value(myConsoleView.getConsole());
|
||||
return myEnabledCondition.value(myConsoleView);
|
||||
}
|
||||
|
||||
public void execute(@Nullable TextRange range, @NotNull String text, @Nullable EditorEx editor) {
|
||||
if (range == null) {
|
||||
((LanguageConsoleImpl)myConsoleView.getConsole()).doAddPromptToHistory();
|
||||
((LanguageConsoleImpl)myConsoleView).doAddPromptToHistory();
|
||||
myConsoleView.print(text, ConsoleViewContentType.USER_INPUT);
|
||||
if (!text.endsWith("\n")) {
|
||||
myConsoleView.print("\n", ConsoleViewContentType.USER_INPUT);
|
||||
@@ -102,7 +102,7 @@ public class ConsoleExecuteAction extends DumbAwareAction {
|
||||
}
|
||||
else {
|
||||
assert editor != null;
|
||||
((LanguageConsoleImpl)myConsoleView.getConsole()).addTextRangeToHistory(range, editor, myExecuteActionHandler.myPreserveMarkup);
|
||||
((LanguageConsoleImpl)myConsoleView).addTextRangeToHistory(range, editor, myExecuteActionHandler.myPreserveMarkup);
|
||||
}
|
||||
myExecuteActionHandler.addToCommandHistoryAndExecute(myConsoleView, text);
|
||||
}
|
||||
@@ -140,10 +140,10 @@ public class ConsoleExecuteAction extends DumbAwareAction {
|
||||
beforeExecution(consoleView);
|
||||
}
|
||||
|
||||
String text = ((LanguageConsoleImpl)consoleView.getConsole()).prepareExecuteAction(myAddToHistory && !myUseProcessStdIn,
|
||||
String text = ((LanguageConsoleImpl)consoleView).prepareExecuteAction(myAddToHistory && !myUseProcessStdIn,
|
||||
myPreserveMarkup, true);
|
||||
((UndoManagerImpl)UndoManager.getInstance(consoleView.getProject())).invalidateActionsFor(DocumentReferenceManager.getInstance().create(
|
||||
consoleView.getConsole().getCurrentEditor().getDocument()));
|
||||
consoleView.getCurrentEditor().getDocument()));
|
||||
|
||||
if (myUseProcessStdIn) {
|
||||
consoleView.print(text, ConsoleViewContentType.USER_INPUT);
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ConsoleHistoryController {
|
||||
}
|
||||
};
|
||||
|
||||
private final LanguageConsole myConsole;
|
||||
private final LanguageConsoleView myConsole;
|
||||
private final AnAction myHistoryNext = new MyAction(true, getKeystrokesUpDown(true));
|
||||
private final AnAction myHistoryPrev = new MyAction(false, getKeystrokesUpDown(false));
|
||||
private final AnAction myBrowseHistory = new MyBrowseAction();
|
||||
@@ -100,21 +100,21 @@ public class ConsoleHistoryController {
|
||||
|
||||
@Deprecated
|
||||
public ConsoleHistoryController(@NotNull String type, @Nullable String persistenceId,
|
||||
@NotNull LanguageConsole console, @NotNull ConsoleHistoryModel model) {
|
||||
@NotNull LanguageConsoleView console, @NotNull ConsoleHistoryModel model) {
|
||||
this(new ConsoleRootType(type, null) { }, persistenceId, console, model);
|
||||
}
|
||||
|
||||
public ConsoleHistoryController(@NotNull ConsoleRootType rootType, @Nullable String persistenceId, @NotNull LanguageConsole console) {
|
||||
public ConsoleHistoryController(@NotNull ConsoleRootType rootType, @Nullable String persistenceId, @NotNull LanguageConsoleView console) {
|
||||
this(rootType, persistenceId, console, ourModels.get(getHistoryName(rootType, fixNullPersistenceId(persistenceId, console))));
|
||||
}
|
||||
|
||||
private ConsoleHistoryController(@NotNull ConsoleRootType rootType, @Nullable String persistenceId,
|
||||
@NotNull LanguageConsole console, @NotNull ConsoleHistoryModel model) {
|
||||
@NotNull LanguageConsoleView console, @NotNull ConsoleHistoryModel model) {
|
||||
myHelper = new ModelHelper(rootType, fixNullPersistenceId(persistenceId, console), model);
|
||||
myConsole = console;
|
||||
}
|
||||
|
||||
private static String fixNullPersistenceId(@Nullable String persistenceId, @NotNull LanguageConsole console) {
|
||||
private static String fixNullPersistenceId(@Nullable String persistenceId, @NotNull LanguageConsoleView console) {
|
||||
return StringUtil.isEmpty(persistenceId) ? console.getProject().getPresentableUrl() : persistenceId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.console;
|
||||
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
*/
|
||||
public interface LanguageConsole extends Disposable {
|
||||
@NotNull
|
||||
Project getProject();
|
||||
|
||||
@NotNull
|
||||
JComponent getComponent();
|
||||
|
||||
@NotNull
|
||||
String getTitle();
|
||||
|
||||
void setTitle(String title);
|
||||
|
||||
@NotNull
|
||||
PsiFile getFile();
|
||||
|
||||
@NotNull
|
||||
VirtualFile getVirtualFile();
|
||||
|
||||
@NotNull
|
||||
Editor getCurrentEditor();
|
||||
|
||||
@NotNull
|
||||
EditorEx getConsoleEditor();
|
||||
|
||||
@NotNull
|
||||
Document getEditorDocument();
|
||||
|
||||
@NotNull
|
||||
EditorEx getHistoryViewer();
|
||||
|
||||
@NotNull
|
||||
Language getLanguage();
|
||||
|
||||
void setLanguage(@NotNull Language language);
|
||||
|
||||
@Nullable
|
||||
String getPrompt();
|
||||
|
||||
void setPrompt(@Nullable String prompt);
|
||||
|
||||
void setPromptAttributes(@NotNull ConsoleViewContentType textAttributes);
|
||||
|
||||
void setInputText(@NotNull String inputText);
|
||||
|
||||
boolean isEditable();
|
||||
|
||||
void setEditable(boolean editable);
|
||||
|
||||
boolean isConsoleEditorEnabled();
|
||||
|
||||
void setConsoleEditorEnabled(boolean enabled);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public final class LanguageConsoleBuilder {
|
||||
@Nullable
|
||||
private LanguageConsoleView consoleView;
|
||||
@Nullable
|
||||
private Condition<LanguageConsole> executionEnabled = Conditions.alwaysTrue();
|
||||
private Condition<LanguageConsoleView> executionEnabled = Conditions.alwaysTrue();
|
||||
|
||||
@Nullable
|
||||
private PairFunction<VirtualFile, Project, PsiFile> psiFileFactory;
|
||||
@@ -72,17 +72,17 @@ public final class LanguageConsoleBuilder {
|
||||
}
|
||||
|
||||
public LanguageConsoleBuilder processHandler(@NotNull final ProcessHandler processHandler) {
|
||||
executionEnabled = new Condition<LanguageConsole>() {
|
||||
executionEnabled = new Condition<LanguageConsoleView>() {
|
||||
|
||||
@Override
|
||||
public boolean value(LanguageConsole console) {
|
||||
public boolean value(LanguageConsoleView console) {
|
||||
return !processHandler.isProcessTerminated();
|
||||
}
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public LanguageConsoleBuilder executionEnabled(@NotNull Condition<LanguageConsole> condition) {
|
||||
public LanguageConsoleBuilder executionEnabled(@NotNull Condition<LanguageConsoleView> condition) {
|
||||
executionEnabled = condition;
|
||||
return this;
|
||||
}
|
||||
@@ -109,9 +109,9 @@ public final class LanguageConsoleBuilder {
|
||||
|
||||
private void doInitAction(@NotNull LanguageConsoleView consoleView, @NotNull BaseConsoleExecuteActionHandler executeActionHandler, @NotNull String historyType) {
|
||||
ConsoleExecuteAction action = new ConsoleExecuteAction(consoleView, executeActionHandler, executionEnabled);
|
||||
action.registerCustomShortcutSet(action.getShortcutSet(), consoleView.getConsole().getConsoleEditor().getComponent());
|
||||
action.registerCustomShortcutSet(action.getShortcutSet(), consoleView.getConsoleEditor().getComponent());
|
||||
|
||||
new ConsoleHistoryController(historyType, null, consoleView.getConsole(), executeActionHandler.getConsoleHistoryModel()).install();
|
||||
new ConsoleHistoryController(historyType, null, consoleView, executeActionHandler.getConsoleHistoryModel()).install();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ public final class LanguageConsoleBuilder {
|
||||
@NotNull final Consumer<String> executeActionHandler,
|
||||
@NotNull String historyType,
|
||||
@Nullable String historyPersistenceId,
|
||||
@Nullable Condition<LanguageConsole> enabledCondition) {
|
||||
@Nullable Condition<LanguageConsoleView> enabledCondition) {
|
||||
ConsoleExecuteAction.ConsoleExecuteActionHandler handler = new ConsoleExecuteAction.ConsoleExecuteActionHandler(true) {
|
||||
@Override
|
||||
void doExecute(@NotNull String text, @NotNull LanguageConsoleView consoleView) {
|
||||
@@ -130,9 +130,9 @@ public final class LanguageConsoleBuilder {
|
||||
};
|
||||
|
||||
ConsoleExecuteAction action = new ConsoleExecuteAction(console, handler, enabledCondition);
|
||||
action.registerCustomShortcutSet(action.getShortcutSet(), console.getConsole().getConsoleEditor().getComponent());
|
||||
action.registerCustomShortcutSet(action.getShortcutSet(), console.getConsoleEditor().getComponent());
|
||||
|
||||
ConsoleHistoryController historyController = new ConsoleHistoryController(historyType, historyPersistenceId, console.getConsole(), handler.getConsoleHistoryModel());
|
||||
ConsoleHistoryController historyController = new ConsoleHistoryController(historyType, historyPersistenceId, console, handler.getConsoleHistoryModel());
|
||||
historyController.install();
|
||||
return new Pair<AnAction, ConsoleHistoryController>(action, historyController);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public final class LanguageConsoleBuilder {
|
||||
if (PropertiesComponent.getInstance().getBoolean(processInputStateKey, false)) {
|
||||
executeActionHandler.myUseProcessStdIn = true;
|
||||
DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(consoleView.getProject());
|
||||
daemonCodeAnalyzer.setHighlightingEnabled(consoleView.getConsole().getFile(), false);
|
||||
daemonCodeAnalyzer.setHighlightingEnabled(consoleView.getFile(), false);
|
||||
}
|
||||
consoleView.addCustomConsoleAction(new UseConsoleInputAction(processInputStateKey));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.impl.ConsoleViewUtil;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.lang.Language;
|
||||
@@ -75,7 +76,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* @author Gregory.Shrago
|
||||
* In case of REPL consider to use {@link LanguageConsoleBuilder}
|
||||
*/
|
||||
public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageConsole, LanguageConsoleView, DataProvider {
|
||||
public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageConsoleView, DataProvider {
|
||||
private final Project myProject;
|
||||
|
||||
private final EditorEx myConsoleEditor;
|
||||
@@ -99,6 +100,9 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons
|
||||
@Override
|
||||
public void focusGained(Editor editor) {
|
||||
myCurrentEditor = editor;
|
||||
if (GeneralSettings.getInstance().isSaveOnFrameDeactivation()) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments(); // PY-12487
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,12 +334,6 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LanguageConsole getConsole() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTitle() {
|
||||
return myTitle;
|
||||
@@ -469,9 +467,12 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
// double dispose via RunContentDescriptor and ContentImpl
|
||||
if (myHistoryViewer.isDisposed()) return;
|
||||
|
||||
EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
editorFactory.releaseEditor(myConsoleEditor);
|
||||
//editorFactory.releaseEditor(myHistoryViewer);
|
||||
editorFactory.releaseEditor(myHistoryViewer);
|
||||
|
||||
if (getProject().isOpen()) {
|
||||
FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -16,16 +16,67 @@
|
||||
package com.intellij.execution.console;
|
||||
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
* @author gregsh
|
||||
*/
|
||||
public interface LanguageConsoleView extends ConsoleView {
|
||||
public interface LanguageConsoleView extends ConsoleView, Disposable {
|
||||
@NotNull
|
||||
Project getProject();
|
||||
|
||||
@NotNull
|
||||
LanguageConsole getConsole();
|
||||
String getTitle();
|
||||
|
||||
void setTitle(String title);
|
||||
|
||||
@NotNull
|
||||
PsiFile getFile();
|
||||
|
||||
@NotNull
|
||||
VirtualFile getVirtualFile();
|
||||
|
||||
@NotNull
|
||||
Editor getCurrentEditor();
|
||||
|
||||
@NotNull
|
||||
EditorEx getConsoleEditor();
|
||||
|
||||
@NotNull
|
||||
Document getEditorDocument();
|
||||
|
||||
@NotNull
|
||||
EditorEx getHistoryViewer();
|
||||
|
||||
@NotNull
|
||||
Language getLanguage();
|
||||
|
||||
void setLanguage(@NotNull Language language);
|
||||
|
||||
@Nullable
|
||||
String getPrompt();
|
||||
|
||||
void setPrompt(@Nullable String prompt);
|
||||
|
||||
void setPromptAttributes(@NotNull ConsoleViewContentType textAttributes);
|
||||
|
||||
void setInputText(@NotNull String inputText);
|
||||
|
||||
boolean isEditable();
|
||||
|
||||
void setEditable(boolean editable);
|
||||
|
||||
boolean isConsoleEditorEnabled();
|
||||
|
||||
void setConsoleEditorEnabled(boolean enabled);
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import java.nio.charset.Charset;
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
public class ProcessBackedConsoleExecuteActionHandler extends BaseConsoleExecuteActionHandler implements Condition<LanguageConsole> {
|
||||
public class ProcessBackedConsoleExecuteActionHandler extends BaseConsoleExecuteActionHandler implements Condition<LanguageConsoleView> {
|
||||
private volatile ProcessHandler myProcessHandler;
|
||||
|
||||
public ProcessBackedConsoleExecuteActionHandler(ProcessHandler processHandler, boolean preserveMarkup) {
|
||||
@@ -69,7 +69,7 @@ public class ProcessBackedConsoleExecuteActionHandler extends BaseConsoleExecute
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean value(LanguageConsole console) {
|
||||
public boolean value(LanguageConsoleView console) {
|
||||
return !isProcessTerminated();
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ final class UseConsoleInputAction extends ToggleAction implements DumbAware {
|
||||
LanguageConsoleView consoleView = (LanguageConsoleView)event.getData(LangDataKeys.CONSOLE_VIEW);
|
||||
assert consoleView != null;
|
||||
DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(consoleView.getProject());
|
||||
PsiFile file = consoleView.getConsole().getFile();
|
||||
PsiFile file = consoleView.getFile();
|
||||
daemonCodeAnalyzer.setHighlightingEnabled(file, state);
|
||||
daemonCodeAnalyzer.restart(file);
|
||||
if (state) {
|
||||
@@ -49,7 +49,7 @@ final class UseConsoleInputAction extends ToggleAction implements DumbAware {
|
||||
PropertiesComponent.getInstance().setValue(processInputStateKey, "true");
|
||||
}
|
||||
|
||||
List<AnAction> actions = ActionUtil.getActions(consoleView.getConsole().getConsoleEditor().getComponent());
|
||||
List<AnAction> actions = ActionUtil.getActions(consoleView.getConsoleEditor().getComponent());
|
||||
ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
|
||||
action.myExecuteActionHandler.myUseProcessStdIn = !state;
|
||||
}
|
||||
|
||||
@@ -518,7 +518,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
myEditor = null;
|
||||
myHyperlinks = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelAllFlushRequests() {
|
||||
synchronized (myCurrentRequests) {
|
||||
|
||||
+3
-5
@@ -23,7 +23,6 @@ import com.intellij.execution.ExecutionHelper;
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.console.ConsoleExecuteAction;
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.console.ProcessBackedConsoleExecuteActionHandler;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
@@ -142,7 +141,6 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
|
||||
final List<AnAction> actions = fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor);
|
||||
registerActionShortcuts(actions, getLanguageConsole().getConsoleEditor().getComponent());
|
||||
registerActionShortcuts(actions, panel);
|
||||
panel.updateUI();
|
||||
|
||||
showConsole(defaultExecutor, contentDescriptor);
|
||||
}
|
||||
@@ -187,7 +185,7 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
|
||||
}
|
||||
|
||||
protected void finishConsole() {
|
||||
myConsoleView.getConsole().setEditable(false);
|
||||
myConsoleView.setEditable(false);
|
||||
}
|
||||
|
||||
protected abstract T createConsoleView();
|
||||
@@ -236,8 +234,8 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
|
||||
return ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM);
|
||||
}
|
||||
|
||||
public LanguageConsole getLanguageConsole() {
|
||||
return myConsoleView.getConsole();
|
||||
public LanguageConsoleView getLanguageConsole() {
|
||||
return myConsoleView;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class XEvaluateInConsoleFromEditorActionHandler extends XAddToWatchesFrom
|
||||
return null;
|
||||
}
|
||||
|
||||
List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView)consoleView).getConsole().getConsoleEditor().getComponent());
|
||||
List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView)consoleView).getConsoleEditor().getComponent());
|
||||
ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
|
||||
return action == null || !action.isEnabled() ? null : action;
|
||||
}
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@ package com.intellij.xdebugger.impl.evaluate.quick;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
@@ -96,7 +95,7 @@ public class XValueHint extends AbstractValueHint {
|
||||
VirtualFile file;
|
||||
ConsoleView consoleView = ConsoleViewImpl.CONSOLE_VIEW_IN_EDITOR_VIEW.get(editor);
|
||||
if (consoleView instanceof LanguageConsoleView) {
|
||||
LanguageConsole console = ((LanguageConsoleView)consoleView).getConsole();
|
||||
LanguageConsoleView console = ((LanguageConsoleView)consoleView);
|
||||
file = console.getHistoryViewer() == editor ? console.getVirtualFile() : null;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -213,7 +213,7 @@ public abstract class GroovyShellActionBase extends AnAction {
|
||||
@Override
|
||||
protected LanguageConsoleView createConsoleView() {
|
||||
LanguageConsoleView res = createConsole(getProject(), getConsoleTitle());
|
||||
GroovyFileImpl file = (GroovyFileImpl)res.getConsole().getFile();
|
||||
GroovyFileImpl file = (GroovyFileImpl)res.getFile();
|
||||
assert file.getContext() == null;
|
||||
file.putUserData(GROOVY_SHELL_FILE, Boolean.TRUE);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.jetbrains.python.console.PyCodeExecutor;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -41,7 +40,7 @@ public class PyConsoleProcessHandler extends PythonProcessHandler {
|
||||
|
||||
@Override
|
||||
public void coloredTextAvailable(final String text, final Key attributes) {
|
||||
final String string = PyConsoleUtil.processPrompts(getConsole(), StringUtil.convertLineSeparators(text));
|
||||
String string = PyConsoleUtil.processPrompts(myConsoleView, StringUtil.convertLineSeparators(text));
|
||||
|
||||
myConsoleView.print(string, attributes);
|
||||
|
||||
@@ -83,9 +82,5 @@ public class PyConsoleProcessHandler extends PythonProcessHandler {
|
||||
// waiting for REPL communication before destroying process handler
|
||||
}
|
||||
}
|
||||
|
||||
private LanguageConsole getConsole() {
|
||||
return myConsoleView.getConsole();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class PyConsoleSourceHighlighter {
|
||||
myLexer.start(text, 0, text.length(), getLexerState());
|
||||
while (hasNext()) {
|
||||
Pair<String, ConsoleViewContentType> pair = next();
|
||||
myPythonConsoleView.printText(pair.first, pair.second);
|
||||
myPythonConsoleView.print(pair.first, pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -56,7 +56,7 @@ public class PyConsoleUtil {
|
||||
return prompt != null && IPYTHON_PAGING_PROMPT.equals(prompt.trim());
|
||||
}
|
||||
|
||||
static String processPrompts(final LanguageConsole languageConsole, String string) {
|
||||
static String processPrompts(final LanguageConsoleView languageConsole, String string) {
|
||||
// Change prompt
|
||||
for (String prompt : PROMPTS) {
|
||||
if (string.startsWith(prompt)) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.console.ProcessBackedConsoleExecuteActionHandler;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
@@ -25,6 +24,7 @@ import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileTypes.PlainTextLanguage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -95,13 +95,9 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
if (myInputBuffer == null) {
|
||||
myInputBuffer = new StringBuilder();
|
||||
}
|
||||
|
||||
myInputBuffer.append(text);
|
||||
|
||||
final LanguageConsole console = myConsoleView.getConsole();
|
||||
final Editor currentEditor = console.getConsoleEditor();
|
||||
|
||||
sendLineToConsole(new ConsoleCommunication.ConsoleCodeFragment(myInputBuffer.toString(), false), console, currentEditor);
|
||||
sendLineToConsole(new ConsoleCommunication.ConsoleCodeFragment(myInputBuffer.toString(), false));
|
||||
}
|
||||
|
||||
private void processOneLine(String line) {
|
||||
@@ -123,9 +119,6 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
}
|
||||
|
||||
public void doProcessLine(final String line) {
|
||||
final LanguageConsole console = myConsoleView.getConsole();
|
||||
final Editor currentEditor = console.getConsoleEditor();
|
||||
|
||||
if (myInputBuffer == null) {
|
||||
myInputBuffer = new StringBuilder();
|
||||
}
|
||||
@@ -146,10 +139,11 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
if (PyConsoleUtil.isDoubleQuoteMultilineStarts(line) || PyConsoleUtil.isSingleQuoteMultilineStarts(line)) {
|
||||
myInMultilineStringState = null;
|
||||
// restore language
|
||||
console.setLanguage(PythonLanguage.getInstance());
|
||||
console.setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
|
||||
} else {
|
||||
if(line.equals("\n")) {
|
||||
myConsoleView.setLanguage(PythonLanguage.getInstance());
|
||||
myConsoleView.setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
|
||||
}
|
||||
else {
|
||||
if (line.equals("\n")) {
|
||||
myInputBuffer.append("\n");
|
||||
}
|
||||
return;
|
||||
@@ -164,15 +158,15 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
}
|
||||
if (myInMultilineStringState != null) {
|
||||
// change language
|
||||
console.setLanguage(PlainTextLanguage.INSTANCE);
|
||||
console.setPrompt(PyConsoleUtil.INDENT_PROMPT);
|
||||
myConsoleView.setLanguage(PlainTextLanguage.INSTANCE);
|
||||
myConsoleView.setPrompt(PyConsoleUtil.INDENT_PROMPT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Process line continuation
|
||||
if (line.endsWith("\\")) {
|
||||
console.setPrompt(PyConsoleUtil.INDENT_PROMPT);
|
||||
myConsoleView.setPrompt(PyConsoleUtil.INDENT_PROMPT);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -185,8 +179,8 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
}
|
||||
if ((myCurrentIndentSize > 0 && indent > 0) || flag) {
|
||||
setCurrentIndentSize(indent);
|
||||
indentEditor(currentEditor, indent);
|
||||
more(console, currentEditor);
|
||||
indentEditor(myConsoleView.getConsoleEditor(), indent);
|
||||
more();
|
||||
|
||||
myConsoleCommunication.notifyCommandExecuted(true);
|
||||
return;
|
||||
@@ -194,14 +188,12 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
}
|
||||
|
||||
|
||||
sendLineToConsole(new ConsoleCommunication.ConsoleCodeFragment(myInputBuffer.toString(), true), console, currentEditor);
|
||||
sendLineToConsole(new ConsoleCommunication.ConsoleCodeFragment(myInputBuffer.toString(), true));
|
||||
}
|
||||
|
||||
private void sendLineToConsole(@NotNull final ConsoleCommunication.ConsoleCodeFragment code,
|
||||
@NotNull final LanguageConsole console,
|
||||
@NotNull final Editor currentEditor) {
|
||||
if(!StringUtil.isEmptyOrSpaces(code.getText())) {
|
||||
myIpythonInputPromptCount+=1;
|
||||
private void sendLineToConsole(@NotNull final ConsoleCommunication.ConsoleCodeFragment code) {
|
||||
if (!StringUtil.isEmptyOrSpaces(code.getText())) {
|
||||
myIpythonInputPromptCount += 1;
|
||||
}
|
||||
if (myConsoleCommunication != null) {
|
||||
final boolean waitedForInputBefore = myConsoleCommunication.isWaitingForInput();
|
||||
@@ -209,7 +201,7 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
myInputBuffer.setLength(0);
|
||||
}
|
||||
else {
|
||||
executingPrompt(console);
|
||||
executingPrompt();
|
||||
}
|
||||
myConsoleCommunication.execInterpreter(code, new Function<InterpreterResponse, Object>() {
|
||||
@Override
|
||||
@@ -222,23 +214,24 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
|
||||
// Handle prompt
|
||||
if (interpreterResponse.more) {
|
||||
more(console, currentEditor);
|
||||
more();
|
||||
if (myCurrentIndentSize == 0) {
|
||||
// compute current indentation
|
||||
setCurrentIndentSize(
|
||||
IndentHelperImpl.getIndent(getProject(), PythonFileType.INSTANCE, lastLine(code.getText()), false) + getPythonIndent());
|
||||
// In this case we can insert indent automatically
|
||||
final EditorEx editor = myConsoleView.getConsoleEditor();
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
indentEditor(currentEditor, myCurrentIndentSize);
|
||||
indentEditor(editor, myCurrentIndentSize);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!myConsoleCommunication.isWaitingForInput()) {
|
||||
inPrompt(console, currentEditor);
|
||||
inPrompt();
|
||||
}
|
||||
setCurrentIndentSize(0);
|
||||
}
|
||||
@@ -248,8 +241,8 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
});
|
||||
// After requesting input we got no call back to change prompt, change it manually
|
||||
if (waitedForInputBefore && !myConsoleCommunication.isWaitingForInput()) {
|
||||
myIpythonInputPromptCount-=1;
|
||||
inPrompt(console, currentEditor);
|
||||
myIpythonInputPromptCount -= 1;
|
||||
inPrompt();
|
||||
setCurrentIndentSize(0);
|
||||
}
|
||||
}
|
||||
@@ -260,33 +253,33 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
return lines[lines.length - 1];
|
||||
}
|
||||
|
||||
private void inPrompt(LanguageConsole console, Editor currentEditor){
|
||||
if(ipythonEnabled(console)){
|
||||
ipythonInPrompt(console, currentEditor);
|
||||
} else {
|
||||
ordinaryPrompt(console, currentEditor);
|
||||
private void inPrompt() {
|
||||
if (ipythonEnabled()) {
|
||||
ipythonInPrompt();
|
||||
}
|
||||
else {
|
||||
ordinaryPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
private void ordinaryPrompt(LanguageConsole console, Editor currentEditor) {
|
||||
private void ordinaryPrompt() {
|
||||
if (!myConsoleCommunication.isExecuting()) {
|
||||
if (!PyConsoleUtil.ORDINARY_PROMPT.equals(console.getPrompt())) {
|
||||
console.setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
|
||||
PyConsoleUtil.scrollDown(currentEditor);
|
||||
if (!PyConsoleUtil.ORDINARY_PROMPT.equals(myConsoleView.getPrompt())) {
|
||||
myConsoleView.setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
|
||||
PyConsoleUtil.scrollDown(myConsoleView.getCurrentEditor());
|
||||
}
|
||||
}
|
||||
else {
|
||||
executingPrompt(console);
|
||||
executingPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean ipythonEnabled(LanguageConsole console){
|
||||
return console.getFile().getVirtualFile() != null ?
|
||||
PyConsoleUtil.getOrCreateIPythonData(console.getFile().getVirtualFile()).isIPythonEnabled() : false;
|
||||
private boolean ipythonEnabled() {
|
||||
return PyConsoleUtil.getOrCreateIPythonData(myConsoleView.getVirtualFile()).isIPythonEnabled();
|
||||
}
|
||||
|
||||
private void ipythonInPrompt(LanguageConsole console, Editor currentEditor){
|
||||
console.setPromptAttributes(new ConsoleViewContentType("", ConsoleViewContentType.USER_INPUT_KEY) {
|
||||
private void ipythonInPrompt() {
|
||||
myConsoleView.setPromptAttributes(new ConsoleViewContentType("", ConsoleViewContentType.USER_INPUT_KEY) {
|
||||
@Override
|
||||
public TextAttributes getAttributes() {
|
||||
TextAttributes attrs = super.getAttributes();
|
||||
@@ -294,18 +287,18 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
return attrs;
|
||||
}
|
||||
});
|
||||
console.setPrompt("In[" + myIpythonInputPromptCount + "]:");
|
||||
PyConsoleUtil.scrollDown(currentEditor);
|
||||
myConsoleView.setPrompt("In[" + myIpythonInputPromptCount + "]:");
|
||||
PyConsoleUtil.scrollDown(myConsoleView.getCurrentEditor());
|
||||
}
|
||||
|
||||
private static void executingPrompt(LanguageConsole console) {
|
||||
console.setPrompt(PyConsoleUtil.EXECUTING_PROMPT);
|
||||
private void executingPrompt() {
|
||||
myConsoleView.setPrompt(PyConsoleUtil.EXECUTING_PROMPT);
|
||||
}
|
||||
|
||||
private static void more(LanguageConsole console, Editor currentEditor) {
|
||||
if (!PyConsoleUtil.INDENT_PROMPT.equals(console.getPrompt())) {
|
||||
console.setPrompt(PyConsoleUtil.INDENT_PROMPT);
|
||||
PyConsoleUtil.scrollDown(currentEditor);
|
||||
private void more() {
|
||||
if (!PyConsoleUtil.INDENT_PROMPT.equals(myConsoleView.getPrompt())) {
|
||||
myConsoleView.setPrompt(PyConsoleUtil.INDENT_PROMPT);
|
||||
PyConsoleUtil.scrollDown(myConsoleView.getCurrentEditor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,19 +308,14 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
|
||||
@Override
|
||||
public void commandExecuted(boolean more) {
|
||||
if (!more) {
|
||||
final LanguageConsole console = myConsoleView.getConsole();
|
||||
final Editor currentEditor = console.getConsoleEditor();
|
||||
|
||||
if(!ipythonEnabled(console)){
|
||||
ordinaryPrompt(console, currentEditor);
|
||||
}
|
||||
if (!more && !ipythonEnabled()) {
|
||||
ordinaryPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputRequested() {
|
||||
final LanguageConsole console = myConsoleView.getConsole();
|
||||
final LanguageConsoleView console = myConsoleView;
|
||||
final Editor currentEditor = console.getConsoleEditor();
|
||||
|
||||
if (!PyConsoleUtil.INPUT_PROMPT.equals(console.getPrompt()) && !PyConsoleUtil.HELP_PROMPT.equals(console.getPrompt())) {
|
||||
@@ -338,7 +326,7 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
}
|
||||
|
||||
public void finishExecution() {
|
||||
final LanguageConsole console = myConsoleView.getConsole();
|
||||
final LanguageConsoleView console = myConsoleView;
|
||||
final Editor currentEditor = console.getConsoleEditor();
|
||||
|
||||
if (myInputBuffer != null) {
|
||||
@@ -364,7 +352,7 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
@Nullable
|
||||
private VirtualFile getConsoleFile() {
|
||||
if (myConsoleView != null) {
|
||||
return myConsoleView.getConsole().getFile().getVirtualFile();
|
||||
return myConsoleView.getFile().getVirtualFile();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -394,7 +382,7 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
}
|
||||
|
||||
private Project getProject() {
|
||||
return myConsoleView.getConsole().getProject();
|
||||
return myConsoleView.getProject();
|
||||
}
|
||||
|
||||
public String getCantExecuteMessage() {
|
||||
@@ -413,27 +401,27 @@ public class PydevConsoleExecuteActionHandler extends ProcessBackedConsoleExecut
|
||||
public void runExecuteAction(@NotNull LanguageConsoleView console) {
|
||||
if (isEnabled()) {
|
||||
if (!canExecuteNow()) {
|
||||
HintManager.getInstance().showErrorHint(console.getConsole().getConsoleEditor(), getPrevCommandRunningMessage());
|
||||
HintManager.getInstance().showErrorHint(console.getConsoleEditor(), getPrevCommandRunningMessage());
|
||||
}
|
||||
else {
|
||||
doRunExecuteAction(console);
|
||||
}
|
||||
}
|
||||
else {
|
||||
HintManager.getInstance().showErrorHint(console.getConsole().getConsoleEditor(), getConsoleIsNotEnabledMessage());
|
||||
HintManager.getInstance().showErrorHint(console.getConsoleEditor(), getConsoleIsNotEnabledMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void doRunExecuteAction(LanguageConsoleView console) {
|
||||
if (shouldCopyToHistory(console.getConsole())) {
|
||||
if (shouldCopyToHistory(console)) {
|
||||
copyToHistoryAndExecute(console);
|
||||
}
|
||||
else {
|
||||
processLine(console.getConsole().getConsoleEditor().getDocument().getText());
|
||||
processLine(console.getConsoleEditor().getDocument().getText());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldCopyToHistory(@NotNull LanguageConsole console) {
|
||||
private static boolean shouldCopyToHistory(@NotNull LanguageConsoleView console) {
|
||||
return !PyConsoleUtil.isPagingPrompt(console.getPrompt());
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
public static final int PORTS_WAITING_TIMEOUT = 20000;
|
||||
|
||||
private Sdk mySdk;
|
||||
@NotNull private CommandLineArgumentsProvider myCommandLineArgumentsProvider;
|
||||
private CommandLineArgumentsProvider myCommandLineArgumentsProvider;
|
||||
protected int[] myPorts;
|
||||
private PydevConsoleCommunication myPydevConsoleCommunication;
|
||||
private PyConsoleProcessHandler myProcessHandler;
|
||||
@@ -240,10 +240,6 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
return command.replace(WORKING_DIR_ENV, path);
|
||||
}
|
||||
|
||||
public void setStatementsToExecute(String... statementsToExecute) {
|
||||
myStatementsToExecute = statementsToExecute;
|
||||
}
|
||||
|
||||
public static Map<String, String> addDefaultEnvironments(Sdk sdk, Map<String, String> envs, @NotNull Project project) {
|
||||
Charset defaultCharset = EncodingProjectManager.getInstance(project).getDefaultCharset();
|
||||
|
||||
@@ -415,7 +411,7 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
@Override
|
||||
protected PythonConsoleView createConsoleView() {
|
||||
PythonConsoleView consoleView = new PythonConsoleView(getProject(), getConsoleTitle(), mySdk);
|
||||
myPydevConsoleCommunication.setConsoleFile(consoleView.getConsoleVirtualFile());
|
||||
myPydevConsoleCommunication.setConsoleFile(consoleView.getVirtualFile());
|
||||
consoleView.addMessageFilter(new PythonTracebackFilter(getProject()));
|
||||
return consoleView;
|
||||
}
|
||||
@@ -629,13 +625,13 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
EditorEx consoleEditor = getConsoleView().getConsole().getConsoleEditor();
|
||||
EditorEx consoleEditor = getConsoleView().getConsoleEditor();
|
||||
boolean enabled = IJSwingUtilities.hasFocus(consoleEditor.getComponent()) && !consoleEditor.getSelectionModel().hasSelection();
|
||||
e.getPresentation().setEnabled(enabled);
|
||||
}
|
||||
};
|
||||
anAction
|
||||
.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.CTRL_MASK, getConsoleView().getConsole().getConsoleEditor().getComponent());
|
||||
.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.CTRL_MASK, getConsoleView().getConsoleEditor().getComponent());
|
||||
anAction.getTemplatePresentation().setVisible(false);
|
||||
return anAction;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
@@ -129,7 +130,7 @@ public class PythonConsoleToolWindow {
|
||||
private static Content createContent(final @NotNull RunContentDescriptor contentDescriptor) {
|
||||
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
|
||||
|
||||
final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, contentDescriptor.getDisplayName(), false);
|
||||
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, contentDescriptor.getDisplayName(), false);
|
||||
content.setCloseable(true);
|
||||
|
||||
resetContent(contentDescriptor, panel, content);
|
||||
@@ -138,9 +139,13 @@ public class PythonConsoleToolWindow {
|
||||
}
|
||||
|
||||
private static void resetContent(RunContentDescriptor contentDescriptor, SimpleToolWindowPanel panel, Content content) {
|
||||
RunContentDescriptor oldDescriptor = content.getDisposer() instanceof RunContentDescriptor ? (RunContentDescriptor)content.getDisposer() : null;
|
||||
if (oldDescriptor != null) Disposer.dispose(oldDescriptor);
|
||||
|
||||
panel.setContent(contentDescriptor.getComponent());
|
||||
|
||||
content.setComponent(panel);
|
||||
content.setDisposer(contentDescriptor);
|
||||
content.setPreferredFocusableComponent(contentDescriptor.getComponent());
|
||||
|
||||
content.putUserData(CONTENT_DESCRIPTOR, contentDescriptor);
|
||||
|
||||
@@ -16,24 +16,15 @@
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.execution.console.LanguageConsoleImpl;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.filters.Filter;
|
||||
import com.intellij.execution.filters.HyperlinkInfo;
|
||||
import com.intellij.execution.filters.OpenFileHyperlinkInfo;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.execution.ui.ObservableConsoleView;
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -63,85 +54,49 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
public class PythonConsoleView extends JPanel implements LanguageConsoleView, ObservableConsoleView, PyCodeExecutor {
|
||||
public class PythonConsoleView extends LanguageConsoleImpl implements ObservableConsoleView, PyCodeExecutor {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(PythonConsoleView.class);
|
||||
|
||||
private final Project myProject;
|
||||
private PydevConsoleExecuteActionHandler myExecuteActionHandler;
|
||||
private PyConsoleSourceHighlighter mySourceHighlighter;
|
||||
private boolean myIsIPythonOutput = false;
|
||||
private boolean myIsIPythonOutput;
|
||||
private final PyHighlighter myPyHighlighter;
|
||||
private final EditorColorsScheme myScheme;
|
||||
private boolean myHyperlink;
|
||||
|
||||
private final LanguageConsoleImpl myLanguageConsoleView;
|
||||
|
||||
private Disposable mySplitDisposable;
|
||||
private XStandaloneVariablesView mySplitView;
|
||||
|
||||
public PythonConsoleView(final Project project, final String title, final Sdk sdk) {
|
||||
super(new BorderLayout());
|
||||
super(project, title, PythonLanguage.getInstance());
|
||||
|
||||
myLanguageConsoleView = new LanguageConsoleImpl(project, title, PythonLanguage.getInstance());
|
||||
myLanguageConsoleView.getVirtualFile().putUserData(LanguageLevel.KEY, PythonSdkType.getLanguageLevelForSdk(sdk));
|
||||
getVirtualFile().putUserData(LanguageLevel.KEY, PythonSdkType.getLanguageLevelForSdk(sdk));
|
||||
// Mark editor as console one, to prevent autopopup completion
|
||||
myLanguageConsoleView.getConsoleEditor().putUserData(PythonConsoleAutopopupBlockingHandler.REPL_KEY, new Object());
|
||||
getConsoleEditor().putUserData(PythonConsoleAutopopupBlockingHandler.REPL_KEY, new Object());
|
||||
|
||||
Disposer.register(this, myLanguageConsoleView);
|
||||
|
||||
add(myLanguageConsoleView.getComponent(), BorderLayout.CENTER);
|
||||
|
||||
addSaveContentFocusListener(getLanguageConsole().getConsoleEditor().getContentComponent());
|
||||
|
||||
getPythonLanguageConsole().setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
|
||||
myLanguageConsoleView.setUpdateFoldingsEnabled(false);
|
||||
myProject = project;
|
||||
setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
|
||||
setUpdateFoldingsEnabled(false);
|
||||
//noinspection ConstantConditions
|
||||
myPyHighlighter = new PyHighlighter(
|
||||
sdk != null && sdk.getVersionString() != null ? LanguageLevel.fromPythonVersion(sdk.getVersionString()) : LanguageLevel.getDefault());
|
||||
myScheme = getPythonLanguageConsole().getConsoleEditor().getColorsScheme();
|
||||
myScheme = getConsoleEditor().getColorsScheme();
|
||||
}
|
||||
|
||||
public void setConsoleCommunication(final ConsoleCommunication communication) {
|
||||
getPythonLanguageConsole().getFile().putCopyableUserData(PydevConsoleRunner.CONSOLE_KEY, communication);
|
||||
getFile().putCopyableUserData(PydevConsoleRunner.CONSOLE_KEY, communication);
|
||||
}
|
||||
|
||||
public void setExecutionHandler(@NotNull PydevConsoleExecuteActionHandler consoleExecuteActionHandler) {
|
||||
myExecuteActionHandler = consoleExecuteActionHandler;
|
||||
}
|
||||
|
||||
private void addSaveContentFocusListener(JComponent component) {
|
||||
component.addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
if (GeneralSettings.getInstance().isSaveOnFrameDeactivation()) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
IdeFocusManager.findInstance().requestFocus(getPythonLanguageConsole().getConsoleEditor().getContentComponent(), true);
|
||||
}
|
||||
|
||||
private LanguageConsole getPythonLanguageConsole() {
|
||||
return getLanguageConsole();
|
||||
}
|
||||
|
||||
public LanguageConsole getLanguageConsole() {
|
||||
return myLanguageConsoleView.getConsole();
|
||||
IdeFocusManager.findInstance().requestFocus(getConsoleEditor().getContentComponent(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +135,7 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
}
|
||||
|
||||
private void showConsole(@NotNull Runnable runnable) {
|
||||
PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(myProject);
|
||||
PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(getProject());
|
||||
if (toolWindow != null && !toolWindow.getToolWindow().isVisible() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
toolWindow.getToolWindow().activate(runnable);
|
||||
}
|
||||
@@ -199,13 +154,13 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String text = getPythonLanguageConsole().getConsoleEditor().getDocument().getText();
|
||||
String text = getConsoleEditor().getDocument().getText();
|
||||
|
||||
getPythonLanguageConsole().setInputText(code);
|
||||
myExecuteActionHandler.runExecuteAction(myLanguageConsoleView);
|
||||
setInputText(code);
|
||||
myExecuteActionHandler.runExecuteAction(PythonConsoleView.this);
|
||||
|
||||
if (!StringUtil.isEmpty(text)) {
|
||||
getPythonLanguageConsole().setInputText(text);
|
||||
setInputText(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -220,10 +175,6 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
print(text, outputTypeForAttributes(attributes));
|
||||
}
|
||||
|
||||
public void printText(String text, final ConsoleViewContentType outputType) {
|
||||
myLanguageConsoleView.print(text, outputType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(@NotNull String text, @NotNull final ConsoleViewContentType outputType) {
|
||||
detectIPython(text, outputType);
|
||||
@@ -241,7 +192,7 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
}
|
||||
else {
|
||||
//Print text normally with converted attributes
|
||||
myLanguageConsoleView.print(text, outputType);
|
||||
super.print(text, outputType);
|
||||
}
|
||||
myHyperlink = detectHyperlink(text);
|
||||
if (mySourceHighlighter == null && myIsIPythonOutput && PyConsoleUtil.detectSourcePrinting(text)) {
|
||||
@@ -259,94 +210,17 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
myLanguageConsoleView.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollTo(int offset) {
|
||||
myLanguageConsoleView.scrollTo(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachToProcess(ProcessHandler processHandler) {
|
||||
myLanguageConsoleView.attachToProcess(processHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputPaused(boolean value) {
|
||||
myLanguageConsoleView.setOutputPaused(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutputPaused() {
|
||||
return myLanguageConsoleView.isOutputPaused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDeferredOutput() {
|
||||
return myLanguageConsoleView.hasDeferredOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performWhenNoDeferredOutput(Runnable runnable) {
|
||||
myLanguageConsoleView.performWhenNoDeferredOutput(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelpId(String helpId) {
|
||||
myLanguageConsoleView.setHelpId(helpId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageFilter(Filter filter) {
|
||||
myLanguageConsoleView.addMessageFilter(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHyperlink(String hyperlinkText, HyperlinkInfo info) {
|
||||
myLanguageConsoleView.printHyperlink(hyperlinkText, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentSize() {
|
||||
return myLanguageConsoleView.getContentSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPause() {
|
||||
return myLanguageConsoleView.canPause();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] createConsoleActions() {
|
||||
return myLanguageConsoleView.createConsoleActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allowHeavyFilters() {
|
||||
myLanguageConsoleView.allowHeavyFilters();
|
||||
}
|
||||
|
||||
public void detectIPython(String text, final ConsoleViewContentType outputType) {
|
||||
VirtualFile file = getConsoleVirtualFile();
|
||||
if (file != null) {
|
||||
if (PyConsoleUtil.detectIPythonImported(text, outputType)) {
|
||||
PyConsoleUtil.markIPython(file);
|
||||
}
|
||||
if (PyConsoleUtil.detectIPythonAutomagicOn(text)) {
|
||||
PyConsoleUtil.setIPythonAutomagic(file, true);
|
||||
}
|
||||
if (PyConsoleUtil.detectIPythonAutomagicOff(text)) {
|
||||
PyConsoleUtil.setIPythonAutomagic(file, false);
|
||||
}
|
||||
VirtualFile file = getVirtualFile();
|
||||
if (PyConsoleUtil.detectIPythonImported(text, outputType)) {
|
||||
PyConsoleUtil.markIPython(file);
|
||||
}
|
||||
if (PyConsoleUtil.detectIPythonAutomagicOn(text)) {
|
||||
PyConsoleUtil.setIPythonAutomagic(file, true);
|
||||
}
|
||||
if (PyConsoleUtil.detectIPythonAutomagicOff(text)) {
|
||||
PyConsoleUtil.setIPythonAutomagic(file, false);
|
||||
}
|
||||
}
|
||||
|
||||
public VirtualFile getConsoleVirtualFile() {
|
||||
return getLanguageConsole().getFile().getVirtualFile();
|
||||
}
|
||||
|
||||
private boolean detectHyperlink(@NotNull String text) {
|
||||
@@ -358,12 +232,12 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(text.trim());
|
||||
|
||||
if (vFile != null) {
|
||||
OpenFileHyperlinkInfo hyperlink = new OpenFileHyperlinkInfo(myProject, vFile, -1);
|
||||
OpenFileHyperlinkInfo hyperlink = new OpenFileHyperlinkInfo(getProject(), vFile, -1);
|
||||
|
||||
myLanguageConsoleView.printHyperlink(text, hyperlink);
|
||||
super.printHyperlink(text, hyperlink);
|
||||
}
|
||||
else {
|
||||
myLanguageConsoleView.print(text, contentType);
|
||||
super.print(text, contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,44 +258,12 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
}
|
||||
|
||||
public void setSdk(Sdk sdk) {
|
||||
getPythonLanguageConsole().getFile().putCopyableUserData(PydevConsoleRunner.CONSOLE_SDK, sdk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusableComponent() {
|
||||
return myLanguageConsoleView.getPreferredFocusableComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
Disposer.dispose(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChangeListener(@NotNull ChangeListener listener, @NotNull Disposable parent) {
|
||||
myLanguageConsoleView.addChangeListener(listener, parent);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LanguageConsole getConsole() {
|
||||
return myLanguageConsoleView.getConsole();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
getFile().putCopyableUserData(PydevConsoleRunner.CONSOLE_SDK, sdk);
|
||||
}
|
||||
|
||||
public void showVariables(PydevConsoleCommunication consoleCommunication) {
|
||||
PyStackFrame stackFrame = new PyStackFrame(myProject, consoleCommunication, new PyStackFrameInfo("", "", "", null), null);
|
||||
final XStandaloneVariablesView view = new XStandaloneVariablesView(myProject, new PyDebuggerEditorsProvider(), stackFrame);
|
||||
PyStackFrame stackFrame = new PyStackFrame(getProject(), consoleCommunication, new PyStackFrameInfo("", "", "", null), null);
|
||||
final XStandaloneVariablesView view = new XStandaloneVariablesView(getProject(), new PyDebuggerEditorsProvider(), stackFrame);
|
||||
consoleCommunication.addCommunicationListener(new ConsoleCommunicationListener() {
|
||||
@Override
|
||||
public void commandExecuted(boolean more) {
|
||||
@@ -432,30 +274,33 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
public void inputRequested() {
|
||||
}
|
||||
});
|
||||
splitWindow(view.getPanel(), view);
|
||||
mySplitView = view;
|
||||
Disposer.register(this, view);
|
||||
splitWindow();
|
||||
}
|
||||
|
||||
private void splitWindow(JComponent component, Disposable componentDisposable) {
|
||||
private void splitWindow() {
|
||||
Component console = getComponent(0);
|
||||
removeAll();
|
||||
JSplitPane p = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||
p.add(myLanguageConsoleView.getComponent(), JSplitPane.LEFT);
|
||||
mySplitDisposable = componentDisposable;
|
||||
p.add(component, JSplitPane.RIGHT);
|
||||
p.setBorder(BorderFactory.createEmptyBorder());
|
||||
p.add(console, JSplitPane.LEFT);
|
||||
p.add(mySplitView.getPanel(), JSplitPane.RIGHT);
|
||||
p.setDividerLocation((int)getSize().getWidth() * 2 / 3);
|
||||
add(p, BorderLayout.CENTER);
|
||||
|
||||
validate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void restoreWindow() {
|
||||
JSplitPane pane = (JSplitPane)getComponent(0);
|
||||
removeAll();
|
||||
add(myLanguageConsoleView.getComponent(), BorderLayout.CENTER);
|
||||
if (mySplitView != null) {
|
||||
Disposer.dispose(mySplitView);
|
||||
mySplitView = null;
|
||||
}
|
||||
add(pane.getLeftComponent(), BorderLayout.CENTER);
|
||||
validate();
|
||||
repaint();
|
||||
if (mySplitDisposable != null) {
|
||||
Disposer.dispose(mySplitDisposable);
|
||||
mySplitDisposable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.execution.console.DuplexConsoleView;
|
||||
import com.intellij.execution.console.LanguageConsole;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
@@ -70,10 +69,9 @@ public class PythonDebugLanguageConsoleView extends DuplexConsoleView<ConsoleVie
|
||||
super.enableConsole(primary);
|
||||
|
||||
if (!primary && !isPrimaryConsoleEnabled()) {
|
||||
PythonConsoleView pydevConsoleView = getPydevConsoleView();
|
||||
LanguageConsole languageConsole = pydevConsoleView.getConsole();
|
||||
PythonConsoleView console = getPydevConsoleView();
|
||||
|
||||
IdeFocusManager.findInstance().requestFocus(languageConsole.getConsoleEditor().getContentComponent(), true);
|
||||
IdeFocusManager.findInstance().requestFocus(console.getConsoleEditor().getContentComponent(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class PythonScriptCommandLineState extends PythonCommandLineState {
|
||||
@Override
|
||||
protected void createContentDescriptorAndActions() {
|
||||
AnAction a = createConsoleExecAction(myConsoleExecuteActionHandler);
|
||||
registerActionShortcuts(Lists.newArrayList(a), getConsoleView().getConsole().getConsoleEditor().getComponent());
|
||||
registerActionShortcuts(Lists.newArrayList(a), getConsoleView().getConsoleEditor().getComponent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public class IPythonConsoleTest extends PyEnvTestCase {
|
||||
public void run() {
|
||||
PsiFile psi =
|
||||
PsiDocumentManager.getInstance(getProject())
|
||||
.getPsiFile(getConsoleView().getLanguageConsole().getConsoleEditor().getDocument());
|
||||
.getPsiFile(getConsoleView().getConsoleEditor().getDocument());
|
||||
Assert.assertThat("No errors expected", getErrors(psi), Matchers.empty());
|
||||
}
|
||||
});
|
||||
@@ -76,7 +76,7 @@ public class IPythonConsoleTest extends PyEnvTestCase {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiFile psi =
|
||||
PsiDocumentManager.getInstance(getProject()).getPsiFile(getConsoleView().getLanguageConsole().getConsoleEditor().getDocument());
|
||||
PsiDocumentManager.getInstance(getProject()).getPsiFile(getConsoleView().getConsoleEditor().getDocument());
|
||||
//TreeUtil.ensureParsed(psi.getNode());
|
||||
assertTrue(PsiTreeUtil.hasErrorElements(psi));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask {
|
||||
|
||||
@NotNull
|
||||
protected String output() {
|
||||
return myConsoleView.getConsole().getHistoryViewer().getDocument().getText();
|
||||
return myConsoleView.getHistoryViewer().getDocument().getText();
|
||||
}
|
||||
|
||||
public void setProcessCanTerminate(boolean processCanTerminate) {
|
||||
@@ -364,7 +364,7 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getConsoleView().getLanguageConsole().setInputText(text);
|
||||
getConsoleView().setInputText(text);
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user