Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support and require IDEA 13.1 #90

Merged
merged 4 commits into from May 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -23,7 +23,7 @@ Please reports issues to the GitHub issue tracker

To build the project:

% mvn -Didea.home="/Applications/Idea 12.app" install
% mvn -Didea.home="/Applications/IntelliJ Idea 13.1.app" install
% ls -la sbt-dist/target/idea-sbt-plugin-*.zip # File, Settings, Plugins, Install from Disk

You can also open this project in IntelliJ. Point the Project SDK to an IntelliJ Plugin SDK,
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@

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

<modules>
Expand Down
2 changes: 1 addition & 1 deletion sbt-dist/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.orfjackal.idea-sbt-plugin</groupId>
<artifactId>sbt</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>sbt-dist</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sbt-plugin/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.orfjackal.idea-sbt-plugin</groupId>
<artifactId>sbt</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>

<artifactId>sbt-plugin</artifactId>
Expand Down
66 changes: 27 additions & 39 deletions sbt-plugin/src/main/java/net/orfjackal/sbt/plugin/SbtConsole.java
Expand Up @@ -4,25 +4,19 @@

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.console.*;
import com.intellij.execution.filters.*;
import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.process.ConsoleHistoryModel;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.AbstractConsoleRunnerWithHistory;
import com.intellij.execution.runners.ConsoleExecuteActionHandler;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.command.impl.UndoManagerImpl;
import com.intellij.openapi.command.undo.DocumentReferenceManager;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.ScrollingModel;
Expand All @@ -35,24 +29,24 @@
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.ui.components.JBScrollBar;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.intellij.util.ui.ButtonlessScrollBarUI;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.ui.UIUtil;
import net.orfjackal.sbt.plugin.sbtlang.SbtFileType;
import net.orfjackal.sbt.plugin.sbtlang.SbtLanguage;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;

public class SbtConsole {
Expand Down Expand Up @@ -126,42 +120,36 @@ public void runExecuteAction(LanguageConsoleImpl languageConsole) {
EditorEx consoleEditor = languageConsole.getConsoleEditor();
consoleEditor.setCaretEnabled(false);

//
// COPY PASTED from base class to use custom history model.
//

// process input and add to history
Document document = languageConsole.getCurrentEditor().getDocument();
String text = document.getText();
TextRange range = new TextRange(0, document.getTextLength());

languageConsole.getCurrentEditor().getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset());

if (true /*myAddCurrentToHistory*/) {
languageConsole.addCurrentToHistory(range, false, false);
}

languageConsole.setInputText("");

UndoManager manager = UndoManager.getInstance(languageConsole.getProject());
((UndoManagerImpl)manager).invalidateActionsFor(DocumentReferenceManager.getInstance().create(document));

myConsoleHistoryModel.addToHistory(text);
// execute(text);
processLine(text);

//
// END COPY/PASTE
//
super.runExecuteAction(languageConsole);

// hide the prompts until the command has completed.
languageConsole.setPrompt(" ");
}
consoleEditor.setCaretEnabled(true);
}
protected void execute(@NotNull String text, @NotNull LanguageConsoleView console) {
EditorEx consoleEditor = console.getConsole().getConsoleEditor();
consoleEditor.setCaretEnabled(false);
super.execute(text, console);
// hide the prompts until the command has completed.
console.getConsole().setPrompt(" ");
consoleEditor.setCaretEnabled(true);
}

};
// SBT echos the command, don't add it to the output a second time.
executeActionHandler.setAddCurrentToHistory(true);
AnAction action = AbstractConsoleRunnerWithHistory.createConsoleExecAction(sbtLanguageConsole, processHandler, executeActionHandler);
try {
java.util.List<Field> fields = ReflectionUtil.collectFields(executeActionHandler.getClass());
for (Field field : fields) {
if (field.getType() == ConsoleHistoryModel.class) {
field.setAccessible(true);
field.set(executeActionHandler, myConsoleHistoryModel);
}
}
} catch (Exception err) {
logger.warn("Unable to reflectively set field in " + executeActionHandler.getClass() + ", history in the SBT console may not work.", err);
}
AnAction action = new ConsoleExecuteAction(this, executeActionHandler);
action.registerCustomShortcutSet(action.getShortcutSet(), sbtLanguageConsole.getComponent());
}

Expand Down
5 changes: 4 additions & 1 deletion sbt-plugin/src/main/resources/META-INF/plugin.xml
Expand Up @@ -4,7 +4,7 @@
<id>SBT</id>
<name>SBT</name>
<version>${project.version}</version>
<idea-version since-build="122.327"/>
<idea-version since-build="135.690"/>
<category>Build</category>

<vendor url="http://www.orfjackal.net">Esko Luontola</vendor>
Expand All @@ -23,6 +23,9 @@
<change-notes><![CDATA[
<ul>

<dt><b>1.6.0 (2014-05-17)</b></dt>
<li>Require IntelliJ IDEA 13.1 (Cardea)</li>

<dt><b>1.5.1 (2013-10-17)</b></dt>
<li>Compatibility with IntelliJ IDEA 13 (Cardea)</li>

Expand Down