show Kotlin bytecode by explicit request, rather than always
This commit is contained in:
@@ -105,6 +105,11 @@
|
|||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
<action id="ShowKotlinBytecode" class="org.jetbrains.kotlin.idea.actions.ShowKotlinBytecodeAction"
|
||||||
|
text="Show Kotlin Bytecode">
|
||||||
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
|
</action>
|
||||||
|
|
||||||
<action id="ExtractFunction" class="org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ExtractFunctionAction"
|
<action id="ExtractFunction" class="org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ExtractFunctionAction"
|
||||||
text="_Function..." use-shortcut-of="ExtractMethod">
|
text="_Function..." use-shortcut-of="ExtractMethod">
|
||||||
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="ExtractMethod"/>
|
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="ExtractMethod"/>
|
||||||
@@ -499,13 +504,6 @@
|
|||||||
|
|
||||||
<exceptionFilter implementation="org.jetbrains.kotlin.idea.filters.JetExceptionFilterFactory" order="first"/>
|
<exceptionFilter implementation="org.jetbrains.kotlin.idea.filters.JetExceptionFilterFactory" order="first"/>
|
||||||
|
|
||||||
<toolWindow id="Kotlin Bytecode"
|
|
||||||
factoryClass="org.jetbrains.kotlin.idea.internal.KotlinBytecodeToolWindow$Factory"
|
|
||||||
anchor="right"
|
|
||||||
icon="/org/jetbrains/kotlin/idea/icons/kotlin13.png"
|
|
||||||
canCloseContents="true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<applicationService serviceInterface="org.jetbrains.kotlin.idea.editor.JetEditorOptions"
|
<applicationService serviceInterface="org.jetbrains.kotlin.idea.editor.JetEditorOptions"
|
||||||
serviceImplementation="org.jetbrains.kotlin.idea.editor.JetEditorOptions"/>
|
serviceImplementation="org.jetbrains.kotlin.idea.editor.JetEditorOptions"/>
|
||||||
<editorAppearanceConfigurable instance="org.jetbrains.kotlin.idea.editor.JetSettingEditorConfigurable"/>
|
<editorAppearanceConfigurable instance="org.jetbrains.kotlin.idea.editor.JetSettingEditorConfigurable"/>
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 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 org.jetbrains.kotlin.idea.actions
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||||
|
import com.intellij.openapi.util.IconLoader
|
||||||
|
import com.intellij.openapi.wm.ToolWindowAnchor
|
||||||
|
import com.intellij.openapi.wm.ToolWindowManager
|
||||||
|
import com.intellij.ui.content.ContentFactory
|
||||||
|
import org.jetbrains.kotlin.idea.JetFileType
|
||||||
|
import org.jetbrains.kotlin.idea.internal.KotlinBytecodeToolWindow
|
||||||
|
|
||||||
|
public class ShowKotlinBytecodeAction(): AnAction() {
|
||||||
|
val TOOLWINDOW_ID = "Kotlin Bytecode"
|
||||||
|
|
||||||
|
override fun actionPerformed(e: AnActionEvent) {
|
||||||
|
val project = e.getProject() ?: return
|
||||||
|
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||||
|
|
||||||
|
var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID)
|
||||||
|
if (toolWindow == null) {
|
||||||
|
toolWindow = toolWindowManager.registerToolWindow("Kotlin Bytecode", true, ToolWindowAnchor.RIGHT)
|
||||||
|
toolWindow.setIcon(IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin13.png"))
|
||||||
|
|
||||||
|
val contentManager = toolWindow.getContentManager()
|
||||||
|
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||||
|
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, toolWindow), "", false))
|
||||||
|
}
|
||||||
|
toolWindow?.activate(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun update(e: AnActionEvent) {
|
||||||
|
val file = e.getData(CommonDataKeys.PSI_FILE)
|
||||||
|
e.getPresentation().setEnabled(e.getProject() != null && file?.getFileType() == JetFileType.INSTANCE)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,8 +31,6 @@ import com.intellij.openapi.util.Pair;
|
|||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.wm.ToolWindow;
|
import com.intellij.openapi.wm.ToolWindow;
|
||||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||||
import com.intellij.ui.content.ContentFactory;
|
|
||||||
import com.intellij.ui.content.ContentManager;
|
|
||||||
import com.intellij.util.Alarm;
|
import com.intellij.util.Alarm;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
||||||
@@ -362,14 +360,4 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
|
|||||||
public void dispose() {
|
public void dispose() {
|
||||||
EditorFactory.getInstance().releaseEditor(myEditor);
|
EditorFactory.getInstance().releaseEditor(myEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Factory implements ToolWindowFactory {
|
|
||||||
@Override
|
|
||||||
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
|
|
||||||
ContentManager contentManager = toolWindow.getContentManager();
|
|
||||||
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
|
|
||||||
contentManager.addContent(contentFactory.createContent(
|
|
||||||
new KotlinBytecodeToolWindow(project, toolWindow), "", false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user