-
Notifications
You must be signed in to change notification settings - Fork 34
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 #620 from snyk/feat/transfer-sdk-to-ls-on-command-…
…execution feat: use configured sdk in language server [IDE-688]
- Loading branch information
Showing
7 changed files
with
52 additions
and
2 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
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
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,31 @@ | ||
package snyk.sdk | ||
|
||
import com.intellij.openapi.module.ModuleManager | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.projectRoots.Sdk | ||
import com.intellij.openapi.roots.ModuleRootManager | ||
import com.intellij.openapi.util.io.FileUtil | ||
import snyk.common.lsp.LsSdk | ||
|
||
class SdkHelper { | ||
companion object { | ||
fun getSdks(project: Project): List<LsSdk> { | ||
val list: MutableList<LsSdk> = mutableListOf() | ||
val modules = ModuleManager.getInstance(project).modules | ||
for (module in modules) { | ||
val moduleSdk = ModuleRootManager.getInstance(module).sdk | ||
addSdkToList(moduleSdk, list) | ||
} | ||
return list.toList() | ||
} | ||
|
||
private fun addSdkToList( | ||
sdk: Sdk?, | ||
list: MutableList<LsSdk> | ||
) { | ||
if (sdk != null && sdk.homeDirectory != null) { | ||
list.add(LsSdk(sdk.sdkType.name, FileUtil.toSystemDependentName(sdk.homeDirectory!!.path))) | ||
} | ||
} | ||
} | ||
} |
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