rename PSI classes according to current terminology:
KtMultiDeclaration(Entry) -> KtDestructuringDeclaration(Entry) KtFunctionLiteralExpression -> KtLambdaExpression KtFunctionLiteralArgument -> KtLambdaArgument KtDelegationSpecifierList -> KtSuperTypeList KtDelegationSpecifier -> KtSuperTypeListEntry KtDelegatorToSuperClass -> KtSuperTypeEntry KtDelegatorToSuperCall -> KtSuperTypeCallEntry KtDelegationByExpressionSpecifier ->KtDelegatedSuperTypeEntry
This commit is contained in:
+2
-2
@@ -119,7 +119,7 @@ private object KotlinResolveDataProvider {
|
||||
// TODO: Non-analyzable so far, add more granular analysis
|
||||
javaClass<KtAnnotationEntry>(),
|
||||
javaClass<KtTypeConstraint>(),
|
||||
javaClass<KtDelegationSpecifierList>(),
|
||||
javaClass<KtSuperTypeList>(),
|
||||
javaClass<KtTypeParameter>(),
|
||||
javaClass<KtParameter>()
|
||||
)
|
||||
@@ -133,7 +133,7 @@ private object KotlinResolveDataProvider {
|
||||
val analyzableElement = when (topmostElement) {
|
||||
is KtAnnotationEntry,
|
||||
is KtTypeConstraint,
|
||||
is KtDelegationSpecifierList,
|
||||
is KtSuperTypeList,
|
||||
is KtTypeParameter,
|
||||
is KtParameter -> PsiTreeUtil.getParentOfType(topmostElement, javaClass<KtClassOrObject>(), javaClass<KtCallableDeclaration>())
|
||||
else -> topmostElement
|
||||
|
||||
+5
-5
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.psi.KtClassBody
|
||||
import org.jetbrains.kotlin.psi.KtDelegationSpecifierList
|
||||
import org.jetbrains.kotlin.psi.KtDelegatorToSuperClass
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeEntry
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeList
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtClassElementType
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinClassStubImpl
|
||||
@@ -144,11 +144,11 @@ private class ClassClsStubBuilder(
|
||||
if (supertypeIds.isEmpty()) return
|
||||
|
||||
val delegationSpecifierListStub =
|
||||
KotlinPlaceHolderStubImpl<KtDelegationSpecifierList>(classOrObjectStub, KtStubElementTypes.DELEGATION_SPECIFIER_LIST)
|
||||
KotlinPlaceHolderStubImpl<KtSuperTypeList>(classOrObjectStub, KtStubElementTypes.SUPER_TYPE_LIST)
|
||||
|
||||
classProto.supertypes(c.typeTable).forEach { type ->
|
||||
val superClassStub = KotlinPlaceHolderStubImpl<KtDelegatorToSuperClass>(
|
||||
delegationSpecifierListStub, KtStubElementTypes.DELEGATOR_SUPER_CLASS
|
||||
val superClassStub = KotlinPlaceHolderStubImpl<KtSuperTypeEntry>(
|
||||
delegationSpecifierListStub, KtStubElementTypes.SUPER_TYPE_ENTRY
|
||||
)
|
||||
typeStubBuilder.createTypeReferenceStub(superClassStub, type)
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class KotlinFindUsagesProvider : FindUsagesProvider {
|
||||
is KtClass -> "class"
|
||||
is KtParameter -> "parameter"
|
||||
is KtProperty -> if (element.isLocal()) "variable" else "property"
|
||||
is KtMultiDeclarationEntry -> "variable"
|
||||
is KtDestructuringDeclarationEntry -> "variable"
|
||||
is KtTypeParameter -> "type parameter"
|
||||
is KtSecondaryConstructor -> "constructor"
|
||||
is KtObjectDeclaration -> "object"
|
||||
|
||||
@@ -34,7 +34,7 @@ public object UsageTypeUtils {
|
||||
public fun getUsageType(element: PsiElement?): UsageTypeEnum? {
|
||||
when (element) {
|
||||
is KtForExpression -> return IMPLICIT_ITERATION
|
||||
is KtMultiDeclaration -> return READ
|
||||
is KtDestructuringDeclaration -> return READ
|
||||
is KtPropertyDelegate -> return PROPERTY_DELEGATION
|
||||
is KtStringTemplateExpression -> return USAGE_IN_STRING_LITERAL
|
||||
}
|
||||
@@ -83,8 +83,8 @@ public object UsageTypeUtils {
|
||||
|| refExpr.getParentOfTypeAndBranch<KtTypeConstraint>(){ getBoundTypeReference() } != null ->
|
||||
TYPE_CONSTRAINT
|
||||
|
||||
refExpr is KtDelegationSpecifier
|
||||
|| refExpr.getParentOfTypeAndBranch<KtDelegationSpecifier>(){ getTypeReference() } != null ->
|
||||
refExpr is KtSuperTypeListEntry
|
||||
|| refExpr.getParentOfTypeAndBranch<KtSuperTypeListEntry>(){ getTypeReference() } != null ->
|
||||
SUPER_TYPE
|
||||
|
||||
refExpr.getParentOfTypeAndBranch<KtTypedef>(){ getTypeReference() } != null ->
|
||||
@@ -120,7 +120,7 @@ public object UsageTypeUtils {
|
||||
}
|
||||
|
||||
fun getVariableUsageType(): UsageTypeEnum? {
|
||||
if (refExpr.getParentOfTypeAndBranch<KtDelegatorByExpressionSpecifier>(){ getDelegateExpression() } != null) {
|
||||
if (refExpr.getParentOfTypeAndBranch<KtDelegatedSuperTypeEntry>(){ getDelegateExpression() } != null) {
|
||||
return DELEGATE
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public object UsageTypeUtils {
|
||||
}
|
||||
|
||||
return when {
|
||||
refExpr.getParentOfTypeAndBranch<KtDelegationSpecifier>(){ getTypeReference() } != null ->
|
||||
refExpr.getParentOfTypeAndBranch<KtSuperTypeListEntry>(){ getTypeReference() } != null ->
|
||||
SUPER_TYPE
|
||||
|
||||
descriptor is ConstructorDescriptor
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call) {
|
||||
public void visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call) {
|
||||
KtConstructorCalleeExpression calleeExpression = call.getCalleeExpression();
|
||||
KtTypeReference typeRef = calleeExpression.getTypeReference();
|
||||
if (typeRef != null) {
|
||||
@@ -59,7 +59,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visitDelegationToSuperCallSpecifier(call);
|
||||
super.visitSuperTypeCallEntry(call);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -54,7 +54,7 @@ fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: Diagnos
|
||||
var current: PsiElement? = element
|
||||
var suppressAtStatementAllowed = true
|
||||
while (current != null) {
|
||||
if (current is KtDeclaration && current !is KtMultiDeclaration) {
|
||||
if (current is KtDeclaration && current !is KtDestructuringDeclaration) {
|
||||
val declaration = current
|
||||
val kind = DeclarationKindDetector.detect(declaration)
|
||||
if (kind != null) {
|
||||
@@ -64,7 +64,7 @@ fun createSuppressWarningActions(element: PsiElement, diagnosticFactory: Diagnos
|
||||
}
|
||||
else if (current is KtExpression && suppressAtStatementAllowed) {
|
||||
// Add suppress action at first statement
|
||||
if (current.parent is KtBlockExpression || current.parent is KtMultiDeclaration) {
|
||||
if (current.parent is KtBlockExpression || current.parent is KtDestructuringDeclaration) {
|
||||
val kind = if (current.parent is KtBlockExpression) "statement" else "initializer"
|
||||
actions.add(KotlinSuppressIntentionAction(current, diagnosticFactory,
|
||||
AnnotationHostKind(kind, "", true)))
|
||||
@@ -89,8 +89,8 @@ private object DeclarationKindDetector : KtVisitor<AnnotationHostKind?, Unit?>()
|
||||
|
||||
override fun visitProperty(d: KtProperty, data: Unit?) = detect(d, d.getValOrVarKeyword().getText()!!)
|
||||
|
||||
override fun visitMultiDeclaration(d: KtMultiDeclaration, data: Unit?) = detect(d, d.getValOrVarKeyword()?.getText() ?: "val",
|
||||
name = d.getEntries().map { it.getName()!! }.joinToString(", ", "(", ")"))
|
||||
override fun visitDestructuringDeclaration(d: KtDestructuringDeclaration, data: Unit?) = detect(d, d.getValOrVarKeyword()?.getText() ?: "val",
|
||||
name = d.getEntries().map { it.getName()!! }.joinToString(", ", "(", ")"))
|
||||
|
||||
override fun visitTypeParameter(d: KtTypeParameter, data: Unit?) = detect(d, "type parameter", newLineNeeded = false)
|
||||
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.KtFunctionLiteral;
|
||||
import org.jetbrains.kotlin.psi.KtFunctionLiteralExpression;
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression;
|
||||
import org.jetbrains.kotlin.psi.KtVisitorVoid;
|
||||
|
||||
class SoftKeywordsHighlightingVisitor extends KtVisitorVoid {
|
||||
@@ -53,9 +53,9 @@ class SoftKeywordsHighlightingVisitor extends KtVisitorVoid {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression) {
|
||||
public void visitLambdaExpression(@NotNull KtLambdaExpression lambdaExpression) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
KtFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
KtFunctionLiteral functionLiteral = lambdaExpression.getFunctionLiteral();
|
||||
holder.createInfoAnnotation(functionLiteral.getLBrace(), null).setTextAttributes(KotlinHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW);
|
||||
PsiElement closingBrace = functionLiteral.getRBrace();
|
||||
if (closingBrace != null) {
|
||||
|
||||
+3
-3
@@ -73,7 +73,7 @@ public class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(
|
||||
|
||||
private fun isApplicableCall(element: KtCallExpression, caretOffset: Int): Boolean {
|
||||
val lbrace = (element.getValueArgumentList()?.getLeftParenthesis()
|
||||
?: element.getFunctionLiteralArguments().firstOrNull()?.getFunctionLiteral()?.getLeftCurlyBrace()
|
||||
?: element.getLambdaArguments().firstOrNull()?.getLambdaExpression()?.getLeftCurlyBrace()
|
||||
?: return false) as PsiElement
|
||||
if (!lbrace.getTextRange().containsOffset(caretOffset)) return false
|
||||
|
||||
@@ -82,7 +82,7 @@ public class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(
|
||||
if (descriptor is FunctionDescriptor && descriptor.getName() == OperatorNameConventions.INVOKE) {
|
||||
if (element.getParent() is KtDotQualifiedExpression &&
|
||||
element.getCalleeExpression()?.getText() == OperatorNameConventions.INVOKE.asString()) return false
|
||||
return element.getValueArgumentList() != null || element.getFunctionLiteralArguments().isNotEmpty()
|
||||
return element.getValueArgumentList() != null || element.getLambdaArguments().isNotEmpty()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(
|
||||
val callee = element.getCalleeExpression()!!
|
||||
val arguments = element.getValueArgumentList()
|
||||
val argumentString = arguments?.getText()?.removeSurrounding("(", ")")
|
||||
val funcLitArgs = element.getFunctionLiteralArguments()
|
||||
val funcLitArgs = element.getLambdaArguments()
|
||||
val calleeText = callee.getText()
|
||||
val transformation = "$calleeText.${OperatorNameConventions.INVOKE.asString()}" +
|
||||
(if (argumentString == null) "" else "($argumentString)")
|
||||
|
||||
@@ -209,7 +209,7 @@ public class ResolveElementCache(
|
||||
javaClass<KtSecondaryConstructor>(),
|
||||
javaClass<KtProperty>(),
|
||||
javaClass<KtParameter>(),
|
||||
javaClass<KtDelegationSpecifierList>(),
|
||||
javaClass<KtSuperTypeList>(),
|
||||
javaClass<KtInitializerList>(),
|
||||
javaClass<KtImportList>(),
|
||||
javaClass<KtAnnotationEntry>(),
|
||||
@@ -269,7 +269,7 @@ public class ResolveElementCache(
|
||||
|
||||
is KtProperty -> propertyAdditionalResolve(resolveSession, resolveElement, file, createStatementFilter())
|
||||
|
||||
is KtDelegationSpecifierList -> delegationSpecifierAdditionalResolve(resolveSession, resolveElement, resolveElement.getParent() as KtClassOrObject, file)
|
||||
is KtSuperTypeList -> delegationSpecifierAdditionalResolve(resolveSession, resolveElement, resolveElement.getParent() as KtClassOrObject, file)
|
||||
|
||||
is KtInitializerList -> delegationSpecifierAdditionalResolve(resolveSession, resolveElement, resolveElement.getParent() as KtEnumEntry, file)
|
||||
|
||||
@@ -401,12 +401,12 @@ public class ResolveElementCache(
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor.getTypeConstructor().getSupertypes())
|
||||
|
||||
val bodyResolver = createBodyResolver(resolveSession, trace, file, StatementFilter.NONE)
|
||||
bodyResolver.resolveDelegationSpecifierList(DataFlowInfo.EMPTY,
|
||||
classOrObject,
|
||||
descriptor,
|
||||
descriptor.unsubstitutedPrimaryConstructor,
|
||||
descriptor.scopeForConstructorHeaderResolution,
|
||||
descriptor.scopeForMemberDeclarationResolution)
|
||||
bodyResolver.resolveSuperTypeEntryList(DataFlowInfo.EMPTY,
|
||||
classOrObject,
|
||||
descriptor,
|
||||
descriptor.getUnsubstitutedPrimaryConstructor(),
|
||||
descriptor.scopeForConstructorHeaderResolution,
|
||||
descriptor.getScopeForMemberDeclarationResolution())
|
||||
|
||||
return trace
|
||||
}
|
||||
|
||||
+2
-2
@@ -61,8 +61,8 @@ public class KotlinReferenceContributor() : PsiReferenceContributor() {
|
||||
KtPropertyDelegationMethodsReference(it)
|
||||
}
|
||||
|
||||
registerProvider(javaClass<KtMultiDeclaration>()) {
|
||||
KtMultiDeclarationReference(it)
|
||||
registerProvider(javaClass<KtDestructuringDeclaration>()) {
|
||||
KtDestructuringDeclarationReference(it)
|
||||
}
|
||||
|
||||
registerProvider(javaClass<KDocName>()) {
|
||||
|
||||
+4
-4
@@ -16,16 +16,16 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.references
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtMultiDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.psi.KtDestructuringDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
class KtMultiDeclarationReference(element: KtMultiDeclaration) : KtMultiReference<KtMultiDeclaration>(element) {
|
||||
class KtDestructuringDeclarationReference(element: KtDestructuringDeclaration) : KtMultiReference<KtDestructuringDeclaration>(element) {
|
||||
override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {
|
||||
return expression.getEntries().mapNotNull { entry ->
|
||||
context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry)?.getCandidateDescriptor()
|
||||
+3
-3
@@ -83,9 +83,9 @@ public class KtInvokeFunctionReference extends KtSimpleReference<KtCallExpressio
|
||||
}
|
||||
}
|
||||
|
||||
List<KtFunctionLiteralArgument> functionLiteralArguments = getExpression().getFunctionLiteralArguments();
|
||||
for (KtFunctionLiteralArgument functionLiteralArgument : functionLiteralArguments) {
|
||||
KtFunctionLiteralExpression functionLiteralExpression = functionLiteralArgument.getFunctionLiteral();
|
||||
List<KtLambdaArgument> functionLiteralArguments = getExpression().getLambdaArguments();
|
||||
for (KtLambdaArgument functionLiteralArgument : functionLiteralArguments) {
|
||||
KtLambdaExpression functionLiteralExpression = functionLiteralArgument.getLambdaExpression();
|
||||
list.add(getRange(functionLiteralExpression.getLeftCurlyBrace()));
|
||||
ASTNode rightCurlyBrace = functionLiteralExpression.getRightCurlyBrace();
|
||||
if (rightCurlyBrace != null) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
|
||||
is KtInvokeFunctionReference -> {
|
||||
if (candidateTarget !is KtNamedFunction) return false
|
||||
}
|
||||
is KtMultiDeclarationReference -> {
|
||||
is KtDestructuringDeclarationReference -> {
|
||||
if (candidateTarget !is KtNamedFunction && candidateTarget !is KtParameter) return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,8 +169,8 @@ private fun processClassDelegationCallsToSpecifiedConstructor(
|
||||
if (!klass.isEnum()) return true
|
||||
for (declaration in klass.declarations) {
|
||||
if (declaration is KtEnumEntry) {
|
||||
val delegationCall = declaration.getDelegationSpecifiers().firstOrNull()
|
||||
if (delegationCall is KtDelegatorToSuperCall && constructor == delegationCall.calleeExpression.getConstructorCallDescriptor()) {
|
||||
val delegationCall = declaration.getSuperTypeListEntries().firstOrNull()
|
||||
if (delegationCall is KtSuperTypeCallEntry && constructor == delegationCall.calleeExpression.getConstructorCallDescriptor()) {
|
||||
if (!process(delegationCall)) return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user