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:
Dmitry Jemerov
2015-12-09 19:30:38 +01:00
parent ef4b3c99f4
commit 009e3f9cd7
302 changed files with 1375 additions and 1391 deletions
@@ -28,8 +28,8 @@ public interface KtNodeTypes {
IElementType CLASS = KtStubElementTypes.CLASS;
IElementType FUN = KtStubElementTypes.FUNCTION;
IElementType PROPERTY = KtStubElementTypes.PROPERTY;
IElementType MULTI_VARIABLE_DECLARATION = new KtNodeType("MULTI_VARIABLE_DECLARATION", KtMultiDeclaration.class);
IElementType MULTI_VARIABLE_DECLARATION_ENTRY = new KtNodeType("MULTI_VARIABLE_DECLARATION_ENTRY", KtMultiDeclarationEntry.class);
IElementType DESTRUCTURING_DECLARATION = new KtNodeType("DESTRUCTURING_DECLARATION", KtDestructuringDeclaration.class);
IElementType DESTRUCTURING_DECLARATION_ENTRY = new KtNodeType("DESTRUCTURING_DECLARATION_ENTRY", KtDestructuringDeclarationEntry.class);
KtNodeType TYPEDEF = new KtNodeType("TYPEDEF", KtTypedef.class);
IElementType OBJECT_DECLARATION = KtStubElementTypes.OBJECT_DECLARATION;
@@ -42,10 +42,10 @@ public interface KtNodeTypes {
IElementType TYPE_PARAMETER_LIST = KtStubElementTypes.TYPE_PARAMETER_LIST;
IElementType TYPE_PARAMETER = KtStubElementTypes.TYPE_PARAMETER;
IElementType DELEGATION_SPECIFIER_LIST = KtStubElementTypes.DELEGATION_SPECIFIER_LIST;
IElementType DELEGATOR_BY = KtStubElementTypes.DELEGATOR_BY;
IElementType DELEGATOR_SUPER_CALL = KtStubElementTypes.DELEGATOR_SUPER_CALL;
IElementType DELEGATOR_SUPER_CLASS = KtStubElementTypes.DELEGATOR_SUPER_CLASS;
IElementType SUPER_TYPE_LIST = KtStubElementTypes.SUPER_TYPE_LIST;
IElementType DELEGATED_SUPER_TYPE_ENTRY = KtStubElementTypes.DELEGATED_SUPER_TYPE_ENTRY;
IElementType SUPER_TYPE_CALL_ENTRY = KtStubElementTypes.SUPER_TYPE_CALL_ENTRY;
IElementType SUPER_TYPE_ENTRY = KtStubElementTypes.SUPER_TYPE_ENTRY;
KtNodeType PROPERTY_DELEGATE = new KtNodeType("PROPERTY_DELEGATE", KtPropertyDelegate.class);
IElementType CONSTRUCTOR_CALLEE = KtStubElementTypes.CONSTRUCTOR_CALLEE;
IElementType VALUE_PARAMETER_LIST = KtStubElementTypes.VALUE_PARAMETER_LIST;
@@ -63,7 +63,7 @@ public interface KtNodeTypes {
IElementType TYPE_ARGUMENT_LIST = KtStubElementTypes.TYPE_ARGUMENT_LIST;
KtNodeType VALUE_ARGUMENT_LIST = new KtNodeType("VALUE_ARGUMENT_LIST", KtValueArgumentList.class);
KtNodeType VALUE_ARGUMENT = new KtNodeType("VALUE_ARGUMENT", KtValueArgument.class);
KtNodeType FUNCTION_LITERAL_ARGUMENT = new KtNodeType("FUNCTION_LITERAL_ARGUMENT", KtFunctionLiteralArgument.class);
KtNodeType LAMBDA_ARGUMENT = new KtNodeType("LAMBDA_ARGUMENT", KtLambdaArgument.class);
KtNodeType VALUE_ARGUMENT_NAME = new KtNodeType("VALUE_ARGUMENT_NAME", KtValueArgumentName.class);
IElementType TYPE_REFERENCE = KtStubElementTypes.TYPE_REFERENCE;
@@ -116,7 +116,7 @@ public interface KtNodeTypes {
KtNodeType LOOP_RANGE = new KtNodeType("LOOP_RANGE", KtContainerNode.class);
KtNodeType BODY = new KtNodeType("BODY", KtContainerNode.class);
KtNodeType BLOCK = new KtNodeType("BLOCK", KtBlockExpression.class);
KtNodeType FUNCTION_LITERAL_EXPRESSION = new KtNodeType("FUNCTION_LITERAL_EXPRESSION", KtFunctionLiteralExpression.class);
KtNodeType LAMBDA_EXPRESSION = new KtNodeType("LAMBDA_EXPRESSION", KtLambdaExpression.class);
KtNodeType FUNCTION_LITERAL = new KtNodeType("FUNCTION_LITERAL", KtFunctionLiteral.class);
KtNodeType ANNOTATED_EXPRESSION = new KtNodeType("ANNOTATED_EXPRESSION", KtAnnotatedExpression.class);
@@ -880,18 +880,18 @@ public class KotlinControlFlowProcessor {
private void declareLoopParameter(KtForExpression expression) {
KtParameter loopParameter = expression.getLoopParameter();
KtMultiDeclaration multiDeclaration = expression.getMultiParameter();
KtDestructuringDeclaration multiDeclaration = expression.getDestructuringParameter();
if (loopParameter != null) {
builder.declareParameter(loopParameter);
}
else if (multiDeclaration != null) {
visitMultiDeclaration(multiDeclaration, false);
visitDestructuringDeclaration(multiDeclaration, false);
}
}
private void writeLoopParameterAssignment(KtForExpression expression) {
KtParameter loopParameter = expression.getLoopParameter();
KtMultiDeclaration multiDeclaration = expression.getMultiParameter();
KtDestructuringDeclaration multiDeclaration = expression.getDestructuringParameter();
KtExpression loopRange = expression.getLoopRange();
PseudoValue value = builder.magic(
@@ -905,7 +905,7 @@ public class KotlinControlFlowProcessor {
generateInitializer(loopParameter, value);
}
else if (multiDeclaration != null) {
for (KtMultiDeclarationEntry entry : multiDeclaration.getEntries()) {
for (KtDestructuringDeclarationEntry entry : multiDeclaration.getEntries()) {
generateInitializer(entry, value);
}
}
@@ -1079,11 +1079,11 @@ public class KotlinControlFlowProcessor {
}
@Override
public void visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression) {
mark(expression);
KtFunctionLiteral functionLiteral = expression.getFunctionLiteral();
public void visitLambdaExpression(@NotNull KtLambdaExpression lambdaExpression) {
mark(lambdaExpression);
KtFunctionLiteral functionLiteral = lambdaExpression.getFunctionLiteral();
visitFunction(functionLiteral);
copyValue(functionLiteral, expression);
copyValue(functionLiteral, lambdaExpression);
}
@Override
@@ -1161,14 +1161,14 @@ public class KotlinControlFlowProcessor {
}
@Override
public void visitMultiDeclaration(@NotNull KtMultiDeclaration declaration) {
visitMultiDeclaration(declaration, true);
public void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration declaration) {
visitDestructuringDeclaration(declaration, true);
}
private void visitMultiDeclaration(@NotNull KtMultiDeclaration declaration, boolean generateWriteForEntries) {
private void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration declaration, boolean generateWriteForEntries) {
KtExpression initializer = declaration.getInitializer();
generateInstructions(initializer);
for (KtMultiDeclarationEntry entry : declaration.getEntries()) {
for (KtDestructuringDeclarationEntry entry : declaration.getEntries()) {
builder.declareVariable(entry);
ResolvedCall<FunctionDescriptor> resolvedCall = trace.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
@@ -1348,7 +1348,7 @@ public class KotlinControlFlowProcessor {
}
private void generateHeaderDelegationSpecifiers(@NotNull KtClassOrObject classOrObject) {
for (KtDelegationSpecifier specifier : classOrObject.getDelegationSpecifiers()) {
for (KtSuperTypeListEntry specifier : classOrObject.getSuperTypeListEntries()) {
generateInstructions(specifier);
}
}
@@ -1414,7 +1414,7 @@ public class KotlinControlFlowProcessor {
}
@Override
public void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call) {
public void visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call) {
generateCallOrMarkUnresolved(call);
}
@@ -1439,19 +1439,19 @@ public class KotlinControlFlowProcessor {
}
@Override
public void visitDelegationByExpressionSpecifier(@NotNull KtDelegatorByExpressionSpecifier specifier) {
public void visitDelegatedSuperTypeEntry(@NotNull KtDelegatedSuperTypeEntry specifier) {
KtExpression delegateExpression = specifier.getDelegateExpression();
generateInstructions(delegateExpression);
createSyntheticValue(specifier, MagicKind.VALUE_CONSUMER, delegateExpression);
}
@Override
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
public void visitSuperTypeEntry(@NotNull KtSuperTypeEntry specifier) {
// Do not generate UNSUPPORTED_ELEMENT here
}
@Override
public void visitDelegationSpecifierList(@NotNull KtDelegationSpecifierList list) {
public void visitSuperTypeList(@NotNull KtSuperTypeList list) {
list.acceptChildren(this);
}
@@ -633,7 +633,7 @@ public class KotlinFlowInformationProvider {
report(Errors.VARIABLE_WITH_REDUNDANT_INITIALIZER.on(initializer, variableDescriptor), ctxt);
}
}
else if (element instanceof KtMultiDeclarationEntry) {
else if (element instanceof KtDestructuringDeclarationEntry) {
report(VARIABLE_WITH_REDUNDANT_INITIALIZER.on(element, variableDescriptor), ctxt);
}
}
@@ -661,8 +661,8 @@ public class KotlinFlowInformationProvider {
&& PseudocodeUtilsKt.getSideEffectFree(instruction)) {
VariableContext ctxt = new VariableContext(instruction, reportedDiagnosticMap);
report(
element instanceof KtFunctionLiteralExpression
? Errors.UNUSED_LAMBDA_EXPRESSION.on((KtFunctionLiteralExpression) element)
element instanceof KtLambdaExpression
? Errors.UNUSED_LAMBDA_EXPRESSION.on((KtLambdaExpression) element)
: Errors.UNUSED_EXPRESSION.on(element),
ctxt
);
@@ -426,7 +426,7 @@ public class KotlinControlFlowInstructionsGenerator extends KotlinControlFlowBui
@NotNull
@Override
public InstructionWithValue createLambda(@NotNull KtFunction expression) {
return read(expression instanceof KtFunctionLiteral ? (KtFunctionLiteralExpression) expression.getParent() : expression);
return read(expression instanceof KtFunctionLiteral ? (KtLambdaExpression) expression.getParent() : expression);
}
@NotNull
@@ -219,7 +219,7 @@ public fun getExpectedTypePredicate(
}
}
element is KtDelegatorByExpressionSpecifier ->
element is KtDelegatedSuperTypeEntry ->
addSubtypesOf(bindingContext[TYPE, element.getTypeReference()])
}
}
@@ -260,7 +260,7 @@ fun Instruction.calcSideEffectFree(): Boolean {
}
else -> when (element) {
is KtConstantExpression, is KtFunctionLiteralExpression, is KtStringTemplateExpression -> true
is KtConstantExpression, is KtLambdaExpression, is KtStringTemplateExpression -> true
else -> false
}
}
@@ -106,11 +106,11 @@ public class DebugInfoUtil {
}
@Override
public void visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration) {
for (KtMultiDeclarationEntry entry : multiDeclaration.getEntries()) {
public void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration destructuringDeclaration) {
for (KtDestructuringDeclarationEntry entry : destructuringDeclaration.getEntries()) {
reportIfDynamicCall(entry, entry, COMPONENT_RESOLVED_CALL);
}
super.visitMultiDeclaration(multiDeclaration);
super.visitDestructuringDeclaration(destructuringDeclaration);
}
@Override
@@ -78,8 +78,8 @@ public interface Errors {
DiagnosticFactory2<KtParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtTypeReference, EffectiveVisibility, EffectiveVisibility> EXPOSED_RECEIVER_TYPE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtTypeParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_TYPE_PARAMETER_BOUND = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_CLASS = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_INTERFACE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtSuperTypeListEntry, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_CLASS = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtSuperTypeListEntry, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_INTERFACE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory1<KtElement, Collection<ClassDescriptor>> PLATFORM_CLASS_MAPPED_TO_KOTLIN = DiagnosticFactory1.create(WARNING);
@@ -142,7 +142,7 @@ public interface Errors {
// Annotations
DiagnosticFactory0<KtDelegationSpecifierList> SUPERTYPES_FOR_ANNOTATION_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtSuperTypeList> SUPERTYPES_FOR_ANNOTATION_CLASS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtParameter> MISSING_VAL_ON_ANNOTATION_PARAMETER = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtCallExpression> ANNOTATION_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<KtAnnotationEntry, DeclarationDescriptor> NOT_AN_ANNOTATION_CLASS = DiagnosticFactory1.create(ERROR);
@@ -178,7 +178,7 @@ public interface Errors {
DiagnosticFactory0<PsiElement> CYCLIC_INHERITANCE_HIERARCHY = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtDelegatorToSuperClass> SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtSuperTypeEntry> SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtTypeReference> DELEGATION_NOT_TO_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
@@ -188,7 +188,7 @@ public interface Errors {
DiagnosticFactory0<KtTypeReference> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtTypeReference> SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory3<KtDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
DiagnosticFactory3<KtSuperTypeList, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
INCONSISTENT_TYPE_PARAMETER_VALUES = DiagnosticFactory3.create(ERROR);
DiagnosticFactory3<KtTypeParameter, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
INCONSISTENT_TYPE_PARAMETER_BOUNDS = DiagnosticFactory3.create(ERROR);
@@ -207,7 +207,7 @@ public interface Errors {
DiagnosticFactory0<KtConstructorDelegationReferenceExpression> CYCLIC_CONSTRUCTOR_DELEGATION_CALL = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtDeclaration> CONSTRUCTOR_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<KtDelegatorToSuperCall> SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtSuperTypeCallEntry> SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtConstructorDelegationCall> PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED =
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
@@ -231,7 +231,7 @@ public interface Errors {
DiagnosticFactory0<PsiElement> SUPERTYPE_INITIALIZED_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtDelegatorByExpressionSpecifier> DELEGATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtDelegatedSuperTypeEntry> DELEGATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INTERFACE_WITH_SUPERCLASS = DiagnosticFactory0.create(ERROR);
@@ -532,7 +532,7 @@ public interface Errors {
// Destructuring-declarations
DiagnosticFactory0<KtMultiDeclaration> INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
DiagnosticFactory0<KtDestructuringDeclaration> INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
DiagnosticFactory2<KtExpression, Name, KotlinType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
DiagnosticFactory2<KtExpression, Name, Collection<? extends ResolvedCall<?>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
DiagnosticFactory3<KtExpression, Name, KotlinType, KotlinType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
@@ -626,7 +626,7 @@ public interface Errors {
DiagnosticFactory2<KtBinaryExpression, KtElement, DeclarationDescriptor> UNUSED_VALUE = DiagnosticFactory2.create(WARNING, PositioningStrategies.UNUSED_VALUE);
DiagnosticFactory1<KtElement, KtElement> UNUSED_CHANGED_VALUE = DiagnosticFactory1.create(WARNING);
DiagnosticFactory0<KtElement> UNUSED_EXPRESSION = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtFunctionLiteralExpression> UNUSED_LAMBDA_EXPRESSION = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtLambdaExpression> UNUSED_LAMBDA_EXPRESSION = DiagnosticFactory0.create(WARNING);
DiagnosticFactory1<KtExpression, DeclarationDescriptor> VAL_REASSIGNMENT = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<KtExpression, DeclarationDescriptor> SETTER_PROJECTED_OUT = DiagnosticFactory1.create(ERROR);
@@ -49,7 +49,7 @@ public object PositioningStrategies {
is KtObjectLiteralExpression -> {
val objectDeclaration = element.getObjectDeclaration()
val objectKeyword = objectDeclaration.getObjectKeyword()
val delegationSpecifierList = objectDeclaration.getDelegationSpecifierList()
val delegationSpecifierList = objectDeclaration.getSuperTypeList()
if (delegationSpecifierList == null) {
return markElement(objectKeyword)
}
@@ -426,7 +426,7 @@ public object PositioningStrategies {
@JvmField public val DELEGATOR_SUPER_CALL: PositioningStrategy<KtEnumEntry> = object: PositioningStrategy<KtEnumEntry>() {
override fun mark(element: KtEnumEntry): List<TextRange> {
val specifiers = element.getDelegationSpecifiers()
val specifiers = element.getSuperTypeListEntries()
return markElement(if (specifiers.isEmpty()) element else specifiers[0])
}
}
@@ -545,7 +545,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
break;
}
argument.done(FUNCTION_LITERAL_ARGUMENT);
argument.done(LAMBDA_ARGUMENT);
success = true;
}
@@ -1031,7 +1031,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
if (declType != null) {
// we do not attach preceding comments (non-doc) to local variables because they are likely commenting a few statements below
closeDeclarationWithCommentBinders(decl, declType,
declType != KtNodeTypes.PROPERTY && declType != KtNodeTypes.MULTI_VARIABLE_DECLARATION);
declType != KtNodeTypes.PROPERTY && declType != KtNodeTypes.DESTRUCTURING_DECLARATION);
return true;
}
else {
@@ -1104,7 +1104,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
myBuilder.restoreNewlinesState();
literal.done(FUNCTION_LITERAL);
literalExpression.done(FUNCTION_LITERAL_EXPRESSION);
literalExpression.done(LAMBDA_EXPRESSION);
}
private boolean rollbackOrDropAt(PsiBuilder.Marker rollbackMarker, IElementType dropAt) {
@@ -1352,7 +1352,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
if (at(LPAR)) {
myJetParsing.parseMultiDeclarationName(TokenSet.create(IN_KEYWORD, LBRACE));
parameter.done(MULTI_VARIABLE_DECLARATION);
parameter.done(DESTRUCTURING_DECLARATION);
}
else {
expect(IDENTIFIER, "Expecting a variable name", TokenSet.create(COLON, IN_KEYWORD));
@@ -960,7 +960,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
callee.done(CONSTRUCTOR_CALLEE);
myExpressionParsing.parseValueArgumentList();
delegatorSuperCall.done(DELEGATOR_SUPER_CALL);
delegatorSuperCall.done(SUPER_TYPE_CALL_ENTRY);
initializerList.done(INITIALIZER_LIST);
}
if (at(LBRACE)) {
@@ -1284,7 +1284,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
}
}
return multiDeclaration ? MULTI_VARIABLE_DECLARATION : PROPERTY;
return multiDeclaration ? DESTRUCTURING_DECLARATION : PROPERTY;
}
/*
@@ -1329,7 +1329,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
advance(); // COLON
parseTypeRef(follow);
}
property.done(MULTI_VARIABLE_DECLARATION_ENTRY);
property.done(DESTRUCTURING_DECLARATION_ENTRY);
if (!at(COMMA)) break;
advance(); // COMMA
@@ -1637,7 +1637,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
advance(); // COMMA
}
list.done(DELEGATION_SPECIFIER_LIST);
list.done(SUPER_TYPE_LIST);
}
/*
@@ -1660,16 +1660,16 @@ public class KotlinParsing extends AbstractKotlinParsing {
reference.drop();
advance(); // BY_KEYWORD
createForByClause(myBuilder).myExpressionParsing.parseExpression();
delegator.done(DELEGATOR_BY);
delegator.done(DELEGATED_SUPER_TYPE_ENTRY);
}
else if (at(LPAR)) {
reference.done(CONSTRUCTOR_CALLEE);
myExpressionParsing.parseValueArgumentList();
delegator.done(DELEGATOR_SUPER_CALL);
delegator.done(SUPER_TYPE_CALL_ENTRY);
}
else {
reference.drop();
delegator.done(DELEGATOR_SUPER_CLASS);
delegator.done(SUPER_TYPE_ENTRY);
}
}
@@ -49,7 +49,7 @@ public interface Call {
@ReadOnly
@NotNull
List<? extends FunctionLiteralArgument> getFunctionLiteralArguments();
List<? extends LambdaArgument> getFunctionLiteralArguments();
@ReadOnly
@NotNull
@@ -16,9 +16,9 @@
package org.jetbrains.kotlin.psi.debugText
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.lexer.KtTokens
import com.intellij.openapi.diagnostic.Logger
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
// invoke this instead of getText() when you need debug text to identify some place in PSI without storing the element itself
// this is need to avoid unnecessary file parses
@@ -98,11 +98,11 @@ private object DebugTextBuildingVisitor : KtVisitor<String, Unit>() {
return render(constructorCalleeExpression, constructorCalleeExpression.getConstructorReferenceExpression())
}
override fun visitDelegationSpecifier(specifier: KtDelegationSpecifier, data: Unit?): String? {
override fun visitSuperTypeListEntry(specifier: KtSuperTypeListEntry, data: Unit?): String? {
return render(specifier, specifier.getTypeReference())
}
override fun visitDelegationSpecifierList(list: KtDelegationSpecifierList, data: Unit?): String? {
override fun visitSuperTypeList(list: KtSuperTypeList, data: Unit?): String? {
return renderChildren(list, ", ")
}
@@ -208,7 +208,7 @@ private object DebugTextBuildingVisitor : KtVisitor<String, Unit>() {
appendInn(klass.getTypeParameterList())
appendInn(klass.getPrimaryConstructorModifierList(), prefix = " ", suffix = " ")
appendInn(klass.getPrimaryConstructorParameterList())
appendInn(klass.getDelegationSpecifierList(), prefix = " : ")
appendInn(klass.getSuperTypeList(), prefix = " : ")
}
}
@@ -239,7 +239,7 @@ private object DebugTextBuildingVisitor : KtVisitor<String, Unit>() {
appendInn(declaration.getModifierList(), suffix = " ")
append("object ")
appendInn(declaration.getNameAsName())
appendInn(declaration.getDelegationSpecifierList(), prefix = " : ")
appendInn(declaration.getSuperTypeList(), prefix = " : ")
}
}
@@ -75,7 +75,7 @@ public class KtAnnotationEntry extends KtElementImplStub<KotlinAnnotationEntrySt
@NotNull
@Override
public List<KtFunctionLiteralArgument> getFunctionLiteralArguments() {
public List<KtLambdaArgument> getLambdaArguments() {
return Collections.emptyList();
}
@@ -32,7 +32,7 @@ public interface KtCallElement extends KtElement {
List<? extends ValueArgument> getValueArguments();
@NotNull
List<KtFunctionLiteralArgument> getFunctionLiteralArguments();
List<KtLambdaArgument> getLambdaArguments();
@NotNull
List<KtTypeProjection> getTypeArguments();
@@ -60,8 +60,8 @@ public class KtCallExpression extends KtExpressionImpl implements KtCallElement,
*/
@Override
@NotNull
public List<KtFunctionLiteralArgument> getFunctionLiteralArguments() {
return findChildrenByType(KtNodeTypes.FUNCTION_LITERAL_ARGUMENT);
public List<KtLambdaArgument> getLambdaArguments() {
return findChildrenByType(KtNodeTypes.LAMBDA_ARGUMENT);
}
@Override
@@ -69,7 +69,7 @@ public class KtCallExpression extends KtExpressionImpl implements KtCallElement,
public List<KtValueArgument> getValueArguments() {
KtValueArgumentList list = getValueArgumentList();
List<KtValueArgument> valueArgumentsInParentheses = list != null ? list.getArguments() : Collections.<KtValueArgument>emptyList();
List<KtFunctionLiteralArgument> functionLiteralArguments = getFunctionLiteralArguments();
List<KtLambdaArgument> functionLiteralArguments = getLambdaArguments();
if (functionLiteralArguments.isEmpty()) {
return valueArgumentsInParentheses;
}
@@ -25,7 +25,6 @@ import com.intellij.psi.impl.CheckUtil
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil
import com.intellij.psi.stubs.IStubElementType
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
@@ -35,26 +34,26 @@ abstract public class KtClassOrObject :
public constructor(node: ASTNode) : super(node)
public constructor(stub: KotlinClassOrObjectStub<out KtClassOrObject>, nodeType: IStubElementType<*, *>) : super(stub, nodeType)
public fun getDelegationSpecifierList(): KtDelegationSpecifierList? = getStubOrPsiChild(KtStubElementTypes.DELEGATION_SPECIFIER_LIST)
open public fun getDelegationSpecifiers(): List<KtDelegationSpecifier> = getDelegationSpecifierList()?.getDelegationSpecifiers().orEmpty()
public fun getSuperTypeList(): KtSuperTypeList? = getStubOrPsiChild(KtStubElementTypes.SUPER_TYPE_LIST)
open public fun getSuperTypeListEntries(): List<KtSuperTypeListEntry> = getSuperTypeList()?.getEntries().orEmpty()
public fun addDelegationSpecifier(delegationSpecifier: KtDelegationSpecifier): KtDelegationSpecifier {
getDelegationSpecifierList()?.let {
return EditCommaSeparatedListHelper.addItem(it, getDelegationSpecifiers(), delegationSpecifier)
public fun addSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry): KtSuperTypeListEntry {
getSuperTypeList()?.let {
return EditCommaSeparatedListHelper.addItem(it, getSuperTypeListEntries(), superTypeListEntry)
}
val psiFactory = KtPsiFactory(this)
val specifierListToAdd = psiFactory.createDelegatorToSuperCall("A()").replace(delegationSpecifier).getParent()
val specifierListToAdd = psiFactory.createSuperTypeCallEntry("A()").replace(superTypeListEntry).getParent()
val colon = addBefore(psiFactory.createColon(), getBody())
return (addAfter(specifierListToAdd, colon) as KtDelegationSpecifierList).getDelegationSpecifiers().first()
return (addAfter(specifierListToAdd, colon) as KtSuperTypeList).getEntries().first()
}
public fun removeDelegationSpecifier(delegationSpecifier: KtDelegationSpecifier) {
val specifierList = getDelegationSpecifierList() ?: return
assert(delegationSpecifier.getParent() === specifierList)
public fun removeSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry) {
val specifierList = getSuperTypeList() ?: return
assert(superTypeListEntry.getParent() === specifierList)
if (specifierList.getDelegationSpecifiers().size() > 1) {
EditCommaSeparatedListHelper.removeItem<KtElement>(delegationSpecifier)
if (specifierList.getEntries().size() > 1) {
EditCommaSeparatedListHelper.removeItem<KtElement>(superTypeListEntry)
}
else {
deleteChildRange(findChildByType<PsiElement>(KtTokens.COLON) ?: specifierList, specifierList)
@@ -44,7 +44,7 @@ public class KtConstructorDelegationCall extends KtElementImpl implements KtCall
@NotNull
@Override
public List<KtFunctionLiteralArgument> getFunctionLiteralArguments() {
public List<KtLambdaArgument> getLambdaArguments() {
return Collections.emptyList();
}
@@ -22,18 +22,18 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
public class KtDelegatorByExpressionSpecifier extends KtDelegationSpecifier {
public KtDelegatorByExpressionSpecifier(@NotNull ASTNode node) {
public class KtDelegatedSuperTypeEntry extends KtSuperTypeListEntry {
public KtDelegatedSuperTypeEntry(@NotNull ASTNode node) {
super(node);
}
public KtDelegatorByExpressionSpecifier(@NotNull KotlinPlaceHolderStub<? extends KtDelegationSpecifier> stub) {
super(stub, KtStubElementTypes.DELEGATOR_BY);
public KtDelegatedSuperTypeEntry(@NotNull KotlinPlaceHolderStub<? extends KtSuperTypeListEntry> stub) {
super(stub, KtStubElementTypes.DELEGATED_SUPER_TYPE_ENTRY);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitDelegationByExpressionSpecifier(this, data);
return visitor.visitDelegatedSuperTypeEntry(this, data);
}
@Nullable @IfNotParsed
@@ -29,19 +29,19 @@ import java.util.List;
import static org.jetbrains.kotlin.lexer.KtTokens.*;
public class KtMultiDeclaration extends KtDeclarationImpl implements KtValVarKeywordOwner {
public KtMultiDeclaration(@NotNull ASTNode node) {
public class KtDestructuringDeclaration extends KtDeclarationImpl implements KtValVarKeywordOwner {
public KtDestructuringDeclaration(@NotNull ASTNode node) {
super(node);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitMultiDeclaration(this, data);
return visitor.visitDestructuringDeclaration(this, data);
}
@NotNull
public List<KtMultiDeclarationEntry> getEntries() {
return findChildrenByType(KtNodeTypes.MULTI_VARIABLE_DECLARATION_ENTRY);
public List<KtDestructuringDeclarationEntry> getEntries() {
return findChildrenByType(KtNodeTypes.DESTRUCTURING_DECLARATION_ENTRY);
}
@Nullable
@@ -34,8 +34,8 @@ import java.util.List;
import static org.jetbrains.kotlin.lexer.KtTokens.VAL_KEYWORD;
import static org.jetbrains.kotlin.lexer.KtTokens.VAR_KEYWORD;
public class KtMultiDeclarationEntry extends KtNamedDeclarationNotStubbed implements KtVariableDeclaration {
public KtMultiDeclarationEntry(@NotNull ASTNode node) {
public class KtDestructuringDeclarationEntry extends KtNamedDeclarationNotStubbed implements KtVariableDeclaration {
public KtDestructuringDeclarationEntry(@NotNull ASTNode node) {
super(node);
}
@@ -100,7 +100,7 @@ public class KtMultiDeclarationEntry extends KtNamedDeclarationNotStubbed implem
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitMultiDeclarationEntry(this, data);
return visitor.visitDestructuringDeclarationEntry(this, data);
}
@Override
@@ -122,7 +122,7 @@ public class KtMultiDeclarationEntry extends KtNamedDeclarationNotStubbed implem
@NotNull
private ASTNode getParentNode() {
ASTNode parent = getNode().getTreeParent();
assert parent.getElementType() == KtNodeTypes.MULTI_VARIABLE_DECLARATION;
assert parent.getElementType() == KtNodeTypes.DESTRUCTURING_DECLARATION;
return parent;
}
@@ -20,11 +20,8 @@ import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiEnumConstant;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub;
import org.jetbrains.kotlin.psi.stubs.KotlinClassStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
@@ -42,7 +39,7 @@ public class KtEnumEntry extends KtClass {
@NotNull
@Override
public List<KtDelegationSpecifier> getDelegationSpecifiers() {
public List<KtSuperTypeListEntry> getSuperTypeListEntries() {
KtInitializerList initializerList = getInitializerList();
if (initializerList == null) {
return Collections.emptyList();
@@ -51,7 +48,7 @@ public class KtEnumEntry extends KtClass {
}
public boolean hasInitializer() {
return !getDelegationSpecifiers().isEmpty();
return !getSuperTypeListEntries().isEmpty();
}
@Nullable
@@ -38,8 +38,8 @@ public class KtForExpression extends KtLoopExpression {
}
@Nullable
public KtMultiDeclaration getMultiParameter() {
return (KtMultiDeclaration) findChildByType(KtNodeTypes.MULTI_VARIABLE_DECLARATION);
public KtDestructuringDeclaration getDestructuringParameter() {
return (KtDestructuringDeclaration) findChildByType(KtNodeTypes.DESTRUCTURING_DECLARATION);
}
@Nullable @IfNotParsed
@@ -39,7 +39,7 @@ public class KtInitializerList extends KtElementImplStub<KotlinPlaceHolderStub<K
}
@NotNull
public List<KtDelegationSpecifier> getInitializers() {
return Arrays.asList(getStubOrPsiChildren(KtStubElementTypes.DELEGATION_SPECIFIER_TYPES, KtDelegationSpecifier.ARRAY_FACTORY));
public List<KtSuperTypeListEntry> getInitializers() {
return Arrays.asList(getStubOrPsiChildren(KtStubElementTypes.SUPER_TYPE_LIST_ENTRIES, KtSuperTypeListEntry.ARRAY_FACTORY));
}
}
@@ -18,16 +18,16 @@ package org.jetbrains.kotlin.psi
import com.intellij.lang.ASTNode
public class KtFunctionLiteralArgument(node: ASTNode) : KtValueArgument(node), FunctionLiteralArgument {
public class KtLambdaArgument(node: ASTNode) : KtValueArgument(node), LambdaArgument {
override fun getArgumentExpression() = super<KtValueArgument>.getArgumentExpression()!!
override fun getArgumentExpression() = super.getArgumentExpression()!!
override fun getFunctionLiteral(): KtFunctionLiteralExpression = getArgumentExpression().unpackFunctionLiteral()!!
override fun getLambdaExpression(): KtLambdaExpression = getArgumentExpression().unpackFunctionLiteral()!!
}
public fun KtExpression.unpackFunctionLiteral(allowParentheses: Boolean = false): KtFunctionLiteralExpression? {
public fun KtExpression.unpackFunctionLiteral(allowParentheses: Boolean = false): KtLambdaExpression? {
return when (this) {
is KtFunctionLiteralExpression -> this
is KtLambdaExpression -> this
is KtLabeledExpression -> baseExpression?.unpackFunctionLiteral(allowParentheses)
is KtAnnotatedExpression -> baseExpression?.unpackFunctionLiteral(allowParentheses)
is KtParenthesizedExpression -> if (allowParentheses) expression?.unpackFunctionLiteral(allowParentheses) else null
@@ -24,14 +24,14 @@ import org.jetbrains.kotlin.lexer.KtTokens;
import java.util.List;
public class KtFunctionLiteralExpression extends KtExpressionImpl {
public KtFunctionLiteralExpression(@NotNull ASTNode node) {
public class KtLambdaExpression extends KtExpressionImpl {
public KtLambdaExpression(@NotNull ASTNode node) {
super(node);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitFunctionLiteralExpression(this, data);
return visitor.visitLambdaExpression(this, data);
}
@NotNull
@@ -204,8 +204,8 @@ public class KtPsiFactory(private val project: Project) {
return getter
}
public fun createMultiDeclaration(text: String): KtMultiDeclaration {
return (createFunction("fun foo() {$text}").bodyExpression as KtBlockExpression).statements.first() as KtMultiDeclaration
public fun createDestructuringDeclaration(text: String): KtDestructuringDeclaration {
return (createFunction("fun foo() {$text}").bodyExpression as KtBlockExpression).statements.first() as KtDestructuringDeclaration
}
public fun <TDeclaration : KtDeclaration> createDeclaration(text: String): TDeclaration {
@@ -279,7 +279,7 @@ public class KtPsiFactory(private val project: Project) {
}
public fun createFunctionLiteralParameterList(text: String): KtParameterList {
return (createExpression("{ $text -> 0}") as KtFunctionLiteralExpression).getFunctionLiteral().getValueParameterList()!!
return (createExpression("{ $text -> 0}") as KtLambdaExpression).getFunctionLiteral().getValueParameterList()!!
}
public fun createEnumEntry(text: String): KtEnumEntry {
@@ -395,15 +395,15 @@ public class KtPsiFactory(private val project: Project) {
return argumentList.getArguments().single()
}
public fun createDelegatorToSuperCall(text: String): KtDelegatorToSuperCall {
return createClass("class A: $text").getDelegationSpecifiers().first() as KtDelegatorToSuperCall
public fun createSuperTypeCallEntry(text: String): KtSuperTypeCallEntry {
return createClass("class A: $text").getSuperTypeListEntries().first() as KtSuperTypeCallEntry
}
public fun createDelegatorToSuperClass(text: String): KtDelegatorToSuperClass {
return createClass("class A: $text").getDelegationSpecifiers().first() as KtDelegatorToSuperClass
public fun createSuperTypeEntry(text: String): KtSuperTypeEntry {
return createClass("class A: $text").getSuperTypeListEntries().first() as KtSuperTypeEntry
}
public fun createConstructorDelegationCall(text: String): KtConstructorDelegationCall {
public fun creareDelegatedSuperTypeEntry(text: String): KtConstructorDelegationCall {
val colonOrEmpty = if (text.isEmpty()) "" else ": "
return createClass("class A { constructor()$colonOrEmpty$text {}").getSecondaryConstructors().first().getDelegationCall()
}
@@ -298,8 +298,8 @@ public class KtPsiUtil {
public static boolean isVariableNotParameterDeclaration(@NotNull KtDeclaration declaration) {
if (!(declaration instanceof KtVariableDeclaration)) return false;
if (declaration instanceof KtProperty) return true;
assert declaration instanceof KtMultiDeclarationEntry;
KtMultiDeclarationEntry multiDeclarationEntry = (KtMultiDeclarationEntry) declaration;
assert declaration instanceof KtDestructuringDeclarationEntry;
KtDestructuringDeclarationEntry multiDeclarationEntry = (KtDestructuringDeclarationEntry) declaration;
return !(multiDeclarationEntry.getParent().getParent() instanceof KtForExpression);
}
@@ -819,7 +819,7 @@ public class KtPsiUtil {
parent instanceof KtDotQualifiedExpression ||
parent instanceof KtCallExpression ||
parent instanceof KtArrayAccessExpression ||
parent instanceof KtMultiDeclaration) {
parent instanceof KtDestructuringDeclaration) {
if (parent instanceof KtLabeledExpression) {
parent = parent.getParent();
@@ -835,7 +835,7 @@ public class KtPsiUtil {
else if (parent instanceof KtValueArgument || parent instanceof KtValueArgumentList) {
parent = parent.getParent();
}
else if (parent instanceof KtFunctionLiteralExpression || parent instanceof KtAnnotatedExpression) {
else if (parent instanceof KtLambdaExpression || parent instanceof KtAnnotatedExpression) {
parent = parent.getParent();
}
else {
@@ -48,6 +48,6 @@ public class KtSecondaryConstructor : KtConstructor<KtSecondaryConstructor> {
val delegationName = if (isThis) "this" else "super"
return addAfter(psiFactory.createConstructorDelegationCall(delegationName + "()"), colon) as KtConstructorDelegationCall
return addAfter(psiFactory.creareDelegatedSuperTypeEntry(delegationName + "()"), colon) as KtConstructorDelegationCall
}
}
@@ -26,18 +26,18 @@ import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
import java.util.Collections;
import java.util.List;
public class KtDelegatorToSuperCall extends KtDelegationSpecifier implements KtCallElement {
public KtDelegatorToSuperCall(@NotNull ASTNode node) {
public class KtSuperTypeCallEntry extends KtSuperTypeListEntry implements KtCallElement {
public KtSuperTypeCallEntry(@NotNull ASTNode node) {
super(node);
}
public KtDelegatorToSuperCall(@NotNull KotlinPlaceHolderStub<? extends KtDelegationSpecifier> stub) {
super(stub, KtStubElementTypes.DELEGATOR_SUPER_CALL);
public KtSuperTypeCallEntry(@NotNull KotlinPlaceHolderStub<? extends KtSuperTypeListEntry> stub) {
super(stub, KtStubElementTypes.SUPER_TYPE_CALL_ENTRY);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitDelegationToSuperCallSpecifier(this, data);
return visitor.visitSuperTypeCallEntry(this, data);
}
@NotNull
@@ -61,7 +61,7 @@ public class KtDelegatorToSuperCall extends KtDelegationSpecifier implements KtC
@NotNull
@Override
public List<KtFunctionLiteralArgument> getFunctionLiteralArguments() {
public List<KtLambdaArgument> getLambdaArguments() {
return Collections.emptyList();
}
@@ -21,17 +21,17 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
public class KtDelegatorToSuperClass extends KtDelegationSpecifier {
public KtDelegatorToSuperClass(@NotNull ASTNode node) {
public class KtSuperTypeEntry extends KtSuperTypeListEntry {
public KtSuperTypeEntry(@NotNull ASTNode node) {
super(node);
}
public KtDelegatorToSuperClass(@NotNull KotlinPlaceHolderStub<? extends KtDelegationSpecifier> stub) {
super(stub, KtStubElementTypes.DELEGATOR_SUPER_CLASS);
public KtSuperTypeEntry(@NotNull KotlinPlaceHolderStub<? extends KtSuperTypeListEntry> stub) {
super(stub, KtStubElementTypes.SUPER_TYPE_ENTRY);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitDelegationToSuperClassSpecifier(this, data);
return visitor.visitSuperTypeEntry(this, data);
}
}
@@ -24,21 +24,21 @@ import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
import java.util.Arrays;
import java.util.List;
public class KtDelegationSpecifierList extends KtElementImplStub<KotlinPlaceHolderStub<KtDelegationSpecifierList>> {
public KtDelegationSpecifierList(@NotNull ASTNode node) {
public class KtSuperTypeList extends KtElementImplStub<KotlinPlaceHolderStub<KtSuperTypeList>> {
public KtSuperTypeList(@NotNull ASTNode node) {
super(node);
}
public KtDelegationSpecifierList(@NotNull KotlinPlaceHolderStub<KtDelegationSpecifierList> stub) {
super(stub, KtStubElementTypes.DELEGATION_SPECIFIER_LIST);
public KtSuperTypeList(@NotNull KotlinPlaceHolderStub<KtSuperTypeList> stub) {
super(stub, KtStubElementTypes.SUPER_TYPE_LIST);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitDelegationSpecifierList(this, data);
return visitor.visitSuperTypeList(this, data);
}
public List<KtDelegationSpecifier> getDelegationSpecifiers() {
return Arrays.asList(getStubOrPsiChildren(KtStubElementTypes.DELEGATION_SPECIFIER_TYPES, KtDelegationSpecifier.ARRAY_FACTORY));
public List<KtSuperTypeListEntry> getEntries() {
return Arrays.asList(getStubOrPsiChildren(KtStubElementTypes.SUPER_TYPE_LIST_ENTRIES, KtSuperTypeListEntry.ARRAY_FACTORY));
}
}
@@ -24,31 +24,31 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
public class KtDelegationSpecifier extends KtElementImplStub<KotlinPlaceHolderStub<? extends KtDelegationSpecifier>> {
public class KtSuperTypeListEntry extends KtElementImplStub<KotlinPlaceHolderStub<? extends KtSuperTypeListEntry>> {
private static final KtDelegationSpecifier[] EMPTY_ARRAY = new KtDelegationSpecifier[0];
private static final KtSuperTypeListEntry[] EMPTY_ARRAY = new KtSuperTypeListEntry[0];
public static ArrayFactory<KtDelegationSpecifier> ARRAY_FACTORY = new ArrayFactory<KtDelegationSpecifier>() {
public static ArrayFactory<KtSuperTypeListEntry> ARRAY_FACTORY = new ArrayFactory<KtSuperTypeListEntry>() {
@NotNull
@Override
public KtDelegationSpecifier[] create(int count) {
return count == 0 ? EMPTY_ARRAY : new KtDelegationSpecifier[count];
public KtSuperTypeListEntry[] create(int count) {
return count == 0 ? EMPTY_ARRAY : new KtSuperTypeListEntry[count];
}
};
public KtDelegationSpecifier(@NotNull ASTNode node) {
public KtSuperTypeListEntry(@NotNull ASTNode node) {
super(node);
}
public KtDelegationSpecifier(
@NotNull KotlinPlaceHolderStub<? extends KtDelegationSpecifier> stub,
public KtSuperTypeListEntry(
@NotNull KotlinPlaceHolderStub<? extends KtSuperTypeListEntry> stub,
@NotNull IStubElementType nodeType) {
super(stub, nodeType);
}
@Override
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
return visitor.visitDelegationSpecifier(this, data);
return visitor.visitSuperTypeListEntry(this, data);
}
@Nullable
@@ -57,11 +57,11 @@ public class KtVisitor<R, D> extends PsiElementVisitor {
return visitNamedDeclaration(property, data);
}
public R visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration, D data) {
public R visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration, D data) {
return visitDeclaration(multiDeclaration, data);
}
public R visitMultiDeclarationEntry(@NotNull KtMultiDeclarationEntry multiDeclarationEntry, D data) {
public R visitDestructuringDeclarationEntry(@NotNull KtDestructuringDeclarationEntry multiDeclarationEntry, D data) {
return visitNamedDeclaration(multiDeclarationEntry, data);
}
@@ -134,24 +134,24 @@ public class KtVisitor<R, D> extends PsiElementVisitor {
return visitNamedDeclaration(parameter, data);
}
public R visitDelegationSpecifierList(@NotNull KtDelegationSpecifierList list, D data) {
public R visitSuperTypeList(@NotNull KtSuperTypeList list, D data) {
return visitKtElement(list, data);
}
public R visitDelegationSpecifier(@NotNull KtDelegationSpecifier specifier, D data) {
public R visitSuperTypeListEntry(@NotNull KtSuperTypeListEntry specifier, D data) {
return visitKtElement(specifier, data);
}
public R visitDelegationByExpressionSpecifier(@NotNull KtDelegatorByExpressionSpecifier specifier, D data) {
return visitDelegationSpecifier(specifier, data);
public R visitDelegatedSuperTypeEntry(@NotNull KtDelegatedSuperTypeEntry specifier, D data) {
return visitSuperTypeListEntry(specifier, data);
}
public R visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call, D data) {
return visitDelegationSpecifier(call, data);
public R visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call, D data) {
return visitSuperTypeListEntry(call, data);
}
public R visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier, D data) {
return visitDelegationSpecifier(specifier, data);
public R visitSuperTypeEntry(@NotNull KtSuperTypeEntry specifier, D data) {
return visitSuperTypeListEntry(specifier, data);
}
public R visitConstructorDelegationCall(@NotNull KtConstructorDelegationCall call, D data) {
@@ -258,7 +258,7 @@ public class KtVisitor<R, D> extends PsiElementVisitor {
return visitLoopExpression(expression, data);
}
public R visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression, D data) {
public R visitLambdaExpression(@NotNull KtLambdaExpression expression, D data) {
return visitExpression(expression, data);
}
@@ -53,12 +53,12 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
super.visitProperty(property, null);
}
public void visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration) {
super.visitMultiDeclaration(multiDeclaration, null);
public void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration destructuringDeclaration) {
super.visitDestructuringDeclaration(destructuringDeclaration, null);
}
public void visitMultiDeclarationEntry(@NotNull KtMultiDeclarationEntry multiDeclarationEntry) {
super.visitMultiDeclarationEntry(multiDeclarationEntry, null);
public void visitDestructuringDeclarationEntry(@NotNull KtDestructuringDeclarationEntry multiDeclarationEntry) {
super.visitDestructuringDeclarationEntry(multiDeclarationEntry, null);
}
public void visitTypedef(@NotNull KtTypedef typedef) {
@@ -121,24 +121,24 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
super.visitParameter(parameter, null);
}
public void visitDelegationSpecifierList(@NotNull KtDelegationSpecifierList list) {
super.visitDelegationSpecifierList(list, null);
public void visitSuperTypeList(@NotNull KtSuperTypeList list) {
super.visitSuperTypeList(list, null);
}
public void visitDelegationSpecifier(@NotNull KtDelegationSpecifier specifier) {
super.visitDelegationSpecifier(specifier, null);
public void visitSuperTypeListEntry(@NotNull KtSuperTypeListEntry specifier) {
super.visitSuperTypeListEntry(specifier, null);
}
public void visitDelegationByExpressionSpecifier(@NotNull KtDelegatorByExpressionSpecifier specifier) {
super.visitDelegationByExpressionSpecifier(specifier, null);
public void visitDelegatedSuperTypeEntry(@NotNull KtDelegatedSuperTypeEntry specifier) {
super.visitDelegatedSuperTypeEntry(specifier, null);
}
public void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call) {
super.visitDelegationToSuperCallSpecifier(call, null);
public void visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call) {
super.visitSuperTypeCallEntry(call, null);
}
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
super.visitDelegationToSuperClassSpecifier(specifier, null);
public void visitSuperTypeEntry(@NotNull KtSuperTypeEntry specifier) {
super.visitSuperTypeEntry(specifier, null);
}
public void visitConstructorDelegationCall(@NotNull KtConstructorDelegationCall call) {
@@ -245,8 +245,8 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
super.visitDoWhileExpression(expression, null);
}
public void visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression) {
super.visitFunctionLiteralExpression(expression, null);
public void visitLambdaExpression(@NotNull KtLambdaExpression lambdaExpression) {
super.visitLambdaExpression(lambdaExpression, null);
}
public void visitAnnotatedExpression(@NotNull KtAnnotatedExpression expression) {
@@ -487,14 +487,14 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
}
@Override
public final Void visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration, Void data) {
visitMultiDeclaration(multiDeclaration);
public final Void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration, Void data) {
visitDestructuringDeclaration(multiDeclaration);
return null;
}
@Override
public final Void visitMultiDeclarationEntry(@NotNull KtMultiDeclarationEntry multiDeclarationEntry, Void data) {
visitMultiDeclarationEntry(multiDeclarationEntry);
public final Void visitDestructuringDeclarationEntry(@NotNull KtDestructuringDeclarationEntry multiDeclarationEntry, Void data) {
visitDestructuringDeclarationEntry(multiDeclarationEntry);
return null;
}
@@ -589,34 +589,34 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
}
@Override
public final Void visitDelegationSpecifierList(@NotNull KtDelegationSpecifierList list, Void data) {
visitDelegationSpecifierList(list);
public final Void visitSuperTypeList(@NotNull KtSuperTypeList list, Void data) {
visitSuperTypeList(list);
return null;
}
@Override
public final Void visitDelegationSpecifier(@NotNull KtDelegationSpecifier specifier, Void data) {
visitDelegationSpecifier(specifier);
public final Void visitSuperTypeListEntry(@NotNull KtSuperTypeListEntry specifier, Void data) {
visitSuperTypeListEntry(specifier);
return null;
}
@Override
public final Void visitDelegationByExpressionSpecifier(
@NotNull KtDelegatorByExpressionSpecifier specifier, Void data
public final Void visitDelegatedSuperTypeEntry(
@NotNull KtDelegatedSuperTypeEntry specifier, Void data
) {
visitDelegationByExpressionSpecifier(specifier);
visitDelegatedSuperTypeEntry(specifier);
return null;
}
@Override
public final Void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call, Void data) {
visitDelegationToSuperCallSpecifier(call);
public final Void visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call, Void data) {
visitSuperTypeCallEntry(call);
return null;
}
@Override
public final Void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier, Void data) {
visitDelegationToSuperClassSpecifier(specifier);
public final Void visitSuperTypeEntry(@NotNull KtSuperTypeEntry specifier, Void data) {
visitSuperTypeEntry(specifier);
return null;
}
@@ -777,8 +777,8 @@ public class KtVisitorVoid extends KtVisitor<Void, Void> {
}
@Override
public final Void visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression, Void data) {
visitFunctionLiteralExpression(expression);
public final Void visitLambdaExpression(@NotNull KtLambdaExpression expression, Void data) {
visitLambdaExpression(expression);
return null;
}
@@ -50,12 +50,12 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
super.visitProperty(property, data);
}
public void visitMultiDeclarationVoid(@NotNull KtMultiDeclaration multiDeclaration, P data) {
super.visitMultiDeclaration(multiDeclaration, data);
public void visitDestructuringDeclarationVoid(@NotNull KtDestructuringDeclaration multiDeclaration, P data) {
super.visitDestructuringDeclaration(multiDeclaration, data);
}
public void visitMultiDeclarationEntryVoid(@NotNull KtMultiDeclarationEntry multiDeclarationEntry, P data) {
super.visitMultiDeclarationEntry(multiDeclarationEntry, data);
public void visitDestructuringDeclarationEntryVoid(@NotNull KtDestructuringDeclarationEntry multiDeclarationEntry, P data) {
super.visitDestructuringDeclarationEntry(multiDeclarationEntry, data);
}
public void visitTypedefVoid(@NotNull KtTypedef typedef, P data) {
@@ -118,27 +118,27 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
super.visitParameter(parameter, data);
}
public void visitDelegationSpecifierListVoid(@NotNull KtDelegationSpecifierList list, P data) {
super.visitDelegationSpecifierList(list, data);
public void visitSuperTypeListVoid(@NotNull KtSuperTypeList list, P data) {
super.visitSuperTypeList(list, data);
}
public void visitDelegationSpecifierVoid(@NotNull KtDelegationSpecifier specifier, P data) {
super.visitDelegationSpecifier(specifier, data);
public void visitSuperTypeListEntryVoid(@NotNull KtSuperTypeListEntry specifier, P data) {
super.visitSuperTypeListEntry(specifier, data);
}
public void visitDelegationByExpressionSpecifierVoid(@NotNull KtDelegatorByExpressionSpecifier specifier, P data) {
super.visitDelegationByExpressionSpecifier(specifier, data);
public void visitDelegatedSuperTypeEntryVoid(@NotNull KtDelegatedSuperTypeEntry specifier, P data) {
super.visitDelegatedSuperTypeEntry(specifier, data);
}
public void visitDelegationToSuperCallSpecifierVoid(@NotNull KtDelegatorToSuperCall call, P data) {
super.visitDelegationToSuperCallSpecifier(call, data);
public void visitSuperTypeCallEntryVoid(@NotNull KtSuperTypeCallEntry call, P data) {
super.visitSuperTypeCallEntry(call, data);
}
public void visitDelegationToSuperClassSpecifierVoid(@NotNull KtDelegatorToSuperClass specifier, P data) {
super.visitDelegationToSuperClassSpecifier(specifier, data);
public void visitSuperTypeEntryVoid(@NotNull KtSuperTypeEntry specifier, P data) {
super.visitSuperTypeEntry(specifier, data);
}
public void visitDelegationCallVoid(@NotNull KtConstructorDelegationCall call, P data) {
public void visitConstructorDelegationCallVoid(@NotNull KtConstructorDelegationCall call, P data) {
super.visitConstructorDelegationCall(call, data);
}
@@ -242,8 +242,8 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
super.visitDoWhileExpression(expression, data);
}
public void visitFunctionLiteralExpressionVoid(@NotNull KtFunctionLiteralExpression expression, P data) {
super.visitFunctionLiteralExpression(expression, data);
public void visitLambdaExpressionVoid(@NotNull KtLambdaExpression expression, P data) {
super.visitLambdaExpression(expression, data);
}
public void visitAnnotatedExpressionVoid(@NotNull KtAnnotatedExpression expression, P data) {
@@ -460,14 +460,14 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
}
@Override
public final Void visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration, P data) {
visitMultiDeclarationVoid(multiDeclaration, data);
public final Void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration, P data) {
visitDestructuringDeclarationVoid(multiDeclaration, data);
return null;
}
@Override
public final Void visitMultiDeclarationEntry(@NotNull KtMultiDeclarationEntry multiDeclarationEntry, P data) {
visitMultiDeclarationEntryVoid(multiDeclarationEntry, data);
public final Void visitDestructuringDeclarationEntry(@NotNull KtDestructuringDeclarationEntry multiDeclarationEntry, P data) {
visitDestructuringDeclarationEntryVoid(multiDeclarationEntry, data);
return null;
}
@@ -556,40 +556,40 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
}
@Override
public final Void visitDelegationSpecifierList(@NotNull KtDelegationSpecifierList list, P data) {
visitDelegationSpecifierListVoid(list, data);
public final Void visitSuperTypeList(@NotNull KtSuperTypeList list, P data) {
visitSuperTypeListVoid(list, data);
return null;
}
@Override
public final Void visitDelegationSpecifier(@NotNull KtDelegationSpecifier specifier, P data) {
visitDelegationSpecifierVoid(specifier, data);
public final Void visitSuperTypeListEntry(@NotNull KtSuperTypeListEntry specifier, P data) {
visitSuperTypeListEntryVoid(specifier, data);
return null;
}
@Override
public final Void visitDelegationByExpressionSpecifier(
@NotNull KtDelegatorByExpressionSpecifier specifier, P data
public final Void visitDelegatedSuperTypeEntry(
@NotNull KtDelegatedSuperTypeEntry specifier, P data
) {
visitDelegationByExpressionSpecifierVoid(specifier, data);
visitDelegatedSuperTypeEntryVoid(specifier, data);
return null;
}
@Override
public final Void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call, P data) {
visitDelegationToSuperCallSpecifierVoid(call, data);
public final Void visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call, P data) {
visitSuperTypeCallEntryVoid(call, data);
return null;
}
@Override
public final Void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier, P data) {
visitDelegationToSuperClassSpecifierVoid(specifier, data);
public final Void visitSuperTypeEntry(@NotNull KtSuperTypeEntry specifier, P data) {
visitSuperTypeEntryVoid(specifier, data);
return null;
}
@Override
public final Void visitConstructorDelegationCall(@NotNull KtConstructorDelegationCall call, P data) {
visitDelegationCallVoid(call, data);
visitConstructorDelegationCallVoid(call, data);
return null;
}
@@ -744,8 +744,8 @@ public class KtVisitorVoidWithParameter<P> extends KtVisitor<Void, P> {
}
@Override
public final Void visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression, P data) {
visitFunctionLiteralExpressionVoid(expression, data);
public final Void visitLambdaExpression(@NotNull KtLambdaExpression expression, P data) {
visitLambdaExpressionVoid(expression, data);
return null;
}
@@ -36,8 +36,8 @@ public interface ValueArgument {
public fun isExternal(): Boolean
}
public interface FunctionLiteralArgument : ValueArgument {
public fun getFunctionLiteral(): KtFunctionLiteralExpression
public interface LambdaArgument : ValueArgument {
public fun getLambdaExpression(): KtLambdaExpression
override fun getArgumentExpression(): KtExpression
}
@@ -164,7 +164,7 @@ public fun <TElement : KtElement> createByPattern(pattern: String, vararg args:
for ((pointer, n) in pointers) {
var element = pointer.getElement()!!
if (element is KtFunctionLiteral) {
element = element.getParent() as KtFunctionLiteralExpression
element = element.getParent() as KtLambdaExpression
}
(argumentTypes[n] as PsiElementPlaceholderArgumentType<in Any, in PsiElement>).replacePlaceholderElement(element, args[n])
}
@@ -232,7 +232,7 @@ public fun StubBasedPsiElementBase<out KotlinClassOrObjectStub<out KtClassOrObje
return stub.getSuperNames()
}
val specifiers = (this as KtClassOrObject).getDelegationSpecifiers()
val specifiers = (this as KtClassOrObject).getSuperTypeListEntries()
if (specifiers.isEmpty()) return Collections.emptyList<String>()
val result = ArrayList<String>()
@@ -351,11 +351,11 @@ public fun KtSimpleNameExpression.isPackageDirectiveExpression(): Boolean {
return parent is KtPackageDirective || parent?.getParent() is KtPackageDirective
}
public fun KtExpression.isFunctionLiteralOutsideParentheses(): Boolean {
public fun KtExpression.isLambdaOutsideParentheses(): Boolean {
val parent = getParent()
return when (parent) {
is KtFunctionLiteralArgument -> true
is KtLabeledExpression -> parent.isFunctionLiteralOutsideParentheses()
is KtLambdaArgument -> true
is KtLabeledExpression -> parent.isLambdaOutsideParentheses()
else -> false
}
}
@@ -387,7 +387,7 @@ public fun KtNamedDeclaration.getValueParameterList(): KtParameterList? {
}
}
public fun KtFunctionLiteralArgument.getFunctionLiteralArgumentName(bindingContext: BindingContext): Name? {
public fun KtLambdaArgument.getLambdaArgumentName(bindingContext: BindingContext): Name? {
val callExpression = getParent() as KtCallExpression
val resolvedCall = callExpression.getResolvedCall(bindingContext)
return (resolvedCall?.getArgumentMapping(this) as? ArgumentMatch)?.valueParameter?.getName()
@@ -100,19 +100,19 @@ public interface KtStubElementTypes {
KtPlaceHolderStubElementType<KtTypeArgumentList> TYPE_ARGUMENT_LIST =
new KtPlaceHolderStubElementType<KtTypeArgumentList>("TYPE_ARGUMENT_LIST", KtTypeArgumentList.class);
KtPlaceHolderStubElementType<KtDelegationSpecifierList> DELEGATION_SPECIFIER_LIST =
new KtPlaceHolderStubElementType<KtDelegationSpecifierList>("DELEGATION_SPECIFIER_LIST", KtDelegationSpecifierList.class);
KtPlaceHolderStubElementType<KtSuperTypeList> SUPER_TYPE_LIST =
new KtPlaceHolderStubElementType<KtSuperTypeList>("SUPER_TYPE_LIST", KtSuperTypeList.class);
KtPlaceHolderStubElementType<KtInitializerList> INITIALIZER_LIST =
new KtPlaceHolderStubElementType<KtInitializerList>("INITIALIZER_LIST", KtInitializerList.class);
KtPlaceHolderStubElementType<KtDelegatorByExpressionSpecifier> DELEGATOR_BY =
new KtPlaceHolderStubElementType<KtDelegatorByExpressionSpecifier>("DELEGATOR_BY", KtDelegatorByExpressionSpecifier.class);
KtPlaceHolderStubElementType<KtDelegatedSuperTypeEntry> DELEGATED_SUPER_TYPE_ENTRY =
new KtPlaceHolderStubElementType<KtDelegatedSuperTypeEntry>("DELEGATED_SUPER_TYPE_ENTRY", KtDelegatedSuperTypeEntry.class);
KtPlaceHolderStubElementType<KtDelegatorToSuperCall> DELEGATOR_SUPER_CALL =
new KtPlaceHolderStubElementType<KtDelegatorToSuperCall>("DELEGATOR_SUPER_CALL", KtDelegatorToSuperCall.class);
KtPlaceHolderStubElementType<KtDelegatorToSuperClass> DELEGATOR_SUPER_CLASS =
new KtPlaceHolderStubElementType<KtDelegatorToSuperClass>("DELEGATOR_SUPER_CLASS", KtDelegatorToSuperClass.class);
KtPlaceHolderStubElementType<KtSuperTypeCallEntry> SUPER_TYPE_CALL_ENTRY =
new KtPlaceHolderStubElementType<KtSuperTypeCallEntry>("SUPER_TYPE_CALL_ENTRY", KtSuperTypeCallEntry.class);
KtPlaceHolderStubElementType<KtSuperTypeEntry> SUPER_TYPE_ENTRY =
new KtPlaceHolderStubElementType<KtSuperTypeEntry>("SUPER_TYPE_ENTRY", KtSuperTypeEntry.class);
KtPlaceHolderStubElementType<KtConstructorCalleeExpression> CONSTRUCTOR_CALLEE =
new KtPlaceHolderStubElementType<KtConstructorCalleeExpression>("CONSTRUCTOR_CALLEE", KtConstructorCalleeExpression.class);
@@ -121,7 +121,7 @@ public interface KtStubElementTypes {
TokenSet DECLARATION_TYPES =
TokenSet.create(CLASS, OBJECT_DECLARATION, FUNCTION, PROPERTY, CLASS_INITIALIZER, SECONDARY_CONSTRUCTOR, ENUM_ENTRY);
TokenSet DELEGATION_SPECIFIER_TYPES = TokenSet.create(DELEGATOR_BY, DELEGATOR_SUPER_CALL, DELEGATOR_SUPER_CLASS);
TokenSet SUPER_TYPE_LIST_ENTRIES = TokenSet.create(DELEGATED_SUPER_TYPE_ENTRY, SUPER_TYPE_CALL_ENTRY, SUPER_TYPE_ENTRY);
TokenSet TYPE_ELEMENT_TYPES = TokenSet.create(USER_TYPE, NULLABLE_TYPE, FUNCTION_TYPE, DYNAMIC_TYPE, SELF_TYPE);
@@ -67,7 +67,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
public fun checkExpression(expression: KtExpression, trace: BindingTrace) {
checkEntries(expression.getAnnotationEntries(), getActualTargetList(expression, null), trace)
if (expression is KtFunctionLiteralExpression) {
if (expression is KtLambdaExpression) {
for (parameter in expression.valueParameters) {
parameter.typeReference?.let { check(it, trace) }
}
@@ -112,7 +112,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
val retention = descriptor.type.constructor.declarationDescriptor?.getAnnotationRetention()
if (retention == KotlinRetention.SOURCE) return
val functionLiteralExpression = annotatedExpression.baseExpression as? KtFunctionLiteralExpression ?: return
val functionLiteralExpression = annotatedExpression.baseExpression as? KtLambdaExpression ?: return
if (InlineUtil.isInlinedArgument(functionLiteralExpression.functionLiteral, trace.bindingContext, false)) {
trace.report(Errors.NON_SOURCE_ANNOTATION_ON_INLINED_LAMBDA_EXPRESSION.on(entry))
}
@@ -170,7 +170,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
return when (annotated) {
is KtClassOrObject ->
(descriptor as? ClassDescriptor)?.let { TargetList(KotlinTarget.classActualTargets(it)) } ?: TargetLists.T_CLASSIFIER
is KtMultiDeclarationEntry -> TargetLists.T_LOCAL_VARIABLE
is KtDestructuringDeclarationEntry -> TargetLists.T_LOCAL_VARIABLE
is KtProperty -> {
if (annotated.isLocal)
TargetLists.T_LOCAL_VARIABLE
@@ -203,8 +203,8 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
is KtTypeProjection ->
if (annotated.projectionKind == KtProjectionKind.STAR) TargetLists.T_STAR_PROJECTION else TargetLists.T_TYPE_PROJECTION
is KtAnonymousInitializer -> TargetLists.T_INITIALIZER
is KtMultiDeclaration -> TargetLists.T_DESTRUCTURING_DECLARATION
is KtFunctionLiteralExpression -> TargetLists.T_FUNCTION_LITERAL
is KtDestructuringDeclaration -> TargetLists.T_DESTRUCTURING_DECLARATION
is KtLambdaExpression -> TargetLists.T_FUNCTION_LITERAL
is KtObjectLiteralExpression -> TargetLists.T_OBJECT_LITERAL
is KtExpression -> TargetLists.T_EXPRESSION
else -> TargetLists.EMPTY
@@ -125,7 +125,7 @@ public interface BindingContext {
WritableSlice<PropertyDescriptor, ResolvedCall<FunctionDescriptor>> DELEGATED_PROPERTY_PD_RESOLVED_CALL = Slices.createSimpleSlice();
WritableSlice<KtMultiDeclarationEntry, ResolvedCall<FunctionDescriptor>> COMPONENT_RESOLVED_CALL = Slices.createSimpleSlice();
WritableSlice<KtDestructuringDeclarationEntry, ResolvedCall<FunctionDescriptor>> COMPONENT_RESOLVED_CALL = Slices.createSimpleSlice();
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_GET = Slices.createSimpleSlice();
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_SET = Slices.createSimpleSlice();
@@ -189,9 +189,9 @@ public interface BindingContext {
};
WritableSlice<PropertyDescriptor, Boolean> IS_UNINITIALIZED = Slices.createSimpleSetSlice();
WritableSlice<KtFunctionLiteralExpression, Boolean> BLOCK = new Slices.SetSlice<KtFunctionLiteralExpression>(DO_NOTHING) {
WritableSlice<KtLambdaExpression, Boolean> BLOCK = new Slices.SetSlice<KtLambdaExpression>(DO_NOTHING) {
@Override
public Boolean computeValue(SlicedMap map, KtFunctionLiteralExpression expression, Boolean isBlock, boolean valueNotFound) {
public Boolean computeValue(SlicedMap map, KtLambdaExpression expression, Boolean isBlock, boolean valueNotFound) {
isBlock = valueNotFound ? false : isBlock;
return isBlock && !expression.getFunctionLiteral().hasParameterSpecification();
}
@@ -98,7 +98,7 @@ public class BodyResolver {
}
private void resolveBehaviorDeclarationBodies(@NotNull BodiesResolveContext c) {
resolveDelegationSpecifierLists(c);
resolveSuperTypeEntryLists(c);
resolvePropertyDeclarationBodies(c);
@@ -231,20 +231,20 @@ public class BodyResolver {
functionAnalyzerExtension.process(c);
}
private void resolveDelegationSpecifierLists(@NotNull BodiesResolveContext c) {
private void resolveSuperTypeEntryLists(@NotNull BodiesResolveContext c) {
// TODO : Make sure the same thing is not initialized twice
for (Map.Entry<KtClassOrObject, ClassDescriptorWithResolutionScopes> entry : c.getDeclaredClasses().entrySet()) {
KtClassOrObject classOrObject = entry.getKey();
ClassDescriptorWithResolutionScopes descriptor = entry.getValue();
resolveDelegationSpecifierList(c.getOuterDataFlowInfo(), classOrObject, descriptor,
descriptor.getUnsubstitutedPrimaryConstructor(),
descriptor.getScopeForConstructorHeaderResolution(),
descriptor.getScopeForMemberDeclarationResolution());
resolveSuperTypeEntryList(c.getOuterDataFlowInfo(), classOrObject, descriptor,
descriptor.getUnsubstitutedPrimaryConstructor(),
descriptor.getScopeForConstructorHeaderResolution(),
descriptor.getScopeForMemberDeclarationResolution());
}
}
public void resolveDelegationSpecifierList(
public void resolveSuperTypeEntryList(
@NotNull final DataFlowInfo outerDataFlowInfo,
@NotNull KtClassOrObject jetClass,
@NotNull final ClassDescriptor descriptor,
@@ -267,7 +267,7 @@ public class BodyResolver {
}
@Override
public void visitDelegationByExpressionSpecifier(@NotNull KtDelegatorByExpressionSpecifier specifier) {
public void visitDelegatedSuperTypeEntry(@NotNull KtDelegatedSuperTypeEntry specifier) {
if (descriptor.getKind() == ClassKind.INTERFACE) {
trace.report(DELEGATION_IN_INTERFACE.on(specifier));
}
@@ -294,7 +294,7 @@ public class BodyResolver {
}
@Override
public void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call) {
public void visitSuperTypeCallEntry(@NotNull KtSuperTypeCallEntry call) {
KtValueArgumentList valueArgumentList = call.getValueArgumentList();
PsiElement elementToMark = valueArgumentList == null ? call : valueArgumentList;
if (descriptor.getKind() == ClassKind.INTERFACE) {
@@ -336,7 +336,7 @@ public class BodyResolver {
}
@Override
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
public void visitSuperTypeEntry(@NotNull KtSuperTypeEntry specifier) {
KtTypeReference typeReference = specifier.getTypeReference();
KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
recordSupertype(typeReference, supertype);
@@ -363,12 +363,12 @@ public class BodyResolver {
}
};
for (KtDelegationSpecifier delegationSpecifier : jetClass.getDelegationSpecifiers()) {
for (KtSuperTypeListEntry delegationSpecifier : jetClass.getSuperTypeListEntries()) {
delegationSpecifier.accept(visitor);
}
if (DescriptorUtils.isAnnotationClass(descriptor) && jetClass.getDelegationSpecifierList() != null) {
trace.report(SUPERTYPES_FOR_ANNOTATION_CLASS.on(jetClass.getDelegationSpecifierList()));
if (DescriptorUtils.isAnnotationClass(descriptor) && jetClass.getSuperTypeList() != null) {
trace.report(SUPERTYPES_FOR_ANNOTATION_CLASS.on(jetClass.getSuperTypeList()));
}
if (primaryConstructorDelegationCall[0] != null && primaryConstructor != null) {
@@ -149,7 +149,7 @@ class DeclarationsChecker(
private fun checkTypesInClassHeader(classOrObject: KtClassOrObject) {
fun KtTypeReference.type(): KotlinType? = trace.bindingContext.get(TYPE, this)
for (delegationSpecifier in classOrObject.getDelegationSpecifiers()) {
for (delegationSpecifier in classOrObject.getSuperTypeListEntries()) {
val typeReference = delegationSpecifier.typeReference ?: continue
typeReference.type()?.let { DescriptorResolver.checkBounds(typeReference, it, trace) }
typeReference.checkNotEnumEntry(trace)
@@ -212,7 +212,7 @@ class DeclarationsChecker(
val containingDeclaration = typeParameterDescriptor.containingDeclaration as? ClassDescriptor
?: throw AssertionError("Not a class descriptor: " + typeParameterDescriptor.containingDeclaration)
if (sourceElement is KtClassOrObject) {
val delegationSpecifierList = sourceElement.getDelegationSpecifierList() ?: continue
val delegationSpecifierList = sourceElement.getSuperTypeList() ?: continue
trace.report(INCONSISTENT_TYPE_PARAMETER_VALUES.on(
delegationSpecifierList, typeParameterDescriptor, containingDeclaration, conflictingTypes
))
@@ -252,7 +252,7 @@ class DeclarationsChecker(
private fun checkExposedSupertypes(klass: KtClassOrObject, classDescriptor: ClassDescriptor) {
val classVisibility = classDescriptor.effectiveVisibility()
val isInterface = classDescriptor.kind == ClassKind.INTERFACE
val delegationList = klass.getDelegationSpecifiers()
val delegationList = klass.getSuperTypeListEntries()
classDescriptor.typeConstructor.supertypes.forEachIndexed { i, superType ->
if (i >= delegationList.size) return
val superDescriptor = TypeUtils.getClassDescriptor(superType) ?: return@forEachIndexed
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION
import org.jetbrains.kotlin.diagnostics.Errors.MANY_IMPL_MEMBER_NOT_IMPLEMENTED
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtDelegatorByExpressionSpecifier
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
import org.jetbrains.kotlin.psi.KtTypeReference
import org.jetbrains.kotlin.resolve.OverridingUtil.OverrideCompatibilityInfo.Result.OVERRIDABLE
import org.jetbrains.kotlin.types.KotlinType
@@ -37,8 +37,8 @@ class DelegationResolver<T : CallableMemberDescriptor> private constructor(
private fun generateDelegatedMembers(): Collection<T> {
val delegatedMembers = hashSetOf<T>()
for (delegationSpecifier in classOrObject.getDelegationSpecifiers()) {
if (delegationSpecifier !is KtDelegatorByExpressionSpecifier) {
for (delegationSpecifier in classOrObject.getSuperTypeListEntries()) {
if (delegationSpecifier !is KtDelegatedSuperTypeEntry) {
continue
}
val typeReference = delegationSpecifier.typeReference ?: continue
@@ -109,8 +109,8 @@ public class DescriptorResolver {
BindingTrace trace
) {
List<KotlinType> supertypes = Lists.newArrayList();
List<KtDelegationSpecifier> delegationSpecifiers = jetClass.getDelegationSpecifiers();
Collection<KotlinType> declaredSupertypes = resolveDelegationSpecifiers(
List<KtSuperTypeListEntry> delegationSpecifiers = jetClass.getSuperTypeListEntries();
Collection<KotlinType> declaredSupertypes = resolveSuperTypeListEntries(
scope,
delegationSpecifiers,
typeResolver, trace, false);
@@ -166,9 +166,9 @@ public class DescriptorResolver {
return builtIns.getAnyType();
}
public Collection<KotlinType> resolveDelegationSpecifiers(
public Collection<KotlinType> resolveSuperTypeListEntries(
LexicalScope extensibleScope,
List<KtDelegationSpecifier> delegationSpecifiers,
List<KtSuperTypeListEntry> delegationSpecifiers,
@NotNull TypeResolver resolver,
BindingTrace trace,
boolean checkBounds
@@ -177,7 +177,7 @@ public class DescriptorResolver {
return Collections.emptyList();
}
Collection<KotlinType> result = Lists.newArrayList();
for (KtDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
for (KtSuperTypeListEntry delegationSpecifier : delegationSpecifiers) {
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
if (typeReference != null) {
KotlinType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve
import com.google.common.collect.HashMultimap
import com.google.common.collect.Multimap
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
@@ -163,7 +162,7 @@ public class LazyTopDownAnalyzer(
trace.report(UNSUPPORTED.on(typedef, "Typedefs are not supported"))
}
override fun visitMultiDeclaration(multiDeclaration: KtMultiDeclaration) {
override fun visitDestructuringDeclaration(destructuringDeclaration: KtDestructuringDeclaration) {
// Ignore: multi-declarations are only allowed locally
}
@@ -192,10 +192,10 @@ public class ModifiersChecker {
checkModifierListCommon(modifierListOwner, descriptor);
}
public void checkModifiersForMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration) {
public void checkModifiersForDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration) {
annotationChecker.check(multiDeclaration, trace, null);
ModifierCheckerCore.INSTANCE.check(multiDeclaration, trace, null);
for (KtMultiDeclarationEntry multiEntry: multiDeclaration.getEntries()) {
for (KtDestructuringDeclarationEntry multiEntry: multiDeclaration.getEntries()) {
annotationChecker.check(multiEntry, trace, null);
ModifierCheckerCore.INSTANCE.check(multiEntry, trace, null);
UnderscoreChecker.INSTANCE.checkNamed(multiEntry, trace);
@@ -57,7 +57,7 @@ class VarianceChecker(private val trace: BindingTrace) {
private fun checkClasses(c: TopDownAnalysisContext) {
for (jetClassOrObject in c.getDeclaredClasses()!!.keySet()) {
if (jetClassOrObject is KtClass) {
for (specifier in jetClassOrObject.getDelegationSpecifiers()) {
for (specifier in jetClassOrObject.getSuperTypeListEntries()) {
specifier.getTypeReference()?.checkTypePosition(trace.getBindingContext(), OUT_VARIANCE, trace)
}
jetClassOrObject.checkTypeParameters(trace.getBindingContext(), OUT_VARIANCE, trace)
@@ -30,22 +30,15 @@ import org.jetbrains.kotlin.resolve.TemporaryBindingTrace;
import org.jetbrains.kotlin.resolve.TypeResolver;
import org.jetbrains.kotlin.resolve.callableReferences.CallableReferencesResolutionUtilsKt;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext;
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode;
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImplKt;
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory;
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.FunctionPlaceholders;
import org.jetbrains.kotlin.types.FunctionPlaceholdersKt;
import org.jetbrains.kotlin.types.KotlinType;
@@ -117,7 +110,7 @@ public class ArgumentTypeResolver {
for (ValueArgument valueArgument : context.call.getValueArguments()) {
KtExpression argumentExpression = valueArgument.getArgumentExpression();
if (argumentExpression != null && !(argumentExpression instanceof KtFunctionLiteralExpression)) {
if (argumentExpression != null && !(argumentExpression instanceof KtLambdaExpression)) {
checkArgumentTypeWithNoCallee(context, argumentExpression);
}
}
@@ -173,8 +166,8 @@ public class ArgumentTypeResolver {
@NotNull KtExpression expression, @NotNull ResolutionContext context
) {
KtExpression deparenthesizedExpression = getLastElementDeparenthesized(expression, context.statementFilter);
if (deparenthesizedExpression instanceof KtFunctionLiteralExpression) {
return ((KtFunctionLiteralExpression) deparenthesizedExpression).getFunctionLiteral();
if (deparenthesizedExpression instanceof KtLambdaExpression) {
return ((KtLambdaExpression) deparenthesizedExpression).getFunctionLiteral();
}
if (deparenthesizedExpression instanceof KtFunction) {
return (KtFunction) deparenthesizedExpression;
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
@@ -222,7 +221,7 @@ public class CallExpressionResolver {
if (result[0]) {
FunctionDescriptor functionDescriptor = resolvedCall != null ? resolvedCall.getResultingDescriptor() : null;
temporaryForFunction.commit();
if (callExpression.getValueArgumentList() == null && callExpression.getFunctionLiteralArguments().isEmpty()) {
if (callExpression.getValueArgumentList() == null && callExpression.getLambdaArguments().isEmpty()) {
// there are only type arguments
boolean hasValueParameters = functionDescriptor == null || functionDescriptor.getValueParameters().size() > 0;
context.trace.report(FUNCTION_CALL_EXPECTED.on(callExpression, callExpression, hasValueParameters));
@@ -330,8 +330,8 @@ public class CallResolver {
// Here we handle the case where the callee expression must be something of type function, e.g. (foo.bar())(1, 2)
KotlinType expectedType = NO_EXPECTED_TYPE;
if (calleeExpression instanceof KtFunctionLiteralExpression) {
int parameterNumber = ((KtFunctionLiteralExpression) calleeExpression).getValueParameters().size();
if (calleeExpression instanceof KtLambdaExpression) {
int parameterNumber = ((KtLambdaExpression) calleeExpression).getValueParameters().size();
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(parameterNumber);
for (int i = 0; i < parameterNumber; i++) {
parameterTypes.add(NO_EXPECTED_TYPE);
@@ -117,7 +117,7 @@ public fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boole
fun isConventionCall(call: Call): Boolean {
if (call is CallTransformer.CallForImplicitInvoke) return true
val callElement = call.callElement
if (callElement is KtArrayAccessExpression || callElement is KtMultiDeclarationEntry) return true
if (callElement is KtArrayAccessExpression || callElement is KtDestructuringDeclarationEntry) return true
val calleeExpression = call.calleeExpression as? KtOperationReferenceExpression ?: return false
return calleeExpression.getNameForConventionalOperation() != null
}
@@ -113,7 +113,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
@NotNull
@Override
public List<FunctionLiteralArgument> getFunctionLiteralArguments() {
public List<LambdaArgument> getFunctionLiteralArguments() {
return Collections.emptyList();
}
@@ -256,10 +256,10 @@ public class ValueArgumentsToParametersMapper {
D candidate = candidateCall.getCandidateDescriptor();
List<ValueParameterDescriptor> valueParameters = candidate.getValueParameters();
List<? extends FunctionLiteralArgument> functionLiteralArguments = call.getFunctionLiteralArguments();
List<? extends LambdaArgument> functionLiteralArguments = call.getFunctionLiteralArguments();
if (!functionLiteralArguments.isEmpty()) {
FunctionLiteralArgument functionLiteralArgument = functionLiteralArguments.get(0);
KtExpression possiblyLabeledFunctionLiteral = functionLiteralArgument.getArgumentExpression();
LambdaArgument lambdaArgument = functionLiteralArguments.get(0);
KtExpression possiblyLabeledFunctionLiteral = lambdaArgument.getArgumentExpression();
if (valueParameters.isEmpty()) {
report(TOO_MANY_ARGUMENTS.on(possiblyLabeledFunctionLiteral, candidate));
@@ -277,7 +277,7 @@ public class ValueArgumentsToParametersMapper {
setStatus(WEAK_ERROR);
}
else {
putVararg(valueParameterDescriptor, functionLiteralArgument);
putVararg(valueParameterDescriptor, lambdaArgument);
}
}
}
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.diagnostics.Errors.UNRESOLVED_REFERENCE
import org.jetbrains.kotlin.diagnostics.Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER
import org.jetbrains.kotlin.psi.Call
import org.jetbrains.kotlin.psi.KtConstructorDelegationCall
import org.jetbrains.kotlin.psi.KtFunctionLiteralArgument
import org.jetbrains.kotlin.psi.KtLambdaArgument
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
import org.jetbrains.kotlin.resolve.BindingContext.CALL
import org.jetbrains.kotlin.resolve.BindingContext.REFERENCE_TARGET
@@ -172,7 +172,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
))
}
fun getFunctionType(funLiteralExpr: KtFunctionLiteralExpression): KotlinType {
fun getFunctionType(funLiteralExpr: KtLambdaExpression): KotlinType {
val funLiteral = funLiteralExpr.getFunctionLiteral()
val receiverType = funLiteral.getReceiverTypeReference()?.let { dynamicType }
@@ -189,7 +189,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
val argExpression = KtPsiUtil.deparenthesize(arg.getArgumentExpression())
when {
argExpression is KtFunctionLiteralExpression -> {
argExpression is KtLambdaExpression -> {
outType = getFunctionType(argExpression)
varargElementType = null
}
@@ -210,7 +210,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
if (hasSpreadOperator) {
for (funLiteralArg in call.getFunctionLiteralArguments()) {
addParameter(funLiteralArg, getFunctionType(funLiteralArg.getFunctionLiteral()), null)
addParameter(funLiteralArg, getFunctionType(funLiteralArg.getLambdaExpression()), null)
}
break
@@ -164,7 +164,7 @@ public class CallMaker {
@NotNull
@Override
public List<FunctionLiteralArgument> getFunctionLiteralArguments() {
public List<LambdaArgument> getFunctionLiteralArguments() {
return Collections.emptyList();
}
@NotNull
@@ -304,8 +304,8 @@ public class CallMaker {
@Override
@NotNull
public List<? extends FunctionLiteralArgument> getFunctionLiteralArguments() {
return callElement.getFunctionLiteralArguments();
public List<? extends LambdaArgument> getFunctionLiteralArguments() {
return callElement.getLambdaArguments();
}
@Override
@@ -73,7 +73,7 @@ public class DelegatingCall implements Call {
@Override
@NotNull
public List<? extends FunctionLiteralArgument> getFunctionLiteralArguments() {
public List<? extends LambdaArgument> getFunctionLiteralArguments() {
return delegate.getFunctionLiteralArguments();
}
@@ -87,14 +87,14 @@ public fun KtCallElement.getValueArgumentsInParentheses(): List<ValueArgument> =
public fun Call.getValueArgumentListOrElement(): KtElement = getValueArgumentList() ?: getCalleeExpression() ?: getCallElement()
@Suppress("UNCHECKED_CAST")
private fun List<ValueArgument?>.filterArgsInParentheses() = filter { it !is KtFunctionLiteralArgument } as List<ValueArgument>
private fun List<ValueArgument?>.filterArgsInParentheses() = filter { it !is KtLambdaArgument } as List<ValueArgument>
public fun Call.getValueArgumentForExpression(expression: KtExpression): ValueArgument? {
fun KtElement.deparenthesizeStructurally(): KtElement? {
val deparenthesized = if (this is KtExpression) KtPsiUtil.deparenthesizeOnce(this) else this
return when {
deparenthesized != this -> deparenthesized
this is KtFunctionLiteralExpression -> this.getFunctionLiteral()
this is KtLambdaExpression -> this.getFunctionLiteral()
this is KtFunctionLiteral -> this.getBodyExpression()
else -> null
}
@@ -54,7 +54,7 @@ public abstract class AbstractPsiBasedDeclarationProvider(storageManager: Storag
val scriptInfo = JetScriptInfo(declaration)
classesAndObjects.put(scriptInfo.script.nameAsName, scriptInfo)
}
else if (declaration is KtParameter || declaration is KtTypedef || declaration is KtMultiDeclaration) {
else if (declaration is KtParameter || declaration is KtTypedef || declaration is KtDestructuringDeclaration) {
// Do nothing, just put it into allDeclarations is enough
}
else {
@@ -159,7 +159,7 @@ protected constructor(
result.addAll(classDescriptors(name))
}
}
else if (declaration is KtTypedef || declaration is KtMultiDeclaration) {
else if (declaration is KtTypedef || declaration is KtDestructuringDeclaration) {
// Do nothing for typedefs as they are not supported.
// MultiDeclarations are not supported on global level too.
}
@@ -641,7 +641,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
PsiElement elementToMark = null;
if (psiElement instanceof KtClassOrObject) {
KtClassOrObject classOrObject = (KtClassOrObject) psiElement;
for (KtDelegationSpecifier delegationSpecifier : classOrObject.getDelegationSpecifiers()) {
for (KtSuperTypeListEntry delegationSpecifier : classOrObject.getSuperTypeListEntries()) {
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
if (typeReference == null) continue;
KotlinType supertype = trace.get(TYPE, typeReference);
@@ -55,7 +55,7 @@ public class DeprecatedSymbolValidator : SymbolUsageValidator {
return
// Do not check types in calls to super constructor in extends list, rely on call message
val superExpression = KtStubbedPsiUtil.getPsiOrStubParent(element, javaClass<KtDelegatorToSuperCall>(), true)
val superExpression = KtStubbedPsiUtil.getPsiOrStubParent(element, javaClass<KtSuperTypeCallEntry>(), true)
if (superExpression != null && superExpression.getCalleeExpression().getConstructorReferenceExpression() == element)
return
@@ -49,7 +49,7 @@ public class OperatorValidator : SymbolUsageValidator {
}
fun isMultiDeclaration(): Boolean {
return (resolvedCall != null) && (call?.callElement is KtMultiDeclarationEntry)
return (resolvedCall != null) && (call?.callElement is KtDestructuringDeclarationEntry)
}
fun isConventionOperator(): Boolean {
@@ -46,10 +46,10 @@ abstract class AssignedVariablesSearcher: KtTreeVisitorVoid() {
currentDeclaration = previous
}
override fun visitFunctionLiteralExpression(functionLiteralExpression: KtFunctionLiteralExpression) {
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
val previous = currentDeclaration
currentDeclaration = functionLiteralExpression.functionLiteral
super.visitFunctionLiteralExpression(functionLiteralExpression)
currentDeclaration = lambdaExpression.functionLiteral
super.visitLambdaExpression(lambdaExpression)
currentDeclaration = previous
}
@@ -743,9 +743,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
expression.getObjectDeclaration());
temporaryTrace.commit();
DataFlowInfo resultFlowInfo = context.dataFlowInfo;
for (KtDelegationSpecifier specifier : expression.getObjectDeclaration().getDelegationSpecifiers()) {
if (specifier instanceof KtDelegatorToSuperCall) {
KtDelegatorToSuperCall delegator = (KtDelegatorToSuperCall) specifier;
for (KtSuperTypeListEntry specifier : expression.getObjectDeclaration().getSuperTypeListEntries()) {
if (specifier instanceof KtSuperTypeCallEntry) {
KtSuperTypeCallEntry delegator = (KtSuperTypeCallEntry) specifier;
KotlinTypeInfo delegatorTypeInfo = context.trace.get(EXPRESSION_TYPE_INFO, delegator.getCalleeExpression());
if (delegatorTypeInfo != null) {
resultFlowInfo = resultFlowInfo.and(delegatorTypeInfo.getDataFlowInfo());
@@ -246,7 +246,7 @@ public class ControlStructureTypingUtils {
@NotNull
@Override
public List<FunctionLiteralArgument> getFunctionLiteralArguments() {
public List<LambdaArgument> getFunctionLiteralArguments() {
return Collections.emptyList();
}
@@ -313,7 +313,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
// .and it with entrance data flow information, because do-while body is executed at least once
// See KT-6283
KotlinTypeInfo bodyTypeInfo;
if (body instanceof KtFunctionLiteralExpression) {
if (body instanceof KtLambdaExpression) {
// As a matter of fact, function literal is always unused at this point
bodyTypeInfo = facade.getTypeInfo(body, context.replaceScope(context.scope));
}
@@ -397,15 +397,15 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
loopScope.addVariableDescriptor(variableDescriptor);
}
else {
KtMultiDeclaration multiParameter = expression.getMultiParameter();
KtDestructuringDeclaration multiParameter = expression.getDestructuringParameter();
if (multiParameter != null && loopRange != null) {
KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType;
TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType);
components.annotationResolver.resolveAnnotationsWithArguments(loopScope, multiParameter.getModifierList(), context.trace);
components.multiDeclarationResolver.defineLocalVariablesFromMultiDeclaration(
components.destructuringDeclarationResolver.defineLocalVariablesFromMultiDeclaration(
loopScope, multiParameter, iteratorNextAsReceiver, loopRange, context
);
components.modifiersChecker.withTrace(context.trace).checkModifiersForMultiDeclaration(multiParameter);
components.modifiersChecker.withTrace(context.trace).checkModifiersForDestructuringDeclaration(multiParameter);
components.modifiersChecker.withTrace(context.trace).checkParameterHasNoValOrVar(multiParameter, VAL_OR_VAR_ON_LOOP_MULTI_PARAMETER);
components.identifierChecker.checkDeclaration(multiParameter, context.trace);
}
@@ -538,7 +538,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
}
if (expression.getTargetLabel() == null) {
while (parentDeclaration instanceof KtMultiDeclaration) {
while (parentDeclaration instanceof KtDestructuringDeclaration) {
//TODO: It's hacking fix for KT-5100: Strange "Return is not allowed here" for multi-declaration initializer with elvis expression
parentDeclaration = PsiTreeUtil.getParentOfType(parentDeclaration, KtDeclaration.class);
}
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.types.expressions
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtDestructuringDeclaration
import org.jetbrains.kotlin.psi.KtDestructuringDeclarationEntry
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtMultiDeclaration
import org.jetbrains.kotlin.psi.KtMultiDeclarationEntry
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorResolver
import org.jetbrains.kotlin.resolve.TypeResolver
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
public class MultiDeclarationResolver(
public class DestructuringDeclarationResolver(
private val fakeCallResolver: FakeCallResolver,
private val descriptorResolver: DescriptorResolver,
private val typeResolver: TypeResolver,
@@ -40,12 +40,12 @@ public class MultiDeclarationResolver(
) {
public fun defineLocalVariablesFromMultiDeclaration(
writableScope: LexicalWritableScope,
multiDeclaration: KtMultiDeclaration,
destructuringDeclaration: KtDestructuringDeclaration,
receiver: ReceiverValue,
reportErrorsOn: KtExpression,
context: ExpressionTypingContext
) {
for ((componentIndex, entry) in multiDeclaration.getEntries().withIndex()) {
for ((componentIndex, entry) in destructuringDeclaration.getEntries().withIndex()) {
val componentName = createComponentName(componentIndex + 1)
val expectedType = getExpectedTypeForComponent(context, entry)
@@ -80,7 +80,7 @@ public class MultiDeclarationResolver(
}
}
private fun getExpectedTypeForComponent(context: ExpressionTypingContext, entry: KtMultiDeclarationEntry): KotlinType {
private fun getExpectedTypeForComponent(context: ExpressionTypingContext, entry: KtDestructuringDeclarationEntry): KotlinType {
val entryTypeRef = entry.getTypeReference() ?: return TypeUtils.NO_EXPECTED_TYPE
return typeResolver.resolveType(context.scope, entryTypeRef, context.trace, true)
}
@@ -49,7 +49,7 @@ public class ExpressionTypingComponents {
/*package*/ TypeResolver typeResolver;
/*package*/ AnnotationResolver annotationResolver;
/*package*/ ValueParameterResolver valueParameterResolver;
/*package*/ MultiDeclarationResolver multiDeclarationResolver;
/*package*/ DestructuringDeclarationResolver destructuringDeclarationResolver;
/*package*/ ConstantExpressionEvaluator constantExpressionEvaluator;
/*package*/ ModifiersChecker modifiersChecker;
/*package*/ DataFlowAnalyzer dataFlowAnalyzer;
@@ -142,8 +142,8 @@ public class ExpressionTypingComponents {
}
@Inject
public void setMultiDeclarationResolver(MultiDeclarationResolver multiDeclarationResolver) {
this.multiDeclarationResolver = multiDeclarationResolver;
public void setDestructuringDeclarationResolver(DestructuringDeclarationResolver destructuringDeclarationResolver) {
this.destructuringDeclarationResolver = destructuringDeclarationResolver;
}
@NotNull
@@ -229,8 +229,8 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor<Kotlin
//////////////////////////////////////////////////////////////////////////////////////////////
@Override
public KotlinTypeInfo visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression, ExpressionTypingContext data) {
return functions.visitFunctionLiteralExpression(expression, data);
public KotlinTypeInfo visitLambdaExpression(@NotNull KtLambdaExpression expression, ExpressionTypingContext data) {
return functions.visitLambdaExpression(expression, data);
}
@Override
@@ -163,7 +163,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
}
@Override
public KotlinTypeInfo visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration, ExpressionTypingContext context) {
public KotlinTypeInfo visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration, ExpressionTypingContext context) {
components.annotationResolver.resolveAnnotationsWithArguments(scope, multiDeclaration.getModifierList(), context.trace);
KtExpression initializer = multiDeclaration.getInitializer();
@@ -177,8 +177,9 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
if (expressionReceiver == null) {
return TypeInfoFactoryKt.noTypeInfo(context);
}
components.multiDeclarationResolver.defineLocalVariablesFromMultiDeclaration(scope, multiDeclaration, expressionReceiver, initializer, context);
components.modifiersChecker.withTrace(context.trace).checkModifiersForMultiDeclaration(multiDeclaration);
components.destructuringDeclarationResolver
.defineLocalVariablesFromMultiDeclaration(scope, multiDeclaration, expressionReceiver, initializer, context);
components.modifiersChecker.withTrace(context.trace).checkModifiersForDestructuringDeclaration(multiDeclaration);
components.identifierChecker.checkDeclaration(multiDeclaration, context.trace);
return typeInfo.replaceType(components.dataFlowAnalyzer.checkStatementType(multiDeclaration, context));
}
@@ -130,7 +130,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
return components.builtIns.getFunctionType(Annotations.EMPTY, receiverType, parameters, returnType)
}
override fun visitFunctionLiteralExpression(expression: KtFunctionLiteralExpression, context: ExpressionTypingContext): KotlinTypeInfo? {
override fun visitLambdaExpression(expression: KtLambdaExpression, context: ExpressionTypingContext): KotlinTypeInfo? {
if (!expression.getFunctionLiteral().hasBody()) return null
val expectedType = context.expectedType
@@ -154,7 +154,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
}
private fun createFunctionLiteralDescriptor(
expression: KtFunctionLiteralExpression,
expression: KtLambdaExpression,
context: ExpressionTypingContext
): AnonymousFunctionDescriptor {
val functionLiteral = expression.getFunctionLiteral()
@@ -174,7 +174,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
}
private fun computeReturnType(
expression: KtFunctionLiteralExpression,
expression: KtLambdaExpression,
context: ExpressionTypingContext,
functionDescriptor: SimpleFunctionDescriptorImpl,
functionTypeExpected: Boolean
@@ -191,7 +191,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
}
private fun computeUnsafeReturnType(
expression: KtFunctionLiteralExpression,
expression: KtLambdaExpression,
context: ExpressionTypingContext,
functionDescriptor: SimpleFunctionDescriptorImpl,
expectedReturnType: KotlinType?
@@ -65,7 +65,7 @@ public class LabelResolver {
return getLabelNameIfAny(element.getParent());
}
if (element instanceof KtFunctionLiteralExpression) {
if (element instanceof KtLambdaExpression) {
return getLabelForFunctionalExpression((KtExpression) element);
}
@@ -88,8 +88,8 @@ public class LabelResolver {
@NotNull
private KtExpression getExpressionUnderLabel(@NotNull KtExpression labeledExpression) {
KtExpression expression = KtPsiUtil.safeDeparenthesize(labeledExpression);
if (expression instanceof KtFunctionLiteralExpression) {
return ((KtFunctionLiteralExpression) expression).getFunctionLiteral();
if (expression instanceof KtLambdaExpression) {
return ((KtLambdaExpression) expression).getFunctionLiteral();
}
return expression;
}
@@ -111,7 +111,7 @@ public class LabelResolver {
@Nullable
private KtCallExpression getContainingCallExpression(@NotNull KtExpression expression) {
PsiElement parent = expression.getParent();
if (parent instanceof KtFunctionLiteralArgument) {
if (parent instanceof KtLambdaArgument) {
// f {}
PsiElement call = parent.getParent();
if (call instanceof KtCallExpression) {