Scopri come trovare il dietologo giusto per le tue esigenze. Questo articolo offre consigli pratici e suggerimenti utili per scegliere un professionista qualificato, ottimizzando il tuo percorso verso una salute migliore attraverso una nutrizione consapevole e personalizzata. Non perdere l'opportunità di migliorare il tuo benessere!
Trova professionisti vicino a te
Trova professionisti
/*
* Copyright (c) 2017. tangzx([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tang.intellij.lua.psi
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.SearchScope
import com.intellij.util.IncorrectOperationException
import com.tang.intellij.lua.Constants
import com.tang.intellij.lua.search.SearchContext
/**
* local
* Created by tangzx on 2017/2/9.
*/
class LuaLocalVarReference(element: LuaLocalVarDef) : PsiReferenceBase(element), PsiPolyVariantReference {
override fun multiResolve(incompleteCode: Boolean): Array {
val element = element
val name = element.name
val project = element.project
val searchContext = SearchContext.get(element)
val resolvedElements = searchContext.findLocal(name)
return resolvedElements.map { LuaResolveResult(it) }.toTypedArray()
}
override fun resolve(): PsiElement? {
val resolveResults = multiResolve(false)
return if (resolveResults.size == 1) resolveResults[0].element else null
}
override fun getVariants(): Array {
return PsiElement.EMPTY_ARRAY
}
override fun getRangeInElement(): TextRange {
val text = element.text
val name = element.name
return TextRange.from(text.indexOf(name), name.length)
}
override fun handleElementRename(newElementName: String): PsiElement {
throw IncorrectOperationException("rename local not support")
}
override fun getCanonicalText(): String {
return element.name
}
override fun isReferenceTo(element: PsiElement): Boolean {
return this.element == element
}
override fun getElement(): LuaLocalVarDef {
return element
}
override fun bindToElement(element: PsiElement): PsiElement {
throw IncorrectOperationException("bindToElement not supported")
}
override fun isSoft(): Boolean {
return false
}
override fun getReferenceNameElement(): PsiElement {
return element
}
override fun getContext(): PsiElement? {
return element
}
override fun getGlobalSearchScope(): SearchScope {
return GlobalSearchScope.projectScope(element.project)
}
override fun getClassName(): String {
return Constants.WORD_LOCAL
}
}