From 01f4719c4a3cc02bc21e1f5d43bcb5650d9291fe Mon Sep 17 00:00:00 2001 From: Piotr Tomiak Date: Thu, 28 Mar 2024 13:31:58 +0100 Subject: [PATCH] WEB-49174 "Property is not provided by any applicable directive" error when using custom directive with ng-template selector GitOrigin-RevId: de5ec407ab28077b88fdfa5fc8f67d08c60a1e4d --- .../query/impl/WebSymbolMatchImpl.kt | 27 ++++++++----- .../webSymbols/utils/MappedWebSymbol.kt | 39 +++++++++++++++++++ 2 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 platform/webSymbols/src/com/intellij/webSymbols/utils/MappedWebSymbol.kt diff --git a/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolMatchImpl.kt b/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolMatchImpl.kt index b3636168d6cf..ccbdfe22c750 100644 --- a/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolMatchImpl.kt +++ b/platform/webSymbols/src/com/intellij/webSymbols/query/impl/WebSymbolMatchImpl.kt @@ -1,8 +1,6 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.webSymbols.query.impl -import com.intellij.find.usages.api.SearchTarget -import com.intellij.find.usages.symbol.SearchTargetSymbol import com.intellij.model.Pointer import com.intellij.model.Symbol import com.intellij.openapi.project.Project @@ -15,6 +13,7 @@ import com.intellij.webSymbols.documentation.WebSymbolDocumentation import com.intellij.webSymbols.documentation.WebSymbolDocumentationTarget import com.intellij.webSymbols.html.WebSymbolHtmlAttributeValue import com.intellij.webSymbols.query.WebSymbolMatch +import com.intellij.webSymbols.refactoring.WebSymbolRenameTarget import com.intellij.webSymbols.search.WebSymbolSearchTarget import com.intellij.webSymbols.utils.coalesceApiStatus import com.intellij.webSymbols.utils.merge @@ -141,14 +140,22 @@ internal open class WebSymbolMatchImpl private constructor( } override val searchTarget: WebSymbolSearchTarget? - get() = if (nameSegments.filter { it.start != it.end } - .takeIf { it.size == 1 } - ?.get(0) - ?.symbols - ?.all { it is SearchTarget || it is SearchTargetSymbol || it.searchTarget != null } == true) - WebSymbolSearchTarget.create(this) - else - null + get() = nameSegments.filter { it.start != it.end } + .takeIf { it.size == 1 } + ?.get(0) + ?.symbols + ?.takeIf { it.size == 1 } + ?.get(0) + ?.searchTarget + + override val renameTarget: WebSymbolRenameTarget? + get() = nameSegments.filter { it.start != it.end } + .takeIf { it.size == 1 } + ?.get(0) + ?.symbols + ?.takeIf { it.size == 1 } + ?.get(0) + ?.renameTarget override fun equals(other: Any?): Boolean = other is WebSymbolMatch diff --git a/platform/webSymbols/src/com/intellij/webSymbols/utils/MappedWebSymbol.kt b/platform/webSymbols/src/com/intellij/webSymbols/utils/MappedWebSymbol.kt new file mode 100644 index 000000000000..bc62b329a0dc --- /dev/null +++ b/platform/webSymbols/src/com/intellij/webSymbols/utils/MappedWebSymbol.kt @@ -0,0 +1,39 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.webSymbols.utils + +import com.intellij.model.Pointer +import com.intellij.webSymbols.* +import com.intellij.webSymbols.patterns.WebSymbolsPattern +import com.intellij.webSymbols.patterns.WebSymbolsPatternFactory + +/** + * A utility [WebSymbol], which allows to map + * from one symbol to another symbol. + * + * The mapping will be made, if the [MappedWebSymbol.name] + * matches exactly the queried name. As a result, + * a reference to the symbol resolved through the + * `mappingPath` will be created. + */ +class MappedWebSymbol private constructor( + override val namespace: SymbolNamespace, + override val kind: SymbolKind, + override val name: String, + override val origin: WebSymbolOrigin, + vararg mappingPath: WebSymbolQualifiedName, + override val priority: WebSymbol.Priority? = null, +) : WebSymbol { + + constructor(qualifiedKind: WebSymbolQualifiedKind, + name: String, + origin: WebSymbolOrigin, + vararg mappingPath: WebSymbolQualifiedName, + priority: WebSymbol.Priority? = null) + : this(qualifiedKind.namespace, qualifiedKind.kind, name, origin, *mappingPath, priority = priority) + + override val pattern: WebSymbolsPattern = + WebSymbolsPatternFactory.createSingleSymbolReferencePattern(mappingPath.toList()) + + override fun createPointer(): Pointer = + Pointer.hardPointer(this) +} \ No newline at end of file