mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 17:03:12 +07:00
[path-annotations] chore: Refactor path annotation inspection methods
Remove unused methods and redundant parameters to simplify the codebase. Streamline logic for determining path handling, improving maintainability and clarity. GitOrigin-RevId: fae3959e53c4956fd68cf5913dafe342434aa665
This commit is contained in:
committed by
intellij-monorepo-bot
parent
13e69d0530
commit
69fa89210b
@@ -484,15 +484,10 @@ class PathAnnotationInspection : DevKitUastInspectionBase() {
|
||||
}
|
||||
|
||||
// Check if the expression is passed to a Path constructor or factory method
|
||||
if (isPassedToMultiRoutingMethod(expression, nonAnnotatedTargets)) {
|
||||
if (isPassedToMultiRoutingMethod(expression)) {
|
||||
return PathAnnotationInfo.MultiRouting
|
||||
}
|
||||
|
||||
// Check if the expression is passed to a method that expects a native path
|
||||
if (isPassedToNativePathMethod(expression, nonAnnotatedTargets)) {
|
||||
return PathAnnotationInfo.Native
|
||||
}
|
||||
|
||||
return PathAnnotationInfo.Unspecified
|
||||
}
|
||||
|
||||
@@ -535,10 +530,7 @@ class PathAnnotationInspection : DevKitUastInspectionBase() {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun isPassedToMultiRoutingMethod(
|
||||
expression: UExpression,
|
||||
nonAnnotatedTargets: MutableSet<PsiModifierListOwner>,
|
||||
): Boolean {
|
||||
private fun isPassedToMultiRoutingMethod(expression: UExpression): Boolean {
|
||||
// Check if the expression is passed to a Path constructor or factory method
|
||||
val parent = expression.uastParent
|
||||
if (parent is UCallExpression) {
|
||||
@@ -550,32 +542,6 @@ class PathAnnotationInspection : DevKitUastInspectionBase() {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun isPassedToPathResolveMethod(
|
||||
expression: UExpression,
|
||||
): Boolean {
|
||||
// Check if the expression is passed to Path.resolve()
|
||||
val parent = expression.uastParent
|
||||
if (parent is UCallExpression) {
|
||||
val method = parent.resolve() ?: return false
|
||||
if (isPathResolveMethod(method)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun isPassedToNativePathMethod(
|
||||
expression: UExpression,
|
||||
nonAnnotatedTargets: MutableSet<PsiModifierListOwner>,
|
||||
): Boolean {
|
||||
// Check if the expression is passed to a method that expects a native path
|
||||
// This would be specific to your codebase, but could include methods like:
|
||||
// - Docker container path methods
|
||||
// - WSL path methods
|
||||
// For now, we'll just return false as a placeholder
|
||||
return false
|
||||
}
|
||||
|
||||
private fun getParameterForArgument(method: PsiElement, index: Int): PsiModifierListOwner? {
|
||||
if (method is com.intellij.psi.PsiMethod) {
|
||||
val parameters = method.parameterList.parameters
|
||||
@@ -753,26 +719,6 @@ class PathAnnotationInspection : DevKitUastInspectionBase() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick fix to add @LocalPath annotation.
|
||||
*/
|
||||
private class AddLocalPathAnnotationFix() : LocalQuickFix {
|
||||
override fun getFamilyName(): String = DevKitBundle.message("inspections.intention.family.name.add.localpath.annotation")
|
||||
|
||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||
val element = descriptor.psiElement
|
||||
if (element is PsiModifierListOwner) {
|
||||
val annotationOwner = element.modifierList
|
||||
if (annotationOwner != null) {
|
||||
AddAnnotationPsiFix.addPhysicalAnnotationIfAbsent(
|
||||
LocalPath::class.java.name,
|
||||
emptyArray(),
|
||||
annotationOwner
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun findVariableToAnnotate(element: PsiElement): PsiModifierListOwner? {
|
||||
|
||||
Reference in New Issue
Block a user