Don't use PsiElement.getReference() on JetElement
This commit is contained in:
+10
-8
@@ -14,16 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.psi;
|
||||
package org.jetbrains.kotlin.psi
|
||||
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.psi.NavigatablePsiElement
|
||||
import com.intellij.psi.PsiReference
|
||||
|
||||
public interface JetElement extends NavigatablePsiElement {
|
||||
@NotNull
|
||||
JetFile getContainingJetFile();
|
||||
public interface JetElement : NavigatablePsiElement {
|
||||
public fun getContainingJetFile(): JetFile
|
||||
|
||||
<D> void acceptChildren(@NotNull JetVisitor<Void, D> visitor, D data);
|
||||
public fun <D> acceptChildren(visitor: JetVisitor<Void, D>, data: D)
|
||||
|
||||
<R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data);
|
||||
public fun <R, D> accept(visitor: JetVisitor<R, D>, data: D): R
|
||||
|
||||
@deprecated("Don't use getReference() on JetElement for the choice is unpredictable")
|
||||
override fun getReference(): PsiReference?
|
||||
}
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT
|
||||
return null
|
||||
}
|
||||
|
||||
private val stringExpressionEvaluator = object : JetVisitor<TypedCompileTimeConstant<String>, Nothing>() {
|
||||
private val stringExpressionEvaluator = object : JetVisitor<TypedCompileTimeConstant<String>, Nothing?>() {
|
||||
private fun createStringConstant(compileTimeConstant: CompileTimeConstant<*>): TypedCompileTimeConstant<String>? {
|
||||
val constantValue = compileTimeConstant.toConstantValue(TypeUtils.NO_EXPECTED_TYPE)
|
||||
return when (constantValue) {
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
|
||||
import org.jetbrains.kotlin.idea.references.JetArrayAccessReference
|
||||
import org.jetbrains.kotlin.idea.references.JetInvokeFunctionReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.references.unwrappedTargets
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
@@ -161,8 +162,7 @@ public object UsageTypeUtils {
|
||||
}
|
||||
|
||||
fun getFunctionUsageType(descriptor: FunctionDescriptor): UsageTypeEnum? {
|
||||
val ref = refExpr.getReference()
|
||||
when (ref) {
|
||||
when (refExpr.mainReference) {
|
||||
is JetArrayAccessReference -> {
|
||||
return when {
|
||||
context[BindingContext.INDEXED_LVALUE_GET, refExpr] != null -> IMPLICIT_GET
|
||||
@@ -216,7 +216,7 @@ public object UsageTypeUtils {
|
||||
else -> getClassUsageType()
|
||||
}
|
||||
is PackageViewDescriptor -> {
|
||||
if (refExpr.getReference()?.resolve() is PsiPackage) getPackageUsageType() else getClassUsageType()
|
||||
if (refExpr.mainReference.resolve() is PsiPackage) getPackageUsageType() else getClassUsageType()
|
||||
}
|
||||
is VariableDescriptor -> getVariableUsageType()
|
||||
is FunctionDescriptor -> getFunctionUsageType(descriptor)
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
|
||||
import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor
|
||||
import org.jetbrains.kotlin.idea.quickfix.QuickFixes
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.psi.JetCodeFragment
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
@@ -104,7 +105,7 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension {
|
||||
when (factory) {
|
||||
in Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS -> {
|
||||
val referenceExpression = diagnostic.getPsiElement() as JetReferenceExpression
|
||||
val reference = referenceExpression.getReference()
|
||||
val reference = referenceExpression.mainReference
|
||||
if (reference is MultiRangeReference) {
|
||||
for (range in reference.getRanges()) {
|
||||
val annotation = holder.createErrorAnnotation(range.shiftRight(referenceExpression.getTextOffset()), getDefaultMessage(diagnostic))
|
||||
|
||||
+4
-4
@@ -20,10 +20,12 @@ import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.JetDynamicType;
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.kotlin.psi.JetTypeParameter;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
|
||||
@@ -34,8 +36,6 @@ class TypeKindHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
|
||||
@Override
|
||||
public void visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression) {
|
||||
PsiReference ref = expression.getReference();
|
||||
if (ref == null) return;
|
||||
if (JetPsiChecker.Companion.getNamesHighlightingEnabled()) {
|
||||
DeclarationDescriptor referenceTarget = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
|
||||
if (referenceTarget instanceof ConstructorDescriptor) {
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
|
||||
|
||||
public class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() {
|
||||
@@ -29,8 +30,8 @@ public class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() {
|
||||
private class KDocUnresolvedReferenceVisitor(private val holder: ProblemsHolder): PsiElementVisitor() {
|
||||
override fun visitElement(element: PsiElement) {
|
||||
if (element is KDocName) {
|
||||
val ref = element.getReference()
|
||||
if (ref != null && ref.resolve() == null) {
|
||||
val ref = element.mainReference
|
||||
if (ref.resolve() == null) {
|
||||
holder.registerProblem(ref)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||
import java.util.Collections
|
||||
|
||||
public trait JetReference : PsiPolyVariantReference {
|
||||
public fun resolveToDescriptors(bindingContext: BindingContext): Collection<DeclarationDescriptor>
|
||||
public interface JetReference : PsiPolyVariantReference {
|
||||
fun resolveToDescriptors(bindingContext: BindingContext): Collection<DeclarationDescriptor>
|
||||
|
||||
override fun getElement(): JetElement
|
||||
}
|
||||
|
||||
public abstract class AbstractJetReference<T : JetElement>(element: T)
|
||||
|
||||
@@ -19,12 +19,14 @@ package org.jetbrains.kotlin.idea.references
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.asJava.unwrapped
|
||||
import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.dataClassComponentFunctionName
|
||||
import org.jetbrains.kotlin.idea.kdoc.KDocReference
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
import java.util.HashSet
|
||||
|
||||
@@ -111,6 +113,25 @@ fun AbstractJetReference<out JetExpression>.renameImplicitConventionalCall(newNa
|
||||
if (newName == null) return expression
|
||||
|
||||
val expr = OperatorToFunctionIntention.convert(expression) as JetQualifiedExpression
|
||||
val newCallee = (expr.getSelectorExpression() as JetCallExpression).getCalleeExpression()!!.getReference()!!.handleElementRename(newName)
|
||||
val callee = (expr.getSelectorExpression() as JetCallExpression).getCalleeExpression() as JetSimpleNameExpression
|
||||
val newCallee = callee.mainReference.handleElementRename(newName)
|
||||
return newCallee.getStrictParentOfType<JetQualifiedExpression>() as JetExpression
|
||||
}
|
||||
|
||||
val JetSimpleNameExpression.mainReference: JetSimpleNameReference
|
||||
get() = getReferences().firstIsInstance()
|
||||
|
||||
val JetReferenceExpression.mainReference: JetReference
|
||||
get() = if (this is JetSimpleNameExpression) mainReference else getReferences().firstIsInstance<JetReference>()
|
||||
|
||||
val KDocName.mainReference: KDocReference
|
||||
get() = getReferences().firstIsInstance()
|
||||
|
||||
val JetElement.mainReference: JetReference?
|
||||
get() {
|
||||
return when {
|
||||
this is JetSimpleNameExpression -> mainReference
|
||||
this is KDocName -> mainReference
|
||||
else -> getReferences().firstIsInstanceOrNull<JetReference>()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ class ClassUsagesSearchHelper(
|
||||
val resolvedCall = bindingContext[BindingContext.RESOLVED_CALL, call] ?: return
|
||||
if ((resolvedCall.getDispatchReceiver() as? ClassReceiver)?.getDeclarationDescriptor() == companionObjectDescriptor
|
||||
|| (resolvedCall.getExtensionReceiver() as? ClassReceiver)?.getDeclarationDescriptor() == companionObjectDescriptor) {
|
||||
element.getReference()?.let { processor.process(it) }
|
||||
element.getReferences().forEach { processor.process(it) }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.idea.completion.smart.LambdaItems
|
||||
import org.jetbrains.kotlin.idea.completion.smart.SmartCompletion
|
||||
import org.jetbrains.kotlin.idea.core.*
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.CallType
|
||||
import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
@@ -84,7 +85,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
protected val expression: JetExpression?
|
||||
|
||||
init {
|
||||
val reference = position.getParent()?.getReferences()?.firstIsInstanceOrNull<JetSimpleNameReference>()
|
||||
val reference = (position.getParent() as? JetSimpleNameExpression)?.mainReference
|
||||
if (reference != null) {
|
||||
if (reference.expression is JetLabelReferenceExpression) {
|
||||
this.nameExpression = null
|
||||
|
||||
+3
-3
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.JetIcons
|
||||
import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler
|
||||
import org.jetbrains.kotlin.idea.core.mapArgumentsToParameters
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -80,9 +81,8 @@ object NamedArgumentCompletion {
|
||||
val callElement = valueArgument.getStrictParentOfType<JetCallElement>() ?: return
|
||||
val callSimpleName = callElement.getCallNameExpression() ?: return
|
||||
|
||||
val callReference = callSimpleName.getReference() as JetReference
|
||||
|
||||
val functionDescriptors = callReference.resolveToDescriptors(bindingContext).map { it as? FunctionDescriptor }.filterNotNull()
|
||||
val functionDescriptors = callSimpleName.mainReference.resolveToDescriptors(bindingContext)
|
||||
.filterIsInstance<FunctionDescriptor>()
|
||||
|
||||
for (funDescriptor in functionDescriptors) {
|
||||
if (!funDescriptor.hasStableParameterNames()) continue
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
<orderEntry type="library" name="idea-full" level="project" />
|
||||
<orderEntry type="module" module-name="frontend" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="idea-analysis" />
|
||||
</component>
|
||||
</module>
|
||||
+2
-3
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiClass
|
||||
import org.jetbrains.android.util.AndroidUtils
|
||||
import com.android.SdkConstants
|
||||
import org.jetbrains.android.augment.AndroidPsiElementFinder
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.JetDotQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
@@ -65,9 +66,7 @@ private fun getReferredInfo(
|
||||
|
||||
val firstPart = getReceiverAsSimpleNameExpression(middlePart) ?: return null
|
||||
|
||||
val reference = firstPart.getReference() ?: return null
|
||||
|
||||
val resolvedClass = reference.resolve() as? PsiClass ?: return null
|
||||
val resolvedClass = firstPart.mainReference.resolve() as? PsiClass ?: return null
|
||||
|
||||
//the following code is copied from
|
||||
// org.jetbrains.android.util.AndroidResourceUtil.getReferredResourceOrManifestField
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.idea.imports.importableFqNameSafe
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.JetDescriptorIconProvider
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||
|
||||
/**
|
||||
@@ -166,10 +167,8 @@ public class JetAddImportAction(
|
||||
val file = element.getContainingFile() as JetFile
|
||||
val descriptor = selectedVariant.descriptorToImport
|
||||
// for class or package we use ShortenReferences because we not necessary insert an import but may want to insert partly qualified name
|
||||
if (descriptor is ClassDescriptor || descriptor is PackageViewDescriptor) {
|
||||
val fqName = descriptor.importableFqNameSafe
|
||||
val reference = element.getReference() as JetSimpleNameReference
|
||||
reference.bindToFqName(fqName, JetSimpleNameReference.ShorteningMode.FORCED_SHORTENING)
|
||||
if (element is JetSimpleNameExpression && (descriptor is ClassDescriptor || descriptor is PackageViewDescriptor)) {
|
||||
element.mainReference.bindToFqName(descriptor.importableFqNameSafe, JetSimpleNameReference.ShorteningMode.FORCED_SHORTENING)
|
||||
}
|
||||
else {
|
||||
ImportInsertHelper.getInstance(project).importDescriptor(file, descriptor)
|
||||
|
||||
+37
-49
@@ -42,14 +42,13 @@ import org.jetbrains.kotlin.idea.conversion.copy.range
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.start
|
||||
import org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport
|
||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
import org.jetbrains.kotlin.idea.references.JetMultiReference
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.references.*
|
||||
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.elementsInRange
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
@@ -138,37 +137,31 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
) {
|
||||
if (PsiTreeUtil.getNonStrictParentOfType(element, *IGNORE_REFERENCES_INSIDE) != null) return
|
||||
|
||||
element.accept(object : PsiElementVisitor() {
|
||||
override fun visitElement(element: PsiElement) {
|
||||
if (element.javaClass in IGNORE_REFERENCES_INSIDE) return
|
||||
element.forEachDescendantOfType<JetElement>(canGoInside = { it.javaClass !in IGNORE_REFERENCES_INSIDE }) { element ->
|
||||
val reference = element.mainReference ?: return@forEachDescendantOfType
|
||||
|
||||
element.acceptChildren(this)
|
||||
val descriptors = reference.resolveToDescriptors(element.analyze()) //TODO: we could use partial body resolve for all references together
|
||||
//check whether this reference is unambiguous
|
||||
if (reference !is JetMultiReference<*> && descriptors.size() > 1) return@forEachDescendantOfType
|
||||
|
||||
val reference = element.getReference() as? JetReference ?: return
|
||||
for (descriptor in descriptors) {
|
||||
val declarations = DescriptorToSourceUtilsIde.getAllDeclarations(file.getProject(), descriptor)
|
||||
val declaration = declarations.singleOrNull()
|
||||
if (declaration != null && declaration.isInCopiedArea(file, startOffsets, endOffsets)) continue
|
||||
|
||||
val descriptors = reference.resolveToDescriptors((element as JetElement).analyze()) //TODO: we could use partial body resolve for all references together
|
||||
//check whether this reference is unambiguous
|
||||
if (reference !is JetMultiReference<*> && descriptors.size() > 1) return
|
||||
|
||||
for (descriptor in descriptors) {
|
||||
val declarations = DescriptorToSourceUtilsIde.getAllDeclarations(file.getProject(), descriptor)
|
||||
val declaration = declarations.singleOrNull()
|
||||
if (declaration != null && declaration.isInCopiedArea(file, startOffsets, endOffsets)) continue
|
||||
|
||||
if (!descriptor.isExtension) {
|
||||
if (element !is JetNameReferenceExpression) continue
|
||||
if (element.getIdentifier() == null) continue // skip 'this' etc
|
||||
if (element.getReceiverExpression() != null) continue
|
||||
}
|
||||
|
||||
val fqName = descriptor.importableFqName ?: continue
|
||||
if (!descriptor.canBeReferencedViaImport()) continue
|
||||
|
||||
val kind = KotlinReferenceData.Kind.fromDescriptor(descriptor) ?: continue
|
||||
add(KotlinReferenceData(element.range.start - startOffset, element.range.end - startOffset, fqName.asString(), kind))
|
||||
if (!descriptor.isExtension) {
|
||||
if (element !is JetNameReferenceExpression) continue
|
||||
if (element.getIdentifier() == null) continue // skip 'this' etc
|
||||
if (element.getReceiverExpression() != null) continue
|
||||
}
|
||||
|
||||
val fqName = descriptor.importableFqName ?: continue
|
||||
if (!descriptor.canBeReferencedViaImport()) continue
|
||||
|
||||
val kind = KotlinReferenceData.Kind.fromDescriptor(descriptor) ?: continue
|
||||
add(KotlinReferenceData(element.range.start - startOffset, element.range.end - startOffset, fqName.asString(), kind))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private data class ReferenceToRestoreData(
|
||||
@@ -213,36 +206,32 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
|
||||
val fileResolutionScope = file.getResolutionFacade().getFileTopLevelScope(file)
|
||||
return referenceData.map {
|
||||
val referenceElement = findReference(it, file, blockStart)
|
||||
if (referenceElement != null)
|
||||
createReferenceToRestoreData(referenceElement, it, file, fileResolutionScope)
|
||||
val reference = findReference(it, file, blockStart)
|
||||
if (reference != null)
|
||||
createReferenceToRestoreData(reference, it, file, fileResolutionScope)
|
||||
else
|
||||
null
|
||||
}.filterNotNull()
|
||||
}
|
||||
|
||||
private fun findReference(data: KotlinReferenceData, file: JetFile, blockStart: Int): JetElement? {
|
||||
private fun findReference(data: KotlinReferenceData, file: JetFile, blockStart: Int): JetReference? {
|
||||
val startOffset = data.startOffset + blockStart
|
||||
val endOffset = data.endOffset + blockStart
|
||||
val element = file.findElementAt(startOffset)
|
||||
val desiredRange = TextRange(startOffset, endOffset)
|
||||
var expression = element
|
||||
while (expression != null) {
|
||||
val range = expression!!.range
|
||||
if (range == desiredRange && expression!!.getReference() != null) {
|
||||
return expression as? JetElement
|
||||
}
|
||||
if (range in desiredRange) {
|
||||
expression = expression!!.getParent()
|
||||
}
|
||||
else {
|
||||
return null
|
||||
var current = element
|
||||
while (current != null) {
|
||||
val range = current.range
|
||||
if (current is JetElement && range == desiredRange) {
|
||||
current.mainReference?.let { return it }
|
||||
}
|
||||
if (range !in desiredRange) return null
|
||||
current = current.getParent()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun createReferenceToRestoreData(element: JetElement, refData: KotlinReferenceData, file: JetFile, fileResolutionScope: JetScope): ReferenceToRestoreData? {
|
||||
private fun createReferenceToRestoreData(reference: JetReference, refData: KotlinReferenceData, file: JetFile, fileResolutionScope: JetScope): ReferenceToRestoreData? {
|
||||
val originalFqName = FqName(refData.fqName)
|
||||
|
||||
if (refData.kind == KotlinReferenceData.Kind.EXTENSION_FUNCTION) {
|
||||
@@ -252,12 +241,11 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
if (fileResolutionScope.getProperties(originalFqName.shortName()).any { it.importableFqName == originalFqName }) return null // already imported
|
||||
}
|
||||
|
||||
val reference = element.getReference() as? JetReference ?: return null
|
||||
val referencedDescriptors = try {
|
||||
reference.resolveToDescriptors(element.analyze()) //TODO: we could use partial body resolve for all references together
|
||||
reference.resolveToDescriptors(reference.getElement().analyze()) //TODO: we could use partial body resolve for all references together
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
LOG.error("Failed to analyze reference (${element.getText()}) after copy paste", e)
|
||||
LOG.error("Failed to analyze reference ($reference) after copy paste", e)
|
||||
return null
|
||||
}
|
||||
val referencedFqNames = referencedDescriptors
|
||||
@@ -303,7 +291,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
||||
importHelper.importDescriptor(file, descriptor)
|
||||
}
|
||||
for ((pointer, fqName) in bindingRequests) {
|
||||
val reference = pointer.getElement()!!.getReference() as JetSimpleNameReference
|
||||
val reference = pointer.getElement()!!.mainReference
|
||||
reference.bindToFqName(fqName, JetSimpleNameReference.ShorteningMode.DELAYED_SHORTENING)
|
||||
}
|
||||
performDelayedShortening(file.getProject())
|
||||
|
||||
@@ -36,7 +36,7 @@ public abstract class CalleeReferenceVisitorBase extends JetTreeVisitorVoid {
|
||||
this.deepTraversal = deepTraversal;
|
||||
}
|
||||
|
||||
protected abstract void processDeclaration(JetReferenceExpression reference, PsiElement declaration);
|
||||
protected abstract void processDeclaration(JetSimpleNameExpression reference, PsiElement declaration);
|
||||
|
||||
@Override
|
||||
public void visitJetElement(@NotNull JetElement element) {
|
||||
|
||||
+3
-2
@@ -27,6 +27,7 @@ import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.asJava.KotlinLightMethod;
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.idea.references.ReferencesPackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
|
||||
@@ -90,8 +91,8 @@ public class KotlinCalleeMethodsTreeStructure extends KotlinCallTreeStructure {
|
||||
element.accept(
|
||||
new CalleeReferenceVisitorBase(ResolvePackage.analyze(element, BodyResolveMode.FULL), false) {
|
||||
@Override
|
||||
protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) {
|
||||
referencesToCalleeElements.put(reference.getReference(), declaration);
|
||||
protected void processDeclaration(JetSimpleNameExpression reference, PsiElement declaration) {
|
||||
referencesToCalleeElements.put(ReferencesPackage.getMainReference(reference), declaration);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
+3
-2
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.asJava.LightClassUtil;
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.idea.hierarchy.HierarchyUtils;
|
||||
import org.jetbrains.kotlin.idea.references.JetReference;
|
||||
import org.jetbrains.kotlin.idea.references.ReferencesPackage;
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchPackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
@@ -75,7 +76,7 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure {
|
||||
final Map<PsiReference, PsiElement> referencesToElements = new HashMap<PsiReference, PsiElement>();
|
||||
codeBlockForLocalDeclaration.accept(new CalleeReferenceVisitorBase(bindingContext, true) {
|
||||
@Override
|
||||
protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) {
|
||||
protected void processDeclaration(JetSimpleNameExpression reference, PsiElement declaration) {
|
||||
if (!declaration.equals(element)) return;
|
||||
|
||||
//noinspection unchecked
|
||||
@@ -88,7 +89,7 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure {
|
||||
}
|
||||
|
||||
if (container != null) {
|
||||
referencesToElements.put(reference.getReference(), container);
|
||||
referencesToElements.put(ReferencesPackage.getMainReference(reference), container);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import com.intellij.psi.tree.TokenSet
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.util.Consumer
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
@@ -86,7 +87,7 @@ public class KotlinHighlightExitPointsHandlerFactory: HighlightUsagesHandlerFact
|
||||
|
||||
private fun JetExpression.getRelevantFunction(): JetFunction? {
|
||||
if (this is JetReturnExpression) {
|
||||
(this.getTargetLabel()?.getReference()?.resolve() as? JetFunction)?.let { return it }
|
||||
(this.getTargetLabel()?.mainReference?.resolve() as? JetFunction)?.let { return it }
|
||||
}
|
||||
for (parent in parents) {
|
||||
if (InlineUtil.canBeInlineArgument(parent) && !InlineUtil.isInlinedArgument(parent as JetFunction, parent.analyze(), false)) {
|
||||
|
||||
@@ -187,30 +187,31 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
}
|
||||
|
||||
override fun visitJetElement(element: JetElement) {
|
||||
val reference = element.getReference()
|
||||
if (reference is JetReference) {
|
||||
val referencedName = (element as? JetNameReferenceExpression)?.getReferencedNameAsName() //TODO: other types of references
|
||||
for (reference in element.getReferences()) {
|
||||
if (reference is JetReference) {
|
||||
val referencedName = (element as? JetNameReferenceExpression)?.getReferencedNameAsName() //TODO: other types of references
|
||||
|
||||
val bindingContext = element.analyze()
|
||||
//class qualifiers that refer to companion objects should be considered (containing) class references
|
||||
val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, element as? JetReferenceExpression]?.let { listOf(it) }
|
||||
?: reference.resolveToDescriptors(bindingContext)
|
||||
for (target in targets) {
|
||||
if (!target.canBeReferencedViaImport()) continue
|
||||
if (target is PackageViewDescriptor && target.fqName.parent() == FqName.ROOT) continue // no need to import top-level packages
|
||||
val bindingContext = element.analyze()
|
||||
//class qualifiers that refer to companion objects should be considered (containing) class references
|
||||
val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, element as? JetReferenceExpression]?.let { listOf(it) }
|
||||
?: reference.resolveToDescriptors(bindingContext)
|
||||
for (target in targets) {
|
||||
if (!target.canBeReferencedViaImport()) continue
|
||||
if (target is PackageViewDescriptor && target.fqName.parent() == FqName.ROOT) continue // no need to import top-level packages
|
||||
|
||||
if (!target.isExtension) { // for non-extension targets, count only non-qualified simple name usages
|
||||
if (element !is JetNameReferenceExpression) continue
|
||||
if (element.getIdentifier() == null) continue // skip 'this' etc
|
||||
if (element.getReceiverExpression() != null) continue
|
||||
if (!target.isExtension) { // for non-extension targets, count only non-qualified simple name usages
|
||||
if (element !is JetNameReferenceExpression) continue
|
||||
if (element.getIdentifier() == null) continue // skip 'this' etc
|
||||
if (element.getReceiverExpression() != null) continue
|
||||
}
|
||||
|
||||
val importableDescriptor = target.getImportableDescriptor()
|
||||
if (referencedName != null && importableDescriptor.getName() != referencedName) continue // resolved via alias
|
||||
|
||||
if (isAccessibleAsMember(importableDescriptor, element)) continue
|
||||
|
||||
usedDescriptors.add(importableDescriptor)
|
||||
}
|
||||
|
||||
val importableDescriptor = target.getImportableDescriptor()
|
||||
if (referencedName != null && importableDescriptor.getName() != referencedName) continue // resolved via alias
|
||||
|
||||
if (isAccessibleAsMember(importableDescriptor, element)) continue
|
||||
|
||||
usedDescriptors.add(importableDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.JetFunctionLiteral
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
@@ -57,8 +58,8 @@ public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBa
|
||||
private fun targetFunctionLiteral(element: PsiElement, caretOffset: Int): JetFunctionLiteral? {
|
||||
val expression = element.getParentOfType<JetSimpleNameExpression>(true)
|
||||
if (expression != null) {
|
||||
val reference = expression.getReference() as JetReference?
|
||||
val target = reference?.resolveToDescriptors(expression.analyze())?.firstOrNull() as? ParameterDescriptor ?: return null
|
||||
val target = expression.mainReference.resolveToDescriptors(expression.analyze())
|
||||
.singleOrNull() as? ParameterDescriptor ?: return null
|
||||
val functionDescriptor = target.getContainingDeclaration() as? AnonymousFunctionDescriptor ?: return null
|
||||
return DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor) as? JetFunctionLiteral
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.JetFunctionLiteral
|
||||
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||
@@ -35,8 +36,7 @@ public class ReplaceItWithExplicitFunctionLiteralParamIntention() : JetSelfTarge
|
||||
= isAutoCreatedItUsage(element)
|
||||
|
||||
override fun applyTo(element: JetSimpleNameExpression, editor: Editor) {
|
||||
val reference = element.getReference() as JetReference
|
||||
val target = reference.resolveToDescriptors(element.analyze()).single()
|
||||
val target = element.mainReference.resolveToDescriptors(element.analyze()).single()
|
||||
|
||||
val functionLiteral = DescriptorToSourceUtils.descriptorToDeclaration(target.getContainingDeclaration()!!) as JetFunctionLiteral
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.idea.util.ShortenReferences
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
@@ -66,8 +67,7 @@ fun JetContainerNode.description(): String? {
|
||||
fun isAutoCreatedItUsage(expression: JetSimpleNameExpression): Boolean {
|
||||
if (expression.getReferencedName() != "it") return false
|
||||
val context = expression.analyze()
|
||||
val reference = expression.getReference() as JetReference?
|
||||
val target = reference?.resolveToDescriptors(context)?.singleOrNull() as? ValueParameterDescriptor? ?: return false
|
||||
val target = expression.mainReference.resolveToDescriptors(context).singleOrNull() as? ValueParameterDescriptor? ?: return false
|
||||
return context[BindingContext.AUTO_CREATED_IT, target]!!
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinI
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
@@ -104,9 +105,7 @@ fun JetIfExpression.introduceValueForCondition(occurrenceInThenClause: JetExpres
|
||||
}
|
||||
|
||||
fun JetSimpleNameExpression.inlineIfDeclaredLocallyAndOnlyUsedOnceWithPrompt(editor: Editor) {
|
||||
val declaration = this.getReference()?.resolve() as JetDeclaration
|
||||
|
||||
if (declaration !is JetProperty) return
|
||||
val declaration = this.mainReference.resolve() as? JetProperty ?: return
|
||||
|
||||
val enclosingElement = JetPsiUtil.getEnclosingElementForLocalDeclaration(declaration)
|
||||
val isLocal = enclosingElement != null
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.j2k
|
||||
import com.intellij.openapi.editor.RangeMarker
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.psi.search.LocalSearchScope
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
@@ -34,6 +35,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.I
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention
|
||||
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.RemoveRightPartOfBinaryExpressionFix
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
|
||||
import org.jetbrains.kotlin.j2k.PostProcessor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -188,4 +190,6 @@ public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun simpleNameReference(nameExpression: JetSimpleNameExpression) = nameExpression.mainReference
|
||||
}
|
||||
|
||||
+9
-10
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.idea.JetBundle;
|
||||
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil;
|
||||
import org.jetbrains.kotlin.idea.references.ReferencesPackage;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
|
||||
@@ -50,16 +51,14 @@ public class AddOpenModifierToClassDeclarationFix extends JetIntentionAction<Jet
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiReference reference = referenceExpression.getReference();
|
||||
if (reference != null) {
|
||||
PsiElement target = reference.resolve();
|
||||
if (target instanceof JetSecondaryConstructor) {
|
||||
target = ((JetSecondaryConstructor) target).getContainingClassOrObject();
|
||||
}
|
||||
if (target instanceof JetClass && QuickFixUtil.canModifyElement(target)) {
|
||||
classDeclaration = (JetClass) target;
|
||||
return !(classDeclaration.isEnum() || classDeclaration.isInterface());
|
||||
}
|
||||
PsiReference reference = ReferencesPackage.getMainReference(referenceExpression);
|
||||
PsiElement target = reference.resolve();
|
||||
if (target instanceof JetSecondaryConstructor) {
|
||||
target = ((JetSecondaryConstructor) target).getContainingClassOrObject();
|
||||
}
|
||||
if (target instanceof JetClass && QuickFixUtil.canModifyElement(target)) {
|
||||
classDeclaration = (JetClass) target;
|
||||
return !(classDeclaration.isEnum() || classDeclaration.isInterface());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+3
-2
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory
|
||||
import org.jetbrains.kotlin.idea.findUsages.KotlinFunctionFindUsagesOptions
|
||||
import org.jetbrains.kotlin.idea.findUsages.KotlinPropertyFindUsagesOptions
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.stubindex.JetSourceFilterScope
|
||||
import org.jetbrains.kotlin.idea.util.application.executeCommand
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
@@ -68,7 +69,7 @@ public class DeprecatedSymbolUsageInWholeProjectFix(
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean {
|
||||
if (!super.isAvailable(project, editor, file)) return false
|
||||
val targetPsiElement = element.getReference()?.resolve()
|
||||
val targetPsiElement = element.mainReference.resolve()
|
||||
return targetPsiElement is JetNamedFunction || targetPsiElement is JetProperty
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ public class DeprecatedSymbolUsageInWholeProjectFix(
|
||||
project: Project,
|
||||
editor: Editor?
|
||||
) {
|
||||
val psiElement = element.getReference()!!.resolve()!!
|
||||
val psiElement = element.mainReference.resolve()!!
|
||||
|
||||
ProgressManager.getInstance().run(
|
||||
object : Task.Modal(project, "Applying '$text'", true) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.idea.JetBundle;
|
||||
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil;
|
||||
import org.jetbrains.kotlin.idea.references.ReferencesPackage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
|
||||
public class MakeClassAnAnnotationClassFix extends JetIntentionAction<JetAnnotationEntry> {
|
||||
@@ -57,13 +58,11 @@ public class MakeClassAnAnnotationClassFix extends JetIntentionAction<JetAnnotat
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiReference reference = referenceExpression.getReference();
|
||||
if (reference != null) {
|
||||
PsiElement target = reference.resolve();
|
||||
if (target instanceof JetClass) {
|
||||
annotationClass = (JetClass) target;
|
||||
return QuickFixUtil.canModifyElement(annotationClass);
|
||||
}
|
||||
PsiReference reference = ReferencesPackage.getMainReference(referenceExpression);
|
||||
PsiElement target = reference.resolve();
|
||||
if (target instanceof JetClass) {
|
||||
annotationClass = (JetClass) target;
|
||||
return QuickFixUtil.canModifyElement(annotationClass);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.idea.codeInsight.JetFileReferencesResolver;
|
||||
import org.jetbrains.kotlin.idea.core.refactoring.RefactoringPackage;
|
||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.*;
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference;
|
||||
import org.jetbrains.kotlin.idea.references.ReferencesPackage;
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchPackage;
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocName;
|
||||
@@ -1009,7 +1010,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
|
||||
if (usageInfo instanceof MoveRenameUsageInfo && isJavaMethodUsage) {
|
||||
JetSimpleNameExpression callee = PsiTreeUtil.getParentOfType(usageInfo.getElement(), JetSimpleNameExpression.class, false);
|
||||
PsiReference ref = callee != null ? callee.getReference() : null;
|
||||
PsiReference ref = callee != null ? ReferencesPackage.getMainReference(callee) : null;
|
||||
if (ref instanceof JetSimpleNameReference) {
|
||||
((JetSimpleNameReference) ref).handleElementRename(((PsiMethod)method).getName());
|
||||
return true;
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.compareDescriptors
|
||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -110,7 +111,7 @@ public class JetParameterInfo(
|
||||
}
|
||||
|
||||
override fun visitSimpleNameExpression(expression: JetSimpleNameExpression) {
|
||||
val ref = expression.getReference() as? JetReference ?: return
|
||||
val ref = expression.mainReference
|
||||
val descriptor = getRelevantDescriptor(expression, ref) ?: return
|
||||
map[ref] = descriptor
|
||||
}
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages
|
||||
import com.intellij.usageView.UsageInfo
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||
import org.jetbrains.kotlin.psi.JetQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
|
||||
@@ -38,7 +39,7 @@ public class JetPropertyCallUsage(element: JetSimpleNameExpression): JetUsageInf
|
||||
|
||||
private fun updateName(changeInfo: JetChangeInfo, element: JetSimpleNameExpression) {
|
||||
if (changeInfo.isNameChanged()) {
|
||||
element.getReference()?.handleElementRename(changeInfo.getNewName())
|
||||
element.mainReference.handleElementRename(changeInfo.getNewName())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputVa
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValue.Jump
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference.ShorteningMode
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.approximateFlexibleTypes
|
||||
import org.jetbrains.kotlin.idea.util.isAnnotatedNotNull
|
||||
import org.jetbrains.kotlin.idea.util.isAnnotatedNullable
|
||||
@@ -118,7 +119,7 @@ class FqNameReplacement(val fqName: FqName): Replacement {
|
||||
return thisExpr.replaced(JetPsiFactory(e).createExpression(fqName.asString())).getQualifiedElementSelector()!!
|
||||
}
|
||||
|
||||
val newExpr = (e.getReference() as? JetSimpleNameReference)?.bindToFqName(fqName, ShorteningMode.NO_SHORTENING) as JetElement
|
||||
val newExpr = (e as? JetSimpleNameExpression)?.mainReference?.bindToFqName(fqName, ShorteningMode.NO_SHORTENING) as JetElement
|
||||
return if (newExpr is JetQualifiedExpression) newExpr.getSelectorExpression()!! else newExpr
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -59,6 +59,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputVa
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValue.Jump
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValue.ParameterUpdate
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValueBoxer.AsList
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.idea.util.approximateWithResolvableType
|
||||
import org.jetbrains.kotlin.idea.util.isResolvableInScope
|
||||
@@ -428,7 +429,7 @@ private fun JetType.collectReferencedTypes(processTypeArguments: Boolean): List<
|
||||
fun JetTypeParameter.collectRelevantConstraints(): List<JetTypeConstraint> {
|
||||
val typeConstraints = getNonStrictParentOfType<JetTypeParameterListOwner>()?.getTypeConstraints()
|
||||
if (typeConstraints == null) return Collections.emptyList()
|
||||
return typeConstraints.filter { it.getSubjectTypeParameterName()?.getReference()?.resolve() == this}
|
||||
return typeConstraints.filter { it.getSubjectTypeParameterName()?.mainReference?.resolve() == this}
|
||||
}
|
||||
|
||||
fun TypeParameter.collectReferencedTypes(bindingContext: BindingContext): List<JetType> {
|
||||
@@ -780,7 +781,7 @@ private fun ExtractionData.checkDeclarationsMovingOutOfScope(
|
||||
controlFlow.jumpOutputValue?.elementToInsertAfterCall?.accept(
|
||||
object : JetTreeVisitorVoid() {
|
||||
override fun visitSimpleNameExpression(expression: JetSimpleNameExpression) {
|
||||
val target = expression.getReference()?.resolve()
|
||||
val target = expression.mainReference.resolve()
|
||||
if (target is JetNamedDeclaration
|
||||
&& target.isInsideOf(originalElements)
|
||||
&& target.getStrictParentOfType<JetDeclaration>() == enclosingDeclaration) {
|
||||
@@ -1006,7 +1007,7 @@ fun ExtractableCodeDescriptor.validate(): ExtractableCodeDescriptorWithConflicts
|
||||
object : JetTreeVisitorVoid() {
|
||||
override fun visitUserType(userType: JetUserType) {
|
||||
val refExpr = userType.getReferenceExpression() ?: return
|
||||
val declaration = refExpr.getReference()?.resolve() as? PsiNamedElement ?: return
|
||||
val declaration = refExpr.mainReference.resolve() as? PsiNamedElement ?: return
|
||||
val diagnostics = bindingContext.getDiagnostics().forElement(refExpr)
|
||||
diagnostics.firstOrNull { it.getFactory() == Errors.INVISIBLE_REFERENCE }?.let {
|
||||
conflicts.putValue(declaration, getDeclarationMessage(declaration, "0.will.become.invisible.after.extraction"))
|
||||
|
||||
+2
-1
@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinI
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.selectElementsWithTargetParent
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.showErrorHint
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.showErrorHintByKey
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.search
|
||||
@@ -367,7 +368,7 @@ private fun findInternalUsagesOfParametersAndReceiver(
|
||||
override fun visitThisExpression(expression: JetThisExpression) {
|
||||
super.visitThisExpression(expression)
|
||||
|
||||
if (expression.getInstanceReference().getReference()?.resolve() == targetDescriptor) {
|
||||
if (expression.getInstanceReference().mainReference.resolve() == targetDescriptor) {
|
||||
usages.putValue(receiverTypeRef, expression)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -41,6 +41,7 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention;
|
||||
import org.jetbrains.kotlin.idea.references.ReferencesPackage;
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
@@ -394,7 +395,7 @@ public class KotlinInplaceVariableIntroducer<D extends JetCallableDeclaration> e
|
||||
new Function1<JetSimpleNameExpression, PsiReference>() {
|
||||
@Override
|
||||
public PsiReference invoke(JetSimpleNameExpression expression) {
|
||||
return expression.getReference();
|
||||
return ReferencesPackage.getMainReference(expression);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import java.util.ArrayList
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
|
||||
public class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler {
|
||||
override fun correctInnerClassUsage(usage: UsageInfo, outerClass: PsiClass) {
|
||||
@@ -38,7 +39,7 @@ public class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler
|
||||
is JetQualifiedExpression -> receiver.getQualifiedElementSelector()
|
||||
else -> null
|
||||
} as? JetSimpleNameExpression
|
||||
if (outerClassRef?.getReference()?.resolve() != outerClass) return
|
||||
if (outerClassRef?.mainReference?.resolve() != outerClass) return
|
||||
|
||||
val outerCall = outerClassRef!!.getParent() as? JetCallExpression ?: return
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.Mo
|
||||
import org.jetbrains.kotlin.idea.references.JetReference
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference.ShorteningMode
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
|
||||
import org.jetbrains.kotlin.idea.util.application.executeCommand
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
@@ -119,7 +120,7 @@ public fun JetElement.getInternalReferencesToUpdateOnPackageNameChange(packageNa
|
||||
packageName == packageNameInfo.oldPackageName,
|
||||
packageName == packageNameInfo.newPackageName,
|
||||
isImported(descriptor) -> {
|
||||
(refExpr.getReference() as? JetSimpleNameReference)?.let { createMoveUsageInfoIfPossible(it, declaration, false) }
|
||||
refExpr.mainReference?.let { createMoveUsageInfoIfPossible(it, declaration, false) }
|
||||
}
|
||||
|
||||
else -> null
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
|
||||
import org.jetbrains.kotlin.idea.jsonUtils.getNullableString
|
||||
import org.jetbrains.kotlin.idea.jsonUtils.getString
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.search.allScope
|
||||
import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils
|
||||
import org.jetbrains.kotlin.idea.test.KotlinMultiFileTestCase
|
||||
@@ -215,7 +216,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() {
|
||||
Assert.assertTrue("File '${mainFilePath}' should have package containing ${fqn}", fileFqn.isSubpackageOf(fqn))
|
||||
|
||||
val packageSegment = jetFile.getPackageDirective()!!.getPackageNames()[fqn.pathSegments().size() - 1]
|
||||
val segmentReference = packageSegment.getReference()!!
|
||||
val segmentReference = packageSegment.mainReference
|
||||
|
||||
val psiElement = segmentReference.resolve()!!
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ class ConstructorConverter(
|
||||
if (expression is PsiReferenceExpression && expression.getQualifier() == null) {
|
||||
val replacement = parameterUsageReplacementMap[expression.getReferenceName()]
|
||||
if (replacement != null) {
|
||||
val target = expression.getReference()?.resolve()
|
||||
val target = expression.resolve()
|
||||
if (target is PsiParameter) {
|
||||
val scope = target.getDeclarationScope()
|
||||
// we do not check for exactly this constructor because default values reference parameters in other constructors
|
||||
|
||||
@@ -397,7 +397,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
}
|
||||
|
||||
val referenceName = expression.getReferenceName()!!
|
||||
val target = expression.getReference()?.resolve()
|
||||
val target = expression.resolve()
|
||||
val isNullable = target is PsiVariable && typeConverter.variableNullability(target).isNullable(codeConverter.settings)
|
||||
val qualifier = expression.getQualifierExpression()
|
||||
|
||||
|
||||
@@ -59,10 +59,12 @@ public interface PostProcessor {
|
||||
}
|
||||
|
||||
Errors.VAL_REASSIGNMENT -> { ->
|
||||
val property = (psiElement as? JetSimpleNameExpression)?.getReference()?.resolve() as? JetProperty
|
||||
if (property != null && !property.isVar()) {
|
||||
val factory = JetPsiFactory(psiElement.getProject())
|
||||
property.getValOrVarKeyword().replace(factory.createVarKeyword())
|
||||
if (psiElement is JetSimpleNameExpression) {
|
||||
val property = simpleNameReference(psiElement).resolve() as? JetProperty
|
||||
if (property != null && !property.isVar()) {
|
||||
val factory = JetPsiFactory(psiElement.getProject())
|
||||
property.getValOrVarKeyword().replace(factory.createVarKeyword())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +73,8 @@ public interface PostProcessor {
|
||||
}
|
||||
|
||||
public fun doAdditionalProcessing(file: JetFile, rangeMarker: RangeMarker?)
|
||||
|
||||
public fun simpleNameReference(nameExpression: JetSimpleNameExpression): PsiReference
|
||||
}
|
||||
|
||||
public enum class ParseContext {
|
||||
@@ -233,7 +237,7 @@ public class JavaToKotlinConverter(
|
||||
|
||||
var references = listOf(reference)
|
||||
for (processor in processors) {
|
||||
references = references.flatMap { processor.processUsage(it) ?: listOf(it) }
|
||||
references = references.flatMap { processor.processUsage(it)?.toList() ?: listOf(it) }
|
||||
references.forEach { checkReferenceValid(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.j2k.usageProcessing
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.j2k.AccessorKind
|
||||
import org.jetbrains.kotlin.j2k.CodeConverter
|
||||
import org.jetbrains.kotlin.j2k.ResolverForConverter
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
@@ -53,7 +54,7 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi
|
||||
null
|
||||
else
|
||||
object : ExternalCodeProcessor {
|
||||
override fun processUsage(reference: PsiReference): Collection<PsiReference>? {
|
||||
override fun processUsage(reference: PsiReference): Array<PsiReference>? {
|
||||
val nameExpr = reference.getElement() as? JetSimpleNameExpression ?: return null
|
||||
val callExpr = nameExpr.getParent() as? JetCallExpression ?: return null
|
||||
|
||||
@@ -64,7 +65,7 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi
|
||||
if (accessorKind == AccessorKind.GETTER) {
|
||||
if (arguments.size() != 0) return null // incorrect call
|
||||
propertyNameExpr = callExpr.replace(propertyNameExpr) as JetSimpleNameExpression
|
||||
return listOf(propertyNameExpr.getReference()!!)
|
||||
return propertyNameExpr.getReferences()
|
||||
}
|
||||
else {
|
||||
val value = arguments.singleOrNull()?.getArgumentExpression() ?: return null
|
||||
@@ -76,12 +77,12 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi
|
||||
callExpr.replace(propertyNameExpr)
|
||||
assignment.getLeft()!!.replace(qualifiedExpression)
|
||||
assignment = qualifiedExpression.replace(assignment) as JetBinaryExpression
|
||||
return listOf((assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReference()!!)
|
||||
return (assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReferences()
|
||||
}
|
||||
else {
|
||||
assignment.getLeft()!!.replace(propertyNameExpr)
|
||||
assignment = callExpr.replace(assignment) as JetBinaryExpression
|
||||
return listOf(assignment.getLeft()!!.getReference()!!)
|
||||
return assignment.getLeft()!!.getReferences()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.kotlin.j2k.usageProcessing
|
||||
|
||||
import com.intellij.psi.PsiReference
|
||||
import org.jetbrains.kotlin.j2k.ResolverForConverter
|
||||
|
||||
class ElementRenamedCodeProcessor(private val newName: String) : ExternalCodeProcessor {
|
||||
override fun processUsage(reference: PsiReference): Collection<PsiReference>? {
|
||||
val newReference = reference.handleElementRename(newName).getReference()!!
|
||||
return listOf(newReference)
|
||||
override fun processUsage(reference: PsiReference): Array<PsiReference>? {
|
||||
return reference.handleElementRename(newName).getReferences()
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v
|
||||
private inner class UseAccessorsJavaCodeProcessor : ExternalCodeProcessor {
|
||||
private val factory = PsiElementFactory.SERVICE.getInstance(field.getProject())
|
||||
|
||||
override fun processUsage(reference: PsiReference): Collection<PsiReference>? {
|
||||
override fun processUsage(reference: PsiReference): Array<PsiReference>? {
|
||||
val refExpr = reference.getElement() as? PsiReferenceExpression ?: return null
|
||||
val qualifier = refExpr.getQualifierExpression()
|
||||
|
||||
@@ -78,7 +78,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v
|
||||
if (refExpr == parent.getLExpression()) {
|
||||
if (parent.getOperationTokenType() == JavaTokenType.EQ) {
|
||||
val callExpr = parent.replace(generateSetterCall(qualifier, parent.getRExpression() ?: return null)) as PsiMethodCallExpression
|
||||
return listOf(callExpr.getMethodExpression())
|
||||
return arrayOf(callExpr.getMethodExpression())
|
||||
}
|
||||
else {
|
||||
val assignmentOpText = parent.getOperationSign().getText()
|
||||
@@ -107,11 +107,11 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v
|
||||
}
|
||||
|
||||
val callExpr = refExpr.replace(generateGetterCall(qualifier)) as PsiMethodCallExpression
|
||||
return listOf(callExpr.getMethodExpression())
|
||||
return arrayOf(callExpr.getMethodExpression())
|
||||
}
|
||||
|
||||
//TODO: what if qualifier has side effects?
|
||||
private fun PsiExpression.replaceWithModificationCalls(qualifier: PsiExpression?, op: String, value: PsiExpression): Collection<PsiReference> {
|
||||
private fun PsiExpression.replaceWithModificationCalls(qualifier: PsiExpression?, op: String, value: PsiExpression): Array<PsiReference> {
|
||||
var getCall = generateGetterCall(qualifier)
|
||||
|
||||
var binary = factory.createExpressionFromText("x $op y", null) as PsiBinaryExpression
|
||||
@@ -124,7 +124,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v
|
||||
binary = setCall.getArgumentList().getExpressions().single() as PsiBinaryExpression
|
||||
getCall = binary.getLOperand() as PsiMethodCallExpression
|
||||
|
||||
return listOf(getCall.getMethodExpression().getReference()!!, setCall.getMethodExpression().getReference()!!)
|
||||
return arrayOf(getCall.getMethodExpression(), setCall.getMethodExpression())
|
||||
}
|
||||
|
||||
private fun generateGetterCall(qualifier: PsiExpression?): PsiMethodCallExpression {
|
||||
|
||||
@@ -24,19 +24,19 @@ public class MethodIntoObjectProcessing(private val method: PsiMethod, private v
|
||||
override val convertedCodeProcessor: ConvertedCodeProcessor? get() = null
|
||||
|
||||
override val javaCodeProcessor = object: ExternalCodeProcessor {
|
||||
override fun processUsage(reference: PsiReference): Collection<PsiReference>? {
|
||||
override fun processUsage(reference: PsiReference): Array<PsiReference>? {
|
||||
val refExpr = reference.getElement() as? PsiReferenceExpression ?: return null
|
||||
val qualifier = refExpr.getQualifierExpression()
|
||||
val factory = PsiElementFactory.SERVICE.getInstance(method.getProject())
|
||||
if (qualifier != null) {
|
||||
val newQualifier = factory.createExpressionFromText(qualifier.getText() + "." + objectName, null)
|
||||
qualifier.replace(newQualifier)
|
||||
return listOf(reference)
|
||||
return arrayOf(reference)
|
||||
}
|
||||
else {
|
||||
var qualifiedExpr = factory.createExpressionFromText(objectName + "." + refExpr.getText(), null) as PsiReferenceExpression
|
||||
qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression
|
||||
return listOf(qualifiedExpr.getReference()!!)
|
||||
return arrayOf(qualifiedExpr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,12 +25,12 @@ class ToObjectWithOnlyMethodsProcessing(private val psiClass: PsiClass) : UsageP
|
||||
override val convertedCodeProcessor: ConvertedCodeProcessor? get() = null
|
||||
|
||||
override val javaCodeProcessor = object: ExternalCodeProcessor {
|
||||
override fun processUsage(reference: PsiReference): Collection<PsiReference>? {
|
||||
override fun processUsage(reference: PsiReference): Array<PsiReference>? {
|
||||
val refExpr = reference.getElement() as? PsiReferenceExpression ?: return null
|
||||
val factory = PsiElementFactory.SERVICE.getInstance(psiClass.getProject())
|
||||
var qualifiedExpr = factory.createExpressionFromText(refExpr.getText() + "." + JvmAbi.INSTANCE_FIELD, null) as PsiReferenceExpression
|
||||
qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression
|
||||
return listOf(qualifiedExpr.getReference()!!)
|
||||
return arrayOf(qualifiedExpr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ trait ConvertedCodeProcessor {
|
||||
}
|
||||
|
||||
trait ExternalCodeProcessor {
|
||||
fun processUsage(reference: PsiReference): Collection<PsiReference>?
|
||||
fun processUsage(reference: PsiReference): Array<PsiReference>?
|
||||
}
|
||||
|
||||
class UsageProcessingExpressionConverter(val processings: Map<PsiElement, Collection<UsageProcessing>>) : SpecialExpressionConverter {
|
||||
|
||||
Reference in New Issue
Block a user