From 8e4f6c6bee96411f9b397c8362894191a2dd3019 Mon Sep 17 00:00:00 2001 From: Piotr Tomiak Date: Thu, 27 Mar 2025 13:39:53 +0100 Subject: [PATCH] [angular] WEB-72193 Support for inputBinding, outputBinding and twoWayBinding - improve error messages - reuse referencing Web Symbol name as the reference display name (cherry picked from commit ad2d73618df1ca1e6e26c5d5945b1d56249667d9) IJ-CR-158672 GitOrigin-RevId: 9aa4af56283843889ae094d1bb085213d0b00409 --- platform/webSymbols/api-dump-experimental.txt | 2 ++ .../query/WebSymbolsQueryExecutor.kt | 2 ++ .../query/impl/WebSymbolsQueryExecutorImpl.kt | 23 ++++++++++++++++--- .../webSymbols/utils/ReferencingWebSymbol.kt | 2 +- ...mbolHtmlAttributeValueReferenceProvider.kt | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/platform/webSymbols/api-dump-experimental.txt b/platform/webSymbols/api-dump-experimental.txt index 0c784afa2fec..8f609980e681 100644 --- a/platform/webSymbols/api-dump-experimental.txt +++ b/platform/webSymbols/api-dump-experimental.txt @@ -817,6 +817,7 @@ - a:createPointer():com.intellij.model.Pointer - a:getContext():com.intellij.webSymbols.context.WebSymbolsContext - getFramework():java.lang.String +- a:getKeepUnresolvedTopLevelReferences():Z - a:getLocation():com.intellij.psi.PsiElement - a:getNamesProvider():com.intellij.webSymbols.query.WebSymbolNamesProvider - a:getResultsCustomizer():com.intellij.webSymbols.query.WebSymbolsQueryResultsCustomizer @@ -838,6 +839,7 @@ - bs:runNameMatchQuery$default(com.intellij.webSymbols.query.WebSymbolsQueryExecutor,com.intellij.webSymbols.WebSymbolQualifiedName,Z,Z,Z,java.util.List,I,java.lang.Object):java.util.List - bs:runNameMatchQuery$default(com.intellij.webSymbols.query.WebSymbolsQueryExecutor,java.lang.String,java.lang.String,java.lang.String,Z,Z,Z,java.util.List,I,java.lang.Object):java.util.List - bs:runNameMatchQuery$default(com.intellij.webSymbols.query.WebSymbolsQueryExecutor,java.util.List,Z,Z,Z,java.util.List,I,java.lang.Object):java.util.List +- a:setKeepUnresolvedTopLevelReferences(Z):V - a:withNameConversionRules(java.util.List):com.intellij.webSymbols.query.WebSymbolsQueryExecutor *:com.intellij.webSymbols.query.WebSymbolsQueryExecutorFactory - com.intellij.openapi.Disposable diff --git a/platform/webSymbols/src/com/intellij/webSymbols/query/WebSymbolsQueryExecutor.kt b/platform/webSymbols/src/com/intellij/webSymbols/query/WebSymbolsQueryExecutor.kt index b95f7bc1924f..821c0313b8cf 100644 --- a/platform/webSymbols/src/com/intellij/webSymbols/query/WebSymbolsQueryExecutor.kt +++ b/platform/webSymbols/src/com/intellij/webSymbols/query/WebSymbolsQueryExecutor.kt @@ -34,6 +34,8 @@ interface WebSymbolsQueryExecutor : ModificationTracker { val resultsCustomizer: WebSymbolsQueryResultsCustomizer + var keepUnresolvedTopLevelReferences: Boolean + fun createPointer(): Pointer fun runNameMatchQuery(namespace: SymbolNamespace, diff --git a/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolsQueryExecutorImpl.kt b/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolsQueryExecutorImpl.kt index 1348b143773f..89b73df1ce1b 100644 --- a/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolsQueryExecutorImpl.kt +++ b/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolsQueryExecutorImpl.kt @@ -40,6 +40,8 @@ class WebSymbolsQueryExecutorImpl( private val rootScope: List = initializeCompoundScopes(rootScope) private var nestingLevel: Int = 0 + override var keepUnresolvedTopLevelReferences: Boolean = false + override fun hashCode(): Int = Objects.hash(location, rootScope, context, namesProvider, resultsCustomizer) @@ -161,9 +163,18 @@ class WebSymbolsQueryExecutorImpl( .asSequence() .flatMap { scope -> ProgressManager.checkCanceled() - scope.getMatchingSymbols(qualifiedName, params, Stack(finalContext)) + val prev = keepUnresolvedTopLevelReferences + keepUnresolvedTopLevelReferences = false + try { + scope.getMatchingSymbols(qualifiedName, params, Stack(finalContext)) + } finally { + keepUnresolvedTopLevelReferences = prev + } + } + .filter { + keepUnresolvedTopLevelReferences + || it !is WebSymbolMatch || it.nameSegments.size > 1 || (it.nameSegments.isNotEmpty() && it.nameSegments[0].problem == null) } - .filter { it !is WebSymbolMatch || it.nameSegments.size > 1 || (it.nameSegments.isNotEmpty() && it.nameSegments[0].problem == null) } .distinct() .toList() .customizeMatches(params.strictScope, qualifiedName) @@ -300,7 +311,13 @@ class WebSymbolsQueryExecutorImpl( val scopeSymbols = scope .takeLastUntilExclusiveScopeFor(qName.qualifiedKind) .flatMap { - it.getMatchingSymbols(qName, contextQueryParams, Stack(scope)) + val prev = keepUnresolvedTopLevelReferences + keepUnresolvedTopLevelReferences = false + try { + it.getMatchingSymbols(qName, contextQueryParams, Stack(scope)) + } finally { + keepUnresolvedTopLevelReferences = prev + } } scopeSymbols.flatMapTo(scope) { it.queryScope diff --git a/platform/webSymbols/src/com/intellij/webSymbols/utils/ReferencingWebSymbol.kt b/platform/webSymbols/src/com/intellij/webSymbols/utils/ReferencingWebSymbol.kt index 1048c3a25f6a..b45869c4c6b0 100644 --- a/platform/webSymbols/src/com/intellij/webSymbols/utils/ReferencingWebSymbol.kt +++ b/platform/webSymbols/src/com/intellij/webSymbols/utils/ReferencingWebSymbol.kt @@ -52,7 +52,7 @@ class ReferencingWebSymbol private constructor( }.toTypedArray() )), false, WebSymbolsPatternFactory.createPatternSequence( - WebSymbolsPatternFactory.createSymbolReferencePlaceholder(), + WebSymbolsPatternFactory.createSymbolReferencePlaceholder(name), ) ) diff --git a/xml/xml-psi-impl/src/com/intellij/html/webSymbols/attributeValues/WebSymbolHtmlAttributeValueReferenceProvider.kt b/xml/xml-psi-impl/src/com/intellij/html/webSymbols/attributeValues/WebSymbolHtmlAttributeValueReferenceProvider.kt index ec0e7d5bfb40..650e5c3e4c2f 100644 --- a/xml/xml-psi-impl/src/com/intellij/html/webSymbols/attributeValues/WebSymbolHtmlAttributeValueReferenceProvider.kt +++ b/xml/xml-psi-impl/src/com/intellij/html/webSymbols/attributeValues/WebSymbolHtmlAttributeValueReferenceProvider.kt @@ -43,6 +43,7 @@ class WebSymbolHtmlAttributeValueReferenceProvider : PsiWebSymbolReferenceProvid ?.asSingleSymbol() else queryExecutor + .also { it.keepUnresolvedTopLevelReferences = true } .runNameMatchQuery(WebSymbol.HTML_ATTRIBUTE_VALUES.withName(name)) .takeIf { it.isNotEmpty()