Skip to content

Commit

Permalink
fixed IJ plugin dev inspection warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dkandalov committed Sep 10, 2024
1 parent b8e2b58 commit e5a40c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/liveplugin/implementation/common/ide-util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fun AnActionEvent.selectedFiles(): List<FilePath> =
dataContext.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)?.map { it.toFilePath() } ?: emptyList()

@Suppress("UnstableApiUsage")
class MapDataContext(val map: Map<String, Any?>) : DataContext, AsyncDataContext {
class MapDataContext(val map: Map<String, Any?>) : AsyncDataContext {
override fun getData(dataId: String) = map[dataId]
}

Expand Down
21 changes: 8 additions & 13 deletions src/main/liveplugin/implementation/ide-extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ import org.jetbrains.jps.model.module.UnknownSourceRootType
// but it's also used for enabling Kotlin intentions in live plugin, i.e. outside of project
// (since change in IJ 2022.1: Anna Kozlova* 22/12/2021, 17:21 [kotlin] disable intentions which modifies code in libraries (KTIJ-20543))
class ScratchLivePluginRootType : RootType("LivePlugin", "Live Plugins") {
init {
System.setProperty(PathManager.PROPERTY_SCRATCH_PATH + "/LivePlugin", livePluginsPath.value)
}

override fun substituteIcon(project: Project, file: VirtualFile) =
if (file.toFilePath().isPluginFolder()) pluginIcon else super.substituteIcon(project, file)

companion object {
init {
System.setProperty(PathManager.PROPERTY_SCRATCH_PATH + "/LivePlugin", livePluginsPath.value)
}
}
}

class LivePluginDeletedListener : BulkFileListener {
Expand Down Expand Up @@ -107,19 +105,16 @@ object FindUsageInLivePlugin {

class UseScopeExtension : UseScopeEnlarger() {
override fun getAdditionalUseScope(element: PsiElement): SearchScope? =
if (element.useScope is LocalSearchScope) null else SCOPE_KEY.getValue(element.project)
if (element.useScope is LocalSearchScope) null else scopeKey.getValue(element.project)

private val scopeKey: NotNullLazyKey<LivePluginsSearchScope, Project> =
NotNullLazyKey.createLazyKey("LIVEPLUGIN_SEARCH_SCOPE_KEY") { project -> LivePluginsSearchScope(project) }

private class LivePluginsSearchScope(project: Project) : GlobalSearchScope(project) {
override fun getDisplayName() = "LivePlugins"
override fun contains(file: VirtualFile) = file.toFilePath().isPluginFolder()
override fun isSearchInModuleContent(aModule: Module) = false
override fun isSearchInLibraries() = false
}

companion object {
private val SCOPE_KEY = NotNullLazyKey.createLazyKey<LivePluginsSearchScope, Project>("LIVEPLUGIN_SEARCH_SCOPE_KEY") { project ->
LivePluginsSearchScope(project)
}
}
}
}

0 comments on commit e5a40c2

Please sign in to comment.