mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
WEB-63554 Refactor runListSymbolsQuery and runCodeCompletionQuery to use qualified kind and name
GitOrigin-RevId: 2783b167a3eaa8633cab1a61a599df40698759db
This commit is contained in:
committed by
intellij-monorepo-bot
parent
69ad67c04b
commit
a00bdc9704
@@ -65,7 +65,7 @@ class WebSymbolsPatternReferenceResolver(private vararg val items: Reference) :
|
||||
queryExecutor: WebSymbolsQueryExecutor,
|
||||
expandPatterns: Boolean): List<WebSymbol> {
|
||||
val symbols = queryExecutor.withNameConversionRules(nameConversionRules)
|
||||
.runListSymbolsQuery(location, qualifiedKind.namespace, qualifiedKind.kind,
|
||||
.runListSymbolsQuery(location, qualifiedKind,
|
||||
expandPatterns, includeVirtual, includeAbstract, false, scope)
|
||||
if (filter == null) return symbols
|
||||
return filter.filterNameMatches(symbols, queryExecutor, scope, emptyMap())
|
||||
|
||||
@@ -55,18 +55,16 @@ interface WebSymbolsQueryExecutor : ModificationTracker {
|
||||
strictScope: Boolean = false,
|
||||
scope: List<WebSymbolsScope> = emptyList()): List<WebSymbol>
|
||||
|
||||
fun runListSymbolsQuery(namespace: SymbolNamespace,
|
||||
kind: SymbolKind,
|
||||
fun runListSymbolsQuery(qualifiedKind: WebSymbolQualifiedKind,
|
||||
expandPatterns: Boolean,
|
||||
virtualSymbols: Boolean = true,
|
||||
abstractSymbols: Boolean = false,
|
||||
strictScope: Boolean = false,
|
||||
scope: List<WebSymbolsScope> = emptyList()): List<WebSymbol> =
|
||||
runListSymbolsQuery(emptyList(), namespace, kind, expandPatterns, virtualSymbols, abstractSymbols, strictScope, scope)
|
||||
runListSymbolsQuery(emptyList(), qualifiedKind, expandPatterns, virtualSymbols, abstractSymbols, strictScope, scope)
|
||||
|
||||
fun runListSymbolsQuery(path: List<WebSymbolQualifiedName>,
|
||||
namespace: SymbolNamespace,
|
||||
kind: SymbolKind,
|
||||
qualifiedKind: WebSymbolQualifiedKind,
|
||||
expandPatterns: Boolean,
|
||||
virtualSymbols: Boolean = true,
|
||||
abstractSymbols: Boolean = false,
|
||||
@@ -82,6 +80,13 @@ interface WebSymbolsQueryExecutor : ModificationTracker {
|
||||
scope: List<WebSymbolsScope> = emptyList()): List<WebSymbolCodeCompletionItem> =
|
||||
runCodeCompletionQuery(listOf(WebSymbolQualifiedName(namespace, kind, name)), position, virtualSymbols, scope)
|
||||
|
||||
fun runCodeCompletionQuery(qualifiedName: WebSymbolQualifiedName,
|
||||
/** Position to complete at in the last segment of the path **/
|
||||
position: Int,
|
||||
virtualSymbols: Boolean = true,
|
||||
scope: List<WebSymbolsScope> = emptyList()): List<WebSymbolCodeCompletionItem> =
|
||||
runCodeCompletionQuery(listOf(qualifiedName), position, virtualSymbols, scope)
|
||||
|
||||
fun runCodeCompletionQuery(path: List<WebSymbolQualifiedName>,
|
||||
/** Position to complete at in the last segment of the path **/
|
||||
position: Int,
|
||||
|
||||
@@ -8,7 +8,10 @@ import com.intellij.openapi.util.RecursionManager
|
||||
import com.intellij.util.applyIf
|
||||
import com.intellij.util.concurrency.annotations.RequiresReadLock
|
||||
import com.intellij.util.containers.Stack
|
||||
import com.intellij.webSymbols.*
|
||||
import com.intellij.webSymbols.WebSymbol
|
||||
import com.intellij.webSymbols.WebSymbolQualifiedKind
|
||||
import com.intellij.webSymbols.WebSymbolQualifiedName
|
||||
import com.intellij.webSymbols.WebSymbolsScope
|
||||
import com.intellij.webSymbols.completion.WebSymbolCodeCompletionItem
|
||||
import com.intellij.webSymbols.context.WebSymbolsContext
|
||||
import com.intellij.webSymbols.impl.filterByQueryParams
|
||||
@@ -65,14 +68,13 @@ internal class WebSymbolsQueryExecutorImpl(private val rootScope: List<WebSymbol
|
||||
runNameMatchQuery(path, WebSymbolsNameMatchQueryParams(this, virtualSymbols, abstractSymbols, strictScope), scope)
|
||||
|
||||
override fun runListSymbolsQuery(path: List<WebSymbolQualifiedName>,
|
||||
namespace: SymbolNamespace,
|
||||
kind: SymbolKind,
|
||||
qualifiedKind: WebSymbolQualifiedKind,
|
||||
expandPatterns: Boolean,
|
||||
virtualSymbols: Boolean,
|
||||
abstractSymbols: Boolean,
|
||||
strictScope: Boolean,
|
||||
scope: List<WebSymbolsScope>): List<WebSymbol> =
|
||||
runListSymbolsQuery(path + WebSymbolQualifiedName(namespace, kind, ""),
|
||||
runListSymbolsQuery(path + qualifiedKind.withName(""),
|
||||
WebSymbolsListSymbolsQueryParams(this, expandPatterns = expandPatterns, virtualSymbols = virtualSymbols,
|
||||
abstractSymbols = abstractSymbols, strictScope = strictScope), scope)
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ internal fun Reference.resolve(scope: List<WebSymbolsScope>,
|
||||
if (path.isEmpty()) return@processWebSymbols emptyList()
|
||||
val lastSegment = path.last()
|
||||
if (lastSegment.name.isEmpty())
|
||||
runListSymbolsQuery(path.subList(0, path.size - 1), lastSegment.namespace, lastSegment.kind,
|
||||
runListSymbolsQuery(path.subList(0, path.size - 1), lastSegment.qualifiedKind,
|
||||
false, virtualSymbols2, abstractSymbols2, false, scope)
|
||||
else
|
||||
runNameMatchQuery(path, virtualSymbols2, abstractSymbols2, false, scope)
|
||||
@@ -212,7 +212,7 @@ internal fun Reference.list(scope: List<WebSymbolsScope>,
|
||||
processWebSymbols(null, scope, queryExecutor, virtualSymbols, abstractSymbols) { path, virtualSymbols2, abstractSymbols2 ->
|
||||
if (path.isEmpty()) return@processWebSymbols emptyList()
|
||||
val lastSegment = path.last()
|
||||
runListSymbolsQuery(path.subList(0, path.size - 1), lastSegment.namespace, lastSegment.kind,
|
||||
runListSymbolsQuery(path.subList(0, path.size - 1), lastSegment.qualifiedKind,
|
||||
expandPatterns, virtualSymbols2, abstractSymbols2, false, scope)
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ class WebSymbolsListQueryTest : WebSymbolsMockQueryExecutorTestBase() {
|
||||
.asSingleSymbol()
|
||||
}
|
||||
val results = queryExecutor
|
||||
.runListSymbolsQuery(parsedPath.subList(0, parsedPath.size - 1), last.namespace, last.kind,
|
||||
.runListSymbolsQuery(parsedPath.subList(0, parsedPath.size - 1), last.qualifiedKind,
|
||||
true, includeVirtual, false)
|
||||
.filter { !it.extension }
|
||||
assertEquals(printMatches(codeCompletionResults), printMatches(results))
|
||||
@@ -221,7 +221,7 @@ class WebSymbolsListQueryTest : WebSymbolsMockQueryExecutorTestBase() {
|
||||
|
||||
doTest(testPath) {
|
||||
queryExecutor
|
||||
.runListSymbolsQuery(parsedPath.subList(0, parsedPath.size - 1), last.namespace, last.kind,
|
||||
.runListSymbolsQuery(parsedPath.subList(0, parsedPath.size - 1), last.qualifiedKind,
|
||||
expandPatterns, includeVirtual, false)
|
||||
.let { printMatches(it) }
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.psi.xml.XmlTag
|
||||
import com.intellij.util.asSafely
|
||||
import com.intellij.webSymbols.WebSymbol
|
||||
import com.intellij.webSymbols.WebSymbol.Companion.HTML_ATTRIBUTES
|
||||
import com.intellij.webSymbols.WebSymbol.Companion.KIND_HTML_ATTRIBUTES
|
||||
import com.intellij.webSymbols.WebSymbol.Companion.KIND_HTML_ELEMENTS
|
||||
import com.intellij.webSymbols.WebSymbol.Companion.NAMESPACE_HTML
|
||||
@@ -31,7 +32,7 @@ class WebSymbolAttributeDescriptorsProvider : XmlAttributeDescriptorsProvider {
|
||||
val symbols = (context.descriptor as? WebSymbolElementDescriptor)?.symbol?.let { listOf(it) }
|
||||
?: queryExecutor.runNameMatchQuery(NAMESPACE_HTML, KIND_HTML_ELEMENTS, context.name)
|
||||
queryExecutor
|
||||
.runListSymbolsQuery(NAMESPACE_HTML, KIND_HTML_ATTRIBUTES, expandPatterns = true, scope = symbols, virtualSymbols = false)
|
||||
.runListSymbolsQuery(HTML_ATTRIBUTES, expandPatterns = true, scope = symbols, virtualSymbols = false)
|
||||
.asSequence()
|
||||
.filter { !it.hasOnlyStandardHtmlSymbolsOrExtensions() }
|
||||
.map { it.getAttributeDescriptor(it.name, context, queryExecutor) }
|
||||
|
||||
@@ -14,10 +14,7 @@ import com.intellij.psi.impl.source.xml.XmlDescriptorUtil.wrapInDelegating
|
||||
import com.intellij.psi.xml.XmlAttribute
|
||||
import com.intellij.psi.xml.XmlTag
|
||||
import com.intellij.util.asSafely
|
||||
import com.intellij.webSymbols.SymbolKind
|
||||
import com.intellij.webSymbols.SymbolNamespace
|
||||
import com.intellij.webSymbols.WebSymbol
|
||||
import com.intellij.webSymbols.WebSymbolQualifiedName
|
||||
import com.intellij.webSymbols.*
|
||||
import com.intellij.webSymbols.completion.WebSymbolCodeCompletionItem
|
||||
import com.intellij.webSymbols.query.WebSymbolsQueryExecutorFactory
|
||||
import com.intellij.webSymbols.utils.nameSegments
|
||||
@@ -47,23 +44,20 @@ open class WebSymbolElementDescriptor private constructor(private val tag: XmlTa
|
||||
.runNameMatchQuery(listOf(WebSymbolQualifiedName(namespace, kind, name)), virtualSymbols, abstractSymbols, strictScope,
|
||||
listOf(symbol))
|
||||
|
||||
fun runListSymbolsQuery(namespace: SymbolNamespace,
|
||||
kind: SymbolKind,
|
||||
fun runListSymbolsQuery(qualifiedKind: WebSymbolQualifiedKind,
|
||||
expandPatterns: Boolean,
|
||||
virtualSymbols: Boolean = true,
|
||||
abstractSymbols: Boolean = false,
|
||||
strictScope: Boolean = false): List<WebSymbol> =
|
||||
WebSymbolsQueryExecutorFactory.create(tag)
|
||||
.runListSymbolsQuery(namespace, kind, expandPatterns, virtualSymbols, abstractSymbols, strictScope, listOf(symbol))
|
||||
.runListSymbolsQuery(qualifiedKind, expandPatterns, virtualSymbols, abstractSymbols, strictScope, listOf(symbol))
|
||||
|
||||
fun runCodeCompletionQuery(namespace: SymbolNamespace,
|
||||
kind: SymbolKind,
|
||||
name: String,
|
||||
fun runCodeCompletionQuery(qualifiedName: WebSymbolQualifiedName,
|
||||
/** Position to complete at in the last segment of the path **/
|
||||
position: Int,
|
||||
virtualSymbols: Boolean = true): List<WebSymbolCodeCompletionItem> =
|
||||
WebSymbolsQueryExecutorFactory.create(tag)
|
||||
.runCodeCompletionQuery(listOf(WebSymbolQualifiedName(namespace, kind, name)), position, virtualSymbols, listOf(symbol))
|
||||
.runCodeCompletionQuery(qualifiedName, position, virtualSymbols, listOf(symbol))
|
||||
|
||||
override fun getQualifiedName(): String {
|
||||
return name
|
||||
|
||||
Reference in New Issue
Block a user