mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[compose] IJPL-208258 Suppress unused symbols inspection for @Preview methods
GitOrigin-RevId: b51e58fd837143faa650d392dea1d33683af8053
This commit is contained in:
committed by
intellij-monorepo-bot
parent
02105622ac
commit
94f1f1e565
@@ -38,6 +38,7 @@
|
||||
factoryClass="com.intellij.devkit.compose.preview.ComposePreviewToolWindowFactory"
|
||||
icon="org.jetbrains.idea.devkit.DevKitIcons.ComposeToolWindow"
|
||||
librarySearchClass="com.intellij.devkit.compose.preview.ComposePreviewSearcher"/>
|
||||
<implicitUsageProvider implementation="com.intellij.devkit.compose.preview.ComposePreviewImplicitUsageProvider"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.lang.reflect.Modifier
|
||||
|
||||
private val logger = Logger.getInstance(ComposableFunctionFinder::class.java)
|
||||
|
||||
internal val PREVIEW_ANNOTATIONS = setOf(
|
||||
"androidx.compose.desktop.ui.tooling.preview.Preview",
|
||||
internal val PREVIEW_ANNOTATIONS: Set<String> = setOf(
|
||||
"org.jetbrains.compose.ui.tooling.preview.Preview",
|
||||
"androidx.compose.ui.tooling.preview.Preview", // Android fallback
|
||||
)
|
||||
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.devkit.compose.preview
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil
|
||||
import com.intellij.codeInsight.daemon.ImplicitUsageProvider
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.idea.devkit.util.PsiUtil
|
||||
|
||||
/**
|
||||
* @Preview methods are useful for UI previews in IDE even when unused in production, suppress unused symbol inspection for them.
|
||||
*/
|
||||
internal class ComposePreviewImplicitUsageProvider : ImplicitUsageProvider {
|
||||
override fun isImplicitRead(element: PsiElement): Boolean = false
|
||||
override fun isImplicitWrite(element: PsiElement): Boolean = false
|
||||
|
||||
override fun isImplicitUsage(element: PsiElement): Boolean {
|
||||
if (element !is PsiMethod) return false
|
||||
val module = ModuleUtilCore.findModuleForPsiElement(element) ?: return false
|
||||
|
||||
return PsiUtil.isPluginModule(module)
|
||||
&& AnnotationUtil.isAnnotated(element, PREVIEW_ANNOTATIONS, 0)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user