-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
83 additions
and
213 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/kotlin/dev/slint/ideaplugin/ide/actions/LspAction.kt
This file was deleted.
Oops, something went wrong.
19 changes: 9 additions & 10 deletions
19
src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
package dev.slint.ideaplugin.ide.actions | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.notification.Notification | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.actionSystem.CommonDataKeys.VIRTUAL_FILE | ||
import com.intellij.platform.lsp.api.LspServer | ||
import dev.slint.ideaplugin.ide.lsp.requests.PreviewMessageRequest | ||
import com.intellij.openapi.components.service | ||
import dev.slint.ideaplugin.ide.services.SlintServerService | ||
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) { | ||
internal class PreviewAction : AnAction() { | ||
|
||
override fun update(e: AnActionEvent) { | ||
val psiFile = e.getData(CommonDataKeys.PSI_FILE) ?: return | ||
e.presentation.isEnabledAndVisible = psiFile.language.isKindOf(SlintLanguage.INSTANCE) | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent, servers: List<LspServer>) { | ||
override fun actionPerformed(e: AnActionEvent) { | ||
val virtualFile = e.getData(VIRTUAL_FILE) ?: return | ||
val uriFile = Path(virtualFile.path).toUri() | ||
|
||
val request = PreviewMessageRequest(servers.first(), uriFile.toString(), "") | ||
servers.first().requestExecutor.sendRequestSync(request) | ||
val project = e.project ?: return | ||
val slintServerService = project.service<SlintServerService>() | ||
|
||
notification?.expire() | ||
slintServerService.previewComponent(uriFile.toString(), "") | ||
} | ||
} |
27 changes: 13 additions & 14 deletions
27
src/main/kotlin/dev/slint/ideaplugin/ide/actions/PreviewComponentAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
package dev.slint.ideaplugin.ide.actions | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.notification.Notification | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.platform.lsp.api.LspServer | ||
import dev.slint.ideaplugin.ide.lsp.requests.PreviewMessageRequest | ||
import com.intellij.openapi.actionSystem.CommonDataKeys.VIRTUAL_FILE | ||
import com.intellij.openapi.components.service | ||
import dev.slint.ideaplugin.ide.services.SlintServerService | ||
import kotlin.io.path.Path | ||
|
||
internal class PreviewComponentAction( | ||
private val componentName: String, | ||
private val notification: Notification? = null, | ||
) : | ||
LspAction("Show Component Preview", null, AllIcons.Actions.ShowCode) { | ||
override fun actionPerformed(e: AnActionEvent, servers: List<LspServer>) { | ||
val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return | ||
|
||
internal class PreviewComponentAction(private val componentName: String) : | ||
AnAction("Show Component Preview", null, AllIcons.Actions.ShowCode) { | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val virtualFile = e.getData(VIRTUAL_FILE) ?: return | ||
val uriFile = Path(virtualFile.path).toUri() | ||
|
||
val request = PreviewMessageRequest(servers.first(), uriFile.toString(), componentName) | ||
servers.first().requestExecutor.sendRequestSync(request) | ||
val project = e.project ?: return | ||
val slintServerService = project.service<SlintServerService>() | ||
|
||
notification?.expire() | ||
slintServerService.previewComponent(uriFile.toString(), componentName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 1 addition & 106 deletions
107
src/main/kotlin/dev/slint/ideaplugin/ide/lsp/LspLanguageClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,11 @@ | ||
package dev.slint.ideaplugin.ide.lsp | ||
|
||
import com.intellij.openapi.components.service | ||
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 org.eclipse.lsp4j.* | ||
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification | ||
import java.util.concurrent.CompletableFuture | ||
|
||
class LspLanguageClient(project: Project) : | ||
Lsp4jClient(LspServerNotificationsMiddleware(project)) { | ||
class LspLanguageClient(handler: LspServerNotificationsHandler) : Lsp4jClient(handler) { | ||
@JsonNotification("experimental/serverStatus") | ||
fun serverStatus(status: Any?) { | ||
} | ||
} | ||
|
||
|
||
class LspServerNotificationsMiddleware( | ||
project: Project | ||
) : LspServerNotificationsHandler { | ||
private val fileEditorService = project.service<FileEditorService>() | ||
|
||
override fun applyEdit(params: ApplyWorkspaceEditParams): CompletableFuture<ApplyWorkspaceEditResponse> { | ||
fileEditorService.applyEdit(params) | ||
return CompletableFuture.supplyAsync { | ||
ApplyWorkspaceEditResponse(true) | ||
} | ||
} | ||
|
||
override fun configuration(params: ConfigurationParams): CompletableFuture<List<Any?>> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun createProgress(params: WorkDoneProgressCreateParams): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun logMessage(params: MessageParams) {} | ||
|
||
override fun logTrace(params: LogTraceParams) {} | ||
|
||
override fun notifyProgress(params: ProgressParams) {} | ||
|
||
override fun publishDiagnostics(params: PublishDiagnosticsParams) {} | ||
|
||
override fun refreshCodeLenses(): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun refreshDiagnostics(): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun refreshInlayHints(): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun refreshInlineValues(): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun refreshSemanticTokens(): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun registerCapability(params: RegistrationParams): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun showDocument(params: ShowDocumentParams): CompletableFuture<ShowDocumentResult> { | ||
fileEditorService.showDocument(params) | ||
return CompletableFuture.supplyAsync { | ||
ShowDocumentResult(true) | ||
} | ||
} | ||
|
||
override fun showMessage(params: MessageParams) {} | ||
|
||
override fun showMessageRequest(params: ShowMessageRequestParams): CompletableFuture<MessageActionItem> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun telemetryEvent(`object`: Any) {} | ||
|
||
override fun unregisterCapability(params: UnregistrationParams): CompletableFuture<Void> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
|
||
override fun workspaceFolders(): CompletableFuture<List<WorkspaceFolder>> { | ||
return CompletableFuture.supplyAsync { | ||
null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/kotlin/dev/slint/ideaplugin/ide/lsp/requests/PreviewMessageRequest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.