Switch to 201 platform
This commit is contained in:
@@ -30,15 +30,18 @@ class ShowKotlinBytecodeAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID)
|
||||
if (toolWindow == null) {
|
||||
toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT)
|
||||
toolWindow.icon = KotlinIcons.SMALL_LOGO_13
|
||||
|
||||
val contentManager = toolWindow.contentManager
|
||||
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, toolWindow), "", false))
|
||||
}
|
||||
val toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID) ?: toolWindowManager.registerToolWindow(
|
||||
TOOLWINDOW_ID,
|
||||
false,
|
||||
ToolWindowAnchor.RIGHT,
|
||||
)
|
||||
.apply {
|
||||
setIcon(KotlinIcons.SMALL_LOGO_13)
|
||||
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, this), "", false))
|
||||
}
|
||||
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
|
||||
|
||||
+8
-11
@@ -30,18 +30,15 @@ class ShowKotlinBytecodeAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID)
|
||||
if (toolWindow == null) {
|
||||
toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT)
|
||||
toolWindow.icon = KotlinIcons.SMALL_LOGO_13
|
||||
|
||||
val toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID) ?: toolWindowManager.registerToolWindow(
|
||||
TOOLWINDOW_ID,
|
||||
false,
|
||||
ToolWindowAnchor.RIGHT,
|
||||
)
|
||||
.apply {
|
||||
setIcon(KotlinIcons.SMALL_LOGO_13)
|
||||
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, this), "", false))
|
||||
}
|
||||
|
||||
val contentManager = toolWindow.contentManager
|
||||
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, toolWindow), "", false))
|
||||
}
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
|
||||
+32
-42
@@ -20,12 +20,12 @@ import com.intellij.execution.filters.OpenFileHyperlinkInfo
|
||||
import com.intellij.execution.impl.ConsoleViewImpl
|
||||
import com.intellij.execution.runners.ExecutionUtil
|
||||
import com.intellij.execution.ui.ConsoleViewContentType
|
||||
import com.intellij.ide.scratch.ScratchFileType
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.TransactionGuard
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.wm.ToolWindow
|
||||
@@ -113,8 +113,8 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
OpenFileHyperlinkInfo(
|
||||
project,
|
||||
psiFile.virtualFile,
|
||||
expression.lineStart,
|
||||
),
|
||||
expression.lineStart
|
||||
)
|
||||
)
|
||||
print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
toolWindow.show(null)
|
||||
}
|
||||
|
||||
toolWindow.icon = ExecutionUtil.getLiveIndicator(scratchIcon())
|
||||
toolWindow.setIcon(ExecutionUtil.getLiveIndicator(ScratchFileType.INSTANCE.icon))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
toolWindow.hide(null)
|
||||
}
|
||||
|
||||
toolWindow.icon = scratchIcon()
|
||||
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon is expected to be present"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,22 +187,18 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
val project = file.project
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
toolWindowManager.registerToolWindow(ScratchToolWindowFactory.ID, true, ToolWindowAnchor.BOTTOM)
|
||||
val window = toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID)
|
||||
val window =
|
||||
toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID) ?: error("ScratchToolWindowFactory.ID should be registered")
|
||||
ScratchToolWindowFactory().createToolWindowContent(project, window)
|
||||
|
||||
Disposer.register(
|
||||
parentDisposable,
|
||||
Disposable {
|
||||
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
||||
},
|
||||
)
|
||||
Disposer.register(parentDisposable, Disposable {
|
||||
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
||||
})
|
||||
|
||||
return window
|
||||
}
|
||||
}
|
||||
|
||||
private fun scratchIcon() = PlainTextFileType.INSTANCE.icon
|
||||
|
||||
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
|
||||
"${psiFile.name}:${expression.lineStart + 1}"
|
||||
|
||||
@@ -213,8 +209,8 @@ private class ScratchToolWindowFactory : ToolWindowFactory {
|
||||
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val consoleView = ConsoleViewImpl(project, true)
|
||||
toolWindow.isToHideOnEmptyContent = true
|
||||
toolWindow.icon = scratchIcon()
|
||||
toolWindow.setToHideOnEmptyContent(true)
|
||||
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon should be present"))
|
||||
toolWindow.hide(null)
|
||||
|
||||
val contentManager = toolWindow.contentManager
|
||||
@@ -242,33 +238,27 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
||||
}
|
||||
|
||||
override fun onFinish(file: ScratchFile) {
|
||||
TransactionGuard.submitTransaction(
|
||||
file.project,
|
||||
Runnable {
|
||||
val psiFile = file.getPsiFile()
|
||||
?: error(
|
||||
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
||||
"project.isDisposed = ${file.project.isDisposed}\n" +
|
||||
"inlays = ${inlays.joinToString { it.second }}\n" +
|
||||
"errors = ${errors.joinToString()}",
|
||||
)
|
||||
TransactionGuard.submitTransaction(file.project, Runnable {
|
||||
val psiFile = file.getPsiFile()
|
||||
?: error(
|
||||
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
||||
"project.isDisposed = ${file.project.isDisposed}\n" +
|
||||
"inlays = ${inlays.joinToString { it.second }}\n" +
|
||||
"errors = ${errors.joinToString()}"
|
||||
)
|
||||
|
||||
if (inlays.isNotEmpty()) {
|
||||
testPrint(
|
||||
psiFile,
|
||||
inlays.map { (expression, text) ->
|
||||
"/** ${getLineInfo(psiFile, expression)} $text */"
|
||||
},
|
||||
)
|
||||
inlays.clear()
|
||||
}
|
||||
if (inlays.isNotEmpty()) {
|
||||
testPrint(psiFile, inlays.map { (expression, text) ->
|
||||
"/** ${getLineInfo(psiFile, expression)} $text */"
|
||||
})
|
||||
inlays.clear()
|
||||
}
|
||||
|
||||
if (errors.isNotEmpty()) {
|
||||
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
||||
errors.clear()
|
||||
}
|
||||
},
|
||||
)
|
||||
if (errors.isNotEmpty()) {
|
||||
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
||||
errors.clear()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun testPrint(file: PsiFile, comments: List<String>) {
|
||||
@@ -276,7 +266,7 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
||||
for (comment in comments) {
|
||||
file.addAfter(
|
||||
KtPsiFactory(file.project).createComment(comment),
|
||||
file.lastChild,
|
||||
file.lastChild
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+42
-32
@@ -20,12 +20,12 @@ import com.intellij.execution.filters.OpenFileHyperlinkInfo
|
||||
import com.intellij.execution.impl.ConsoleViewImpl
|
||||
import com.intellij.execution.runners.ExecutionUtil
|
||||
import com.intellij.execution.ui.ConsoleViewContentType
|
||||
import com.intellij.ide.scratch.ScratchFileType
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.TransactionGuard
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.wm.ToolWindow
|
||||
@@ -113,8 +113,8 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
OpenFileHyperlinkInfo(
|
||||
project,
|
||||
psiFile.virtualFile,
|
||||
expression.lineStart
|
||||
)
|
||||
expression.lineStart,
|
||||
),
|
||||
)
|
||||
print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
toolWindow.show(null)
|
||||
}
|
||||
|
||||
toolWindow.setIcon(ExecutionUtil.getLiveIndicator(ScratchFileType.INSTANCE.icon))
|
||||
toolWindow.icon = ExecutionUtil.getLiveIndicator(scratchIcon())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
toolWindow.hide(null)
|
||||
}
|
||||
|
||||
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon is expected to be present"))
|
||||
toolWindow.icon = scratchIcon()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,18 +187,22 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
||||
val project = file.project
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
toolWindowManager.registerToolWindow(ScratchToolWindowFactory.ID, true, ToolWindowAnchor.BOTTOM)
|
||||
val window =
|
||||
toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID) ?: error("ScratchToolWindowFactory.ID should be registered")
|
||||
val window = toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID)
|
||||
ScratchToolWindowFactory().createToolWindowContent(project, window)
|
||||
|
||||
Disposer.register(parentDisposable, Disposable {
|
||||
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
||||
})
|
||||
Disposer.register(
|
||||
parentDisposable,
|
||||
Disposable {
|
||||
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
||||
},
|
||||
)
|
||||
|
||||
return window
|
||||
}
|
||||
}
|
||||
|
||||
private fun scratchIcon() = PlainTextFileType.INSTANCE.icon
|
||||
|
||||
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
|
||||
"${psiFile.name}:${expression.lineStart + 1}"
|
||||
|
||||
@@ -209,8 +213,8 @@ private class ScratchToolWindowFactory : ToolWindowFactory {
|
||||
|
||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||
val consoleView = ConsoleViewImpl(project, true)
|
||||
toolWindow.setToHideOnEmptyContent(true)
|
||||
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon should be present"))
|
||||
toolWindow.isToHideOnEmptyContent = true
|
||||
toolWindow.icon = scratchIcon()
|
||||
toolWindow.hide(null)
|
||||
|
||||
val contentManager = toolWindow.contentManager
|
||||
@@ -238,27 +242,33 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
||||
}
|
||||
|
||||
override fun onFinish(file: ScratchFile) {
|
||||
TransactionGuard.submitTransaction(file.project, Runnable {
|
||||
val psiFile = file.getPsiFile()
|
||||
?: error(
|
||||
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
||||
"project.isDisposed = ${file.project.isDisposed}\n" +
|
||||
"inlays = ${inlays.joinToString { it.second }}\n" +
|
||||
"errors = ${errors.joinToString()}"
|
||||
)
|
||||
TransactionGuard.submitTransaction(
|
||||
file.project,
|
||||
Runnable {
|
||||
val psiFile = file.getPsiFile()
|
||||
?: error(
|
||||
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
||||
"project.isDisposed = ${file.project.isDisposed}\n" +
|
||||
"inlays = ${inlays.joinToString { it.second }}\n" +
|
||||
"errors = ${errors.joinToString()}",
|
||||
)
|
||||
|
||||
if (inlays.isNotEmpty()) {
|
||||
testPrint(psiFile, inlays.map { (expression, text) ->
|
||||
"/** ${getLineInfo(psiFile, expression)} $text */"
|
||||
})
|
||||
inlays.clear()
|
||||
}
|
||||
if (inlays.isNotEmpty()) {
|
||||
testPrint(
|
||||
psiFile,
|
||||
inlays.map { (expression, text) ->
|
||||
"/** ${getLineInfo(psiFile, expression)} $text */"
|
||||
},
|
||||
)
|
||||
inlays.clear()
|
||||
}
|
||||
|
||||
if (errors.isNotEmpty()) {
|
||||
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
||||
errors.clear()
|
||||
}
|
||||
})
|
||||
if (errors.isNotEmpty()) {
|
||||
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
||||
errors.clear()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
private fun testPrint(file: PsiFile, comments: List<String>) {
|
||||
@@ -266,7 +276,7 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
||||
for (comment in comments) {
|
||||
file.addAfter(
|
||||
KtPsiFactory(file.project).createComment(comment),
|
||||
file.lastChild
|
||||
file.lastChild,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.JBSplitter;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.KotlinJvmBundle;
|
||||
@@ -473,7 +472,6 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public void addGutterToTrack(@NotNull EditorGutterComponentEx gutterComponentEx) {}
|
||||
|
||||
public void refresh() {
|
||||
@@ -481,7 +479,6 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
@Override
|
||||
public void dispose() {}
|
||||
}
|
||||
+3
@@ -22,6 +22,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.JBSplitter;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.KotlinJvmBundle;
|
||||
@@ -472,6 +473,7 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
public void addGutterToTrack(@NotNull EditorGutterComponentEx gutterComponentEx) {}
|
||||
|
||||
public void refresh() {
|
||||
@@ -479,6 +481,7 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
@Override
|
||||
public void dispose() {}
|
||||
}
|
||||
Reference in New Issue
Block a user