Skip to content

Commit

Permalink
Change to a LanguageConsole to restore command history.
Browse files Browse the repository at this point in the history
It's a bit of a kludge: the language is 'Plain Text'. But this seems like the path of least resistance. No autocompletion provided: that's a much bigger job.

Requires IDEA 11 (Nika), so bumping the version to 1.4.0-SNAPSHOT and branching
until I release 1.3.2 from master.

Update the release notes accordingly.

Fixes #42, References #33
  • Loading branch information
retronym committed Nov 12, 2011
1 parent ead8117 commit e5c6506
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 71 deletions.
6 changes: 2 additions & 4 deletions .idea/misc.xml
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>net.orfjackal.idea-sbt-plugin</groupId>
<artifactId>sbt</artifactId>
<version>1.3.2-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand All @@ -19,10 +19,12 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- The maven-assembly-plugin will fail to find all dependencies unless these are set to proper values.
If you need to build this project on your own computer, please override these values in your settings.xml
or at least do not commit any changes to this part of the POM. -->
<idea.version>103.255</idea.version>
<idea.home>C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 10.0.3</idea.home>
If you need to build this project on your own computer, please override these values on the
command line with -Didea.home=...
Do not commit any changes to this part of the POM. -->
<idea.version>110.187</idea.version>
<idea.home>/Applications/Nika-IU-110.187.app</idea.home>
</properties>

<name>SBT</name>
Expand Down
2 changes: 1 addition & 1 deletion sbt-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.orfjackal.idea-sbt-plugin</groupId>
<artifactId>sbt</artifactId>
<version>1.3.2-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
</parent>

<artifactId>sbt-dist</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sbt-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.orfjackal.idea-sbt-plugin</groupId>
<artifactId>sbt</artifactId>
<version>1.3.2-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
</parent>

<artifactId>sbt-plugin</artifactId>
Expand Down
43 changes: 32 additions & 11 deletions sbt-plugin/src/main/java/net/orfjackal/sbt/plugin/SbtConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@

package net.orfjackal.sbt.plugin;

import com.intellij.execution.console.ConsoleHistoryController;
import com.intellij.execution.console.LanguageConsoleImpl;
import com.intellij.execution.console.LanguageConsoleViewImpl;
import com.intellij.execution.filters.*;
import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.impl.EditorHyperlinkSupport;
import com.intellij.execution.process.*;
import com.intellij.execution.runners.AbstractConsoleRunnerWithHistory;
import com.intellij.execution.runners.ConsoleExecuteActionHandler;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.ide.CommonActionsManager;
import com.intellij.lang.Language;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
Expand Down Expand Up @@ -50,19 +60,30 @@ public SbtConsole(String title, Project project, SbtRunnerComponent runnerCompon
}

private static ConsoleView createConsoleView(Project project) {
return createConsoleBuilder(project).getConsole();
}
final LanguageConsoleImpl sbtLanguageConsole = new LanguageConsoleImpl(project, "SBT", StdLanguages.TEXT);
LanguageConsoleViewImpl consoleView = new LanguageConsoleViewImpl(project, sbtLanguageConsole) {
@Override
public void attachToProcess(ProcessHandler processHandler) {
super.attachToProcess(processHandler);
ConsoleExecuteActionHandler executeActionHandler = new ConsoleExecuteActionHandler(processHandler, false);
// SBT echos the command, don't add it to the output a second time.
executeActionHandler.setAddCurrentToHistory(false);
ConsoleHistoryController historyController = new ConsoleHistoryController("scala", null, sbtLanguageConsole, executeActionHandler.getConsoleHistoryModel());
historyController.install();
AnAction action = AbstractConsoleRunnerWithHistory.createConsoleExecAction(sbtLanguageConsole, processHandler, executeActionHandler);
action.registerCustomShortcutSet(action.getShortcutSet(), sbtLanguageConsole.getComponent());
}

public static TextConsoleBuilder createConsoleBuilder(Project project) {
TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
};
addFilters(project, consoleView);

final SbtColorizerFilter logLevelFilter = new SbtColorizerFilter();
final ExceptionFilter exceptionFilter = new ExceptionFilter(GlobalSearchScope.allScope(project));
final RegexpFilter regexpFilter = new RegexpFilter(project, CONSOLE_FILTER_REGEXP);
for (Filter filter : Arrays.asList(exceptionFilter, regexpFilter, logLevelFilter)) {
builder.addFilter(filter);
}
return builder;
return consoleView;
}

private static void addFilters(Project project, LanguageConsoleViewImpl consoleView) {
consoleView.addMessageFilter(new ExceptionFilter(GlobalSearchScope.allScope(project)));
consoleView.addMessageFilter(new RegexpFilter(project, CONSOLE_FILTER_REGEXP));
consoleView.addMessageFilter(new SbtColorizerFilter());
}

public boolean isFinished() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SbtRunnerComponent extends AbstractProjectComponent implements Dumb

