diff --git a/README.md b/README.md
index ece6f3d..7988102 100644
--- a/README.md
+++ b/README.md
@@ -7,25 +7,22 @@
## Description
-[Slint](https://slint.dev) support for IDEs based on IntelliJ Platform. **Plugin is experimental and unofficial!**
+[Slint](https://slint.dev) support for IDEs based on IntelliJ Platform. **Plugin is unofficial!**
The following features are supported:
- Syntax highlighting
-- Slint-LSP support
- Preview support
+- Code completion
+- Document formatting
+- Pick elements
+- Drag and Drop elements on Live-Preview
-Tested with:
-- CLion 2023.2
-- IDEA Ultimate 2023.2
-- RustRover 2023.3 EAP
-
## Dependencies
-Slint IntelliJ Plugin communicates with Slint-LSP. Install before you can use the IntelliJ Plugin. To install:
-```sh
-$ cargo install slint-lsp
-```
+Slint IntelliJ Plugin communicates with Slint LSP. Language server are included in plugin assembly (in version 1.0.0 and later).
+
+But you can use an external dependency. Go to Settings > Languages & Frameworks > Slint > Slint-lsp path selected path
## Installation
@@ -38,7 +35,3 @@ Manually:
Download the [latest release](https://github.com/kizeevov/slint-idea-plugin/releases) and install it manually using
Preferences > Plugins > ⚙️ > Install plugin from disk...
-
-## Configuration
-
-Go to Settings > Languages & Frameworks > Slint > Slint-lsp path selected path
diff --git a/gradle.properties b/gradle.properties
index 2a6471c..c57fe0b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -9,7 +9,7 @@ pluginRepositoryUrl = https://github.com/kizeevov/slint-idea-plugin
pluginGroup = dev.slint
pluginName = SlintPlugin
-pluginVersion = 0.3.1
+pluginVersion = 1.0.0
platformType = IU
# platformType = CL
platformVersion = 232-EAP-SNAPSHOT
diff --git a/src/main/kotlin/dev/slint/ideaplugin/SlintBundle.kt b/src/main/kotlin/dev/slint/ideaplugin/SlintBundle.kt
index 94cd6cc..cdb73e8 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/SlintBundle.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/SlintBundle.kt
@@ -14,10 +14,10 @@ object SlintBundle : DynamicBundle(SLINT_BUNDLE) {
@Suppress("SpreadOperator")
@JvmStatic
fun message(@PropertyKey(resourceBundle = SLINT_BUNDLE) key: String, vararg params: Any) =
- getMessage(key, *params)
+ getMessage(key, *params)
@Suppress("SpreadOperator", "unused")
@JvmStatic
fun messagePointer(@PropertyKey(resourceBundle = SLINT_BUNDLE) key: String, vararg params: Any) =
- getLazyMessage(key, *params)
+ getLazyMessage(key, *params)
}
\ No newline at end of file
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/LspAction.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/LspAction.kt
index 531d1d7..47b6ace 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/LspAction.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/LspAction.kt
@@ -7,7 +7,6 @@ import com.intellij.platform.lsp.api.LspServer
import dev.slint.ideaplugin.ide.services.SlintServerService
import javax.swing.Icon
-
abstract class LspAction(text: String, description: String?, icon: Icon?) : AnAction(text, description, icon) {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
@@ -16,6 +15,7 @@ abstract class LspAction(text: String, description: String?, icon: Icon?) : AnAc
if (servers.isEmpty()) {
return
}
+
actionPerformed(e, servers)
}
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewAction.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewAction.kt
index e2d0f83..ef97d0b 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewAction.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewAction.kt
@@ -11,8 +11,7 @@ import dev.slint.ideaplugin.lang.SlintLanguage
import kotlin.io.path.Path
internal class PreviewAction(private val notification: Notification? = null) :
- LspAction("Show All Preview", null, AllIcons.Actions.Preview)
-{
+ LspAction("Show All Preview", null, AllIcons.Actions.Preview) {
override fun update(e: AnActionEvent) {
val psiFile = e.getData(CommonDataKeys.PSI_FILE) ?: return
e.presentation.isEnabledAndVisible = psiFile.language.isKindOf(SlintLanguage.INSTANCE)
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewComponentAction.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewComponentAction.kt
index e69c0ad..647d1e7 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewComponentAction.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewComponentAction.kt
@@ -9,11 +9,10 @@ import dev.slint.ideaplugin.ide.lsp.requests.PreviewMessageRequest
import kotlin.io.path.Path
internal class PreviewComponentAction(
- private val componentName: String,
- private val notification: Notification? = null,
+ private val componentName: String,
+ private val notification: Notification? = null,
) :
- LspAction("Show Component Preview", null, AllIcons.Actions.ShowCode)
-{
+ LspAction("Show Component Preview", null, AllIcons.Actions.ShowCode) {
override fun actionPerformed(e: AnActionEvent, servers: List) {
val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
val uriFile = Path(virtualFile.path).toUri()
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/SlintCreateFileAction.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/SlintCreateFileAction.kt
index dedbcf8..930b8d0 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/actions/SlintCreateFileAction.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/actions/SlintCreateFileAction.kt
@@ -4,10 +4,8 @@ import com.intellij.ide.actions.CreateFileFromTemplateAction
import com.intellij.ide.actions.CreateFileFromTemplateDialog
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
-import com.intellij.openapi.client.currentSession
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
-import com.intellij.openapi.vfs.VfsUtil
import com.intellij.psi.PsiDirectory
import dev.slint.ideaplugin.SlintBundle
import dev.slint.ideaplugin.SlintIcons
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/annotator/SlintAnnotator.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/annotator/SlintAnnotator.kt
index 6c1d7b4..8c15e23 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/annotator/SlintAnnotator.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/annotator/SlintAnnotator.kt
@@ -3,39 +3,35 @@ package dev.slint.ideaplugin.ide.annotator
import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity
-import com.intellij.openapi.editor.DefaultLanguageHighlighterColors
import com.intellij.openapi.editor.colors.TextAttributesKey
-import com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey
import com.intellij.psi.PsiElement
import com.intellij.psi.util.elementType
import dev.slint.ideaplugin.ide.highlighting.SlintColors
import dev.slint.ideaplugin.lang.psi.SlintElementTypes
-
class SlintAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
- if (element.elementType == SlintElementTypes.FIELD_IDENTIFIER)
- {
+ if (element.elementType == SlintElementTypes.FIELD_IDENTIFIER) {
annotateWithInfo(element, holder, SlintColors.FIELD_NAME)
} else if (element.elementType == SlintElementTypes.DURATION_LITERAL
|| element.elementType == SlintElementTypes.LENGTH_LITERAL
|| element.elementType == SlintElementTypes.PHYSICAL_LENGTH_LITERAL
|| element.elementType == SlintElementTypes.ANGLE_LITERAL
|| element.elementType == SlintElementTypes.COLOR_LITERAL
- || element.elementType == SlintElementTypes.RELATIVE_FONT_SIZE_LITERAL)
- {
+ || element.elementType == SlintElementTypes.RELATIVE_FONT_SIZE_LITERAL
+ ) {
annotateWithInfo(element, holder, SlintColors.NUMBER)
}
}
private fun annotateWithInfo(
- element: PsiElement,
- holder: AnnotationHolder,
- attributesKey: TextAttributesKey
+ element: PsiElement,
+ holder: AnnotationHolder,
+ attributesKey: TextAttributesKey
) {
holder.newSilentAnnotation(HighlightSeverity.INFORMATION)
- .range(element.textRange)
- .textAttributes(attributesKey)
- .create()
+ .range(element.textRange)
+ .textAttributes(attributesKey)
+ .create()
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintBraceMatcher.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintBraceMatcher.kt
index f7c7425..19f5e94 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintBraceMatcher.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintBraceMatcher.kt
@@ -6,7 +6,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.tree.IElementType
import dev.slint.ideaplugin.lang.psi.SlintElementTypes
-class SlintBraceMatcher: PairedBraceMatcher {
+class SlintBraceMatcher : PairedBraceMatcher {
override fun getPairs(): Array = braces
override fun isPairedBracesAllowedBeforeType(lbraceType: IElementType, contextType: IElementType?): Boolean = true
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintQuoteHandler.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintQuoteHandler.kt
index 67c48d5..e8c4bb6 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintQuoteHandler.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/editor/SlintQuoteHandler.kt
@@ -3,4 +3,4 @@ package dev.slint.ideaplugin.ide.editor
import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler
import dev.slint.ideaplugin.lang.psi.SLINT_STRINGS
-class SlintQuoteHandler: SimpleTokenSetQuoteHandler(SLINT_STRINGS)
\ No newline at end of file
+class SlintQuoteHandler : SimpleTokenSetQuoteHandler(SLINT_STRINGS)
\ No newline at end of file
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/folding/SlintImportFoldingBuilder.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/folding/SlintImportFoldingBuilder.kt
index 8657247..89eb2a4 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/folding/SlintImportFoldingBuilder.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/folding/SlintImportFoldingBuilder.kt
@@ -65,5 +65,5 @@ private fun PsiElement.nextImport(): SlintImportDefinition? {
return next.nextImport()
}
- return next as? SlintImportDefinition
+ return next as? SlintImportDefinition
}
\ No newline at end of file
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/formatter/SlintLspFormattingService.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/formatter/SlintLspFormattingService.kt
index 07d1546..c042cbf 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/formatter/SlintLspFormattingService.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/formatter/SlintLspFormattingService.kt
@@ -6,7 +6,6 @@ import com.intellij.formatting.service.FormattingService
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.components.service
import com.intellij.openapi.fileEditor.FileEditorManager
-import com.intellij.openapi.progress.util.ProgressIndicatorBase
import com.intellij.psi.PsiFile
import com.jetbrains.rd.util.enumSetOf
import dev.slint.ideaplugin.ide.services.FileEditorService
@@ -17,7 +16,7 @@ import org.eclipse.lsp4j.FormattingOptions
import org.eclipse.lsp4j.TextDocumentIdentifier
import kotlin.io.path.Path
-class SlintLspFormattingService: AsyncDocumentFormattingService() {
+class SlintLspFormattingService : AsyncDocumentFormattingService() {
override fun getFeatures(): Set = FEATURES
override fun canFormat(file: PsiFile): Boolean = file is SlintFile
@@ -40,7 +39,7 @@ class SlintLspFormattingService: AsyncDocumentFormattingService() {
return object : FormattingTask {
override fun run() {
- val edits = server.lsp4jServer.textDocumentService.formatting(params).join()
+ val edits = server.lsp4jServer.textDocumentService.formatting(params).join()
edits.forEach { textEdit ->
WriteCommandAction.runWriteCommandAction(project) {
FileEditorService.applyTextChanges(textEdit, editor)
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintColorSettingsPage.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintColorSettingsPage.kt
deleted file mode 100644
index 9419abd..0000000
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintColorSettingsPage.kt
+++ /dev/null
@@ -1,4 +0,0 @@
-package dev.slint.ideaplugin.ide.highlighting
-
-class SlintColorSettingsPage {
-}
\ No newline at end of file
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintSyntaxHighlighter.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintSyntaxHighlighter.kt
index f30bfea..70169d8 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintSyntaxHighlighter.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/highlighting/SlintSyntaxHighlighter.kt
@@ -12,7 +12,7 @@ class SlintSyntaxHighlighter : SyntaxHighlighterBase() {
override fun getHighlightingLexer(): Lexer = SlintLexer()
override fun getTokenHighlights(tokenType: IElementType): Array =
- pack(attributes[tokenType])
+ pack(attributes[tokenType])
companion object {
private val attributes = buildMap {
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/LspLanguageClient.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/LspLanguageClient.kt
index c42a5dd..5189179 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/LspLanguageClient.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/LspLanguageClient.kt
@@ -1,16 +1,10 @@
package dev.slint.ideaplugin.ide.lsp
-import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.components.service
-import com.intellij.openapi.editor.Editor
-import com.intellij.openapi.editor.LogicalPosition
-import com.intellij.openapi.fileEditor.FileEditorManager
-import com.intellij.openapi.fileEditor.OpenFileDescriptor
import com.intellij.openapi.project.Project
import com.intellij.platform.lsp.api.Lsp4jClient
import com.intellij.platform.lsp.api.LspServerNotificationsHandler
import dev.slint.ideaplugin.ide.services.FileEditorService
-import dev.slint.ideaplugin.ide.services.SlintServerService
import org.eclipse.lsp4j.*
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification
import java.util.concurrent.CompletableFuture
@@ -31,8 +25,6 @@ class LspServerNotificationsMiddleware(
override fun applyEdit(params: ApplyWorkspaceEditParams): CompletableFuture {
fileEditorService.applyEdit(params)
-
- // return serverNotificationsHandler.applyEdit(params)
return CompletableFuture.supplyAsync {
null
}
@@ -88,8 +80,6 @@ class LspServerNotificationsMiddleware(
override fun showDocument(params: ShowDocumentParams): CompletableFuture {
fileEditorService.showDocument(params)
-
- // return serverNotificationsHandler.showDocument(params)
return CompletableFuture.supplyAsync {
null
}
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspCompletionSupport.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspCompletionSupport.kt
index a980668..842bc41 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspCompletionSupport.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspCompletionSupport.kt
@@ -11,7 +11,7 @@ import org.eclipse.lsp4j.CompletionItemKind
import javax.swing.Icon
@Suppress("UnstableApiUsage")
-class SlintLspCompletionSupport: LspCompletionSupport() {
+class SlintLspCompletionSupport : LspCompletionSupport() {
override fun getIcon(item: CompletionItem): Icon {
return super.getIcon(item) ?: SlintIcons.SLINT
}
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerDescriptor.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerDescriptor.kt
index 5436263..4e6f8ec 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerDescriptor.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerDescriptor.kt
@@ -2,11 +2,6 @@ package dev.slint.ideaplugin.ide.lsp
import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.process.OSProcessHandler
-import com.intellij.execution.process.ProcessAdapter
-import com.intellij.execution.process.ProcessEvent
-import com.intellij.ide.plugins.PluginManager
-import com.intellij.openapi.components.service
-import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.platform.lsp.api.Lsp4jClient
@@ -14,17 +9,9 @@ import com.intellij.platform.lsp.api.LspServerListener
import com.intellij.platform.lsp.api.LspServerNotificationsHandler
import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor
import com.intellij.platform.lsp.api.customization.LspCompletionSupport
-import dev.slint.ideaplugin.ide.settings.SlintBackend
import dev.slint.ideaplugin.ide.settings.SlintSettingsState
-import dev.slint.ideaplugin.ide.settings.SlintStyle
import dev.slint.ideaplugin.lang.SlintFileType
import org.eclipse.lsp4j.services.LanguageServer
-import com.intellij.openapi.util.SystemInfo
-import dev.slint.ideaplugin.SlintBundle
-import dev.slint.ideaplugin.ide.services.SlintServerService
-import java.nio.file.Path
-import java.util.*
-import kotlin.concurrent.schedule
@Suppress("UnstableApiUsage")
class SlintLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Slint") {
@@ -35,9 +22,11 @@ class SlintLspServerDescriptor(project: Project) : ProjectWideLspServerDescripto
override fun createInitializationOptions(): Any = SlintSettingsState.getInstance().lspSettings
- override fun createLsp4jClient(handler: LspServerNotificationsHandler): Lsp4jClient = LspLanguageClient(handler, project)
+ override fun createLsp4jClient(handler: LspServerNotificationsHandler): Lsp4jClient =
+ LspLanguageClient(handler, project)
- override fun startServerProcess(): OSProcessHandler = ServerProcessHandler.addListeners(super.startServerProcess(), project)
+ override fun startServerProcess(): OSProcessHandler =
+ ServerProcessHandler.addListeners(super.startServerProcess(), project)
override val lsp4jServerClass: Class = SlintLanguageServer::class.java
override val lspServerListener: LspServerListener = SlintLspServerListener(project)
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerSupportProvider.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerSupportProvider.kt
index 6430b7f..b23dc00 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerSupportProvider.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/SlintLspServerSupportProvider.kt
@@ -7,7 +7,11 @@ import dev.slint.ideaplugin.lang.SlintFileType
@Suppress("UnstableApiUsage")
class SlintLspServerSupportProvider : LspServerSupportProvider {
- override fun fileOpened(project: Project, file: VirtualFile, serverStarter: LspServerSupportProvider.LspServerStarter) {
+ override fun fileOpened(
+ project: Project,
+ file: VirtualFile,
+ serverStarter: LspServerSupportProvider.LspServerStarter
+ ) {
if (file.fileType != SlintFileType) return
serverStarter.ensureServerStarted(SlintLspServerDescriptor(project))
}
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/requests/PreviewMessageRequest.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/requests/PreviewMessageRequest.kt
index 7b714fa..b32a169 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/requests/PreviewMessageRequest.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/requests/PreviewMessageRequest.kt
@@ -5,18 +5,19 @@ import com.intellij.platform.lsp.api.requests.LspRequest
import org.eclipse.lsp4j.ExecuteCommandParams
import java.util.concurrent.CompletableFuture
-class PreviewMessageRequest(private val server: LspServer, private val path: String, private val component: String) : LspRequest(server) {
+class PreviewMessageRequest(private val server: LspServer, private val path: String, private val component: String) :
+ LspRequest(server) {
override fun preprocessResponse(serverResponse: Any): Any {
return serverResponse
}
override fun sendRequest(): CompletableFuture {
return server.lsp4jServer.workspaceService
- .executeCommand(
- ExecuteCommandParams(
- "slint/showPreview",
- listOf(path, component)
- )
+ .executeCommand(
+ ExecuteCommandParams(
+ "slint/showPreview",
+ listOf(path, component)
)
+ )
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/services/FileEditorService.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/services/FileEditorService.kt
index f135cbd..4200c75 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/services/FileEditorService.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/services/FileEditorService.kt
@@ -25,44 +25,36 @@ class FileEditorService(private val project: Project) {
}
fun showDocument(params: ShowDocumentParams) {
- fileEditorManager.openFiles
- .find {
- it.url == params.uri
- }
- ?.let {
- val startPosition = params.selection.start.run {
- LogicalPosition(line, character)
- }
- val endPosition = params.selection.end.run {
- LogicalPosition(line, character)
- }
+ val file = fileEditorManager.openFiles.find { it.url == params.uri } ?: return
- WriteCommandAction.runWriteCommandAction(project) {
- fileEditorManager
- .openTextEditor(OpenFileDescriptor(project, it), true)
- ?.selectionModel
- ?.setBlockSelection(startPosition, endPosition)
- }
- }
+ val startPosition = params.selection.start.run {
+ LogicalPosition(line, character)
+ }
+ val endPosition = params.selection.end.run {
+ LogicalPosition(line, character)
+ }
+
+ WriteCommandAction.runWriteCommandAction(project) {
+ fileEditorManager
+ .openTextEditor(OpenFileDescriptor(project, file), true)
+ ?.selectionModel
+ ?.setBlockSelection(startPosition, endPosition)
+ }
}
private fun applyDocumentChanges(documentChanges: TextDocumentEdit) {
val fileUrl = documentChanges.textDocument.uri
- fileEditorManager.openFiles
- .find {
- it.url == fileUrl
- }
- ?.let { virtualFile ->
- WriteCommandAction.runWriteCommandAction(project) {
- fileEditorManager
- .openTextEditor(OpenFileDescriptor(project, virtualFile), true)
- ?.let { editor: Editor ->
- documentChanges.edits.forEach {
- applyTextChanges(it, editor)
- }
- }
+ val file = fileEditorManager.openFiles.find { it.url == fileUrl } ?: return
+
+ WriteCommandAction.runWriteCommandAction(project) {
+ fileEditorManager
+ .openTextEditor(OpenFileDescriptor(project, file), true)
+ ?.let { editor: Editor ->
+ documentChanges.edits.forEach {
+ applyTextChanges(it, editor)
+ }
}
- }
+ }
}
companion object {
@@ -75,7 +67,7 @@ class FileEditorService(private val project: Project) {
}
val startOffset = editor.logicalPositionToOffset(startPosition)
- val endOffset= editor.logicalPositionToOffset(endPosition)
+ val endOffset = editor.logicalPositionToOffset(endPosition)
editor.document.replaceString(startOffset, endOffset, textEdit.newText)
}
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/settings/PathsTablePanel.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/settings/PathsTablePanel.kt
index 3ab19ae..5a7522d 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/settings/PathsTablePanel.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/settings/PathsTablePanel.kt
@@ -1,10 +1,7 @@
package dev.slint.ideaplugin.ide.settings
-import com.intellij.ide.util.DirectoryChooser
import com.intellij.openapi.fileChooser.FileChooser
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
-import com.intellij.openapi.fileChooser.FileChooserDialog
-import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.ui.MessageDialogBuilder
import com.intellij.ui.ToolbarDecorator
import com.intellij.ui.table.TableView
@@ -14,7 +11,6 @@ import com.intellij.util.ui.ListTableModel
import dev.slint.ideaplugin.SlintBundle
import javax.swing.table.DefaultTableCellRenderer
import javax.swing.table.TableCellRenderer
-import kotlin.io.path.Path
internal class PathsTablePanel {
val component: JComponent
@@ -63,7 +59,8 @@ internal class PathsTablePanel {
private fun removeData() {
val dialog = MessageDialogBuilder.okCancel(
SlintBundle.message("settings.paths.table.remove.dialog.title"),
- SlintBundle.message("settings.paths.table.remove.dialog.message"))
+ SlintBundle.message("settings.paths.table.remove.dialog.message")
+ )
if (dialog.guessWindowAndAsk()) {
model.removeRow(table.selectedRow)
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/settings/SlintLspSettings.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/settings/SlintLspSettings.kt
index b3bb678..c36ad36 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/settings/SlintLspSettings.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/settings/SlintLspSettings.kt
@@ -2,7 +2,7 @@ package dev.slint.ideaplugin.ide.settings
import java.util.*
-data class SlintLspSettings (
+data class SlintLspSettings(
var path: String = "slint-lsp",
var args: String = "",
var style: SlintStyle = SlintStyle.DEFAULT,
diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/widgets/SlintStatusBarWidget.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/widgets/SlintStatusBarWidget.kt
index 252a9e7..11af53a 100644
--- a/src/main/kotlin/dev/slint/ideaplugin/ide/widgets/SlintStatusBarWidget.kt
+++ b/src/main/kotlin/dev/slint/ideaplugin/ide/widgets/SlintStatusBarWidget.kt
@@ -46,28 +46,35 @@ class SlintStatusBarWidget(project: Project) : EditorBasedStatusBarPopup(project
group.add(ActionManager.getInstance().getAction(RestartLspAction.ID))
return JBPopupFactory.getInstance()
- .createActionGroupPopup("Slint Actions", group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true)
+ .createActionGroupPopup(
+ "Slint Actions",
+ group,
+ context,
+ JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
+ true
+ )
}
override fun getWidgetState(file: VirtualFile?): WidgetState {
if (file?.fileType !is SlintFileType) return WidgetState.HIDDEN
val project = ProjectLocator.getInstance().guessProjectForFile(file)
- project?: return WidgetState.HIDDEN
+ project ?: return WidgetState.HIDDEN
val module = ModuleUtil.findModuleForFile(file, this.project)
- module?: return WidgetState.HIDDEN
+ module ?: return WidgetState.HIDDEN
val slintServerService = project.service()
- return when(slintServerService.isRunning) {
+ return when (slintServerService.isRunning) {
true -> {
val state = WidgetState(SlintBundle.message("slint.language.server.is.running"), "Slint", false)
state.icon = SlintIcons.SLINT
state
}
+
false -> {
val state = WidgetState(SlintBundle.message("slint.language.server.is.stopped"), "Slint", true)
- state.icon = AnimatedIcon(1000, SlintIcons.SLINT, getDisabledIcon( SlintIcons.SLINT))
+ state.icon = AnimatedIcon(1000, SlintIcons.SLINT, getDisabledIcon(SlintIcons.SLINT))
state
}
}