mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
[polySymbols/html] Fix issues with lack of proper type evaluation location when resolving attribute descriptors
(cherry picked from commit 1ae3f892cb441cf0fd7885e1b97b3c9264ae741c) IJ-CR-174153 GitOrigin-RevId: 0cb55dbaf5fce9050986cc9d9d08d9ec6c0498fc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
191db8a556
commit
4a134ce764
@@ -1174,6 +1174,7 @@
|
||||
*:com.intellij.polySymbols.utils.PolySymbolTypeSupport
|
||||
- a:getTypeProperty():com.intellij.polySymbols.PolySymbolProperty
|
||||
- a:resolve(java.util.List):java.lang.Object
|
||||
- a:withEvaluationLocation(com.intellij.psi.PsiElement,kotlin.jvm.functions.Function0):java.lang.Object
|
||||
*:com.intellij.polySymbols.utils.PolySymbolTypeSupport$TypeReference
|
||||
- *sf:Companion:com.intellij.polySymbols.utils.PolySymbolTypeSupport$TypeReference$Companion
|
||||
- a:getModule():java.lang.String
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.polySymbols.utils.PolySymbolTypeSupport
|
||||
import com.intellij.polySymbols.webTypes.impl.WebTypesSymbolTypeSupportFactoryEP
|
||||
import com.intellij.polySymbols.webTypes.json.WebTypes
|
||||
import com.intellij.polySymbols.webTypes.json.jsTypesSyntaxWithLegacy
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.*
|
||||
|
||||
@@ -35,6 +36,8 @@ interface WebTypesSymbolTypeSupportFactory {
|
||||
private object EmptySupport : PolySymbolTypeSupport {
|
||||
override val typeProperty: PolySymbolProperty<*>? get() = null
|
||||
override fun resolve(types: List<PolySymbolTypeSupport.TypeReference>): Any? = null
|
||||
override fun <T> withEvaluationLocation(location: PsiElement?, action: () -> T): T =
|
||||
action()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.polySymbols.utils
|
||||
|
||||
import com.intellij.polySymbols.PolySymbolProperty
|
||||
import com.intellij.polySymbols.impl.PolySymbolTypeSupportTypeReferenceData
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
interface PolySymbolTypeSupport {
|
||||
|
||||
@@ -10,6 +11,8 @@ interface PolySymbolTypeSupport {
|
||||
|
||||
fun resolve(types: List<TypeReference>): Any?
|
||||
|
||||
fun <T> withEvaluationLocation(location: PsiElement?, action: () -> T): T
|
||||
|
||||
interface TypeReference {
|
||||
val module: String?
|
||||
val name: String
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.polySymbols.query.impl
|
||||
|
||||
import com.intellij.polySymbols.PolySymbolProperty
|
||||
import com.intellij.polySymbols.utils.PolySymbolTypeSupport
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
object PolySymbolsMockTypeSupport : PolySymbolTypeSupport {
|
||||
|
||||
@@ -19,4 +20,8 @@ object PolySymbolsMockTypeSupport : PolySymbolTypeSupport {
|
||||
else -> it
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T> withEvaluationLocation(location: PsiElement?, action: () -> T): T =
|
||||
action()
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.polySymbols.html.attributes
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.ThreeState
|
||||
import com.intellij.polySymbols.PolySymbol
|
||||
import com.intellij.polySymbols.utils.PolySymbolTypeSupport
|
||||
@@ -14,7 +13,7 @@ interface HtmlAttributeValueSymbolTypeSupport : PolySymbolTypeSupport {
|
||||
* [ThreeState.UNSURE] if the boolean is assignable to the type and
|
||||
* [ThreeState.NO] if boolean is not assignable to the type
|
||||
*/
|
||||
fun isBoolean(symbol: PolySymbol, type: Any?, context: PsiElement): ThreeState
|
||||
fun isBoolean(symbol: PolySymbol, type: Any?): ThreeState
|
||||
|
||||
fun createStringType(symbol: PolySymbol): Any?
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// 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.polySymbols.html.attributes.impl
|
||||
|
||||
import com.intellij.polySymbols.html.attributes.HtmlAttributeSymbolInfo
|
||||
import com.intellij.polySymbols.html.attributes.HtmlAttributeValueSymbolTypeSupport
|
||||
import com.intellij.polySymbols.PolySymbol
|
||||
import com.intellij.polySymbols.PolySymbolModifier
|
||||
import com.intellij.polySymbols.completion.PolySymbolCodeCompletionItem
|
||||
import com.intellij.polySymbols.html.HTML_ATTRIBUTE_VALUES
|
||||
import com.intellij.polySymbols.html.PolySymbolHtmlAttributeValue
|
||||
import com.intellij.polySymbols.html.attributes.HtmlAttributeSymbolInfo
|
||||
import com.intellij.polySymbols.html.attributes.HtmlAttributeValueSymbolTypeSupport
|
||||
import com.intellij.polySymbols.html.htmlAttributeValue
|
||||
import com.intellij.polySymbols.query.PolySymbolQueryExecutor
|
||||
import com.intellij.psi.PsiElement
|
||||
@@ -102,7 +102,7 @@ internal data class HtmlAttributeSymbolInfoImpl(
|
||||
val priority = symbol.priority ?: PolySymbol.Priority.NORMAL
|
||||
val icon = symbol.icon
|
||||
val defaultValue = attrValue?.default
|
||||
val langType = if (typeSupport != null)
|
||||
val langType = typeSupport?.withEvaluationLocation(context) {
|
||||
when (type) {
|
||||
PolySymbolHtmlAttributeValue.Type.STRING -> typeSupport.createStringType(symbol)
|
||||
PolySymbolHtmlAttributeValue.Type.BOOLEAN -> typeSupport.createBooleanType(symbol)
|
||||
@@ -119,13 +119,15 @@ internal data class HtmlAttributeSymbolInfoImpl(
|
||||
PolySymbolHtmlAttributeValue.Type.OF_MATCH -> typeSupport.typeProperty?.let { symbol[it] }
|
||||
PolySymbolHtmlAttributeValue.Type.COMPLEX -> attrValue?.langType
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
val isHtmlBoolean = if (kind == PolySymbolHtmlAttributeValue.Kind.PLAIN)
|
||||
if (type == PolySymbolHtmlAttributeValue.Type.BOOLEAN)
|
||||
ThreeState.YES
|
||||
else
|
||||
typeSupport?.isBoolean(symbol, langType, context) ?: ThreeState.YES
|
||||
typeSupport?.withEvaluationLocation(context) {
|
||||
typeSupport.isBoolean(symbol, langType)
|
||||
} ?: ThreeState.YES
|
||||
else
|
||||
ThreeState.NO
|
||||
val valueRequired = attrValue?.required != false && isHtmlBoolean == ThreeState.NO && kind != PolySymbolHtmlAttributeValue.Kind.NO_VALUE
|
||||
@@ -147,13 +149,18 @@ internal data class HtmlAttributeSymbolInfoImpl(
|
||||
}
|
||||
PolySymbolHtmlAttributeValue.Type.COMPLEX,
|
||||
PolySymbolHtmlAttributeValue.Type.OF_MATCH,
|
||||
-> typeSupport?.getEnumValues(symbol, langType)
|
||||
-> typeSupport?.withEvaluationLocation(context) {
|
||||
typeSupport.getEnumValues(symbol, langType)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
else null
|
||||
|
||||
val strictEnumValues = type == PolySymbolHtmlAttributeValue.Type.ENUM || typeSupport?.strictEnumValues(symbol, langType) == true
|
||||
val strictEnumValues = type == PolySymbolHtmlAttributeValue.Type.ENUM ||
|
||||
typeSupport?.withEvaluationLocation(context) {
|
||||
typeSupport.strictEnumValues(symbol, langType)
|
||||
} == true
|
||||
|
||||
return HtmlAttributeSymbolInfoImpl(name, symbol, acceptsNoValue, acceptsValue,
|
||||
enumValues, strictEnumValues, langType, icon, isRequired,
|
||||
|
||||
Reference in New Issue
Block a user