generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from alexander-doroshko/main
Remove usages of deprecated LSP API
- Loading branch information
Showing
19 changed files
with
86 additions
and
186 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package com.semgrep.idea.actions | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.semgrep.idea.lsp.custom_notifications.LogoutNotifcation | ||
import com.intellij.platform.lsp.api.LspServer | ||
import com.semgrep.idea.lsp.SemgrepLanguageServer | ||
|
||
class LogoutAction : LspAction("Sign out of Semgrep") { | ||
override fun actionPerformed(e: AnActionEvent, servers: List<com.semgrep.idea.lsp.SemgrepLspServer>) { | ||
servers.map { | ||
LogoutNotifcation(it).sendNotification() | ||
} | ||
override fun actionPerformed(lspServer: LspServer) { | ||
lspServer.sendNotification { (it as SemgrepLanguageServer).logout() } | ||
} | ||
} |
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
10 changes: 4 additions & 6 deletions
10
src/main/kotlin/com/semgrep/idea/actions/RefreshRulesAction.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,12 +1,10 @@ | ||
package com.semgrep.idea.actions | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.semgrep.idea.lsp.custom_notifications.RefreshRulesNotification | ||
import com.intellij.platform.lsp.api.LspServer | ||
import com.semgrep.idea.lsp.SemgrepLanguageServer | ||
|
||
class RefreshRulesAction : LspAction("Update Semgrep Rules") { | ||
override fun actionPerformed(e: AnActionEvent, servers: List<com.semgrep.idea.lsp.SemgrepLspServer>) { | ||
servers.map { | ||
RefreshRulesNotification(it).sendNotification() | ||
} | ||
override fun actionPerformed(lspServer: LspServer) { | ||
lspServer.sendNotification { (it as SemgrepLanguageServer).refreshRules() } | ||
} | ||
} |
12 changes: 5 additions & 7 deletions
12
src/main/kotlin/com/semgrep/idea/actions/ScanWorkspaceAction.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,13 +1,11 @@ | ||
package com.semgrep.idea.actions | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.semgrep.idea.lsp.custom_notifications.ScanWorkspaceNotification | ||
import com.semgrep.idea.lsp.custom_notifications.ScanWorkspaceParams | ||
import com.intellij.platform.lsp.api.LspServer | ||
import com.semgrep.idea.lsp.SemgrepLanguageServer | ||
|
||
class ScanWorkspaceAction : LspAction("Scan Workspace with Semgrep") { | ||
override fun actionPerformed(e: AnActionEvent, servers: List<com.semgrep.idea.lsp.SemgrepLspServer>) { | ||
val params = ScanWorkspaceParams(full = false) | ||
servers.map { ScanWorkspaceNotification(it, params).sendNotification() } | ||
override fun actionPerformed(lspServer: LspServer) { | ||
val params = SemgrepLanguageServer.ScanWorkspaceParams(full = false) | ||
lspServer.sendNotification { (it as SemgrepLanguageServer).scanWorkspace(params) } | ||
} | ||
|
||
} |
12 changes: 5 additions & 7 deletions
12
src/main/kotlin/com/semgrep/idea/actions/ScanWorkspaceFullAction.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,13 +1,11 @@ | ||
package com.semgrep.idea.actions | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.semgrep.idea.lsp.custom_notifications.ScanWorkspaceNotification | ||
import com.semgrep.idea.lsp.custom_notifications.ScanWorkspaceParams | ||
import com.intellij.platform.lsp.api.LspServer | ||
import com.semgrep.idea.lsp.SemgrepLanguageServer | ||
|
||
class ScanWorkspaceFullAction : LspAction("Scan Workspace with Semgrep (Including Unmodified Files)") { | ||
override fun actionPerformed(e: AnActionEvent, servers: List<com.semgrep.idea.lsp.SemgrepLspServer>) { | ||
val params = ScanWorkspaceParams(full = true) | ||
servers.map { ScanWorkspaceNotification(it, params).sendNotification() } | ||
override fun actionPerformed(lspServer: LspServer) { | ||
val params = SemgrepLanguageServer.ScanWorkspaceParams(full = true) | ||
lspServer.sendNotification { (it as SemgrepLanguageServer).scanWorkspace(params) } | ||
} | ||
|
||
} |
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,21 +1,21 @@ | ||
package com.semgrep.idea.lsp | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.newvfs.BulkFileListener | ||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent | ||
import org.eclipse.lsp4j.DidSaveTextDocumentParams | ||
import org.eclipse.lsp4j.TextDocumentIdentifier | ||
import java.net.URLEncoder | ||
|
||
class FileSaveManager(private val semgrepLspServer: SemgrepLspServer) : BulkFileListener { | ||
class FileSaveManager(private val project: Project) : BulkFileListener { | ||
override fun after(events: MutableList<out VFileEvent>) { | ||
val lspServer = SemgrepService.getRunningLspServer(project) ?: return | ||
val saveEvents = events.filter { it.isFromSave } | ||
saveEvents.forEach { | ||
val uri = URLEncoder.encode(it.path, "UTF-8") | ||
val textDocumentIdentifier = TextDocumentIdentifier(uri) | ||
val params = DidSaveTextDocumentParams(textDocumentIdentifier) | ||
semgrepLspServer.lsp4jServer.textDocumentService.didSave(params) | ||
lspServer.sendNotification { it.textDocumentService.didSave(params) } | ||
} | ||
super.after(events) | ||
|
||
} | ||
} |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.semgrep.idea.lsp | ||
|
||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.platform.lsp.api.LspServer | ||
import com.intellij.platform.lsp.api.LspServerManager | ||
import com.intellij.platform.lsp.api.LspServerState | ||
import kotlinx.coroutines.CoroutineScope | ||
|
||
@Service(Service.Level.PROJECT) | ||
class SemgrepService(val cs: CoroutineScope) { | ||
companion object { | ||
fun getInstance(project: Project): SemgrepService = project.service<SemgrepService>() | ||
|
||
// There might be no more than one running server | ||
// because `SemgrepLspServerDescriptor` extends `ProjectWideLspServerDescriptor` | ||
fun getRunningLspServer(project: Project): LspServer? = | ||
LspServerManager.getInstance(project) | ||
.getServersForProvider(SemgrepLspServerSupportProvider::class.java) | ||
.firstOrNull { it.state == LspServerState.Running } | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
src/main/kotlin/com/semgrep/idea/lsp/custom_notifications/LoginFinishNotification.kt
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/main/kotlin/com/semgrep/idea/lsp/custom_notifications/LogoutNotifcation.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/main/kotlin/com/semgrep/idea/lsp/custom_notifications/RefreshRulesNotification.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/com/semgrep/idea/lsp/custom_notifications/ScanWorkspaceNotification.kt
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/main/kotlin/com/semgrep/idea/lsp/custom_requests/LoginRequest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.