private SbtRunner sbt;
private SbtConsole console;
private Project project;
private final SbtProjectSettingsComponent projectSettings;
private final SbtApplicationSettingsComponent applicationSettings;

Expand All @@ -44,9 +45,9 @@ protected SbtRunnerComponent(Project project,
SbtProjectSettingsComponent projectSettings,
SbtApplicationSettingsComponent applicationSettings) {
super(project);
this.project = project;
this.projectSettings = projectSettings;
this.applicationSettings = applicationSettings;
console = createConsole(project);
}

public CompletionSignal executeInBackground(final String action) {
Expand Down Expand Up @@ -79,6 +80,7 @@ public void projectOpened() {
final StartupManager manager = StartupManager.getInstance(myProject);
manager.registerPostStartupActivity(new DumbAwareRunnable() {
public void run() {
console = createConsole(project);
registerToolWindow();
}
});
Expand Down
61 changes: 13 additions & 48 deletions sbt-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,32 @@
<id>${plugin.id}</id>
<name>${plugin.name}</name>
<version>${project.version}</version>
<idea-version since-build="103.255"/>
<idea-version since-build="110.187"/>
<category>Build</category>

<vendor url="http://www.orfjackal.net">Esko Luontola</vendor>

<description><![CDATA[
Integrates with Simple Build Tool (SBT) to enable building Scala projects easily and quickly.
<a href="https://github.com/orfjackal/idea-sbt-plugin/wiki">Documentation, Screenshots</a>
<p>
<ol>
<dt><b>Quick Start</b></dt>
<li>Create IDEA Project files from SBT build (see below)</li>
<li>Check that "Settings / SBT" has the right "sbt-launch.jar" file configured</li>
<li>Open the SBT Console Tool Window, manually enter SBT commands</li>
<li>Go to the "Before Launch" options of a Run Configuration (including the Default Run Configuration),
uncheck "Make" and choose "Run SBT Action / test-compile"
</li>
<li>Now when you run it, the project will be compiled using SBT</li>
</ol>
<ol>
<dt><b>Hints</b></dt>
<li>Compatible with <a href="http://code.google.com/p/simple-build-tool/wiki/DocumentationHome">SBT 0.7.x</a>
and <a href="https://github.com/harrah/xsbt/wiki">SBT 0.10.x</a>, just choose the suitable launcher JAR.</li>
<li>You can run multiple actions as a pre-run step, e.g. ";test-compile;jetty-run"</li>
<li>For SBT 0.10.x, use either "products" or "test:products" as the pre-run step.
This compiles sources and copies resources.
</li>
<li>In a multi-project SBT build, you can choose "Run in current module" to limit the "Before Launch"
action to the current module. This speeds up the build.
</li>
</ol>
<ol>
<dt><b>Creating/Updating IDEA project files (SBT 0.10.x)</b></dt>
<li>(One time) Install sbt-idea from the
<a href="https://github.com/harrah/xsbt/wiki/sbt-0.10-plugins-list">SBT 0.10.x Plugins Page</a>
as an SBT Plugin.
</li>
<li>From a terminal, run <code>sbt gen-idea</code></li>
<li>This creates a .idea and .idea_modules folder with project configuration. Open the project with IDEA.
</li>
<li>After each change to your dependencies, run <code>gen-idea</code> in the SBT Console.
When prompted, reload the project.
</li>
</ol>
<ol>
<dt><b>Creating/Updating IDEA project files (SBT 0.7.x)</b></dt>
<li>(One time) Install <a href="https://github.com/mpeltonen/sbt-idea">sbt-idea</a> as an SBT Processor.</li>
<li>From a terminal, run <code>sbt update idea</code></li>
<li>This creates a .idea folder with project configuration. Open the project with IDEA.</li>
<li>After each change to your dependencies, run <code>update idea</code> in the SBT Console.
When prompted, reload the project.
</li>
</ol>
Offers a console where SBT commands can be entered interactively, and a Before Run task
to delegate project compilation to SBT, as an alternative to the built in IntelliJ Make.
<p>
<a href="https://github.com/orfjackal/idea-sbt-plugin/wiki">Documentation, Screenshots</a>
]]></description>
<change-notes><![CDATA[
<ul>
<dt><b>1.4.0 (in progress)</b></dt>
<li>Require IntelliJ 11 (Nika)</li>
<li>Change UI for the console to use a 'Language Console' <a href="https://github.com/orfjackal/idea-sbt-plugin/issues/42">#42</a></li>
<dt><b>1.3.1 (2011-09-22)</b></dt>
<li>Compability with IDEA 11</li>
<dt><b>1.3.0 (2011-06-25)</b></dt>
<li>Workaround IDEA 10.5 Bug that corrupted text entry after a CR was output</li>
<li>Allow use of the SBT Console during re-indexing</li>
Expand Down

0 comments on commit e5c6506

Please sign in to comment.