rename Jet* classes to Kt*
This commit is contained in:
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
|
||||
|
||||
public interface JetNodeTypes {
|
||||
IFileElementType JET_FILE = new IFileElementType(KotlinLanguage.INSTANCE);
|
||||
|
||||
IElementType CLASS = JetStubElementTypes.CLASS;
|
||||
IElementType FUN = JetStubElementTypes.FUNCTION;
|
||||
IElementType PROPERTY = JetStubElementTypes.PROPERTY;
|
||||
IElementType MULTI_VARIABLE_DECLARATION = new JetNodeType("MULTI_VARIABLE_DECLARATION", JetMultiDeclaration.class);
|
||||
IElementType MULTI_VARIABLE_DECLARATION_ENTRY = new JetNodeType("MULTI_VARIABLE_DECLARATION_ENTRY", JetMultiDeclarationEntry.class);
|
||||
|
||||
JetNodeType TYPEDEF = new JetNodeType("TYPEDEF", JetTypedef.class);
|
||||
IElementType OBJECT_DECLARATION = JetStubElementTypes.OBJECT_DECLARATION;
|
||||
JetNodeType OBJECT_DECLARATION_NAME = new JetNodeType("OBJECT_DECLARATION_NAME", JetObjectDeclarationName.class);
|
||||
|
||||
IElementType ENUM_ENTRY = JetStubElementTypes.ENUM_ENTRY;
|
||||
IElementType ANONYMOUS_INITIALIZER = JetStubElementTypes.ANONYMOUS_INITIALIZER;
|
||||
IElementType SECONDARY_CONSTRUCTOR = JetStubElementTypes.SECONDARY_CONSTRUCTOR;
|
||||
IElementType PRIMARY_CONSTRUCTOR = JetStubElementTypes.PRIMARY_CONSTRUCTOR;
|
||||
|
||||
IElementType TYPE_PARAMETER_LIST = JetStubElementTypes.TYPE_PARAMETER_LIST;
|
||||
IElementType TYPE_PARAMETER = JetStubElementTypes.TYPE_PARAMETER;
|
||||
IElementType DELEGATION_SPECIFIER_LIST = JetStubElementTypes.DELEGATION_SPECIFIER_LIST;
|
||||
IElementType DELEGATOR_BY = JetStubElementTypes.DELEGATOR_BY;
|
||||
IElementType DELEGATOR_SUPER_CALL = JetStubElementTypes.DELEGATOR_SUPER_CALL;
|
||||
IElementType DELEGATOR_SUPER_CLASS = JetStubElementTypes.DELEGATOR_SUPER_CLASS;
|
||||
JetNodeType PROPERTY_DELEGATE = new JetNodeType("PROPERTY_DELEGATE", JetPropertyDelegate.class);
|
||||
IElementType CONSTRUCTOR_CALLEE = JetStubElementTypes.CONSTRUCTOR_CALLEE;
|
||||
IElementType VALUE_PARAMETER_LIST = JetStubElementTypes.VALUE_PARAMETER_LIST;
|
||||
IElementType VALUE_PARAMETER = JetStubElementTypes.VALUE_PARAMETER;
|
||||
|
||||
IElementType CLASS_BODY = JetStubElementTypes.CLASS_BODY;
|
||||
IElementType IMPORT_LIST = JetStubElementTypes.IMPORT_LIST;
|
||||
IElementType FILE_ANNOTATION_LIST = JetStubElementTypes.FILE_ANNOTATION_LIST;
|
||||
IElementType IMPORT_DIRECTIVE = JetStubElementTypes.IMPORT_DIRECTIVE;
|
||||
IElementType MODIFIER_LIST = JetStubElementTypes.MODIFIER_LIST;
|
||||
IElementType ANNOTATION = JetStubElementTypes.ANNOTATION;
|
||||
IElementType ANNOTATION_ENTRY = JetStubElementTypes.ANNOTATION_ENTRY;
|
||||
IElementType ANNOTATION_TARGET = JetStubElementTypes.ANNOTATION_TARGET;
|
||||
|
||||
IElementType TYPE_ARGUMENT_LIST = JetStubElementTypes.TYPE_ARGUMENT_LIST;
|
||||
JetNodeType VALUE_ARGUMENT_LIST = new JetNodeType("VALUE_ARGUMENT_LIST", JetValueArgumentList.class);
|
||||
JetNodeType VALUE_ARGUMENT = new JetNodeType("VALUE_ARGUMENT", JetValueArgument.class);
|
||||
JetNodeType FUNCTION_LITERAL_ARGUMENT = new JetNodeType("FUNCTION_LITERAL_ARGUMENT", JetFunctionLiteralArgument.class);
|
||||
JetNodeType VALUE_ARGUMENT_NAME = new JetNodeType("VALUE_ARGUMENT_NAME", JetValueArgumentName.class);
|
||||
IElementType TYPE_REFERENCE = JetStubElementTypes.TYPE_REFERENCE;
|
||||
|
||||
IElementType USER_TYPE = JetStubElementTypes.USER_TYPE;
|
||||
IElementType DYNAMIC_TYPE = JetStubElementTypes.DYNAMIC_TYPE;
|
||||
IElementType FUNCTION_TYPE = JetStubElementTypes.FUNCTION_TYPE;
|
||||
IElementType FUNCTION_TYPE_RECEIVER = JetStubElementTypes.FUNCTION_TYPE_RECEIVER;
|
||||
JetNodeType SELF_TYPE = new JetNodeType("SELF_TYPE", JetSelfType.class);
|
||||
IElementType NULLABLE_TYPE = JetStubElementTypes.NULLABLE_TYPE;
|
||||
IElementType TYPE_PROJECTION = JetStubElementTypes.TYPE_PROJECTION;
|
||||
|
||||
// TODO: review
|
||||
IElementType PROPERTY_ACCESSOR = JetStubElementTypes.PROPERTY_ACCESSOR;
|
||||
IElementType INITIALIZER_LIST = JetStubElementTypes.INITIALIZER_LIST;
|
||||
IElementType TYPE_CONSTRAINT_LIST = JetStubElementTypes.TYPE_CONSTRAINT_LIST;
|
||||
IElementType TYPE_CONSTRAINT = JetStubElementTypes.TYPE_CONSTRAINT;
|
||||
|
||||
IElementType CONSTRUCTOR_DELEGATION_CALL = new JetNodeType("CONSTRUCTOR_DELEGATION_CALL", JetConstructorDelegationCall.class);
|
||||
JetNodeType CONSTRUCTOR_DELEGATION_REFERENCE =
|
||||
new JetNodeType("CONSTRUCTOR_DELEGATION_REFERENCE", JetConstructorDelegationReferenceExpression.class);
|
||||
|
||||
// TODO: Not sure if we need separate NT for each kind of constants
|
||||
JetNodeType NULL = new JetNodeType("NULL", JetConstantExpression.class);
|
||||
JetNodeType BOOLEAN_CONSTANT = new JetNodeType("BOOLEAN_CONSTANT", JetConstantExpression.class);
|
||||
JetNodeType FLOAT_CONSTANT = new JetNodeType("FLOAT_CONSTANT", JetConstantExpression.class);
|
||||
JetNodeType CHARACTER_CONSTANT = new JetNodeType("CHARACTER_CONSTANT", JetConstantExpression.class);
|
||||
JetNodeType INTEGER_CONSTANT = new JetNodeType("INTEGER_CONSTANT", JetConstantExpression.class);
|
||||
|
||||
JetNodeType STRING_TEMPLATE = new JetNodeType("STRING_TEMPLATE", JetStringTemplateExpression.class);
|
||||
JetNodeType LONG_STRING_TEMPLATE_ENTRY = new JetNodeType("LONG_STRING_TEMPLATE_ENTRY", JetBlockStringTemplateEntry.class);
|
||||
JetNodeType SHORT_STRING_TEMPLATE_ENTRY = new JetNodeType("SHORT_STRING_TEMPLATE_ENTRY", JetSimpleNameStringTemplateEntry.class);
|
||||
JetNodeType LITERAL_STRING_TEMPLATE_ENTRY = new JetNodeType("LITERAL_STRING_TEMPLATE_ENTRY", JetLiteralStringTemplateEntry.class);
|
||||
JetNodeType ESCAPE_STRING_TEMPLATE_ENTRY = new JetNodeType("ESCAPE_STRING_TEMPLATE_ENTRY", JetEscapeStringTemplateEntry.class);
|
||||
|
||||
JetNodeType PARENTHESIZED = new JetNodeType("PARENTHESIZED", JetParenthesizedExpression.class);
|
||||
JetNodeType RETURN = new JetNodeType("RETURN", JetReturnExpression.class);
|
||||
JetNodeType THROW = new JetNodeType("THROW", JetThrowExpression.class);
|
||||
JetNodeType CONTINUE = new JetNodeType("CONTINUE", JetContinueExpression.class);
|
||||
JetNodeType BREAK = new JetNodeType("BREAK", JetBreakExpression.class);
|
||||
JetNodeType IF = new JetNodeType("IF", JetIfExpression.class);
|
||||
JetNodeType CONDITION = new JetNodeType("CONDITION", JetContainerNode.class);
|
||||
JetNodeType THEN = new JetNodeType("THEN", JetContainerNode.class);
|
||||
JetNodeType ELSE = new JetNodeType("ELSE", JetContainerNode.class);
|
||||
JetNodeType TRY = new JetNodeType("TRY", JetTryExpression.class);
|
||||
JetNodeType CATCH = new JetNodeType("CATCH", JetCatchClause.class);
|
||||
JetNodeType FINALLY = new JetNodeType("FINALLY", JetFinallySection.class);
|
||||
JetNodeType FOR = new JetNodeType("FOR", JetForExpression.class);
|
||||
JetNodeType WHILE = new JetNodeType("WHILE", JetWhileExpression.class);
|
||||
JetNodeType DO_WHILE = new JetNodeType("DO_WHILE", JetDoWhileExpression.class);
|
||||
JetNodeType LOOP_RANGE = new JetNodeType("LOOP_RANGE", JetContainerNode.class);
|
||||
JetNodeType BODY = new JetNodeType("BODY", JetContainerNode.class);
|
||||
JetNodeType BLOCK = new JetNodeType("BLOCK", JetBlockExpression.class);
|
||||
JetNodeType FUNCTION_LITERAL_EXPRESSION = new JetNodeType("FUNCTION_LITERAL_EXPRESSION", JetFunctionLiteralExpression.class);
|
||||
JetNodeType FUNCTION_LITERAL = new JetNodeType("FUNCTION_LITERAL", JetFunctionLiteral.class);
|
||||
JetNodeType ANNOTATED_EXPRESSION = new JetNodeType("ANNOTATED_EXPRESSION", JetAnnotatedExpression.class);
|
||||
|
||||
IElementType REFERENCE_EXPRESSION = JetStubElementTypes.REFERENCE_EXPRESSION;
|
||||
IElementType ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = JetStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION;
|
||||
JetNodeType OPERATION_REFERENCE = new JetNodeType("OPERATION_REFERENCE", JetOperationReferenceExpression.class);
|
||||
JetNodeType LABEL = new JetNodeType("LABEL", JetLabelReferenceExpression.class);
|
||||
|
||||
JetNodeType LABEL_QUALIFIER = new JetNodeType("LABEL_QUALIFIER", JetContainerNode.class);
|
||||
|
||||
JetNodeType THIS_EXPRESSION = new JetNodeType("THIS_EXPRESSION", JetThisExpression.class);
|
||||
JetNodeType SUPER_EXPRESSION = new JetNodeType("SUPER_EXPRESSION", JetSuperExpression.class);
|
||||
JetNodeType BINARY_EXPRESSION = new JetNodeType("BINARY_EXPRESSION", JetBinaryExpression.class);
|
||||
JetNodeType BINARY_WITH_TYPE = new JetNodeType("BINARY_WITH_TYPE", JetBinaryExpressionWithTypeRHS.class);
|
||||
JetNodeType IS_EXPRESSION = new JetNodeType("IS_EXPRESSION", JetIsExpression.class); // TODO:
|
||||
JetNodeType PREFIX_EXPRESSION = new JetNodeType("PREFIX_EXPRESSION", JetPrefixExpression.class);
|
||||
JetNodeType POSTFIX_EXPRESSION = new JetNodeType("POSTFIX_EXPRESSION", JetPostfixExpression.class);
|
||||
JetNodeType LABELED_EXPRESSION = new JetNodeType("LABELED_EXPRESSION", JetLabeledExpression.class);
|
||||
JetNodeType CALL_EXPRESSION = new JetNodeType("CALL_EXPRESSION", JetCallExpression.class);
|
||||
JetNodeType ARRAY_ACCESS_EXPRESSION = new JetNodeType("ARRAY_ACCESS_EXPRESSION", JetArrayAccessExpression.class);
|
||||
JetNodeType INDICES = new JetNodeType("INDICES", JetContainerNode.class);
|
||||
IElementType DOT_QUALIFIED_EXPRESSION = JetStubElementTypes.DOT_QUALIFIED_EXPRESSION;
|
||||
JetNodeType CALLABLE_REFERENCE_EXPRESSION = new JetNodeType("CALLABLE_REFERENCE_EXPRESSION", JetCallableReferenceExpression.class);
|
||||
JetNodeType CLASS_LITERAL_EXPRESSION = new JetNodeType("CLASS_LITERAL_EXPRESSION", JetClassLiteralExpression.class);
|
||||
JetNodeType SAFE_ACCESS_EXPRESSION = new JetNodeType("SAFE_ACCESS_EXPRESSION", JetSafeQualifiedExpression.class);
|
||||
|
||||
JetNodeType OBJECT_LITERAL = new JetNodeType("OBJECT_LITERAL", JetObjectLiteralExpression.class);
|
||||
JetNodeType ROOT_PACKAGE = new JetNodeType("ROOT_PACKAGE", JetRootPackageExpression.class);
|
||||
|
||||
JetNodeType WHEN = new JetNodeType("WHEN", JetWhenExpression.class);
|
||||
JetNodeType WHEN_ENTRY = new JetNodeType("WHEN_ENTRY", JetWhenEntry.class);
|
||||
|
||||
JetNodeType WHEN_CONDITION_IN_RANGE = new JetNodeType("WHEN_CONDITION_IN_RANGE", JetWhenConditionInRange.class);
|
||||
JetNodeType WHEN_CONDITION_IS_PATTERN = new JetNodeType("WHEN_CONDITION_IS_PATTERN", JetWhenConditionIsPattern.class);
|
||||
JetNodeType WHEN_CONDITION_EXPRESSION = new JetNodeType("WHEN_CONDITION_WITH_EXPRESSION", JetWhenConditionWithExpression.class);
|
||||
|
||||
IElementType PACKAGE_DIRECTIVE = JetStubElementTypes.PACKAGE_DIRECTIVE;
|
||||
|
||||
// SCRIPT: script node type
|
||||
JetNodeType SCRIPT = new JetNodeType("SCRIPT", JetScript.class);
|
||||
|
||||
IFileElementType TYPE_CODE_FRAGMENT = new JetTypeCodeFragmentType();
|
||||
IFileElementType EXPRESSION_CODE_FRAGMENT = new JetExpressionCodeFragmentType();
|
||||
IFileElementType BLOCK_CODE_FRAGMENT = new JetBlockCodeFragmentType();
|
||||
}
|
||||
+8
-8
@@ -21,19 +21,19 @@ import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.JetElementImpl;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.psi.KtElementImpl;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class JetNodeType extends IElementType {
|
||||
private Constructor<? extends JetElement> myPsiFactory;
|
||||
public class KtNodeType extends IElementType {
|
||||
private Constructor<? extends KtElement> myPsiFactory;
|
||||
|
||||
public JetNodeType(@NotNull @NonNls String debugName) {
|
||||
public KtNodeType(@NotNull @NonNls String debugName) {
|
||||
this(debugName, null);
|
||||
}
|
||||
|
||||
public JetNodeType(@NotNull @NonNls String debugName, Class<? extends JetElement> psiClass) {
|
||||
public KtNodeType(@NotNull @NonNls String debugName, Class<? extends KtElement> psiClass) {
|
||||
super(debugName, KotlinLanguage.INSTANCE);
|
||||
try {
|
||||
myPsiFactory = psiClass != null ? psiClass.getConstructor(ASTNode.class) : null;
|
||||
@@ -42,12 +42,12 @@ public class JetNodeType extends IElementType {
|
||||
}
|
||||
}
|
||||
|
||||
public JetElement createPsi(ASTNode node) {
|
||||
public KtElement createPsi(ASTNode node) {
|
||||
assert node.getElementType() == this;
|
||||
|
||||
try {
|
||||
if (myPsiFactory == null) {
|
||||
return new JetElementImpl(node);
|
||||
return new KtElementImpl(node);
|
||||
}
|
||||
return myPsiFactory.newInstance(node);
|
||||
} catch (Exception e) {
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
|
||||
public interface KtNodeTypes {
|
||||
IFileElementType JET_FILE = new IFileElementType(KotlinLanguage.INSTANCE);
|
||||
|
||||
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);
|
||||
|
||||
KtNodeType TYPEDEF = new KtNodeType("TYPEDEF", KtTypedef.class);
|
||||
IElementType OBJECT_DECLARATION = KtStubElementTypes.OBJECT_DECLARATION;
|
||||
KtNodeType OBJECT_DECLARATION_NAME = new KtNodeType("OBJECT_DECLARATION_NAME", KtObjectDeclarationName.class);
|
||||
|
||||
IElementType ENUM_ENTRY = KtStubElementTypes.ENUM_ENTRY;
|
||||
IElementType ANONYMOUS_INITIALIZER = KtStubElementTypes.ANONYMOUS_INITIALIZER;
|
||||
IElementType SECONDARY_CONSTRUCTOR = KtStubElementTypes.SECONDARY_CONSTRUCTOR;
|
||||
IElementType PRIMARY_CONSTRUCTOR = KtStubElementTypes.PRIMARY_CONSTRUCTOR;
|
||||
|
||||
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;
|
||||
KtNodeType PROPERTY_DELEGATE = new KtNodeType("PROPERTY_DELEGATE", KtPropertyDelegate.class);
|
||||
IElementType CONSTRUCTOR_CALLEE = KtStubElementTypes.CONSTRUCTOR_CALLEE;
|
||||
IElementType VALUE_PARAMETER_LIST = KtStubElementTypes.VALUE_PARAMETER_LIST;
|
||||
IElementType VALUE_PARAMETER = KtStubElementTypes.VALUE_PARAMETER;
|
||||
|
||||
IElementType CLASS_BODY = KtStubElementTypes.CLASS_BODY;
|
||||
IElementType IMPORT_LIST = KtStubElementTypes.IMPORT_LIST;
|
||||
IElementType FILE_ANNOTATION_LIST = KtStubElementTypes.FILE_ANNOTATION_LIST;
|
||||
IElementType IMPORT_DIRECTIVE = KtStubElementTypes.IMPORT_DIRECTIVE;
|
||||
IElementType MODIFIER_LIST = KtStubElementTypes.MODIFIER_LIST;
|
||||
IElementType ANNOTATION = KtStubElementTypes.ANNOTATION;
|
||||
IElementType ANNOTATION_ENTRY = KtStubElementTypes.ANNOTATION_ENTRY;
|
||||
IElementType ANNOTATION_TARGET = KtStubElementTypes.ANNOTATION_TARGET;
|
||||
|
||||
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 VALUE_ARGUMENT_NAME = new KtNodeType("VALUE_ARGUMENT_NAME", KtValueArgumentName.class);
|
||||
IElementType TYPE_REFERENCE = KtStubElementTypes.TYPE_REFERENCE;
|
||||
|
||||
IElementType USER_TYPE = KtStubElementTypes.USER_TYPE;
|
||||
IElementType DYNAMIC_TYPE = KtStubElementTypes.DYNAMIC_TYPE;
|
||||
IElementType FUNCTION_TYPE = KtStubElementTypes.FUNCTION_TYPE;
|
||||
IElementType FUNCTION_TYPE_RECEIVER = KtStubElementTypes.FUNCTION_TYPE_RECEIVER;
|
||||
KtNodeType SELF_TYPE = new KtNodeType("SELF_TYPE", KtSelfType.class);
|
||||
IElementType NULLABLE_TYPE = KtStubElementTypes.NULLABLE_TYPE;
|
||||
IElementType TYPE_PROJECTION = KtStubElementTypes.TYPE_PROJECTION;
|
||||
|
||||
// TODO: review
|
||||
IElementType PROPERTY_ACCESSOR = KtStubElementTypes.PROPERTY_ACCESSOR;
|
||||
IElementType INITIALIZER_LIST = KtStubElementTypes.INITIALIZER_LIST;
|
||||
IElementType TYPE_CONSTRAINT_LIST = KtStubElementTypes.TYPE_CONSTRAINT_LIST;
|
||||
IElementType TYPE_CONSTRAINT = KtStubElementTypes.TYPE_CONSTRAINT;
|
||||
|
||||
IElementType CONSTRUCTOR_DELEGATION_CALL = new KtNodeType("CONSTRUCTOR_DELEGATION_CALL", KtConstructorDelegationCall.class);
|
||||
KtNodeType CONSTRUCTOR_DELEGATION_REFERENCE =
|
||||
new KtNodeType("CONSTRUCTOR_DELEGATION_REFERENCE", KtConstructorDelegationReferenceExpression.class);
|
||||
|
||||
// TODO: Not sure if we need separate NT for each kind of constants
|
||||
KtNodeType NULL = new KtNodeType("NULL", KtConstantExpression.class);
|
||||
KtNodeType BOOLEAN_CONSTANT = new KtNodeType("BOOLEAN_CONSTANT", KtConstantExpression.class);
|
||||
KtNodeType FLOAT_CONSTANT = new KtNodeType("FLOAT_CONSTANT", KtConstantExpression.class);
|
||||
KtNodeType CHARACTER_CONSTANT = new KtNodeType("CHARACTER_CONSTANT", KtConstantExpression.class);
|
||||
KtNodeType INTEGER_CONSTANT = new KtNodeType("INTEGER_CONSTANT", KtConstantExpression.class);
|
||||
|
||||
KtNodeType STRING_TEMPLATE = new KtNodeType("STRING_TEMPLATE", KtStringTemplateExpression.class);
|
||||
KtNodeType LONG_STRING_TEMPLATE_ENTRY = new KtNodeType("LONG_STRING_TEMPLATE_ENTRY", KtBlockStringTemplateEntry.class);
|
||||
KtNodeType SHORT_STRING_TEMPLATE_ENTRY = new KtNodeType("SHORT_STRING_TEMPLATE_ENTRY", KtSimpleNameStringTemplateEntry.class);
|
||||
KtNodeType LITERAL_STRING_TEMPLATE_ENTRY = new KtNodeType("LITERAL_STRING_TEMPLATE_ENTRY", KtLiteralStringTemplateEntry.class);
|
||||
KtNodeType ESCAPE_STRING_TEMPLATE_ENTRY = new KtNodeType("ESCAPE_STRING_TEMPLATE_ENTRY", KtEscapeStringTemplateEntry.class);
|
||||
|
||||
KtNodeType PARENTHESIZED = new KtNodeType("PARENTHESIZED", KtParenthesizedExpression.class);
|
||||
KtNodeType RETURN = new KtNodeType("RETURN", KtReturnExpression.class);
|
||||
KtNodeType THROW = new KtNodeType("THROW", KtThrowExpression.class);
|
||||
KtNodeType CONTINUE = new KtNodeType("CONTINUE", KtContinueExpression.class);
|
||||
KtNodeType BREAK = new KtNodeType("BREAK", KtBreakExpression.class);
|
||||
KtNodeType IF = new KtNodeType("IF", KtIfExpression.class);
|
||||
KtNodeType CONDITION = new KtNodeType("CONDITION", KtContainerNode.class);
|
||||
KtNodeType THEN = new KtNodeType("THEN", KtContainerNode.class);
|
||||
KtNodeType ELSE = new KtNodeType("ELSE", KtContainerNode.class);
|
||||
KtNodeType TRY = new KtNodeType("TRY", KtTryExpression.class);
|
||||
KtNodeType CATCH = new KtNodeType("CATCH", KtCatchClause.class);
|
||||
KtNodeType FINALLY = new KtNodeType("FINALLY", KtFinallySection.class);
|
||||
KtNodeType FOR = new KtNodeType("FOR", KtForExpression.class);
|
||||
KtNodeType WHILE = new KtNodeType("WHILE", KtWhileExpression.class);
|
||||
KtNodeType DO_WHILE = new KtNodeType("DO_WHILE", KtDoWhileExpression.class);
|
||||
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 FUNCTION_LITERAL = new KtNodeType("FUNCTION_LITERAL", KtFunctionLiteral.class);
|
||||
KtNodeType ANNOTATED_EXPRESSION = new KtNodeType("ANNOTATED_EXPRESSION", KtAnnotatedExpression.class);
|
||||
|
||||
IElementType REFERENCE_EXPRESSION = KtStubElementTypes.REFERENCE_EXPRESSION;
|
||||
IElementType ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = KtStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION;
|
||||
KtNodeType OPERATION_REFERENCE = new KtNodeType("OPERATION_REFERENCE", KtOperationReferenceExpression.class);
|
||||
KtNodeType LABEL = new KtNodeType("LABEL", KtLabelReferenceExpression.class);
|
||||
|
||||
KtNodeType LABEL_QUALIFIER = new KtNodeType("LABEL_QUALIFIER", KtContainerNode.class);
|
||||
|
||||
KtNodeType THIS_EXPRESSION = new KtNodeType("THIS_EXPRESSION", KtThisExpression.class);
|
||||
KtNodeType SUPER_EXPRESSION = new KtNodeType("SUPER_EXPRESSION", KtSuperExpression.class);
|
||||
KtNodeType BINARY_EXPRESSION = new KtNodeType("BINARY_EXPRESSION", KtBinaryExpression.class);
|
||||
KtNodeType BINARY_WITH_TYPE = new KtNodeType("BINARY_WITH_TYPE", KtBinaryExpressionWithTypeRHS.class);
|
||||
KtNodeType IS_EXPRESSION = new KtNodeType("IS_EXPRESSION", KtIsExpression.class); // TODO:
|
||||
KtNodeType PREFIX_EXPRESSION = new KtNodeType("PREFIX_EXPRESSION", KtPrefixExpression.class);
|
||||
KtNodeType POSTFIX_EXPRESSION = new KtNodeType("POSTFIX_EXPRESSION", KtPostfixExpression.class);
|
||||
KtNodeType LABELED_EXPRESSION = new KtNodeType("LABELED_EXPRESSION", KtLabeledExpression.class);
|
||||
KtNodeType CALL_EXPRESSION = new KtNodeType("CALL_EXPRESSION", KtCallExpression.class);
|
||||
KtNodeType ARRAY_ACCESS_EXPRESSION = new KtNodeType("ARRAY_ACCESS_EXPRESSION", KtArrayAccessExpression.class);
|
||||
KtNodeType INDICES = new KtNodeType("INDICES", KtContainerNode.class);
|
||||
IElementType DOT_QUALIFIED_EXPRESSION = KtStubElementTypes.DOT_QUALIFIED_EXPRESSION;
|
||||
KtNodeType CALLABLE_REFERENCE_EXPRESSION = new KtNodeType("CALLABLE_REFERENCE_EXPRESSION", KtCallableReferenceExpression.class);
|
||||
KtNodeType CLASS_LITERAL_EXPRESSION = new KtNodeType("CLASS_LITERAL_EXPRESSION", KtClassLiteralExpression.class);
|
||||
KtNodeType SAFE_ACCESS_EXPRESSION = new KtNodeType("SAFE_ACCESS_EXPRESSION", KtSafeQualifiedExpression.class);
|
||||
|
||||
KtNodeType OBJECT_LITERAL = new KtNodeType("OBJECT_LITERAL", KtObjectLiteralExpression.class);
|
||||
KtNodeType ROOT_PACKAGE = new KtNodeType("ROOT_PACKAGE", KtRootPackageExpression.class);
|
||||
|
||||
KtNodeType WHEN = new KtNodeType("WHEN", KtWhenExpression.class);
|
||||
KtNodeType WHEN_ENTRY = new KtNodeType("WHEN_ENTRY", KtWhenEntry.class);
|
||||
|
||||
KtNodeType WHEN_CONDITION_IN_RANGE = new KtNodeType("WHEN_CONDITION_IN_RANGE", KtWhenConditionInRange.class);
|
||||
KtNodeType WHEN_CONDITION_IS_PATTERN = new KtNodeType("WHEN_CONDITION_IS_PATTERN", KtWhenConditionIsPattern.class);
|
||||
KtNodeType WHEN_CONDITION_EXPRESSION = new KtNodeType("WHEN_CONDITION_WITH_EXPRESSION", KtWhenConditionWithExpression.class);
|
||||
|
||||
IElementType PACKAGE_DIRECTIVE = KtStubElementTypes.PACKAGE_DIRECTIVE;
|
||||
|
||||
// SCRIPT: script node type
|
||||
KtNodeType SCRIPT = new KtNodeType("SCRIPT", KtScript.class);
|
||||
|
||||
IFileElementType TYPE_CODE_FRAGMENT = new KtTypeCodeFragmentType();
|
||||
IFileElementType EXPRESSION_CODE_FRAGMENT = new KtExpressionCodeFragmentType();
|
||||
IFileElementType BLOCK_CODE_FRAGMENT = new KtBlockCodeFragmentType();
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.descriptors.impl.LazyModuleDependencies
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.TargetEnvironment
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.createModule
|
||||
@@ -92,7 +92,7 @@ public class ResolverForProjectImpl<M : ModuleInfo>(
|
||||
}
|
||||
|
||||
public data class ModuleContent(
|
||||
public val syntheticFiles: Collection<JetFile>,
|
||||
public val syntheticFiles: Collection<KtFile>,
|
||||
public val moduleContentScope: GlobalSearchScope
|
||||
)
|
||||
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
package org.jetbrains.kotlin.cfg;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class BreakableBlockInfo extends BlockInfo {
|
||||
private final JetElement element;
|
||||
private final KtElement element;
|
||||
private final Label entryPoint;
|
||||
private final Label exitPoint;
|
||||
private final Set<Label> referablePoints = Sets.newHashSet();
|
||||
|
||||
public BreakableBlockInfo(JetElement element, Label entryPoint, Label exitPoint) {
|
||||
public BreakableBlockInfo(KtElement element, Label entryPoint, Label exitPoint) {
|
||||
this.element = element;
|
||||
this.entryPoint = entryPoint;
|
||||
this.exitPoint = exitPoint;
|
||||
@@ -39,7 +39,7 @@ public class BreakableBlockInfo extends BlockInfo {
|
||||
Collections.addAll(referablePoints, labels);
|
||||
}
|
||||
|
||||
public JetElement getElement() {
|
||||
public KtElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,32 +32,32 @@ import java.util.Map;
|
||||
|
||||
public interface JetControlFlowBuilder {
|
||||
// Subroutines
|
||||
void enterSubroutine(@NotNull JetElement subroutine);
|
||||
void enterSubroutine(@NotNull KtElement subroutine);
|
||||
|
||||
@NotNull
|
||||
Pseudocode exitSubroutine(@NotNull JetElement subroutine);
|
||||
Pseudocode exitSubroutine(@NotNull KtElement subroutine);
|
||||
|
||||
@NotNull
|
||||
JetElement getCurrentSubroutine();
|
||||
KtElement getCurrentSubroutine();
|
||||
@Nullable
|
||||
JetElement getReturnSubroutine();
|
||||
KtElement getReturnSubroutine();
|
||||
|
||||
// Lexical scopes
|
||||
void enterLexicalScope(@NotNull JetElement element);
|
||||
void exitLexicalScope(@NotNull JetElement element);
|
||||
void enterLexicalScope(@NotNull KtElement element);
|
||||
void exitLexicalScope(@NotNull KtElement element);
|
||||
|
||||
// Entry/exit points
|
||||
@NotNull
|
||||
Label getEntryPoint(@NotNull JetElement labelElement);
|
||||
Label getEntryPoint(@NotNull KtElement labelElement);
|
||||
@NotNull
|
||||
Label getExitPoint(@NotNull JetElement labelElement);
|
||||
Label getExitPoint(@NotNull KtElement labelElement);
|
||||
@NotNull
|
||||
Label getConditionEntryPoint(@NotNull JetElement labelElement);
|
||||
Label getConditionEntryPoint(@NotNull KtElement labelElement);
|
||||
|
||||
// Declarations
|
||||
void declareParameter(@NotNull JetParameter parameter);
|
||||
void declareVariable(@NotNull JetVariableDeclaration property);
|
||||
void declareFunction(@NotNull JetElement subroutine, @NotNull Pseudocode pseudocode);
|
||||
void declareParameter(@NotNull KtParameter parameter);
|
||||
void declareVariable(@NotNull KtVariableDeclaration property);
|
||||
void declareFunction(@NotNull KtElement subroutine, @NotNull Pseudocode pseudocode);
|
||||
|
||||
// Labels
|
||||
@NotNull
|
||||
@@ -68,25 +68,25 @@ public interface JetControlFlowBuilder {
|
||||
void bindLabel(@NotNull Label label);
|
||||
|
||||
// Jumps
|
||||
void jump(@NotNull Label label, @NotNull JetElement element);
|
||||
void jumpOnFalse(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue conditionValue);
|
||||
void jumpOnTrue(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue conditionValue);
|
||||
void nondeterministicJump(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue inputValue); // Maybe, jump to label
|
||||
void nondeterministicJump(@NotNull List<Label> label, @NotNull JetElement element);
|
||||
void jumpToError(@NotNull JetElement element);
|
||||
void jump(@NotNull Label label, @NotNull KtElement element);
|
||||
void jumpOnFalse(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue conditionValue);
|
||||
void jumpOnTrue(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue conditionValue);
|
||||
void nondeterministicJump(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue inputValue); // Maybe, jump to label
|
||||
void nondeterministicJump(@NotNull List<Label> label, @NotNull KtElement element);
|
||||
void jumpToError(@NotNull KtElement element);
|
||||
|
||||
void returnValue(@NotNull JetExpression returnExpression, @NotNull PseudoValue returnValue, @NotNull JetElement subroutine);
|
||||
void returnNoValue(@NotNull JetReturnExpression returnExpression, @NotNull JetElement subroutine);
|
||||
void returnValue(@NotNull KtExpression returnExpression, @NotNull PseudoValue returnValue, @NotNull KtElement subroutine);
|
||||
void returnNoValue(@NotNull KtReturnExpression returnExpression, @NotNull KtElement subroutine);
|
||||
|
||||
void throwException(@NotNull JetThrowExpression throwExpression, @NotNull PseudoValue thrownValue);
|
||||
void throwException(@NotNull KtThrowExpression throwExpression, @NotNull PseudoValue thrownValue);
|
||||
|
||||
// Loops
|
||||
@NotNull
|
||||
LoopInfo enterLoop(@NotNull JetLoopExpression expression);
|
||||
void enterLoopBody(@NotNull JetLoopExpression expression);
|
||||
void exitLoopBody(@NotNull JetLoopExpression expression);
|
||||
LoopInfo enterLoop(@NotNull KtLoopExpression expression);
|
||||
void enterLoopBody(@NotNull KtLoopExpression expression);
|
||||
void exitLoopBody(@NotNull KtLoopExpression expression);
|
||||
@Nullable
|
||||
JetLoopExpression getCurrentLoop();
|
||||
KtLoopExpression getCurrentLoop();
|
||||
|
||||
// Try-Finally
|
||||
void enterTryFinally(@NotNull GenerationTrigger trigger);
|
||||
@@ -95,49 +95,49 @@ public interface JetControlFlowBuilder {
|
||||
void repeatPseudocode(@NotNull Label startLabel, @NotNull Label finishLabel);
|
||||
|
||||
// Reading values
|
||||
void mark(@NotNull JetElement element);
|
||||
void mark(@NotNull KtElement element);
|
||||
|
||||
@Nullable
|
||||
PseudoValue getBoundValue(@Nullable JetElement element);
|
||||
void bindValue(@NotNull PseudoValue value, @NotNull JetElement element);
|
||||
PseudoValue getBoundValue(@Nullable KtElement element);
|
||||
void bindValue(@NotNull PseudoValue value, @NotNull KtElement element);
|
||||
@NotNull
|
||||
PseudoValue newValue(@Nullable JetElement element);
|
||||
PseudoValue newValue(@Nullable KtElement element);
|
||||
|
||||
void loadUnit(@NotNull JetExpression expression);
|
||||
void loadUnit(@NotNull KtExpression expression);
|
||||
|
||||
@NotNull
|
||||
InstructionWithValue loadConstant(@NotNull JetExpression expression, @Nullable CompileTimeConstant<?> constant);
|
||||
InstructionWithValue loadConstant(@NotNull KtExpression expression, @Nullable CompileTimeConstant<?> constant);
|
||||
@NotNull
|
||||
InstructionWithValue createAnonymousObject(@NotNull JetObjectLiteralExpression expression);
|
||||
InstructionWithValue createAnonymousObject(@NotNull KtObjectLiteralExpression expression);
|
||||
@NotNull
|
||||
InstructionWithValue createLambda(@NotNull JetFunction expression);
|
||||
InstructionWithValue createLambda(@NotNull KtFunction expression);
|
||||
@NotNull
|
||||
InstructionWithValue loadStringTemplate(@NotNull JetStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues);
|
||||
InstructionWithValue loadStringTemplate(@NotNull KtStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues);
|
||||
|
||||
@NotNull
|
||||
MagicInstruction magic(
|
||||
@NotNull JetElement instructionElement,
|
||||
@Nullable JetElement valueElement,
|
||||
@NotNull KtElement instructionElement,
|
||||
@Nullable KtElement valueElement,
|
||||
@NotNull List<PseudoValue> inputValues,
|
||||
@NotNull MagicKind kind
|
||||
);
|
||||
|
||||
@NotNull
|
||||
MergeInstruction merge(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull List<PseudoValue> inputValues
|
||||
);
|
||||
|
||||
@NotNull
|
||||
ReadValueInstruction readVariable(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues
|
||||
);
|
||||
|
||||
@NotNull
|
||||
CallInstruction call(
|
||||
@NotNull JetElement valueElement,
|
||||
@NotNull KtElement valueElement,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
||||
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
||||
@@ -150,14 +150,14 @@ public interface JetControlFlowBuilder {
|
||||
}
|
||||
@NotNull
|
||||
OperationInstruction predefinedOperation(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull PredefinedOperation operation,
|
||||
@NotNull List<PseudoValue> inputValues
|
||||
);
|
||||
|
||||
void write(
|
||||
@NotNull JetElement assignment,
|
||||
@NotNull JetElement lValue,
|
||||
@NotNull KtElement assignment,
|
||||
@NotNull KtElement lValue,
|
||||
@NotNull PseudoValue rValue,
|
||||
@NotNull AccessTarget target,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues);
|
||||
|
||||
@@ -36,39 +36,39 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
protected abstract JetControlFlowBuilder getDelegateBuilder();
|
||||
|
||||
@Override
|
||||
public void loadUnit(@NotNull JetExpression expression) {
|
||||
public void loadUnit(@NotNull KtExpression expression) {
|
||||
getDelegateBuilder().loadUnit(expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue loadConstant(@NotNull JetExpression expression, @Nullable CompileTimeConstant<?> constant) {
|
||||
public InstructionWithValue loadConstant(@NotNull KtExpression expression, @Nullable CompileTimeConstant<?> constant) {
|
||||
return getDelegateBuilder().loadConstant(expression, constant);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue createAnonymousObject(@NotNull JetObjectLiteralExpression expression) {
|
||||
public InstructionWithValue createAnonymousObject(@NotNull KtObjectLiteralExpression expression) {
|
||||
return getDelegateBuilder().createAnonymousObject(expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue createLambda(@NotNull JetFunction expression) {
|
||||
public InstructionWithValue createLambda(@NotNull KtFunction expression) {
|
||||
return getDelegateBuilder().createLambda(expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue loadStringTemplate(@NotNull JetStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
public InstructionWithValue loadStringTemplate(@NotNull KtStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
return getDelegateBuilder().loadStringTemplate(expression, inputValues);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MagicInstruction magic(
|
||||
@NotNull JetElement instructionElement,
|
||||
@Nullable JetElement valueElement,
|
||||
@NotNull KtElement instructionElement,
|
||||
@Nullable KtElement valueElement,
|
||||
@NotNull List<PseudoValue> inputValues,
|
||||
@NotNull MagicKind kind
|
||||
) {
|
||||
@@ -77,14 +77,14 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MergeInstruction merge(@NotNull JetExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
public MergeInstruction merge(@NotNull KtExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
return getDelegateBuilder().merge(expression, inputValues);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReadValueInstruction readVariable(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues
|
||||
) {
|
||||
@@ -94,7 +94,7 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
@NotNull
|
||||
@Override
|
||||
public CallInstruction call(
|
||||
@NotNull JetElement valueElement,
|
||||
@NotNull KtElement valueElement,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
||||
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
||||
@@ -105,7 +105,7 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
@NotNull
|
||||
@Override
|
||||
public OperationInstruction predefinedOperation(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull PredefinedOperation operation,
|
||||
@NotNull List<PseudoValue> inputValues
|
||||
) {
|
||||
@@ -130,77 +130,77 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jump(@NotNull Label label, @NotNull JetElement element) {
|
||||
public void jump(@NotNull Label label, @NotNull KtElement element) {
|
||||
getDelegateBuilder().jump(label, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpOnFalse(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue conditionValue) {
|
||||
public void jumpOnFalse(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue conditionValue) {
|
||||
getDelegateBuilder().jumpOnFalse(label, element, conditionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpOnTrue(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue conditionValue) {
|
||||
public void jumpOnTrue(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue conditionValue) {
|
||||
getDelegateBuilder().jumpOnTrue(label, element, conditionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nondeterministicJump(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue inputValue) {
|
||||
public void nondeterministicJump(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue inputValue) {
|
||||
getDelegateBuilder().nondeterministicJump(label, element, inputValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nondeterministicJump(@NotNull List<Label> labels, @NotNull JetElement element) {
|
||||
public void nondeterministicJump(@NotNull List<Label> labels, @NotNull KtElement element) {
|
||||
getDelegateBuilder().nondeterministicJump(labels, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetElement element) {
|
||||
public void jumpToError(@NotNull KtElement element) {
|
||||
getDelegateBuilder().jumpToError(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void throwException(@NotNull JetThrowExpression throwExpression, @NotNull PseudoValue thrownValue) {
|
||||
public void throwException(@NotNull KtThrowExpression throwExpression, @NotNull PseudoValue thrownValue) {
|
||||
getDelegateBuilder().throwException(throwExpression, thrownValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
||||
public Label getEntryPoint(@NotNull KtElement labelElement) {
|
||||
return getDelegateBuilder().getEntryPoint(labelElement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Label getExitPoint(@NotNull JetElement labelElement) {
|
||||
public Label getExitPoint(@NotNull KtElement labelElement) {
|
||||
return getDelegateBuilder().getExitPoint(labelElement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Label getConditionEntryPoint(@NotNull JetElement labelElement) {
|
||||
public Label getConditionEntryPoint(@NotNull KtElement labelElement) {
|
||||
return getDelegateBuilder().getConditionEntryPoint(labelElement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LoopInfo enterLoop(@NotNull JetLoopExpression expression) {
|
||||
public LoopInfo enterLoop(@NotNull KtLoopExpression expression) {
|
||||
return getDelegateBuilder().enterLoop(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLoopBody(@NotNull JetLoopExpression expression) {
|
||||
public void enterLoopBody(@NotNull KtLoopExpression expression) {
|
||||
getDelegateBuilder().enterLoopBody(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitLoopBody(@NotNull JetLoopExpression expression) {
|
||||
public void exitLoopBody(@NotNull KtLoopExpression expression) {
|
||||
getDelegateBuilder().exitLoopBody(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetLoopExpression getCurrentLoop() {
|
||||
public KtLoopExpression getCurrentLoop() {
|
||||
return getDelegateBuilder().getCurrentLoop();
|
||||
}
|
||||
|
||||
@@ -215,42 +215,42 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterSubroutine(@NotNull JetElement subroutine) {
|
||||
public void enterSubroutine(@NotNull KtElement subroutine) {
|
||||
getDelegateBuilder().enterSubroutine(subroutine);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||
public Pseudocode exitSubroutine(@NotNull KtElement subroutine) {
|
||||
return getDelegateBuilder().exitSubroutine(subroutine);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetElement getCurrentSubroutine() {
|
||||
public KtElement getCurrentSubroutine() {
|
||||
return getDelegateBuilder().getCurrentSubroutine();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetElement getReturnSubroutine() {
|
||||
public KtElement getReturnSubroutine() {
|
||||
return getDelegateBuilder().getReturnSubroutine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnValue(@NotNull JetExpression returnExpression, @NotNull PseudoValue returnValue, @NotNull JetElement subroutine) {
|
||||
public void returnValue(@NotNull KtExpression returnExpression, @NotNull PseudoValue returnValue, @NotNull KtElement subroutine) {
|
||||
getDelegateBuilder().returnValue(returnExpression, returnValue, subroutine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnNoValue(@NotNull JetReturnExpression returnExpression, @NotNull JetElement subroutine) {
|
||||
public void returnNoValue(@NotNull KtReturnExpression returnExpression, @NotNull KtElement subroutine) {
|
||||
getDelegateBuilder().returnNoValue(returnExpression, subroutine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(
|
||||
@NotNull JetElement assignment,
|
||||
@NotNull JetElement lValue,
|
||||
@NotNull KtElement assignment,
|
||||
@NotNull KtElement lValue,
|
||||
@NotNull PseudoValue rValue,
|
||||
@NotNull AccessTarget target,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues) {
|
||||
@@ -258,17 +258,17 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareParameter(@NotNull JetParameter parameter) {
|
||||
public void declareParameter(@NotNull KtParameter parameter) {
|
||||
getDelegateBuilder().declareParameter(parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareVariable(@NotNull JetVariableDeclaration property) {
|
||||
public void declareVariable(@NotNull KtVariableDeclaration property) {
|
||||
getDelegateBuilder().declareVariable(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareFunction(@NotNull JetElement subroutine, @NotNull Pseudocode pseudocode) {
|
||||
public void declareFunction(@NotNull KtElement subroutine, @NotNull Pseudocode pseudocode) {
|
||||
getDelegateBuilder().declareFunction(subroutine, pseudocode);
|
||||
}
|
||||
|
||||
@@ -278,34 +278,34 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(@NotNull JetElement element) {
|
||||
public void mark(@NotNull KtElement element) {
|
||||
getDelegateBuilder().mark(element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PseudoValue getBoundValue(@Nullable JetElement element) {
|
||||
public PseudoValue getBoundValue(@Nullable KtElement element) {
|
||||
return getDelegateBuilder().getBoundValue(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindValue(@NotNull PseudoValue value, @NotNull JetElement element) {
|
||||
public void bindValue(@NotNull PseudoValue value, @NotNull KtElement element) {
|
||||
getDelegateBuilder().bindValue(value, element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PseudoValue newValue(@Nullable JetElement element) {
|
||||
public PseudoValue newValue(@Nullable KtElement element) {
|
||||
return getDelegateBuilder().newValue(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLexicalScope(@NotNull JetElement element) {
|
||||
public void enterLexicalScope(@NotNull KtElement element) {
|
||||
getDelegateBuilder().enterLexicalScope(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitLexicalScope(@NotNull JetElement element) {
|
||||
public void exitLexicalScope(@NotNull KtElement element) {
|
||||
getDelegateBuilder().exitLexicalScope(element);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,7 +52,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||
@@ -60,7 +60,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
|
||||
|
||||
import java.util.*;
|
||||
@@ -76,13 +76,13 @@ import static org.jetbrains.kotlin.types.TypeUtils.noExpectedType;
|
||||
|
||||
public class JetFlowInformationProvider {
|
||||
|
||||
private final JetElement subroutine;
|
||||
private final KtElement subroutine;
|
||||
private final Pseudocode pseudocode;
|
||||
private final BindingTrace trace;
|
||||
private PseudocodeVariablesData pseudocodeVariablesData;
|
||||
|
||||
private JetFlowInformationProvider(
|
||||
@NotNull JetElement declaration,
|
||||
@NotNull KtElement declaration,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull Pseudocode pseudocode
|
||||
) {
|
||||
@@ -92,7 +92,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
|
||||
public JetFlowInformationProvider(
|
||||
@NotNull JetElement declaration,
|
||||
@NotNull KtElement declaration,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
this(declaration, trace, new JetControlFlowProcessor(trace).generatePseudocode(declaration));
|
||||
@@ -129,18 +129,18 @@ public class JetFlowInformationProvider {
|
||||
markWhenWithoutElse();
|
||||
}
|
||||
|
||||
public void checkFunction(@Nullable JetType expectedReturnType) {
|
||||
public void checkFunction(@Nullable KtType expectedReturnType) {
|
||||
UnreachableCode unreachableCode = collectUnreachableCode();
|
||||
reportUnreachableCode(unreachableCode);
|
||||
|
||||
if (subroutine instanceof JetFunctionLiteral) return;
|
||||
if (subroutine instanceof KtFunctionLiteral) return;
|
||||
|
||||
checkDefiniteReturn(expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE, unreachableCode);
|
||||
|
||||
markTailCalls();
|
||||
}
|
||||
|
||||
private void collectReturnExpressions(@NotNull final Collection<JetElement> returnedExpressions) {
|
||||
private void collectReturnExpressions(@NotNull final Collection<KtElement> returnedExpressions) {
|
||||
final Set<Instruction> instructions = Sets.newHashSet(pseudocode.getInstructions());
|
||||
SubroutineExitInstruction exitInstruction = pseudocode.getExitInstruction();
|
||||
for (Instruction previousInstruction : exitInstruction.getPreviousInstructions()) {
|
||||
@@ -202,13 +202,13 @@ public class JetFlowInformationProvider {
|
||||
|
||||
private void checkLocalFunctions() {
|
||||
for (LocalFunctionDeclarationInstruction localDeclarationInstruction : pseudocode.getLocalDeclarations()) {
|
||||
JetElement element = localDeclarationInstruction.getElement();
|
||||
if (element instanceof JetDeclarationWithBody) {
|
||||
JetDeclarationWithBody localDeclaration = (JetDeclarationWithBody) element;
|
||||
KtElement element = localDeclarationInstruction.getElement();
|
||||
if (element instanceof KtDeclarationWithBody) {
|
||||
KtDeclarationWithBody localDeclaration = (KtDeclarationWithBody) element;
|
||||
|
||||
CallableDescriptor functionDescriptor =
|
||||
(CallableDescriptor) trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, localDeclaration);
|
||||
JetType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
|
||||
KtType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
|
||||
|
||||
JetFlowInformationProvider providerForLocalDeclaration =
|
||||
new JetFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody());
|
||||
@@ -218,30 +218,30 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDefiniteReturn(final @NotNull JetType expectedReturnType, @NotNull final UnreachableCode unreachableCode) {
|
||||
assert subroutine instanceof JetDeclarationWithBody;
|
||||
JetDeclarationWithBody function = (JetDeclarationWithBody) subroutine;
|
||||
public void checkDefiniteReturn(final @NotNull KtType expectedReturnType, @NotNull final UnreachableCode unreachableCode) {
|
||||
assert subroutine instanceof KtDeclarationWithBody;
|
||||
KtDeclarationWithBody function = (KtDeclarationWithBody) subroutine;
|
||||
|
||||
if (!function.hasBody()) return;
|
||||
|
||||
List<JetElement> returnedExpressions = Lists.newArrayList();
|
||||
List<KtElement> returnedExpressions = Lists.newArrayList();
|
||||
collectReturnExpressions(returnedExpressions);
|
||||
|
||||
final boolean blockBody = function.hasBlockBody();
|
||||
|
||||
final boolean[] noReturnError = new boolean[] { false };
|
||||
for (JetElement returnedExpression : returnedExpressions) {
|
||||
returnedExpression.accept(new JetVisitorVoid() {
|
||||
for (KtElement returnedExpression : returnedExpressions) {
|
||||
returnedExpression.accept(new KtVisitorVoid() {
|
||||
@Override
|
||||
public void visitReturnExpression(@NotNull JetReturnExpression expression) {
|
||||
public void visitReturnExpression(@NotNull KtReturnExpression expression) {
|
||||
if (!blockBody) {
|
||||
trace.report(RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY.on(expression));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJetElement(@NotNull JetElement element) {
|
||||
if (!(element instanceof JetExpression || element instanceof JetWhenCondition)) return;
|
||||
public void visitJetElement(@NotNull KtElement element) {
|
||||
if (!(element instanceof KtExpression || element instanceof KtWhenCondition)) return;
|
||||
|
||||
if (blockBody && !noExpectedType(expectedReturnType)
|
||||
&& !KotlinBuiltIns.isUnit(expectedReturnType)
|
||||
@@ -257,7 +257,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
|
||||
private void reportUnreachableCode(@NotNull UnreachableCode unreachableCode) {
|
||||
for (JetElement element : unreachableCode.getElements()) {
|
||||
for (KtElement element : unreachableCode.getElements()) {
|
||||
trace.report(UNREACHABLE_CODE.on(element, unreachableCode.getUnreachableTextRanges(element)));
|
||||
trace.record(BindingContext.UNREACHABLE_CODE, element, true);
|
||||
}
|
||||
@@ -265,21 +265,21 @@ public class JetFlowInformationProvider {
|
||||
|
||||
@NotNull
|
||||
private UnreachableCode collectUnreachableCode() {
|
||||
Set<JetElement> reachableElements = Sets.newHashSet();
|
||||
Set<JetElement> unreachableElements = Sets.newHashSet();
|
||||
Set<KtElement> reachableElements = Sets.newHashSet();
|
||||
Set<KtElement> unreachableElements = Sets.newHashSet();
|
||||
for (Instruction instruction : pseudocode.getInstructionsIncludingDeadCode()) {
|
||||
if (!(instruction instanceof JetElementInstruction)
|
||||
|| instruction instanceof LoadUnitValueInstruction
|
||||
|| instruction instanceof MergeInstruction
|
||||
|| (instruction instanceof MagicInstruction && ((MagicInstruction) instruction).getSynthetic())) continue;
|
||||
|
||||
JetElement element = ((JetElementInstruction) instruction).getElement();
|
||||
KtElement element = ((JetElementInstruction) instruction).getElement();
|
||||
|
||||
if (instruction instanceof JumpInstruction) {
|
||||
boolean isJumpElement = element instanceof JetBreakExpression
|
||||
|| element instanceof JetContinueExpression
|
||||
|| element instanceof JetReturnExpression
|
||||
|| element instanceof JetThrowExpression;
|
||||
boolean isJumpElement = element instanceof KtBreakExpression
|
||||
|| element instanceof KtContinueExpression
|
||||
|| element instanceof KtReturnExpression
|
||||
|| element instanceof KtThrowExpression;
|
||||
if (!isJumpElement) continue;
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ public class JetFlowInformationProvider {
|
||||
public void markUninitializedVariables() {
|
||||
final Collection<VariableDescriptor> varWithUninitializedErrorGenerated = Sets.newHashSet();
|
||||
final Collection<VariableDescriptor> varWithValReassignErrorGenerated = Sets.newHashSet();
|
||||
final boolean processClassOrObject = subroutine instanceof JetClassOrObject;
|
||||
final boolean processClassOrObject = subroutine instanceof KtClassOrObject;
|
||||
|
||||
PseudocodeVariablesData pseudocodeVariablesData = getPseudocodeVariablesData();
|
||||
Map<Instruction, Edges<Map<VariableDescriptor, VariableControlFlowState>>> initializers =
|
||||
@@ -324,7 +324,7 @@ public class JetFlowInformationProvider {
|
||||
if (ctxt.variableDescriptor == null) return;
|
||||
if (instruction instanceof ReadValueInstruction) {
|
||||
ReadValueInstruction readValueInstruction = (ReadValueInstruction) instruction;
|
||||
JetElement element = readValueInstruction.getElement();
|
||||
KtElement element = readValueInstruction.getElement();
|
||||
boolean error = checkBackingField(ctxt, element);
|
||||
if (!error &&
|
||||
PseudocodeUtil.isThisOrNoDispatchReceiver(readValueInstruction, trace.getBindingContext()) &&
|
||||
@@ -335,18 +335,18 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
if (!(instruction instanceof WriteValueInstruction)) return;
|
||||
WriteValueInstruction writeValueInstruction = (WriteValueInstruction) instruction;
|
||||
JetElement element = writeValueInstruction.getLValue();
|
||||
KtElement element = writeValueInstruction.getLValue();
|
||||
boolean error = checkBackingField(ctxt, element);
|
||||
if (!(element instanceof JetExpression)) return;
|
||||
if (!(element instanceof KtExpression)) return;
|
||||
if (!error) {
|
||||
error = checkValReassignment(ctxt, (JetExpression) element, writeValueInstruction,
|
||||
error = checkValReassignment(ctxt, (KtExpression) element, writeValueInstruction,
|
||||
varWithValReassignErrorGenerated);
|
||||
}
|
||||
if (!error && processClassOrObject) {
|
||||
error = checkAssignmentBeforeDeclaration(ctxt, (JetExpression) element);
|
||||
error = checkAssignmentBeforeDeclaration(ctxt, (KtExpression) element);
|
||||
}
|
||||
if (!error && processClassOrObject) {
|
||||
checkInitializationUsingBackingField(ctxt, (JetExpression) element);
|
||||
checkInitializationUsingBackingField(ctxt, (KtExpression) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,10 +366,10 @@ public class JetFlowInformationProvider {
|
||||
|
||||
private void checkIsInitialized(
|
||||
@NotNull VariableInitContext ctxt,
|
||||
@NotNull JetElement element,
|
||||
@NotNull KtElement element,
|
||||
@NotNull Collection<VariableDescriptor> varWithUninitializedErrorGenerated
|
||||
) {
|
||||
if (!(element instanceof JetSimpleNameExpression)) return;
|
||||
if (!(element instanceof KtSimpleNameExpression)) return;
|
||||
|
||||
|
||||
boolean isDefinitelyInitialized = ctxt.exitInitState.definitelyInitialized();
|
||||
@@ -385,25 +385,25 @@ public class JetFlowInformationProvider {
|
||||
varWithUninitializedErrorGenerated.add(variableDescriptor);
|
||||
}
|
||||
if (variableDescriptor instanceof ValueParameterDescriptor) {
|
||||
report(Errors.UNINITIALIZED_PARAMETER.on((JetSimpleNameExpression) element,
|
||||
report(Errors.UNINITIALIZED_PARAMETER.on((KtSimpleNameExpression) element,
|
||||
(ValueParameterDescriptor) variableDescriptor), ctxt);
|
||||
}
|
||||
else {
|
||||
report(Errors.UNINITIALIZED_VARIABLE.on((JetSimpleNameExpression) element, variableDescriptor), ctxt);
|
||||
report(Errors.UNINITIALIZED_VARIABLE.on((KtSimpleNameExpression) element, variableDescriptor), ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkValReassignment(
|
||||
@NotNull VariableInitContext ctxt,
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull WriteValueInstruction writeValueInstruction,
|
||||
@NotNull Collection<VariableDescriptor> varWithValReassignErrorGenerated
|
||||
) {
|
||||
VariableDescriptor variableDescriptor = ctxt.variableDescriptor;
|
||||
PropertyDescriptor propertyDescriptor = SyntheticFieldDescriptorKt.getReferencedProperty(variableDescriptor);
|
||||
if (JetPsiUtil.isBackingFieldReference(expression, variableDescriptor) && propertyDescriptor != null) {
|
||||
JetPropertyAccessor accessor = PsiTreeUtil.getParentOfType(expression, JetPropertyAccessor.class);
|
||||
if (KtPsiUtil.isBackingFieldReference(expression, variableDescriptor) && propertyDescriptor != null) {
|
||||
KtPropertyAccessor accessor = PsiTreeUtil.getParentOfType(expression, KtPropertyAccessor.class);
|
||||
if (accessor != null) {
|
||||
DeclarationDescriptor accessorDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, accessor);
|
||||
if (propertyDescriptor.getGetter() == accessorDescriptor) {
|
||||
@@ -440,13 +440,13 @@ public class JetFlowInformationProvider {
|
||||
PseudocodeUtil.isThisOrNoDispatchReceiver(writeValueInstruction, trace.getBindingContext());
|
||||
if ((mayBeInitializedNotHere || !hasBackingField || !isThisOrNoDispatchReceiver) && !variableDescriptor.isVar()) {
|
||||
boolean hasReassignMethodReturningUnit = false;
|
||||
JetSimpleNameExpression operationReference = null;
|
||||
KtSimpleNameExpression operationReference = null;
|
||||
PsiElement parent = expression.getParent();
|
||||
if (parent instanceof JetBinaryExpression) {
|
||||
operationReference = ((JetBinaryExpression) parent).getOperationReference();
|
||||
if (parent instanceof KtBinaryExpression) {
|
||||
operationReference = ((KtBinaryExpression) parent).getOperationReference();
|
||||
}
|
||||
else if (parent instanceof JetUnaryExpression) {
|
||||
operationReference = ((JetUnaryExpression) parent).getOperationReference();
|
||||
else if (parent instanceof KtUnaryExpression) {
|
||||
operationReference = ((KtUnaryExpression) parent).getOperationReference();
|
||||
}
|
||||
if (operationReference != null) {
|
||||
DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference);
|
||||
@@ -482,7 +482,7 @@ public class JetFlowInformationProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkAssignmentBeforeDeclaration(@NotNull VariableInitContext ctxt, @NotNull JetExpression expression) {
|
||||
private boolean checkAssignmentBeforeDeclaration(@NotNull VariableInitContext ctxt, @NotNull KtExpression expression) {
|
||||
if (!ctxt.enterInitState.isDeclared && !ctxt.exitInitState.isDeclared
|
||||
&& !ctxt.enterInitState.mayBeInitialized() && ctxt.exitInitState.mayBeInitialized()) {
|
||||
report(Errors.INITIALIZATION_BEFORE_DECLARATION.on(expression, ctxt.variableDescriptor), ctxt);
|
||||
@@ -491,7 +491,7 @@ public class JetFlowInformationProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkInitializationUsingBackingField(@NotNull VariableInitContext ctxt, @NotNull JetExpression expression) {
|
||||
private boolean checkInitializationUsingBackingField(@NotNull VariableInitContext ctxt, @NotNull KtExpression expression) {
|
||||
VariableDescriptor variableDescriptor = ctxt.variableDescriptor;
|
||||
if (variableDescriptor instanceof PropertyDescriptor
|
||||
&& !ctxt.enterInitState.mayBeInitialized()
|
||||
@@ -499,20 +499,20 @@ public class JetFlowInformationProvider {
|
||||
if (!variableDescriptor.isVar()) return false;
|
||||
if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor)) return false;
|
||||
PsiElement property = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
|
||||
assert property instanceof JetProperty;
|
||||
JetPropertyAccessor setter = ((JetProperty) property).getSetter();
|
||||
assert property instanceof KtProperty;
|
||||
KtPropertyAccessor setter = ((KtProperty) property).getSetter();
|
||||
if (((PropertyDescriptor) variableDescriptor).getModality() == Modality.FINAL && (setter == null || !setter.hasBody())) {
|
||||
return false;
|
||||
}
|
||||
JetExpression variable = expression;
|
||||
if (expression instanceof JetDotQualifiedExpression) {
|
||||
if (((JetDotQualifiedExpression) expression).getReceiverExpression() instanceof JetThisExpression) {
|
||||
variable = ((JetDotQualifiedExpression) expression).getSelectorExpression();
|
||||
KtExpression variable = expression;
|
||||
if (expression instanceof KtDotQualifiedExpression) {
|
||||
if (((KtDotQualifiedExpression) expression).getReceiverExpression() instanceof KtThisExpression) {
|
||||
variable = ((KtDotQualifiedExpression) expression).getSelectorExpression();
|
||||
}
|
||||
}
|
||||
if (variable instanceof JetSimpleNameExpression) {
|
||||
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) variable;
|
||||
if (simpleNameExpression.getReferencedNameElementType() != JetTokens.FIELD_IDENTIFIER) {
|
||||
if (variable instanceof KtSimpleNameExpression) {
|
||||
KtSimpleNameExpression simpleNameExpression = (KtSimpleNameExpression) variable;
|
||||
if (simpleNameExpression.getReferencedNameElementType() != KtTokens.FIELD_IDENTIFIER) {
|
||||
trace.record(IS_UNINITIALIZED, (PropertyDescriptor) variableDescriptor);
|
||||
return true;
|
||||
}
|
||||
@@ -521,7 +521,7 @@ public class JetFlowInformationProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkBackingField(@NotNull VariableContext cxtx, @NotNull JetElement element) {
|
||||
private boolean checkBackingField(@NotNull VariableContext cxtx, @NotNull KtElement element) {
|
||||
VariableDescriptor variableDescriptor = cxtx.variableDescriptor;
|
||||
boolean[] error = new boolean[1];
|
||||
if (!isCorrectBackingFieldReference(element, cxtx, error, true)) return false;
|
||||
@@ -551,8 +551,8 @@ public class JetFlowInformationProvider {
|
||||
DeclarationDescriptor containingDeclaration = variableDescriptor.getContainingDeclaration();
|
||||
if ((containingDeclaration instanceof ClassDescriptor)
|
||||
&& DescriptorUtils.isAncestor(containingDeclaration, declarationDescriptor, false)) {
|
||||
if (element instanceof JetSimpleNameExpression) {
|
||||
report(Errors.BACKING_FIELD_USAGE_FORBIDDEN.on((JetSimpleNameExpression) element), cxtx);
|
||||
if (element instanceof KtSimpleNameExpression) {
|
||||
report(Errors.BACKING_FIELD_USAGE_FORBIDDEN.on((KtSimpleNameExpression) element), cxtx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -561,18 +561,18 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
|
||||
private boolean isCorrectBackingFieldReference(
|
||||
@Nullable JetElement element,
|
||||
@Nullable KtElement element,
|
||||
VariableContext ctxt,
|
||||
boolean[] error,
|
||||
boolean reportError
|
||||
) {
|
||||
error[0] = false;
|
||||
if (JetPsiUtil.isBackingFieldReference(element, null)) {
|
||||
if (KtPsiUtil.isBackingFieldReference(element, null)) {
|
||||
return true;
|
||||
}
|
||||
if (element instanceof JetDotQualifiedExpression && isCorrectBackingFieldReference(
|
||||
((JetDotQualifiedExpression) element).getSelectorExpression(), ctxt, error, false)) {
|
||||
if (((JetDotQualifiedExpression) element).getReceiverExpression() instanceof JetThisExpression) {
|
||||
if (element instanceof KtDotQualifiedExpression && isCorrectBackingFieldReference(
|
||||
((KtDotQualifiedExpression) element).getSelectorExpression(), ctxt, error, false)) {
|
||||
if (((KtDotQualifiedExpression) element).getReceiverExpression() instanceof KtThisExpression) {
|
||||
return true;
|
||||
}
|
||||
error[0] = true;
|
||||
@@ -629,50 +629,50 @@ public class JetFlowInformationProvider {
|
||||
PseudocodeVariablesData.VariableUseState variableUseState = in.get(variableDescriptor);
|
||||
if (instruction instanceof WriteValueInstruction) {
|
||||
if (trace.get(CAPTURED_IN_CLOSURE, variableDescriptor) != null) return;
|
||||
JetElement element = ((WriteValueInstruction) instruction).getElement();
|
||||
KtElement element = ((WriteValueInstruction) instruction).getElement();
|
||||
if (variableUseState != READ) {
|
||||
if (element instanceof JetBinaryExpression &&
|
||||
((JetBinaryExpression) element).getOperationToken() == JetTokens.EQ) {
|
||||
JetExpression right = ((JetBinaryExpression) element).getRight();
|
||||
if (element instanceof KtBinaryExpression &&
|
||||
((KtBinaryExpression) element).getOperationToken() == KtTokens.EQ) {
|
||||
KtExpression right = ((KtBinaryExpression) element).getRight();
|
||||
if (right != null) {
|
||||
report(Errors.UNUSED_VALUE.on((JetBinaryExpression) element, right, variableDescriptor), ctxt);
|
||||
report(Errors.UNUSED_VALUE.on((KtBinaryExpression) element, right, variableDescriptor), ctxt);
|
||||
}
|
||||
}
|
||||
else if (element instanceof JetPostfixExpression) {
|
||||
else if (element instanceof KtPostfixExpression) {
|
||||
IElementType operationToken =
|
||||
((JetPostfixExpression) element).getOperationReference().getReferencedNameElementType();
|
||||
if (operationToken == JetTokens.PLUSPLUS || operationToken == JetTokens.MINUSMINUS) {
|
||||
((KtPostfixExpression) element).getOperationReference().getReferencedNameElementType();
|
||||
if (operationToken == KtTokens.PLUSPLUS || operationToken == KtTokens.MINUSMINUS) {
|
||||
report(Errors.UNUSED_CHANGED_VALUE.on(element, element), ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (instruction instanceof VariableDeclarationInstruction) {
|
||||
JetDeclaration element = ((VariableDeclarationInstruction) instruction).getVariableDeclarationElement();
|
||||
if (!(element instanceof JetNamedDeclaration)) return;
|
||||
PsiElement nameIdentifier = ((JetNamedDeclaration) element).getNameIdentifier();
|
||||
KtDeclaration element = ((VariableDeclarationInstruction) instruction).getVariableDeclarationElement();
|
||||
if (!(element instanceof KtNamedDeclaration)) return;
|
||||
PsiElement nameIdentifier = ((KtNamedDeclaration) element).getNameIdentifier();
|
||||
if (nameIdentifier == null) return;
|
||||
if (!VariableUseState.isUsed(variableUseState)) {
|
||||
if (JetPsiUtil.isVariableNotParameterDeclaration(element)) {
|
||||
report(Errors.UNUSED_VARIABLE.on((JetNamedDeclaration) element, variableDescriptor), ctxt);
|
||||
if (KtPsiUtil.isVariableNotParameterDeclaration(element)) {
|
||||
report(Errors.UNUSED_VARIABLE.on((KtNamedDeclaration) element, variableDescriptor), ctxt);
|
||||
}
|
||||
else if (element instanceof JetParameter) {
|
||||
else if (element instanceof KtParameter) {
|
||||
PsiElement owner = element.getParent().getParent();
|
||||
if (owner instanceof JetPrimaryConstructor) {
|
||||
if (!((JetParameter) element).hasValOrVar()) {
|
||||
JetClassOrObject containingClass = ((JetPrimaryConstructor) owner).getContainingClassOrObject();
|
||||
if (owner instanceof KtPrimaryConstructor) {
|
||||
if (!((KtParameter) element).hasValOrVar()) {
|
||||
KtClassOrObject containingClass = ((KtPrimaryConstructor) owner).getContainingClassOrObject();
|
||||
DeclarationDescriptor containingClassDescriptor = trace.get(
|
||||
BindingContext.DECLARATION_TO_DESCRIPTOR, containingClass
|
||||
);
|
||||
if (!DescriptorUtils.isAnnotationClass(containingClassDescriptor)) {
|
||||
report(Errors.UNUSED_PARAMETER.on((JetParameter) element, variableDescriptor), ctxt);
|
||||
report(Errors.UNUSED_PARAMETER.on((KtParameter) element, variableDescriptor), ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (owner instanceof JetFunction) {
|
||||
else if (owner instanceof KtFunction) {
|
||||
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(trace.getBindingContext());
|
||||
boolean isMain = (owner instanceof JetNamedFunction) && mainFunctionDetector.isMain((JetNamedFunction) owner);
|
||||
if (owner instanceof JetFunctionLiteral) return;
|
||||
boolean isMain = (owner instanceof KtNamedFunction) && mainFunctionDetector.isMain((KtNamedFunction) owner);
|
||||
if (owner instanceof KtFunctionLiteral) return;
|
||||
DeclarationDescriptor descriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, owner);
|
||||
assert descriptor instanceof FunctionDescriptor : owner.getText();
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
@@ -685,21 +685,21 @@ public class JetFlowInformationProvider {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
report(Errors.UNUSED_PARAMETER.on((JetParameter) element, variableDescriptor), ctxt);
|
||||
report(Errors.UNUSED_PARAMETER.on((KtParameter) element, variableDescriptor), ctxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (variableUseState == ONLY_WRITTEN_NEVER_READ && JetPsiUtil.isVariableNotParameterDeclaration(element)) {
|
||||
report(Errors.ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE.on((JetNamedDeclaration) element, variableDescriptor), ctxt);
|
||||
else if (variableUseState == ONLY_WRITTEN_NEVER_READ && KtPsiUtil.isVariableNotParameterDeclaration(element)) {
|
||||
report(Errors.ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE.on((KtNamedDeclaration) element, variableDescriptor), ctxt);
|
||||
}
|
||||
else if (variableUseState == WRITTEN_AFTER_READ && element instanceof JetVariableDeclaration) {
|
||||
if (element instanceof JetProperty) {
|
||||
JetExpression initializer = ((JetProperty) element).getInitializer();
|
||||
else if (variableUseState == WRITTEN_AFTER_READ && element instanceof KtVariableDeclaration) {
|
||||
if (element instanceof KtProperty) {
|
||||
KtExpression initializer = ((KtProperty) element).getInitializer();
|
||||
if (initializer != null) {
|
||||
report(Errors.VARIABLE_WITH_REDUNDANT_INITIALIZER.on(initializer, variableDescriptor), ctxt);
|
||||
}
|
||||
}
|
||||
else if (element instanceof JetMultiDeclarationEntry) {
|
||||
else if (element instanceof KtMultiDeclarationEntry) {
|
||||
report(VARIABLE_WITH_REDUNDANT_INITIALIZER.on(element, variableDescriptor), ctxt);
|
||||
}
|
||||
}
|
||||
@@ -720,15 +720,15 @@ public class JetFlowInformationProvider {
|
||||
public void execute(@NotNull Instruction instruction) {
|
||||
if (!(instruction instanceof JetElementInstruction)) return;
|
||||
|
||||
JetElement element = ((JetElementInstruction)instruction).getElement();
|
||||
if (!(element instanceof JetExpression)) return;
|
||||
KtElement element = ((JetElementInstruction)instruction).getElement();
|
||||
if (!(element instanceof KtExpression)) return;
|
||||
|
||||
if (BindingContextUtilsKt.isUsedAsStatement((JetExpression) element, trace.getBindingContext())
|
||||
if (BindingContextUtilsKt.isUsedAsStatement((KtExpression) element, trace.getBindingContext())
|
||||
&& PseudocodeUtilsKt.getSideEffectFree(instruction)) {
|
||||
VariableContext ctxt = new VariableContext(instruction, reportedDiagnosticMap);
|
||||
report(
|
||||
element instanceof JetFunctionLiteralExpression
|
||||
? Errors.UNUSED_FUNCTION_LITERAL.on((JetFunctionLiteralExpression) element)
|
||||
element instanceof KtFunctionLiteralExpression
|
||||
? Errors.UNUSED_FUNCTION_LITERAL.on((KtFunctionLiteralExpression) element)
|
||||
: Errors.UNUSED_EXPRESSION.on(element),
|
||||
ctxt
|
||||
);
|
||||
@@ -751,7 +751,7 @@ public class JetFlowInformationProvider {
|
||||
: null;
|
||||
Pseudocode pseudocode = instruction.getOwner();
|
||||
boolean isUsedAsExpression = !pseudocode.getUsages(value).isEmpty();
|
||||
for (JetElement element : pseudocode.getValueElements(value)) {
|
||||
for (KtElement element : pseudocode.getValueElements(value)) {
|
||||
trace.record(BindingContext.USED_AS_EXPRESSION, element, isUsedAsExpression);
|
||||
}
|
||||
}
|
||||
@@ -767,9 +767,9 @@ public class JetFlowInformationProvider {
|
||||
PseudoValue value = instruction instanceof InstructionWithValue
|
||||
? ((InstructionWithValue) instruction).getOutputValue()
|
||||
: null;
|
||||
for (JetElement element : instruction.getOwner().getValueElements(value)) {
|
||||
if (!(element instanceof JetWhenExpression)) continue;
|
||||
JetWhenExpression whenExpression = (JetWhenExpression) element;
|
||||
for (KtElement element : instruction.getOwner().getValueElements(value)) {
|
||||
if (!(element instanceof KtWhenExpression)) continue;
|
||||
KtWhenExpression whenExpression = (KtWhenExpression) element;
|
||||
if (whenExpression.getElseExpression() != null) continue;
|
||||
|
||||
if (WhenChecker.mustHaveElse(whenExpression, trace)) {
|
||||
@@ -807,7 +807,7 @@ public class JetFlowInformationProvider {
|
||||
this.call = call;
|
||||
}
|
||||
}
|
||||
final Map<JetElement, KindAndCall> calls = new HashMap<JetElement, KindAndCall>();
|
||||
final Map<KtElement, KindAndCall> calls = new HashMap<KtElement, KindAndCall>();
|
||||
PseudocodeTraverserKt.traverse(
|
||||
pseudocode,
|
||||
FORWARD,
|
||||
@@ -823,14 +823,14 @@ public class JetFlowInformationProvider {
|
||||
CallableDescriptor functionDescriptor = resolvedCall.getResultingDescriptor();
|
||||
if (!functionDescriptor.getOriginal().equals(subroutineDescriptor)) return;
|
||||
|
||||
JetElement element = callInstruction.getElement();
|
||||
KtElement element = callInstruction.getElement();
|
||||
//noinspection unchecked
|
||||
JetExpression parent = PsiTreeUtil.getParentOfType(
|
||||
KtExpression parent = PsiTreeUtil.getParentOfType(
|
||||
element,
|
||||
JetTryExpression.class, JetFunction.class, JetClassInitializer.class
|
||||
KtTryExpression.class, KtFunction.class, KtClassInitializer.class
|
||||
);
|
||||
|
||||
if (parent instanceof JetTryExpression) {
|
||||
if (parent instanceof KtTryExpression) {
|
||||
// We do not support tail calls Collections.singletonMap() try-catch-finally, for simplicity of the mental model
|
||||
// very few cases there would be real tail-calls, and it's often not so easy for the user to see why
|
||||
calls.put(element, new KindAndCall(IN_TRY, resolvedCall));
|
||||
@@ -866,8 +866,8 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
);
|
||||
boolean hasTailCalls = false;
|
||||
for (Map.Entry<JetElement, KindAndCall> entry : calls.entrySet()) {
|
||||
JetElement element = entry.getKey();
|
||||
for (Map.Entry<KtElement, KindAndCall> entry : calls.entrySet()) {
|
||||
KtElement element = entry.getKey();
|
||||
KindAndCall kindAndCall = entry.getValue();
|
||||
switch (kindAndCall.kind) {
|
||||
case TAIL_CALL:
|
||||
@@ -884,7 +884,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
|
||||
if (!hasTailCalls) {
|
||||
trace.report(Errors.NO_TAIL_CALLS_FOUND.on((JetNamedFunction) subroutine));
|
||||
trace.report(Errors.NO_TAIL_CALLS_FOUND.on((KtNamedFunction) subroutine));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg;
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetLoopExpression;
|
||||
import org.jetbrains.kotlin.psi.KtLoopExpression;
|
||||
|
||||
public class LoopInfo extends BreakableBlockInfo {
|
||||
private final Label bodyEntryPoint;
|
||||
@@ -24,7 +24,7 @@ public class LoopInfo extends BreakableBlockInfo {
|
||||
private final Label conditionEntryPoint;
|
||||
|
||||
public LoopInfo(
|
||||
JetLoopExpression loopExpression,
|
||||
KtLoopExpression loopExpression,
|
||||
Label entryPoint,
|
||||
Label exitPoint,
|
||||
Label bodyEntryPoint,
|
||||
@@ -39,8 +39,8 @@ public class LoopInfo extends BreakableBlockInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetLoopExpression getElement() {
|
||||
return (JetLoopExpression) super.getElement();
|
||||
public KtLoopExpression getElement() {
|
||||
return (KtLoopExpression) super.getElement();
|
||||
}
|
||||
|
||||
public Label getBodyEntryPoint() {
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.VariableDeclarat
|
||||
import org.jetbrains.kotlin.cfg.pseudocodeTraverser.Edges;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration;
|
||||
import org.jetbrains.kotlin.psi.JetProperty;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtProperty;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -98,7 +98,7 @@ public class PseudocodeVariablesData {
|
||||
Set<VariableDescriptor> declaredVariables = Sets.newHashSet();
|
||||
for (Instruction instruction : pseudocode.getInstructions()) {
|
||||
if (instruction instanceof VariableDeclarationInstruction) {
|
||||
JetDeclaration variableDeclarationElement = ((VariableDeclarationInstruction) instruction).getVariableDeclarationElement();
|
||||
KtDeclaration variableDeclarationElement = ((VariableDeclarationInstruction) instruction).getVariableDeclarationElement();
|
||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, variableDeclarationElement);
|
||||
if (descriptor != null) {
|
||||
assert descriptor instanceof VariableDescriptor;
|
||||
@@ -211,7 +211,7 @@ public class PseudocodeVariablesData {
|
||||
VariableControlFlowState enterInitState = enterInstructionData.get(variable);
|
||||
VariableControlFlowState initializationAtThisElement =
|
||||
VariableControlFlowState
|
||||
.create(((WriteValueInstruction) instruction).getElement() instanceof JetProperty, enterInitState);
|
||||
.create(((WriteValueInstruction) instruction).getElement() instanceof KtProperty, enterInitState);
|
||||
exitInstructionData.put(variable, initializationAtThisElement);
|
||||
}
|
||||
else { // instruction instanceof VariableDeclarationInstruction
|
||||
|
||||
@@ -27,13 +27,13 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps.ThrowExceptionInst
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.MarkInstruction;
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction;
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineSinkInstruction;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
|
||||
public class TailRecursionDetector extends InstructionVisitorWithResult<Boolean> implements Function1<Instruction, Boolean> {
|
||||
private final JetElement subroutine;
|
||||
private final KtElement subroutine;
|
||||
private final Instruction start;
|
||||
|
||||
public TailRecursionDetector(@NotNull JetElement subroutine, @NotNull Instruction start) {
|
||||
public TailRecursionDetector(@NotNull KtElement subroutine, @NotNull Instruction start) {
|
||||
this.subroutine = subroutine;
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
@@ -22,25 +22,25 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetPsiUtil
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import java.util.*
|
||||
|
||||
interface UnreachableCode {
|
||||
val elements: Set<JetElement>
|
||||
fun getUnreachableTextRanges(element: JetElement): List<TextRange>
|
||||
val elements: Set<KtElement>
|
||||
fun getUnreachableTextRanges(element: KtElement): List<TextRange>
|
||||
}
|
||||
|
||||
class UnreachableCodeImpl(
|
||||
private val reachableElements: Set<JetElement>,
|
||||
private val unreachableElements: Set<JetElement>
|
||||
private val reachableElements: Set<KtElement>,
|
||||
private val unreachableElements: Set<KtElement>
|
||||
) : UnreachableCode {
|
||||
|
||||
// This is needed in order to highlight only '1 < 2' and not '1', '<' and '2' as well
|
||||
override val elements = JetPsiUtil.findRootExpressions(unreachableElements)
|
||||
override val elements = KtPsiUtil.findRootExpressions(unreachableElements)
|
||||
|
||||
override fun getUnreachableTextRanges(element: JetElement): List<TextRange> {
|
||||
override fun getUnreachableTextRanges(element: KtElement): List<TextRange> {
|
||||
return if (element.hasChildrenInSet(reachableElements)) {
|
||||
element.getLeavesOrReachableChildren().removeReachableElementsWithMeaninglessSiblings().mergeAdjacentTextRanges()
|
||||
}
|
||||
@@ -49,15 +49,15 @@ class UnreachableCodeImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private fun JetElement.hasChildrenInSet(set: Set<JetElement>): Boolean {
|
||||
private fun KtElement.hasChildrenInSet(set: Set<KtElement>): Boolean {
|
||||
return PsiTreeUtil.collectElements(this) { it != this }.any { it in set }
|
||||
}
|
||||
|
||||
private fun JetElement.getLeavesOrReachableChildren(): List<PsiElement> {
|
||||
private fun KtElement.getLeavesOrReachableChildren(): List<PsiElement> {
|
||||
val children = ArrayList<PsiElement>()
|
||||
acceptChildren(object : PsiElementVisitor() {
|
||||
override fun visitElement(element: PsiElement) {
|
||||
val isReachable = element is JetElement && reachableElements.contains(element) && !element.hasChildrenInSet(unreachableElements)
|
||||
val isReachable = element is KtElement && reachableElements.contains(element) && !element.hasChildrenInSet(unreachableElements)
|
||||
if (isReachable || element.getChildren().size() == 0) {
|
||||
children.add(element)
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class UnreachableCodeImpl(
|
||||
|
||||
fun List<PsiElement>.removeReachableElementsWithMeaninglessSiblings(): List<PsiElement> {
|
||||
fun PsiElement.isMeaningless() = this is PsiWhiteSpace
|
||||
|| this.getNode()?.getElementType() == JetTokens.COMMA
|
||||
|| this.getNode()?.getElementType() == KtTokens.COMMA
|
||||
|| this is PsiComment
|
||||
|
||||
val childrenToRemove = HashSet<PsiElement>()
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -40,8 +40,8 @@ public final class WhenChecker {
|
||||
private WhenChecker() {
|
||||
}
|
||||
|
||||
public static boolean mustHaveElse(@NotNull JetWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
JetType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
public static boolean mustHaveElse(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
KtType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
boolean isUnit = expectedType != null && KotlinBuiltIns.isUnit(expectedType);
|
||||
// Some "statements" are actually expressions returned from lambdas, their expected types are non-null
|
||||
boolean isStatement = BindingContextUtilsKt.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null;
|
||||
@@ -49,12 +49,12 @@ public final class WhenChecker {
|
||||
return !isUnit && !isStatement && !isWhenExhaustive(expression, trace);
|
||||
}
|
||||
|
||||
public static boolean isWhenByEnum(@NotNull JetWhenExpression expression, @NotNull BindingContext context) {
|
||||
public static boolean isWhenByEnum(@NotNull KtWhenExpression expression, @NotNull BindingContext context) {
|
||||
return getClassDescriptorOfTypeIfEnum(whenSubjectType(expression, context)) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable JetType type) {
|
||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KtType type) {
|
||||
if (type == null) return null;
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
if (classDescriptor == null) return null;
|
||||
@@ -64,19 +64,19 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetType whenSubjectType(@NotNull JetWhenExpression expression, @NotNull BindingContext context) {
|
||||
JetExpression subjectExpression = expression.getSubjectExpression();
|
||||
private static KtType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) {
|
||||
KtExpression subjectExpression = expression.getSubjectExpression();
|
||||
return subjectExpression == null ? null : context.getType(subjectExpression);
|
||||
}
|
||||
|
||||
private static boolean isWhenOnBooleanExhaustive(@NotNull JetWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
private static boolean isWhenOnBooleanExhaustive(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
// It's assumed (and not checked) that expression is of the boolean type
|
||||
boolean containsFalse = false;
|
||||
boolean containsTrue = false;
|
||||
for (JetWhenEntry whenEntry: expression.getEntries()) {
|
||||
for (JetWhenCondition whenCondition : whenEntry.getConditions()) {
|
||||
if (whenCondition instanceof JetWhenConditionWithExpression) {
|
||||
JetExpression whenExpression = ((JetWhenConditionWithExpression) whenCondition).getExpression();
|
||||
for (KtWhenEntry whenEntry: expression.getEntries()) {
|
||||
for (KtWhenCondition whenCondition : whenEntry.getConditions()) {
|
||||
if (whenCondition instanceof KtWhenConditionWithExpression) {
|
||||
KtExpression whenExpression = ((KtWhenConditionWithExpression) whenCondition).getExpression();
|
||||
if (CompileTimeConstantUtils.canBeReducedToBooleanConstant(whenExpression, trace, true)) containsTrue = true;
|
||||
if (CompileTimeConstantUtils.canBeReducedToBooleanConstant(whenExpression, trace, false)) containsFalse = true;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
public static boolean isWhenOnEnumExhaustive(
|
||||
@NotNull JetWhenExpression expression,
|
||||
@NotNull KtWhenExpression expression,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull ClassDescriptor enumClassDescriptor
|
||||
) {
|
||||
@@ -118,7 +118,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
private static boolean isWhenOnSealedClassExhaustive(
|
||||
@NotNull JetWhenExpression expression,
|
||||
@NotNull KtWhenExpression expression,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull ClassDescriptor classDescriptor
|
||||
) {
|
||||
@@ -135,8 +135,8 @@ public final class WhenChecker {
|
||||
* @return true if type is nullable, and cannot be smart casted
|
||||
*/
|
||||
private static boolean isNullableTypeWithoutPossibleSmartCast(
|
||||
@Nullable JetExpression expression,
|
||||
@NotNull JetType type,
|
||||
@Nullable KtExpression expression,
|
||||
@NotNull KtType type,
|
||||
@NotNull BindingContext context
|
||||
) {
|
||||
if (expression == null) return false; // Normally should not happen
|
||||
@@ -151,8 +151,8 @@ public final class WhenChecker {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isWhenExhaustive(@NotNull JetWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
JetType type = whenSubjectType(expression, trace.getBindingContext());
|
||||
public static boolean isWhenExhaustive(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
KtType type = whenSubjectType(expression, trace.getBindingContext());
|
||||
if (type == null) return false;
|
||||
ClassDescriptor enumClassDescriptor = getClassDescriptorOfTypeIfEnum(type);
|
||||
|
||||
@@ -185,27 +185,27 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
private static boolean containsAllClassCases(
|
||||
@NotNull JetWhenExpression whenExpression,
|
||||
@NotNull KtWhenExpression whenExpression,
|
||||
@NotNull Set<ClassDescriptor> memberDescriptors,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
Set<ClassDescriptor> checkedDescriptors = new HashSet<ClassDescriptor>();
|
||||
for (JetWhenEntry whenEntry : whenExpression.getEntries()) {
|
||||
for (JetWhenCondition condition : whenEntry.getConditions()) {
|
||||
for (KtWhenEntry whenEntry : whenExpression.getEntries()) {
|
||||
for (KtWhenCondition condition : whenEntry.getConditions()) {
|
||||
boolean negated = false;
|
||||
ClassDescriptor checkedDescriptor = null;
|
||||
if (condition instanceof JetWhenConditionIsPattern) {
|
||||
JetWhenConditionIsPattern conditionIsPattern = (JetWhenConditionIsPattern) condition;
|
||||
JetType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||
if (condition instanceof KtWhenConditionIsPattern) {
|
||||
KtWhenConditionIsPattern conditionIsPattern = (KtWhenConditionIsPattern) condition;
|
||||
KtType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||
if (checkedType != null) {
|
||||
checkedDescriptor = TypeUtils.getClassDescriptor(checkedType);
|
||||
}
|
||||
negated = conditionIsPattern.isNegated();
|
||||
}
|
||||
else if (condition instanceof JetWhenConditionWithExpression) {
|
||||
JetWhenConditionWithExpression conditionWithExpression = (JetWhenConditionWithExpression) condition;
|
||||
else if (condition instanceof KtWhenConditionWithExpression) {
|
||||
KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition;
|
||||
if (conditionWithExpression.getExpression() != null) {
|
||||
JetSimpleNameExpression reference = getReference(conditionWithExpression.getExpression());
|
||||
KtSimpleNameExpression reference = getReference(conditionWithExpression.getExpression());
|
||||
if (reference != null) {
|
||||
DeclarationDescriptor target = trace.get(BindingContext.REFERENCE_TARGET, reference);
|
||||
if (target instanceof ClassDescriptor) {
|
||||
@@ -219,7 +219,7 @@ public final class WhenChecker {
|
||||
// In additional, check without "is" is important only for objects
|
||||
if (checkedDescriptor == null
|
||||
|| !memberDescriptors.contains(checkedDescriptor)
|
||||
|| (condition instanceof JetWhenConditionWithExpression
|
||||
|| (condition instanceof KtWhenConditionWithExpression
|
||||
&& !DescriptorUtils.isObject(checkedDescriptor)
|
||||
&& !DescriptorUtils.isEnumEntry(checkedDescriptor))) {
|
||||
continue;
|
||||
@@ -237,13 +237,13 @@ public final class WhenChecker {
|
||||
return checkedDescriptors.containsAll(memberDescriptors);
|
||||
}
|
||||
|
||||
public static boolean containsNullCase(@NotNull JetWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
for (JetWhenEntry entry : expression.getEntries()) {
|
||||
for (JetWhenCondition condition : entry.getConditions()) {
|
||||
if (condition instanceof JetWhenConditionWithExpression) {
|
||||
JetWhenConditionWithExpression conditionWithExpression = (JetWhenConditionWithExpression) condition;
|
||||
public static boolean containsNullCase(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
for (KtWhenEntry entry : expression.getEntries()) {
|
||||
for (KtWhenCondition condition : entry.getConditions()) {
|
||||
if (condition instanceof KtWhenConditionWithExpression) {
|
||||
KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition;
|
||||
if (conditionWithExpression.getExpression() != null) {
|
||||
JetType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||
KtType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||
if (type != null && KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||
return true;
|
||||
}
|
||||
@@ -255,15 +255,15 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetSimpleNameExpression getReference(@Nullable JetExpression expression) {
|
||||
private static KtSimpleNameExpression getReference(@Nullable KtExpression expression) {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
if (expression instanceof JetSimpleNameExpression) {
|
||||
return (JetSimpleNameExpression) expression;
|
||||
if (expression instanceof KtSimpleNameExpression) {
|
||||
return (KtSimpleNameExpression) expression;
|
||||
}
|
||||
if (expression instanceof JetQualifiedExpression) {
|
||||
return getReference(((JetQualifiedExpression) expression).getSelectorExpression());
|
||||
if (expression instanceof KtQualifiedExpression) {
|
||||
return getReference(((KtQualifiedExpression) expression).getSelectorExpression());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+56
-56
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
private final Stack<LoopInfo> loopInfo = new Stack<LoopInfo>();
|
||||
private final Stack<LexicalScope> lexicalScopes = new Stack<LexicalScope>();
|
||||
private final Map<JetElement, BreakableBlockInfo> elementToBlockInfo = new HashMap<JetElement, BreakableBlockInfo>();
|
||||
private final Map<KtElement, BreakableBlockInfo> elementToBlockInfo = new HashMap<KtElement, BreakableBlockInfo>();
|
||||
private int labelCount = 0;
|
||||
|
||||
private final Stack<JetControlFlowInstructionsGeneratorWorker> builders = new Stack<JetControlFlowInstructionsGeneratorWorker>();
|
||||
@@ -53,13 +53,13 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
return builder;
|
||||
}
|
||||
|
||||
private void pushBuilder(JetElement scopingElement, JetElement subroutine) {
|
||||
private void pushBuilder(KtElement scopingElement, KtElement subroutine) {
|
||||
JetControlFlowInstructionsGeneratorWorker worker = new JetControlFlowInstructionsGeneratorWorker(scopingElement, subroutine);
|
||||
builders.push(worker);
|
||||
builder = worker;
|
||||
}
|
||||
|
||||
private JetControlFlowInstructionsGeneratorWorker popBuilder(@NotNull JetElement element) {
|
||||
private JetControlFlowInstructionsGeneratorWorker popBuilder(@NotNull KtElement element) {
|
||||
JetControlFlowInstructionsGeneratorWorker worker = builders.pop();
|
||||
if (!builders.isEmpty()) {
|
||||
builder = builders.peek();
|
||||
@@ -71,8 +71,8 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterSubroutine(@NotNull JetElement subroutine) {
|
||||
if (builder != null && subroutine instanceof JetFunctionLiteral) {
|
||||
public void enterSubroutine(@NotNull KtElement subroutine) {
|
||||
if (builder != null && subroutine instanceof KtFunctionLiteral) {
|
||||
pushBuilder(subroutine, builder.getReturnSubroutine());
|
||||
}
|
||||
else {
|
||||
@@ -85,7 +85,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||
public Pseudocode exitSubroutine(@NotNull KtElement subroutine) {
|
||||
super.exitSubroutine(subroutine);
|
||||
builder.exitLexicalScope(subroutine);
|
||||
JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
|
||||
@@ -101,12 +101,12 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
private final PseudocodeImpl pseudocode;
|
||||
private final Label error;
|
||||
private final Label sink;
|
||||
private final JetElement returnSubroutine;
|
||||
private final KtElement returnSubroutine;
|
||||
|
||||
private final PseudoValueFactory valueFactory = new PseudoValueFactoryImpl() {
|
||||
@NotNull
|
||||
@Override
|
||||
public PseudoValue newValue(@Nullable JetElement element, @Nullable InstructionWithValue instruction) {
|
||||
public PseudoValue newValue(@Nullable KtElement element, @Nullable InstructionWithValue instruction) {
|
||||
PseudoValue value = super.newValue(element, instruction);
|
||||
if (element != null) {
|
||||
bindValue(value, element);
|
||||
@@ -115,7 +115,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
};
|
||||
|
||||
private JetControlFlowInstructionsGeneratorWorker(@NotNull JetElement scopingElement, @NotNull JetElement returnSubroutine) {
|
||||
private JetControlFlowInstructionsGeneratorWorker(@NotNull KtElement scopingElement, @NotNull KtElement returnSubroutine) {
|
||||
this.pseudocode = new PseudocodeImpl(scopingElement);
|
||||
this.error = pseudocode.createLabel("error", null);
|
||||
this.sink = pseudocode.createLabel("sink", null);
|
||||
@@ -144,7 +144,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final LoopInfo enterLoop(@NotNull JetLoopExpression expression) {
|
||||
public final LoopInfo enterLoop(@NotNull KtLoopExpression expression) {
|
||||
LoopInfo info = new LoopInfo(
|
||||
expression,
|
||||
createUnboundLabel("loop entry point"),
|
||||
@@ -158,7 +158,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLoopBody(@NotNull JetLoopExpression expression) {
|
||||
public void enterLoopBody(@NotNull KtLoopExpression expression) {
|
||||
LoopInfo info = (LoopInfo) elementToBlockInfo.get(expression);
|
||||
bindLabel(info.getBodyEntryPoint());
|
||||
loopInfo.push(info);
|
||||
@@ -166,7 +166,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void exitLoopBody(@NotNull JetLoopExpression expression) {
|
||||
public final void exitLoopBody(@NotNull KtLoopExpression expression) {
|
||||
LoopInfo info = loopInfo.pop();
|
||||
elementToBlockInfo.remove(expression);
|
||||
allBlocks.pop();
|
||||
@@ -174,12 +174,12 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetLoopExpression getCurrentLoop() {
|
||||
public KtLoopExpression getCurrentLoop() {
|
||||
return loopInfo.empty() ? null : loopInfo.peek().getElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterSubroutine(@NotNull JetElement subroutine) {
|
||||
public void enterSubroutine(@NotNull KtElement subroutine) {
|
||||
BreakableBlockInfo blockInfo = new BreakableBlockInfo(
|
||||
subroutine,
|
||||
/* entry point */ createUnboundLabel(),
|
||||
@@ -192,24 +192,24 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetElement getCurrentSubroutine() {
|
||||
public KtElement getCurrentSubroutine() {
|
||||
return pseudocode.getCorrespondingElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetElement getReturnSubroutine() {
|
||||
public KtElement getReturnSubroutine() {
|
||||
return returnSubroutine;// subroutineInfo.empty() ? null : subroutineInfo.peek().getElement();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
||||
public Label getEntryPoint(@NotNull KtElement labelElement) {
|
||||
return elementToBlockInfo.get(labelElement).getEntryPoint();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Label getConditionEntryPoint(@NotNull JetElement labelElement) {
|
||||
public Label getConditionEntryPoint(@NotNull KtElement labelElement) {
|
||||
BreakableBlockInfo blockInfo = elementToBlockInfo.get(labelElement);
|
||||
assert blockInfo instanceof LoopInfo : "expected LoopInfo for " + labelElement.getText() ;
|
||||
return ((LoopInfo)blockInfo).getConditionEntryPoint();
|
||||
@@ -217,7 +217,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Label getExitPoint(@NotNull JetElement labelElement) {
|
||||
public Label getExitPoint(@NotNull KtElement labelElement) {
|
||||
BreakableBlockInfo blockInfo = elementToBlockInfo.get(labelElement);
|
||||
assert blockInfo != null : labelElement.getText();
|
||||
return blockInfo.getExitPoint();
|
||||
@@ -229,14 +229,14 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterLexicalScope(@NotNull JetElement element) {
|
||||
public void enterLexicalScope(@NotNull KtElement element) {
|
||||
LexicalScope current = lexicalScopes.isEmpty() ? null : getCurrentScope();
|
||||
LexicalScope scope = new LexicalScope(current, element);
|
||||
lexicalScopes.push(scope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitLexicalScope(@NotNull JetElement element) {
|
||||
public void exitLexicalScope(@NotNull KtElement element) {
|
||||
LexicalScope currentScope = getCurrentScope();
|
||||
assert currentScope.getElement() == element : "Exit from not the current lexical scope.\n" +
|
||||
"Current scope is for: " + currentScope.getElement() + ".\n" +
|
||||
@@ -269,7 +269,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
|
||||
public Pseudocode exitSubroutine(@NotNull KtElement subroutine) {
|
||||
bindLabel(getExitPoint(subroutine));
|
||||
pseudocode.addExitInstruction(new SubroutineExitInstruction(subroutine, getCurrentScope(), false));
|
||||
bindLabel(error);
|
||||
@@ -282,36 +282,36 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(@NotNull JetElement element) {
|
||||
public void mark(@NotNull KtElement element) {
|
||||
add(new MarkInstruction(element, getCurrentScope()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PseudoValue getBoundValue(@Nullable JetElement element) {
|
||||
public PseudoValue getBoundValue(@Nullable KtElement element) {
|
||||
return pseudocode.getElementValue(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindValue(@NotNull PseudoValue value, @NotNull JetElement element) {
|
||||
public void bindValue(@NotNull PseudoValue value, @NotNull KtElement element) {
|
||||
pseudocode.bindElementToValue(element, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PseudoValue newValue(@Nullable JetElement element) {
|
||||
public PseudoValue newValue(@Nullable KtElement element) {
|
||||
return valueFactory.newValue(element, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnValue(@NotNull JetExpression returnExpression, @NotNull PseudoValue returnValue, @NotNull JetElement subroutine) {
|
||||
public void returnValue(@NotNull KtExpression returnExpression, @NotNull PseudoValue returnValue, @NotNull KtElement subroutine) {
|
||||
Label exitPoint = getExitPoint(subroutine);
|
||||
handleJumpInsideTryFinally(exitPoint);
|
||||
add(new ReturnValueInstruction(returnExpression, getCurrentScope(), exitPoint, returnValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnNoValue(@NotNull JetReturnExpression returnExpression, @NotNull JetElement subroutine) {
|
||||
public void returnNoValue(@NotNull KtReturnExpression returnExpression, @NotNull KtElement subroutine) {
|
||||
Label exitPoint = getExitPoint(subroutine);
|
||||
handleJumpInsideTryFinally(exitPoint);
|
||||
add(new ReturnNoValueInstruction(returnExpression, getCurrentScope(), exitPoint));
|
||||
@@ -319,8 +319,8 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@Override
|
||||
public void write(
|
||||
@NotNull JetElement assignment,
|
||||
@NotNull JetElement lValue,
|
||||
@NotNull KtElement assignment,
|
||||
@NotNull KtElement lValue,
|
||||
@NotNull PseudoValue rValue,
|
||||
@NotNull AccessTarget target,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues) {
|
||||
@@ -328,39 +328,39 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareParameter(@NotNull JetParameter parameter) {
|
||||
public void declareParameter(@NotNull KtParameter parameter) {
|
||||
add(new VariableDeclarationInstruction(parameter, getCurrentScope()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareVariable(@NotNull JetVariableDeclaration property) {
|
||||
public void declareVariable(@NotNull KtVariableDeclaration property) {
|
||||
add(new VariableDeclarationInstruction(property, getCurrentScope()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void declareFunction(@NotNull JetElement subroutine, @NotNull Pseudocode pseudocode) {
|
||||
public void declareFunction(@NotNull KtElement subroutine, @NotNull Pseudocode pseudocode) {
|
||||
add(new LocalFunctionDeclarationInstruction(subroutine, pseudocode, getCurrentScope()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUnit(@NotNull JetExpression expression) {
|
||||
public void loadUnit(@NotNull KtExpression expression) {
|
||||
add(new LoadUnitValueInstruction(expression, getCurrentScope()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jump(@NotNull Label label, @NotNull JetElement element) {
|
||||
public void jump(@NotNull Label label, @NotNull KtElement element) {
|
||||
handleJumpInsideTryFinally(label);
|
||||
add(new UnconditionalJumpInstruction(element, label, getCurrentScope()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpOnFalse(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue conditionValue) {
|
||||
public void jumpOnFalse(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue conditionValue) {
|
||||
handleJumpInsideTryFinally(label);
|
||||
add(new ConditionalJumpInstruction(element, false, getCurrentScope(), label, conditionValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpOnTrue(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue conditionValue) {
|
||||
public void jumpOnTrue(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue conditionValue) {
|
||||
handleJumpInsideTryFinally(label);
|
||||
add(new ConditionalJumpInstruction(element, true, getCurrentScope(), label, conditionValue));
|
||||
}
|
||||
@@ -371,20 +371,20 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nondeterministicJump(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue inputValue) {
|
||||
public void nondeterministicJump(@NotNull Label label, @NotNull KtElement element, @Nullable PseudoValue inputValue) {
|
||||
handleJumpInsideTryFinally(label);
|
||||
add(new NondeterministicJumpInstruction(element, Collections.singletonList(label), getCurrentScope(), inputValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nondeterministicJump(@NotNull List<Label> labels, @NotNull JetElement element) {
|
||||
public void nondeterministicJump(@NotNull List<Label> labels, @NotNull KtElement element) {
|
||||
//todo
|
||||
//handleJumpInsideTryFinally(label);
|
||||
add(new NondeterministicJumpInstruction(element, labels, getCurrentScope(), null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetElement element) {
|
||||
public void jumpToError(@NotNull KtElement element) {
|
||||
handleJumpInsideTryFinally(error);
|
||||
add(new UnconditionalJumpInstruction(element, error, getCurrentScope()));
|
||||
}
|
||||
@@ -395,7 +395,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@Override
|
||||
public void throwException(@NotNull JetThrowExpression expression, @NotNull PseudoValue thrownValue) {
|
||||
public void throwException(@NotNull KtThrowExpression expression, @NotNull PseudoValue thrownValue) {
|
||||
handleJumpInsideTryFinally(error);
|
||||
add(new ThrowExceptionInstruction(expression, getCurrentScope(), error, thrownValue));
|
||||
}
|
||||
@@ -413,33 +413,33 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue loadConstant(@NotNull JetExpression expression, @Nullable CompileTimeConstant<?> constant) {
|
||||
public InstructionWithValue loadConstant(@NotNull KtExpression expression, @Nullable CompileTimeConstant<?> constant) {
|
||||
return read(expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue createAnonymousObject(@NotNull JetObjectLiteralExpression expression) {
|
||||
public InstructionWithValue createAnonymousObject(@NotNull KtObjectLiteralExpression expression) {
|
||||
return read(expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue createLambda(@NotNull JetFunction expression) {
|
||||
return read(expression instanceof JetFunctionLiteral ? (JetFunctionLiteralExpression) expression.getParent() : expression);
|
||||
public InstructionWithValue createLambda(@NotNull KtFunction expression) {
|
||||
return read(expression instanceof KtFunctionLiteral ? (KtFunctionLiteralExpression) expression.getParent() : expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InstructionWithValue loadStringTemplate(@NotNull JetStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
public InstructionWithValue loadStringTemplate(@NotNull KtStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
return inputValues.isEmpty() ? read(expression) : magic(expression, expression, inputValues, MagicKind.STRING_TEMPLATE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MagicInstruction magic(
|
||||
@NotNull JetElement instructionElement,
|
||||
@Nullable JetElement valueElement,
|
||||
@NotNull KtElement instructionElement,
|
||||
@Nullable KtElement valueElement,
|
||||
@NotNull List<PseudoValue> inputValues,
|
||||
@NotNull MagicKind kind
|
||||
) {
|
||||
@@ -452,7 +452,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MergeInstruction merge(@NotNull JetExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
public MergeInstruction merge(@NotNull KtExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
MergeInstruction instruction = new MergeInstruction(expression, getCurrentScope(), inputValues, valueFactory);
|
||||
add(instruction);
|
||||
return instruction;
|
||||
@@ -461,7 +461,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@NotNull
|
||||
@Override
|
||||
public ReadValueInstruction readVariable(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues
|
||||
) {
|
||||
@@ -471,12 +471,12 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@NotNull
|
||||
@Override
|
||||
public CallInstruction call(
|
||||
@NotNull JetElement valueElement,
|
||||
@NotNull KtElement valueElement,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
||||
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
||||
) {
|
||||
JetType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
KtType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
CallInstruction instruction = new CallInstruction(
|
||||
valueElement,
|
||||
getCurrentScope(),
|
||||
@@ -492,7 +492,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@NotNull
|
||||
@Override
|
||||
public OperationInstruction predefinedOperation(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull PredefinedOperation operation,
|
||||
@NotNull List<PseudoValue> inputValues
|
||||
) {
|
||||
@@ -515,7 +515,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
@NotNull
|
||||
private ReadValueInstruction read(
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull KtExpression expression,
|
||||
@Nullable ResolvedCall<?> resolvedCall,
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues
|
||||
) {
|
||||
@@ -528,7 +528,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ReadValueInstruction read(@NotNull JetExpression expression) {
|
||||
private ReadValueInstruction read(@NotNull KtExpression expression) {
|
||||
return read(expression, null, Collections.<PseudoValue, ReceiverValue>emptyMap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValue
|
||||
|
||||
public interface PseudoValue {
|
||||
public val debugName: String
|
||||
public val element: JetElement?
|
||||
public val element: KtElement?
|
||||
public val createdAt: InstructionWithValue?
|
||||
}
|
||||
|
||||
public interface PseudoValueFactory {
|
||||
public fun newValue(element: JetElement?, instruction: InstructionWithValue?): PseudoValue
|
||||
public fun newValue(element: KtElement?, instruction: InstructionWithValue?): PseudoValue
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValue
|
||||
|
||||
class PseudoValueImpl(
|
||||
override val debugName: String,
|
||||
override val element: JetElement?,
|
||||
override val element: KtElement?,
|
||||
override val createdAt: InstructionWithValue?
|
||||
) : PseudoValue {
|
||||
override fun toString(): String = debugName
|
||||
@@ -30,7 +30,7 @@ class PseudoValueImpl(
|
||||
open class PseudoValueFactoryImpl: PseudoValueFactory {
|
||||
private var lastIndex: Int = 0
|
||||
|
||||
override fun newValue(element: JetElement?, instruction: InstructionWithValue?): PseudoValue {
|
||||
override fun newValue(element: KtElement?, instruction: InstructionWithValue?): PseudoValue {
|
||||
return PseudoValueImpl((instruction?.let { "" } ?: "!") + "<v${lastIndex++}>", element, instruction)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDec
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineEnterInstruction;
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction;
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineSinkInstruction;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Pseudocode {
|
||||
@NotNull
|
||||
JetElement getCorrespondingElement();
|
||||
KtElement getCorrespondingElement();
|
||||
|
||||
@Nullable
|
||||
Pseudocode getParent();
|
||||
@@ -57,10 +57,10 @@ public interface Pseudocode {
|
||||
SubroutineEnterInstruction getEnterInstruction();
|
||||
|
||||
@Nullable
|
||||
PseudoValue getElementValue(@Nullable JetElement element);
|
||||
PseudoValue getElementValue(@Nullable KtElement element);
|
||||
|
||||
@NotNull
|
||||
List<? extends JetElement> getValueElements(@Nullable PseudoValue value);
|
||||
List<? extends KtElement> getValueElements(@Nullable PseudoValue value);
|
||||
|
||||
@NotNull
|
||||
List<? extends Instruction> getUsages(@Nullable PseudoValue value);
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineEnterI
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineExitInstruction;
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.SubroutineSinkInstruction;
|
||||
import org.jetbrains.kotlin.cfg.pseudocodeTraverser.PseudocodeTraverserKt;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
private final List<Instruction> mutableInstructionList = new ArrayList<Instruction>();
|
||||
private final List<Instruction> instructions = new ArrayList<Instruction>();
|
||||
|
||||
private final BidirectionalMap<JetElement, PseudoValue> elementsToValues = new BidirectionalMap<JetElement, PseudoValue>();
|
||||
private final BidirectionalMap<KtElement, PseudoValue> elementsToValues = new BidirectionalMap<KtElement, PseudoValue>();
|
||||
|
||||
private final Map<PseudoValue, List<Instruction>> valueUsages = Maps.newHashMap();
|
||||
private final Map<PseudoValue, Set<PseudoValue>> mergedValues = Maps.newHashMap();
|
||||
@@ -104,23 +104,23 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
private Pseudocode parent = null;
|
||||
private Set<LocalFunctionDeclarationInstruction> localDeclarations = null;
|
||||
//todo getters
|
||||
private final Map<JetElement, Instruction> representativeInstructions = new HashMap<JetElement, Instruction>();
|
||||
private final Map<KtElement, Instruction> representativeInstructions = new HashMap<KtElement, Instruction>();
|
||||
|
||||
private final List<PseudocodeLabel> labels = new ArrayList<PseudocodeLabel>();
|
||||
|
||||
private final JetElement correspondingElement;
|
||||
private final KtElement correspondingElement;
|
||||
private SubroutineExitInstruction exitInstruction;
|
||||
private SubroutineSinkInstruction sinkInstruction;
|
||||
private SubroutineExitInstruction errorInstruction;
|
||||
private boolean postPrecessed = false;
|
||||
|
||||
public PseudocodeImpl(JetElement correspondingElement) {
|
||||
public PseudocodeImpl(KtElement correspondingElement) {
|
||||
this.correspondingElement = correspondingElement;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetElement getCorrespondingElement() {
|
||||
public KtElement getCorrespondingElement() {
|
||||
return correspondingElement;
|
||||
}
|
||||
|
||||
@@ -268,15 +268,15 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PseudoValue getElementValue(@Nullable JetElement element) {
|
||||
public PseudoValue getElementValue(@Nullable KtElement element) {
|
||||
return elementsToValues.get(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends JetElement> getValueElements(@Nullable PseudoValue value) {
|
||||
List<? extends JetElement> result = elementsToValues.getKeysByValue(value);
|
||||
return result != null ? result : Collections.<JetElement>emptyList();
|
||||
public List<? extends KtElement> getValueElements(@Nullable PseudoValue value) {
|
||||
List<? extends KtElement> result = elementsToValues.getKeysByValue(value);
|
||||
return result != null ? result : Collections.<KtElement>emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -291,7 +291,7 @@ public class PseudocodeImpl implements Pseudocode {
|
||||
return sideEffectFree.contains(instruction);
|
||||
}
|
||||
|
||||
/*package*/ void bindElementToValue(@NotNull JetElement element, @NotNull PseudoValue value) {
|
||||
/*package*/ void bindElementToValue(@NotNull KtElement element, @NotNull PseudoValue value) {
|
||||
elementsToValues.put(element, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,15 +27,15 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.WriteValueInstructi
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.VariableDeclarationInstruction;
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -43,7 +43,7 @@ import java.util.Collection;
|
||||
|
||||
public class PseudocodeUtil {
|
||||
@NotNull
|
||||
public static Pseudocode generatePseudocode(@NotNull JetDeclaration declaration, @NotNull final BindingContext bindingContext) {
|
||||
public static Pseudocode generatePseudocode(@NotNull KtDeclaration declaration, @NotNull final BindingContext bindingContext) {
|
||||
BindingTrace mockTrace = new BindingTrace() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -72,12 +72,12 @@ public class PseudocodeUtil {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetType getType(@NotNull JetExpression expression) {
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
return bindingContext.getType(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull JetExpression expression, @Nullable JetType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +89,7 @@ public class PseudocodeUtil {
|
||||
|
||||
@Nullable
|
||||
public static VariableDescriptor extractVariableDescriptorIfAny(@NotNull Instruction instruction, boolean onlyReference, @NotNull BindingContext bindingContext) {
|
||||
JetElement element = null;
|
||||
KtElement element = null;
|
||||
if (instruction instanceof ReadValueInstruction) {
|
||||
element = ((ReadValueInstruction) instruction).getElement();
|
||||
}
|
||||
|
||||
@@ -19,39 +19,39 @@ package org.jetbrains.kotlin.cfg.pseudocode
|
||||
import com.intellij.util.SmartFMap
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
|
||||
public interface TypePredicate: (JetType) -> Boolean {
|
||||
override fun invoke(typeToCheck: JetType): Boolean
|
||||
public interface TypePredicate: (KtType) -> Boolean {
|
||||
override fun invoke(typeToCheck: KtType): Boolean
|
||||
}
|
||||
|
||||
public data class SingleType(val targetType: JetType): TypePredicate {
|
||||
override fun invoke(typeToCheck: JetType): Boolean = JetTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||
public data class SingleType(val targetType: KtType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||
override fun toString(): String = targetType.render()
|
||||
}
|
||||
|
||||
public data class AllSubtypes(val upperBound: JetType): TypePredicate {
|
||||
override fun invoke(typeToCheck: JetType): Boolean = JetTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||
public data class AllSubtypes(val upperBound: KtType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||
|
||||
override fun toString(): String = "{<: ${upperBound.render()}}"
|
||||
}
|
||||
|
||||
public data class ForAllTypes(val typeSets: List<TypePredicate>): TypePredicate {
|
||||
override fun invoke(typeToCheck: JetType): Boolean = typeSets.all { it(typeToCheck) }
|
||||
override fun invoke(typeToCheck: KtType): Boolean = typeSets.all { it(typeToCheck) }
|
||||
|
||||
override fun toString(): String = "AND{${typeSets.joinToString(", ")}}"
|
||||
}
|
||||
|
||||
public data class ForSomeType(val typeSets: List<TypePredicate>): TypePredicate {
|
||||
override fun invoke(typeToCheck: JetType): Boolean = typeSets.any { it(typeToCheck) }
|
||||
override fun invoke(typeToCheck: KtType): Boolean = typeSets.any { it(typeToCheck) }
|
||||
|
||||
override fun toString(): String = "OR{${typeSets.joinToString(", ")}}"
|
||||
}
|
||||
|
||||
public object AllTypes : TypePredicate {
|
||||
override fun invoke(typeToCheck: JetType): Boolean = true
|
||||
override fun invoke(typeToCheck: KtType): Boolean = true
|
||||
|
||||
override fun toString(): String = "*"
|
||||
}
|
||||
@@ -71,16 +71,16 @@ public fun or(predicates: Collection<TypePredicate>): TypePredicate? =
|
||||
else -> ForSomeType(predicates.toList())
|
||||
}
|
||||
|
||||
fun JetType.getSubtypesPredicate(): TypePredicate {
|
||||
fun KtType.getSubtypesPredicate(): TypePredicate {
|
||||
return when {
|
||||
KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes
|
||||
TypeUtils.canHaveSubtypes(JetTypeChecker.DEFAULT, this) -> AllSubtypes(this)
|
||||
TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, this) -> AllSubtypes(this)
|
||||
else -> SingleType(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun JetType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
private fun KtType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
|
||||
public fun <T> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
|
||||
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key -> map.plus(key, this) }
|
||||
|
||||
+2
-2
@@ -16,11 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
|
||||
public abstract class InstructionWithNext(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope
|
||||
) : JetElementInstructionImpl(element, lexicalScope) {
|
||||
public var next: Instruction? = null
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
public interface JetElementInstruction : Instruction {
|
||||
public val element: JetElement
|
||||
public val element: KtElement
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
public abstract class JetElementInstructionImpl(
|
||||
override val element: JetElement,
|
||||
override val element: KtElement,
|
||||
lexicalScope: LexicalScope
|
||||
) : InstructionImpl(lexicalScope), JetElementInstruction {
|
||||
protected fun render(element: PsiElement): String =
|
||||
|
||||
+4
-4
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
public class LexicalScope(val parentScope: LexicalScope?, val element: JetElement) {
|
||||
public class LexicalScope(val parentScope: LexicalScope?, val element: KtElement) {
|
||||
//todo remove after KT-4126
|
||||
private val d = (parentScope?.depth ?: 0) + 1
|
||||
val depth: Int get() = d
|
||||
@@ -27,7 +27,7 @@ public class LexicalScope(val parentScope: LexicalScope?, val element: JetElemen
|
||||
val lexicalScopeForContainingDeclaration: LexicalScope? by lazy {
|
||||
var scope: LexicalScope? = this
|
||||
while (scope != null) {
|
||||
if (scope.element is JetDeclaration) {
|
||||
if (scope.element is KtDeclaration) {
|
||||
return@lazy scope
|
||||
}
|
||||
scope = scope.parentScope
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.eval
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionWithNext
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
|
||||
public class LoadUnitValueInstruction(
|
||||
expression: JetExpression,
|
||||
expression: KtExpression,
|
||||
lexicalScope: LexicalScope
|
||||
) : InstructionWithNext(expression, lexicalScope) {
|
||||
override fun accept(visitor: InstructionVisitor) {
|
||||
@@ -39,5 +39,5 @@ public class LoadUnitValueInstruction(
|
||||
"read (Unit)"
|
||||
|
||||
override fun createCopy(): InstructionImpl =
|
||||
LoadUnitValueInstruction(element as JetExpression, lexicalScope)
|
||||
LoadUnitValueInstruction(element as KtExpression, lexicalScope)
|
||||
}
|
||||
|
||||
+8
-8
@@ -20,8 +20,8 @@ import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValueFactory
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.*
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetNamedDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
@@ -40,21 +40,21 @@ public sealed class AccessTarget {
|
||||
}
|
||||
|
||||
public abstract class AccessValueInstruction protected constructor(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
public val target: AccessTarget,
|
||||
override val receiverValues: Map<PseudoValue, ReceiverValue>
|
||||
) : InstructionWithNext(element, lexicalScope), InstructionWithReceivers
|
||||
|
||||
public class ReadValueInstruction private constructor(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
target: AccessTarget,
|
||||
receiverValues: Map<PseudoValue, ReceiverValue>,
|
||||
private var _outputValue: PseudoValue?
|
||||
) : AccessValueInstruction(element, lexicalScope, target, receiverValues), InstructionWithValue {
|
||||
public constructor(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
target: AccessTarget,
|
||||
receiverValues: Map<PseudoValue, ReceiverValue>,
|
||||
@@ -95,11 +95,11 @@ public class ReadValueInstruction private constructor(
|
||||
}
|
||||
|
||||
public class WriteValueInstruction(
|
||||
assignment: JetElement,
|
||||
assignment: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
target: AccessTarget,
|
||||
receiverValues: Map<PseudoValue, ReceiverValue>,
|
||||
public val lValue: JetElement,
|
||||
public val lValue: KtElement,
|
||||
public val rValue: PseudoValue
|
||||
) : AccessValueInstruction(assignment, lexicalScope, target, receiverValues) {
|
||||
override val inputValues: List<PseudoValue>
|
||||
@@ -114,7 +114,7 @@ public class WriteValueInstruction(
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val lhs = (lValue as? JetNamedDeclaration)?.getName() ?: render(lValue)
|
||||
val lhs = (lValue as? KtNamedDeclaration)?.getName() ?: render(lValue)
|
||||
return "w($lhs|${inputValues.joinToString(", ")})"
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -24,12 +24,12 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionWithNext
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
public abstract class OperationInstruction protected constructor(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
override val inputValues: List<PseudoValue>
|
||||
) : InstructionWithNext(element, lexicalScope), InstructionWithValue {
|
||||
@@ -48,20 +48,20 @@ public abstract class OperationInstruction protected constructor(
|
||||
return this
|
||||
}
|
||||
|
||||
protected fun setResult(factory: PseudoValueFactory?, valueElement: JetElement? = element): OperationInstruction {
|
||||
protected fun setResult(factory: PseudoValueFactory?, valueElement: KtElement? = element): OperationInstruction {
|
||||
return setResult(factory?.newValue(valueElement, this))
|
||||
}
|
||||
}
|
||||
|
||||
public class CallInstruction private constructor(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
val resolvedCall: ResolvedCall<*>,
|
||||
override val receiverValues: Map<PseudoValue, ReceiverValue>,
|
||||
public val arguments: Map<PseudoValue, ValueParameterDescriptor>
|
||||
) : OperationInstruction(element, lexicalScope, (receiverValues.keySet() as Collection<PseudoValue>) + arguments.keySet()), InstructionWithReceivers {
|
||||
public constructor (
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
resolvedCall: ResolvedCall<*>,
|
||||
receiverValues: Map<PseudoValue, ReceiverValue>,
|
||||
@@ -92,14 +92,14 @@ public class CallInstruction private constructor(
|
||||
// denote value transformation which can't be expressed by other instructions (such as call or read)
|
||||
// pass more than one value to instruction which formally requires only one (e.g. jump)
|
||||
public class MagicInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
inputValues: List<PseudoValue>,
|
||||
val kind: MagicKind
|
||||
) : OperationInstruction(element, lexicalScope, inputValues) {
|
||||
public constructor (
|
||||
element: JetElement,
|
||||
valueElement: JetElement?,
|
||||
element: KtElement,
|
||||
valueElement: KtElement?,
|
||||
lexicalScope: LexicalScope,
|
||||
inputValues: List<PseudoValue>,
|
||||
kind: MagicKind,
|
||||
@@ -146,12 +146,12 @@ public enum class MagicKind(val sideEffectFree: Boolean = false) {
|
||||
|
||||
// Merges values produced by alternative control-flow paths (such as 'if' branches)
|
||||
class MergeInstruction private constructor(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
inputValues: List<PseudoValue>
|
||||
): OperationInstruction(element, lexicalScope, inputValues) {
|
||||
public constructor (
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
inputValues: List<PseudoValue>,
|
||||
factory: PseudoValueFactory
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.JetElementInstructionImpl
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction
|
||||
import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
|
||||
public abstract class AbstractJumpInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
public val targetLabel: Label,
|
||||
lexicalScope: LexicalScope
|
||||
) : JetElementInstructionImpl(element, lexicalScope), JumpInstruction {
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
import java.util.Arrays
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
|
||||
public class ConditionalJumpInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
public val onTrue: Boolean,
|
||||
lexicalScope: LexicalScope,
|
||||
targetLabel: Label,
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
import com.google.common.collect.Maps
|
||||
import com.google.common.collect.Lists
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
|
||||
public class NondeterministicJumpInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
targetLabels: List<Label>,
|
||||
lexicalScope: LexicalScope,
|
||||
public val inputValue: PseudoValue?
|
||||
|
||||
+2
-2
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
|
||||
public class ReturnNoValueInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
targetLabel: Label
|
||||
) : AbstractJumpInstruction(element, targetLabel, lexicalScope) {
|
||||
|
||||
+5
-5
@@ -17,16 +17,16 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
import java.util.Collections
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
import org.jetbrains.kotlin.psi.JetReturnExpression
|
||||
import org.jetbrains.kotlin.psi.KtReturnExpression
|
||||
|
||||
public class ReturnValueInstruction(
|
||||
returnExpression: JetExpression,
|
||||
returnExpression: KtExpression,
|
||||
lexicalScope: LexicalScope,
|
||||
targetLabel: Label,
|
||||
public val returnedValue: PseudoValue
|
||||
@@ -46,8 +46,8 @@ public class ReturnValueInstruction(
|
||||
}
|
||||
|
||||
override fun createCopy(newLabel: Label, lexicalScope: LexicalScope): AbstractJumpInstruction {
|
||||
return ReturnValueInstruction((element as JetExpression), lexicalScope, newLabel, returnedValue)
|
||||
return ReturnValueInstruction((element as KtExpression), lexicalScope, newLabel, returnedValue)
|
||||
}
|
||||
|
||||
public val returnExpressionIfAny: JetReturnExpression? = element as? JetReturnExpression
|
||||
public val returnExpressionIfAny: KtReturnExpression? = element as? KtReturnExpression
|
||||
}
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||
import org.jetbrains.kotlin.psi.JetThrowExpression
|
||||
import org.jetbrains.kotlin.psi.KtThrowExpression
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
import java.util.Collections
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
|
||||
public class ThrowExceptionInstruction(
|
||||
expression: JetThrowExpression,
|
||||
expression: KtThrowExpression,
|
||||
lexicalScope: LexicalScope,
|
||||
errorLabel: Label,
|
||||
public val thrownValue: PseudoValue
|
||||
@@ -45,6 +45,6 @@ public class ThrowExceptionInstruction(
|
||||
}
|
||||
|
||||
override fun createCopy(newLabel: Label, lexicalScope: LexicalScope): AbstractJumpInstruction {
|
||||
return ThrowExceptionInstruction((element as JetThrowExpression), lexicalScope, newLabel, thrownValue)
|
||||
return ThrowExceptionInstruction((element as KtThrowExpression), lexicalScope, newLabel, thrownValue)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,11 +17,11 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps
|
||||
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.*
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.Label
|
||||
|
||||
public class UnconditionalJumpInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
targetLabel: Label,
|
||||
lexicalScope: LexicalScope
|
||||
) : AbstractJumpInstruction(element, targetLabel, lexicalScope) {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.special
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode
|
||||
import com.google.common.collect.Lists
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
|
||||
public class LocalFunctionDeclarationInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
public val body: Pseudocode,
|
||||
lexicalScope: LexicalScope
|
||||
) : InstructionWithNext(element, lexicalScope) {
|
||||
|
||||
+2
-2
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.special
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionWithNext
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
|
||||
public class MarkInstruction(
|
||||
element: JetElement,
|
||||
element: KtElement,
|
||||
lexicalScope: LexicalScope
|
||||
) : InstructionWithNext(element, lexicalScope) {
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.special
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionWithNext
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
|
||||
public class SubroutineEnterInstruction(
|
||||
public val subroutine: JetElement,
|
||||
public val subroutine: KtElement,
|
||||
lexicalScope: LexicalScope
|
||||
) : InstructionWithNext(subroutine, lexicalScope) {
|
||||
override fun accept(visitor: InstructionVisitor) {
|
||||
|
||||
+2
-2
@@ -17,11 +17,11 @@
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.special
|
||||
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.*
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import java.util.*
|
||||
|
||||
public class SubroutineExitInstruction(
|
||||
public val subroutine: JetElement,
|
||||
public val subroutine: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
public val isError: Boolean
|
||||
) : InstructionImpl(lexicalScope) {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.special
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import java.util.Collections
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
|
||||
public class SubroutineSinkInstruction(
|
||||
public val subroutine: JetElement,
|
||||
public val subroutine: KtElement,
|
||||
lexicalScope: LexicalScope,
|
||||
private val debugLabel: String) : InstructionImpl(lexicalScope) {
|
||||
override val nextInstructions: Collection<Instruction>
|
||||
|
||||
+7
-7
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.special
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetVariableDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetParameter
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtVariableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionWithNext
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
@@ -26,15 +26,15 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
|
||||
public class VariableDeclarationInstruction(
|
||||
element: JetDeclaration,
|
||||
element: KtDeclaration,
|
||||
lexicalScope: LexicalScope
|
||||
) : InstructionWithNext(element, lexicalScope) {
|
||||
init {
|
||||
assert(element is JetVariableDeclaration || element is JetParameter) { "Invalid element: ${render(element)}}" }
|
||||
assert(element is KtVariableDeclaration || element is KtParameter) { "Invalid element: ${render(element)}}" }
|
||||
}
|
||||
|
||||
public val variableDeclarationElement: JetDeclaration
|
||||
get() = element as JetDeclaration
|
||||
public val variableDeclarationElement: KtDeclaration
|
||||
get() = element as KtDeclaration
|
||||
|
||||
override fun accept(visitor: InstructionVisitor) {
|
||||
visitor.visitVariableDeclarationInstruction(this)
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.util.*
|
||||
|
||||
@@ -77,14 +77,14 @@ public fun getExpectedTypePredicate(
|
||||
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
||||
val typePredicates = LinkedHashSet<TypePredicate?>()
|
||||
|
||||
fun addSubtypesOf(jetType: JetType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
fun addSubtypesOf(jetType: KtType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
|
||||
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
||||
val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue()
|
||||
if (receiverValue.exists()) typePredicates.add(getReceiverTypePredicate(resolvedCall, receiverValue))
|
||||
}
|
||||
|
||||
fun getTypePredicateForUnresolvedCallArgument(to: JetElement, inputValueIndex: Int): TypePredicate? {
|
||||
fun getTypePredicateForUnresolvedCallArgument(to: KtElement, inputValueIndex: Int): TypePredicate? {
|
||||
if (inputValueIndex < 0) return null
|
||||
val call = to.getCall(bindingContext) ?: return null
|
||||
val callee = call.getCalleeExpression() ?: return null
|
||||
@@ -147,7 +147,7 @@ public fun getExpectedTypePredicate(
|
||||
is ReturnValueInstruction -> {
|
||||
val returnElement = it.element
|
||||
val functionDescriptor = when(returnElement) {
|
||||
is JetReturnExpression -> returnElement.getTargetFunctionDescriptor(bindingContext)
|
||||
is KtReturnExpression -> returnElement.getTargetFunctionDescriptor(bindingContext)
|
||||
else -> bindingContext[DECLARATION_TO_DESCRIPTOR, pseudocode.getCorrespondingElement()]
|
||||
}
|
||||
addSubtypesOf((functionDescriptor as? CallableDescriptor)?.getReturnType())
|
||||
@@ -204,22 +204,22 @@ public fun getExpectedTypePredicate(
|
||||
addSubtypesOf(builtIns.getBooleanType())
|
||||
|
||||
LOOP_RANGE_ITERATION ->
|
||||
addByExplicitReceiver(bindingContext[LOOP_RANGE_ITERATOR_RESOLVED_CALL, value.element as? JetExpression])
|
||||
addByExplicitReceiver(bindingContext[LOOP_RANGE_ITERATOR_RESOLVED_CALL, value.element as? KtExpression])
|
||||
|
||||
VALUE_CONSUMER -> {
|
||||
val element = it.element
|
||||
when {
|
||||
element.getStrictParentOfType<JetWhileExpression>()?.getCondition() == element ->
|
||||
element.getStrictParentOfType<KtWhileExpression>()?.getCondition() == element ->
|
||||
addSubtypesOf(builtIns.getBooleanType())
|
||||
|
||||
element is JetProperty -> {
|
||||
element is KtProperty -> {
|
||||
val propertyDescriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, element] as? PropertyDescriptor
|
||||
propertyDescriptor?.getAccessors()?.map {
|
||||
addByExplicitReceiver(bindingContext[DELEGATED_PROPERTY_RESOLVED_CALL, it])
|
||||
}
|
||||
}
|
||||
|
||||
element is JetDelegatorByExpressionSpecifier ->
|
||||
element is KtDelegatorByExpressionSpecifier ->
|
||||
addSubtypesOf(bindingContext[TYPE, element.getTypeReference()])
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ fun Instruction.calcSideEffectFree(): Boolean {
|
||||
}
|
||||
|
||||
else -> when (element) {
|
||||
is JetConstantExpression, is JetFunctionLiteralExpression, is JetStringTemplateExpression -> true
|
||||
is KtConstantExpression, is KtFunctionLiteralExpression, is KtStringTemplateExpression -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ fun Instruction.calcSideEffectFree(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
fun Pseudocode.getElementValuesRecursively(element: JetElement): List<PseudoValue> {
|
||||
fun Pseudocode.getElementValuesRecursively(element: KtElement): List<PseudoValue> {
|
||||
val results = ArrayList<PseudoValue>()
|
||||
|
||||
fun Pseudocode.collectValues() {
|
||||
@@ -286,14 +286,14 @@ fun Pseudocode.getElementValuesRecursively(element: JetElement): List<PseudoValu
|
||||
return results
|
||||
}
|
||||
|
||||
public fun JetElement.getContainingPseudocode(context: BindingContext): Pseudocode? {
|
||||
public fun KtElement.getContainingPseudocode(context: BindingContext): Pseudocode? {
|
||||
val pseudocodeDeclaration =
|
||||
PsiTreeUtil.getParentOfType(this, javaClass<JetDeclarationWithBody>(), javaClass<JetClassOrObject>())
|
||||
?: getNonStrictParentOfType<JetProperty>()
|
||||
PsiTreeUtil.getParentOfType(this, javaClass<KtDeclarationWithBody>(), javaClass<KtClassOrObject>())
|
||||
?: getNonStrictParentOfType<KtProperty>()
|
||||
?: return null
|
||||
|
||||
val enclosingPseudocodeDeclaration = (pseudocodeDeclaration as? JetFunctionLiteral)?.let {
|
||||
it.parents.firstOrNull { it is JetDeclaration && it !is JetFunctionLiteral } as? JetDeclaration
|
||||
val enclosingPseudocodeDeclaration = (pseudocodeDeclaration as? KtFunctionLiteral)?.let {
|
||||
it.parents.firstOrNull { it is KtDeclaration && it !is KtFunctionLiteral } as? KtDeclaration
|
||||
} ?: pseudocodeDeclaration
|
||||
|
||||
val enclosingPseudocode = PseudocodeUtil.generatePseudocode(enclosingPseudocodeDeclaration, context)
|
||||
@@ -301,7 +301,7 @@ public fun JetElement.getContainingPseudocode(context: BindingContext): Pseudoco
|
||||
?: throw AssertionError("Can't find nested pseudocode for element: ${pseudocodeDeclaration.getElementTextWithContext()}")
|
||||
}
|
||||
|
||||
public fun Pseudocode.getPseudocodeByElement(element: JetElement): Pseudocode? {
|
||||
public fun Pseudocode.getPseudocodeByElement(element: KtElement): Pseudocode? {
|
||||
if (getCorrespondingElement() == element) return this
|
||||
|
||||
getLocalDeclarations().forEach { decl -> decl.body.getPseudocodeByElement(element)?.let { return it } }
|
||||
|
||||
@@ -39,9 +39,9 @@ import org.jetbrains.kotlin.diagnostics.Severity;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.AbstractDiagnosticWithParametersRenderer;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages;
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.psi.JetReferenceExpression;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.psi.KtReferenceExpression;
|
||||
import org.jetbrains.kotlin.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
|
||||
@@ -119,22 +119,22 @@ public class CheckerTestUtil {
|
||||
final List<Diagnostic> debugAnnotations = Lists.newArrayList();
|
||||
DebugInfoUtil.markDebugAnnotations(root, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
|
||||
@Override
|
||||
public void reportElementWithErrorType(@NotNull JetReferenceExpression expression) {
|
||||
public void reportElementWithErrorType(@NotNull KtReferenceExpression expression) {
|
||||
newDiagnostic(expression, DebugInfoDiagnosticFactory.ELEMENT_WITH_ERROR_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportMissingUnresolved(@NotNull JetReferenceExpression expression) {
|
||||
public void reportMissingUnresolved(@NotNull KtReferenceExpression expression) {
|
||||
newDiagnostic(expression, DebugInfoDiagnosticFactory.MISSING_UNRESOLVED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportUnresolvedWithTarget(@NotNull JetReferenceExpression expression, @NotNull String target) {
|
||||
public void reportUnresolvedWithTarget(@NotNull KtReferenceExpression expression, @NotNull String target) {
|
||||
newDiagnostic(expression, DebugInfoDiagnosticFactory.UNRESOLVED_WITH_TARGET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportDynamicCall(@NotNull JetElement element, DeclarationDescriptor declarationDescriptor) {
|
||||
public void reportDynamicCall(@NotNull KtElement element, DeclarationDescriptor declarationDescriptor) {
|
||||
if (dynamicCallDescriptors != null) {
|
||||
dynamicCallDescriptors.add(declarationDescriptor);
|
||||
}
|
||||
@@ -144,13 +144,13 @@ public class CheckerTestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private void newDiagnostic(JetElement element, DebugInfoDiagnosticFactory factory) {
|
||||
private void newDiagnostic(KtElement element, DebugInfoDiagnosticFactory factory) {
|
||||
debugAnnotations.add(new DebugInfoDiagnostic(element, factory));
|
||||
}
|
||||
});
|
||||
// this code is used in tests and in internal action 'copy current file as diagnostic test'
|
||||
//noinspection TestOnlyProblems
|
||||
for (JetExpression expression : bindingContext.getSliceContents(BindingContext.SMARTCAST).keySet()) {
|
||||
for (KtExpression expression : bindingContext.getSliceContents(BindingContext.SMARTCAST).keySet()) {
|
||||
if (PsiTreeUtil.isAncestor(root, expression, false)) {
|
||||
debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.SMARTCAST));
|
||||
}
|
||||
@@ -533,7 +533,7 @@ public class CheckerTestUtil {
|
||||
}
|
||||
|
||||
public static class DebugInfoDiagnostic extends AbstractDiagnosticForTests {
|
||||
public DebugInfoDiagnostic(@NotNull JetElement element, @NotNull DebugInfoDiagnosticFactory factory) {
|
||||
public DebugInfoDiagnostic(@NotNull KtElement element, @NotNull DebugInfoDiagnosticFactory factory) {
|
||||
super(element, factory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||
@@ -38,13 +38,13 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.*;
|
||||
|
||||
public class DebugInfoUtil {
|
||||
@@ -54,17 +54,17 @@ public class DebugInfoUtil {
|
||||
|
||||
public abstract static class DebugInfoReporter {
|
||||
|
||||
public void preProcessReference(@NotNull JetReferenceExpression expression) {
|
||||
public void preProcessReference(@NotNull KtReferenceExpression expression) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public abstract void reportElementWithErrorType(@NotNull JetReferenceExpression expression);
|
||||
public abstract void reportElementWithErrorType(@NotNull KtReferenceExpression expression);
|
||||
|
||||
public abstract void reportMissingUnresolved(@NotNull JetReferenceExpression expression);
|
||||
public abstract void reportMissingUnresolved(@NotNull KtReferenceExpression expression);
|
||||
|
||||
public abstract void reportUnresolvedWithTarget(@NotNull JetReferenceExpression expression, @NotNull String target);
|
||||
public abstract void reportUnresolvedWithTarget(@NotNull KtReferenceExpression expression, @NotNull String target);
|
||||
|
||||
public void reportDynamicCall(@NotNull JetElement element, DeclarationDescriptor declarationDescriptor) { }
|
||||
public void reportDynamicCall(@NotNull KtElement element, DeclarationDescriptor declarationDescriptor) { }
|
||||
}
|
||||
|
||||
public static void markDebugAnnotations(
|
||||
@@ -72,33 +72,33 @@ public class DebugInfoUtil {
|
||||
@NotNull final BindingContext bindingContext,
|
||||
@NotNull final DebugInfoReporter debugInfoReporter
|
||||
) {
|
||||
final Map<JetReferenceExpression, DiagnosticFactory<?>> markedWithErrorElements = Maps.newHashMap();
|
||||
final Map<KtReferenceExpression, DiagnosticFactory<?>> markedWithErrorElements = Maps.newHashMap();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
DiagnosticFactory<?> factory = diagnostic.getFactory();
|
||||
if (Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS.contains(diagnostic.getFactory())) {
|
||||
markedWithErrorElements.put((JetReferenceExpression) diagnostic.getPsiElement(), factory);
|
||||
markedWithErrorElements.put((KtReferenceExpression) diagnostic.getPsiElement(), factory);
|
||||
}
|
||||
else if (factory == Errors.SUPER_IS_NOT_AN_EXPRESSION
|
||||
|| factory == Errors.SUPER_NOT_AVAILABLE) {
|
||||
JetSuperExpression superExpression = (JetSuperExpression) diagnostic.getPsiElement();
|
||||
KtSuperExpression superExpression = (KtSuperExpression) diagnostic.getPsiElement();
|
||||
markedWithErrorElements.put(superExpression.getInstanceReference(), factory);
|
||||
}
|
||||
else if (factory == Errors.EXPRESSION_EXPECTED_PACKAGE_FOUND) {
|
||||
markedWithErrorElements.put((JetSimpleNameExpression) diagnostic.getPsiElement(), factory);
|
||||
markedWithErrorElements.put((KtSimpleNameExpression) diagnostic.getPsiElement(), factory);
|
||||
}
|
||||
else if (factory == Errors.UNSUPPORTED) {
|
||||
for (JetReferenceExpression reference : PsiTreeUtil.findChildrenOfType(diagnostic.getPsiElement(),
|
||||
JetReferenceExpression.class)) {
|
||||
for (KtReferenceExpression reference : PsiTreeUtil.findChildrenOfType(diagnostic.getPsiElement(),
|
||||
KtReferenceExpression.class)) {
|
||||
markedWithErrorElements.put(reference, factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root.acceptChildren(new JetTreeVisitorVoid() {
|
||||
root.acceptChildren(new KtTreeVisitorVoid() {
|
||||
|
||||
@Override
|
||||
public void visitForExpression(@NotNull JetForExpression expression) {
|
||||
JetExpression range = expression.getLoopRange();
|
||||
public void visitForExpression(@NotNull KtForExpression expression) {
|
||||
KtExpression range = expression.getLoopRange();
|
||||
reportIfDynamicCall(range, range, LOOP_RANGE_ITERATOR_RESOLVED_CALL);
|
||||
reportIfDynamicCall(range, range, LOOP_RANGE_HAS_NEXT_RESOLVED_CALL);
|
||||
reportIfDynamicCall(range, range, LOOP_RANGE_NEXT_RESOLVED_CALL);
|
||||
@@ -106,15 +106,15 @@ public class DebugInfoUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMultiDeclaration(@NotNull JetMultiDeclaration multiDeclaration) {
|
||||
for (JetMultiDeclarationEntry entry : multiDeclaration.getEntries()) {
|
||||
public void visitMultiDeclaration(@NotNull KtMultiDeclaration multiDeclaration) {
|
||||
for (KtMultiDeclarationEntry entry : multiDeclaration.getEntries()) {
|
||||
reportIfDynamicCall(entry, entry, COMPONENT_RESOLVED_CALL);
|
||||
}
|
||||
super.visitMultiDeclaration(multiDeclaration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitProperty(@NotNull JetProperty property) {
|
||||
public void visitProperty(@NotNull KtProperty property) {
|
||||
VariableDescriptor descriptor = bindingContext.get(VARIABLE, property);
|
||||
if (descriptor instanceof PropertyDescriptor && property.getDelegate() != null) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||
@@ -126,7 +126,7 @@ public class DebugInfoUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThisExpression(@NotNull JetThisExpression expression) {
|
||||
public void visitThisExpression(@NotNull KtThisExpression expression) {
|
||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = CallUtilKt.getResolvedCall(expression, bindingContext);
|
||||
if (resolvedCall != null) {
|
||||
reportIfDynamic(expression, resolvedCall.getResultingDescriptor(), debugInfoReporter);
|
||||
@@ -135,23 +135,23 @@ public class DebugInfoUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(@NotNull JetReferenceExpression expression) {
|
||||
public void visitReferenceExpression(@NotNull KtReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
if (!BindingContextUtils.isExpressionWithValidReference(expression, bindingContext)){
|
||||
return;
|
||||
}
|
||||
IElementType referencedNameElementType = null;
|
||||
if (expression instanceof JetSimpleNameExpression) {
|
||||
JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) expression;
|
||||
if (expression instanceof KtSimpleNameExpression) {
|
||||
KtSimpleNameExpression nameExpression = (KtSimpleNameExpression) expression;
|
||||
IElementType elementType = expression.getNode().getElementType();
|
||||
if (elementType == JetNodeTypes.OPERATION_REFERENCE) {
|
||||
if (elementType == KtNodeTypes.OPERATION_REFERENCE) {
|
||||
referencedNameElementType = nameExpression.getReferencedNameElementType();
|
||||
if (EXCLUDED.contains(referencedNameElementType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (elementType == JetNodeTypes.LABEL ||
|
||||
nameExpression.getReferencedNameElementType() == JetTokens.THIS_KEYWORD) {
|
||||
if (elementType == KtNodeTypes.LABEL ||
|
||||
nameExpression.getReferencedNameElementType() == KtTokens.THIS_KEYWORD) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -191,12 +191,12 @@ public class DebugInfoUtil {
|
||||
|
||||
boolean resolved = target != null;
|
||||
boolean markedWithError = markedWithErrorElements.containsKey(expression);
|
||||
if (expression instanceof JetArrayAccessExpression &&
|
||||
markedWithErrorElements.containsKey(((JetArrayAccessExpression) expression).getArrayExpression())) {
|
||||
if (expression instanceof KtArrayAccessExpression &&
|
||||
markedWithErrorElements.containsKey(((KtArrayAccessExpression) expression).getArrayExpression())) {
|
||||
// if 'foo' in 'foo[i]' is unresolved it means 'foo[i]' is unresolved (otherwise 'foo[i]' is marked as 'missing unresolved')
|
||||
markedWithError = true;
|
||||
}
|
||||
JetType expressionType = bindingContext.getType(expression);
|
||||
KtType expressionType = bindingContext.getType(expression);
|
||||
DiagnosticFactory<?> factory = markedWithErrorElements.get(expression);
|
||||
if (declarationDescriptor != null &&
|
||||
(ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) {
|
||||
@@ -214,7 +214,7 @@ public class DebugInfoUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private <E extends JetElement, K, D extends CallableDescriptor> boolean reportIfDynamicCall(E element, K key, WritableSlice<K, ResolvedCall<D>> slice) {
|
||||
private <E extends KtElement, K, D extends CallableDescriptor> boolean reportIfDynamicCall(E element, K key, WritableSlice<K, ResolvedCall<D>> slice) {
|
||||
ResolvedCall<D> resolvedCall = bindingContext.get(slice, key);
|
||||
if (resolvedCall != null) {
|
||||
return reportIfDynamic(element, resolvedCall.getResultingDescriptor(), debugInfoReporter);
|
||||
@@ -224,7 +224,7 @@ public class DebugInfoUtil {
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean reportIfDynamic(JetElement element, DeclarationDescriptor declarationDescriptor, DebugInfoReporter debugInfoReporter) {
|
||||
private static boolean reportIfDynamic(KtElement element, DeclarationDescriptor declarationDescriptor, DebugInfoReporter debugInfoReporter) {
|
||||
if (declarationDescriptor != null && DynamicCallsKt.isDynamic(declarationDescriptor)) {
|
||||
debugInfoReporter.reportDynamicCall(element, declarationDescriptor);
|
||||
return true;
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public class LocalVariableDescriptor extends VariableDescriptorWithInitializerImpl {
|
||||
@@ -29,7 +29,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable JetType type,
|
||||
@Nullable KtType type,
|
||||
boolean mutable,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors.impl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.kotlin.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.WritableScopeImpl;
|
||||
@@ -30,7 +30,7 @@ public class MutablePackageFragmentDescriptor extends PackageFragmentDescriptorI
|
||||
public MutablePackageFragmentDescriptor(@NotNull ModuleDescriptor module, @NotNull FqName fqName) {
|
||||
super(module, fqName);
|
||||
|
||||
scope = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, RedeclarationHandler.DO_NOTHING, "Members of " + fqName + " in " + module);
|
||||
scope = new WritableScopeImpl(KtScope.Empty.INSTANCE$, this, RedeclarationHandler.DO_NOTHING, "Members of " + fqName + " in " + module);
|
||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -21,18 +21,18 @@ import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetProperty
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
|
||||
class SyntheticFieldDescriptor private constructor(
|
||||
val propertyDescriptor: PropertyDescriptor,
|
||||
accessorDescriptor: PropertyAccessorDescriptor,
|
||||
property: JetProperty
|
||||
property: KtProperty
|
||||
): LocalVariableDescriptor(accessorDescriptor, Annotations.EMPTY, SyntheticFieldDescriptor.NAME,
|
||||
propertyDescriptor.type, propertyDescriptor.isVar, property.toSourceElement()) {
|
||||
|
||||
constructor(accessorDescriptor: PropertyAccessorDescriptor,
|
||||
property: JetProperty): this(accessorDescriptor.correspondingProperty, accessorDescriptor, property)
|
||||
property: KtProperty): this(accessorDescriptor.correspondingProperty, accessorDescriptor, property)
|
||||
|
||||
override fun getDispatchReceiverParameter() = propertyDescriptor.dispatchReceiverParameter
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DiagnosticUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String atLocation(JetExpression expression) {
|
||||
public static String atLocation(KtExpression expression) {
|
||||
return atLocation(expression.getNode());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,15 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.lexer.JetKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -63,25 +63,25 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory1<PsiElement, String> REDECLARATION = DiagnosticFactory1.create(ERROR, FOR_REDECLARATION);
|
||||
|
||||
DiagnosticFactory1<JetReferenceExpression, JetReferenceExpression> UNRESOLVED_REFERENCE =
|
||||
DiagnosticFactory1<KtReferenceExpression, KtReferenceExpression> UNRESOLVED_REFERENCE =
|
||||
DiagnosticFactory1.create(ERROR, FOR_UNRESOLVED_REFERENCE);
|
||||
|
||||
//Elements with "INVISIBLE_REFERENCE" error are marked as unresolved, unlike elements with "INVISIBLE_MEMBER" error
|
||||
//"INVISIBLE_REFERENCE" is used for invisible classes references and references in import
|
||||
DiagnosticFactory3<JetSimpleNameExpression, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_REFERENCE =
|
||||
DiagnosticFactory3<KtSimpleNameExpression, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_REFERENCE =
|
||||
DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_MEMBER = DiagnosticFactory3.create(ERROR, CALL_ELEMENT);
|
||||
|
||||
// Exposed visibility group
|
||||
DiagnosticFactory2<JetProperty, EffectiveVisibility, EffectiveVisibility> EXPOSED_PROPERTY_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtProperty, EffectiveVisibility, EffectiveVisibility> EXPOSED_PROPERTY_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, EffectiveVisibility, EffectiveVisibility> EXPOSED_FUNCTION_RETURN_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_PARAMETER_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetTypeReference, EffectiveVisibility, EffectiveVisibility> EXPOSED_RECEIVER_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetTypeParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_TYPE_PARAMETER_BOUND = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_CLASS = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_INTERFACE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_PARAMETER_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtTypeReference, EffectiveVisibility, EffectiveVisibility> EXPOSED_RECEIVER_TYPE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtTypeParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_TYPE_PARAMETER_BOUND = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_CLASS = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_INTERFACE = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<JetElement, Collection<ClassDescriptor>> PLATFORM_CLASS_MAPPED_TO_KOTLIN = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtElement, Collection<ClassDescriptor>> PLATFORM_CLASS_MAPPED_TO_KOTLIN = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -90,13 +90,13 @@ public interface Errors {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DiagnosticFactory0<JetTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<JetNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<JetElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<JetTypeProjection, ClassifierDescriptor> CONFLICTING_PROJECTION = DiagnosticFactory1.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory1<JetTypeProjection, ClassifierDescriptor> REDUNDANT_PROJECTION = DiagnosticFactory1.create(WARNING, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory0<KtTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtTypeProjection, ClassifierDescriptor> CONFLICTING_PROJECTION = DiagnosticFactory1.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory1<KtTypeProjection, ClassifierDescriptor> REDUNDANT_PROJECTION = DiagnosticFactory1.create(WARNING, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory1<PsiElement, VarianceConflictDiagnosticData> TYPE_VARIANCE_CONFLICT =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
|
||||
@@ -108,51 +108,51 @@ public interface Errors {
|
||||
|
||||
// Imports
|
||||
|
||||
DiagnosticFactory1<JetSimpleNameExpression, ClassDescriptor> CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetSimpleNameExpression, Name> CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> PACKAGE_CANNOT_BE_IMPORTED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, ClassDescriptor> CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, Name> CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> PACKAGE_CANNOT_BE_IMPORTED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetImportDirective, String> CONFLICTING_IMPORT = DiagnosticFactory1.create(ERROR, PositioningStrategies.IMPORT_ALIAS);
|
||||
DiagnosticFactory1<KtImportDirective, String> CONFLICTING_IMPORT = DiagnosticFactory1.create(ERROR, PositioningStrategies.IMPORT_ALIAS);
|
||||
|
||||
// Modifiers
|
||||
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> INCOMPATIBLE_MODIFIERS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> DEPRECATED_MODIFIER_PAIR = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, JetModifierKeywordToken> REPEATED_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, JetModifierKeywordToken> REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, String> WRONG_MODIFIER_TARGET = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, String> REDUNDANT_MODIFIER_FOR_TARGET = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, String> WRONG_MODIFIER_CONTAINING_DECLARATION = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, JetModifierKeywordToken, String> DEPRECATED_MODIFIER_CONTAINING_DECLARATION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, JetModifierKeywordToken> ILLEGAL_INLINE_PARAMETER_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetAnnotationEntry, String> WRONG_ANNOTATION_TARGET = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetAnnotationEntry, String, String> WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<JetAnnotationEntry> REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetAnnotationEntry> NON_SOURCE_ANNOTATION_ON_INLINED_FUNCTION_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, KtModifierKeywordToken> INCOMPATIBLE_MODIFIERS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, KtModifierKeywordToken> DEPRECATED_MODIFIER_PAIR = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KtModifierKeywordToken> REPEATED_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, KtModifierKeywordToken> REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, String> WRONG_MODIFIER_TARGET = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, String> REDUNDANT_MODIFIER_FOR_TARGET = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, String> WRONG_MODIFIER_CONTAINING_DECLARATION = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, KtModifierKeywordToken, String> DEPRECATED_MODIFIER_CONTAINING_DECLARATION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KtModifierKeywordToken> ILLEGAL_INLINE_PARAMETER_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtAnnotationEntry, String> WRONG_ANNOTATION_TARGET = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtAnnotationEntry, String, String> WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> NON_SOURCE_ANNOTATION_ON_INLINED_FUNCTION_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Annotations
|
||||
|
||||
DiagnosticFactory0<JetDelegationSpecifierList> SUPERTYPES_FOR_ANNOTATION_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetParameter> MISSING_VAL_ON_ANNOTATION_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetCallExpression> ANNOTATION_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetAnnotationEntry, DeclarationDescriptor> NOT_AN_ANNOTATION_CLASS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtDelegationSpecifierList> 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);
|
||||
DiagnosticFactory0<PsiElement> ANNOTATION_CLASS_WITH_BODY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> INVALID_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> NULLABLE_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ANNOTATION_PARAMETER_MUST_BE_CONST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> INVALID_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> NULLABLE_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ANNOTATION_PARAMETER_MUST_BE_CONST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Const
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_DELEGATE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITHOUT_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CONST_VAL_WITH_NON_CONST_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CONST_VAL_WITH_NON_CONST_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, String> INAPPLICABLE_TARGET_ON_PROPERTY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_FIELD_TARGET_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
@@ -163,257 +163,257 @@ public interface Errors {
|
||||
|
||||
// Classes and interfaces
|
||||
|
||||
DiagnosticFactory0<JetTypeProjection> PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE =
|
||||
DiagnosticFactory0<KtTypeProjection> PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE =
|
||||
DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
|
||||
DiagnosticFactory0<PsiElement> CYCLIC_INHERITANCE_HIERARCHY = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetDelegatorToSuperClass> SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDelegatorToSuperClass> SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetTypeReference> DELEGATION_NOT_TO_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> DELEGATION_NOT_TO_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> GENERICS_IN_CONTAINING_TYPE_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetTypeReference> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<JetDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<JetType>>
|
||||
DiagnosticFactory0<KtTypeReference> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<KtDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<KtType>>
|
||||
INCONSISTENT_TYPE_PARAMETER_VALUES = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
|
||||
DiagnosticFactory0<JetTypeReference> FINAL_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SINGLETON_IN_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetNullableType> NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE);
|
||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> FINAL_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SINGLETON_IN_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtNullableType> NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetElement> MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Secondary constructors
|
||||
|
||||
DiagnosticFactory0<JetConstructorDelegationReferenceExpression> CYCLIC_CONSTRUCTOR_DELEGATION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstructorDelegationReferenceExpression> CYCLIC_CONSTRUCTOR_DELEGATION_CALL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> CONSTRUCTOR_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDelegatorToSuperCall> SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDeclaration> CONSTRUCTOR_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDelegatorToSuperCall> SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetConstructorDelegationCall> PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED =
|
||||
DiagnosticFactory0<KtConstructorDelegationCall> PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED =
|
||||
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
|
||||
|
||||
DiagnosticFactory0<JetConstructorDelegationReferenceExpression> DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR =
|
||||
DiagnosticFactory0<KtConstructorDelegationReferenceExpression> DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR =
|
||||
DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetConstructorDelegationCall> EXPLICIT_DELEGATION_CALL_REQUIRED =
|
||||
DiagnosticFactory0<KtConstructorDelegationCall> EXPLICIT_DELEGATION_CALL_REQUIRED =
|
||||
DiagnosticFactory0.create(ERROR, PositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL);
|
||||
|
||||
DiagnosticFactory1<PsiElement, DeclarationDescriptor> INSTANCE_ACCESS_BEFORE_SUPER_CALL = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Interface-specific
|
||||
|
||||
DiagnosticFactory0<JetModifierListOwner> ABSTRACT_MODIFIER_IN_INTERFACE = DiagnosticFactory0
|
||||
DiagnosticFactory0<KtModifierListOwner> ABSTRACT_MODIFIER_IN_INTERFACE = DiagnosticFactory0
|
||||
.create(WARNING, ABSTRACT_MODIFIER);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> CONSTRUCTOR_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDeclaration> CONSTRUCTOR_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> SUPERTYPE_INITIALIZED_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetDelegatorByExpressionSpecifier> DELEGATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDelegatorByExpressionSpecifier> DELEGATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> INTERFACE_WITH_SUPERCLASS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Enum-specific
|
||||
|
||||
DiagnosticFactory0<PsiElement> CLASS_IN_SUPERTYPE_FOR_ENUM = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeParameterList> TYPE_PARAMETERS_IN_ENUM = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetClass> ENUM_ENTRY_SHOULD_BE_INITIALIZED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetCallExpression> ENUM_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeParameterList> TYPE_PARAMETERS_IN_ENUM = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtClass> ENUM_ENTRY_SHOULD_BE_INITIALIZED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtCallExpression> ENUM_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Sealed-specific
|
||||
DiagnosticFactory0<JetCallExpression> SEALED_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SEALED_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SEALED_SUPERTYPE_IN_LOCAL_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtCallExpression> SEALED_CLASS_CONSTRUCTOR_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SEALED_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SEALED_SUPERTYPE_IN_LOCAL_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Companion objects
|
||||
|
||||
DiagnosticFactory0<JetObjectDeclaration> MANY_COMPANION_OBJECTS = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
|
||||
DiagnosticFactory0<KtObjectDeclaration> MANY_COMPANION_OBJECTS = DiagnosticFactory0.create(ERROR, COMPANION_OBJECT);
|
||||
|
||||
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, DeclarationDescriptor, String> DEPRECATION_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Objects
|
||||
|
||||
DiagnosticFactory1<JetObjectDeclaration, ClassDescriptor> LOCAL_OBJECT_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory1<JetClass, ClassDescriptor> LOCAL_INTERFACE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory1<KtObjectDeclaration, ClassDescriptor> LOCAL_OBJECT_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory1<KtClass, ClassDescriptor> LOCAL_INTERFACE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
// Type parameter declarations
|
||||
|
||||
DiagnosticFactory1<JetTypeReference, JetType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtTypeReference, KtType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||
DiagnosticFactory1<KtNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory2<JetSimpleNameExpression, JetTypeConstraint, JetTypeParameterListOwner> NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER =
|
||||
DiagnosticFactory2<KtSimpleNameExpression, KtTypeConstraint, KtTypeParameterListOwner> NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER =
|
||||
DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetTypeParameter>
|
||||
DiagnosticFactory0<KtTypeParameter>
|
||||
VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY = DiagnosticFactory0.create(ERROR, VARIANCE_MODIFIER);
|
||||
|
||||
DiagnosticFactory0<JetTypeParameterList> DEPRECATED_TYPE_PARAMETER_SYNTAX = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeParameterList> DEPRECATED_TYPE_PARAMETER_SYNTAX = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<PsiElement> REIFIED_TYPE_PARAMETER_NO_INLINE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> TYPE_PARAMETERS_NOT_ALLOWED
|
||||
DiagnosticFactory0<KtDeclaration> TYPE_PARAMETERS_NOT_ALLOWED
|
||||
= DiagnosticFactory0.create(ERROR, TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetTypeParameter> TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeParameter> TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> CYCLIC_GENERIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetTypeParameter> MISPLACED_TYPE_PARAMETER_CONSTRAINTS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeParameter> MISPLACED_TYPE_PARAMETER_CONSTRAINTS = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Members
|
||||
|
||||
DiagnosticFactory2<JetDeclaration, CallableMemberDescriptor, String> CONFLICTING_OVERLOADS =
|
||||
DiagnosticFactory2<KtDeclaration, CallableMemberDescriptor, String> CONFLICTING_OVERLOADS =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
|
||||
DiagnosticFactory0<JetNamedDeclaration> NON_FINAL_MEMBER_IN_FINAL_CLASS = DiagnosticFactory0.create(WARNING, modifierSetPosition(
|
||||
JetTokens.OPEN_KEYWORD));
|
||||
DiagnosticFactory0<KtNamedDeclaration> NON_FINAL_MEMBER_IN_FINAL_CLASS = DiagnosticFactory0.create(WARNING, modifierSetPosition(
|
||||
KtTokens.OPEN_KEYWORD));
|
||||
|
||||
DiagnosticFactory1<JetModifierListOwner, CallableMemberDescriptor> NOTHING_TO_OVERRIDE = DiagnosticFactory1.create(ERROR, OVERRIDE_MODIFIER);
|
||||
DiagnosticFactory1<KtModifierListOwner, CallableMemberDescriptor> NOTHING_TO_OVERRIDE = DiagnosticFactory1.create(ERROR, OVERRIDE_MODIFIER);
|
||||
|
||||
DiagnosticFactory3<JetNamedDeclaration, CallableMemberDescriptor, CallableMemberDescriptor, DeclarationDescriptor> VIRTUAL_MEMBER_HIDDEN =
|
||||
DiagnosticFactory3<KtNamedDeclaration, CallableMemberDescriptor, CallableMemberDescriptor, DeclarationDescriptor> VIRTUAL_MEMBER_HIDDEN =
|
||||
DiagnosticFactory3.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory2<JetModifierListOwner, CallableMemberDescriptor, CallableDescriptor> CANNOT_OVERRIDE_INVISIBLE_MEMBER =
|
||||
DiagnosticFactory2<KtModifierListOwner, CallableMemberDescriptor, CallableDescriptor> CANNOT_OVERRIDE_INVISIBLE_MEMBER =
|
||||
DiagnosticFactory2.create(ERROR, OVERRIDE_MODIFIER);
|
||||
|
||||
DiagnosticFactory2<PsiElement, CallableMemberDescriptor, DeclarationDescriptor> DATA_CLASS_OVERRIDE_CONFLICT =
|
||||
DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetDeclaration, CallableMemberDescriptor> CANNOT_INFER_VISIBILITY =
|
||||
DiagnosticFactory1<KtDeclaration, CallableMemberDescriptor> CANNOT_INFER_VISIBILITY =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
|
||||
DiagnosticFactory2<JetNamedDeclaration, CallableMemberDescriptor, DeclarationDescriptor> OVERRIDING_FINAL_MEMBER =
|
||||
DiagnosticFactory2<KtNamedDeclaration, CallableMemberDescriptor, DeclarationDescriptor> OVERRIDING_FINAL_MEMBER =
|
||||
DiagnosticFactory2.create(ERROR, OVERRIDE_MODIFIER);
|
||||
|
||||
DiagnosticFactory3<JetModifierListOwner, Visibility, CallableMemberDescriptor, DeclarationDescriptor> CANNOT_WEAKEN_ACCESS_PRIVILEGE =
|
||||
DiagnosticFactory3<KtModifierListOwner, Visibility, CallableMemberDescriptor, DeclarationDescriptor> CANNOT_WEAKEN_ACCESS_PRIVILEGE =
|
||||
DiagnosticFactory3.create(ERROR, VISIBILITY_MODIFIER);
|
||||
DiagnosticFactory3<JetModifierListOwner, Visibility, CallableMemberDescriptor, DeclarationDescriptor> CANNOT_CHANGE_ACCESS_PRIVILEGE =
|
||||
DiagnosticFactory3<KtModifierListOwner, Visibility, CallableMemberDescriptor, DeclarationDescriptor> CANNOT_CHANGE_ACCESS_PRIVILEGE =
|
||||
DiagnosticFactory3.create(ERROR, VISIBILITY_MODIFIER);
|
||||
DiagnosticFactory2<JetNamedDeclaration, CallableMemberDescriptor, CallableMemberDescriptor> RETURN_TYPE_MISMATCH_ON_OVERRIDE =
|
||||
DiagnosticFactory2<KtNamedDeclaration, CallableMemberDescriptor, CallableMemberDescriptor> RETURN_TYPE_MISMATCH_ON_OVERRIDE =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_RETURN_TYPE);
|
||||
DiagnosticFactory2<JetNamedDeclaration, CallableMemberDescriptor, CallableMemberDescriptor> PROPERTY_TYPE_MISMATCH_ON_OVERRIDE =
|
||||
DiagnosticFactory2<KtNamedDeclaration, CallableMemberDescriptor, CallableMemberDescriptor> PROPERTY_TYPE_MISMATCH_ON_OVERRIDE =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_RETURN_TYPE);
|
||||
|
||||
DiagnosticFactory2<JetClassOrObject, JetClassOrObject, CallableMemberDescriptor> ABSTRACT_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> ABSTRACT_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory2<JetClassOrObject, JetClassOrObject, CallableMemberDescriptor> ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory2<JetClassOrObject, JetClassOrObject, CallableMemberDescriptor> MANY_IMPL_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> MANY_IMPL_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory2<JetClassOrObject, JetClassOrObject, CallableMemberDescriptor> MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2<KtClassOrObject, KtClassOrObject, CallableMemberDescriptor> MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED =
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
|
||||
DiagnosticFactory1<JetNamedDeclaration, Collection<JetType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1<KtNamedDeclaration, Collection<KtType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
// Property-specific
|
||||
|
||||
DiagnosticFactory2<JetNamedDeclaration, PropertyDescriptor, PropertyDescriptor> VAR_OVERRIDDEN_BY_VAL =
|
||||
DiagnosticFactory2<KtNamedDeclaration, PropertyDescriptor, PropertyDescriptor> VAR_OVERRIDDEN_BY_VAL =
|
||||
DiagnosticFactory2.create(ERROR, VAL_OR_VAR_NODE);
|
||||
|
||||
DiagnosticFactory0<PsiElement> REDUNDANT_MODIFIER_IN_GETTER = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ACCESSOR_VISIBILITY_FOR_ABSTRACT_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetModifierListOwner>
|
||||
DiagnosticFactory0<KtModifierListOwner>
|
||||
ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory0<JetExpression> ABSTRACT_PROPERTY_WITH_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyAccessor> ABSTRACT_PROPERTY_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyAccessor> ABSTRACT_PROPERTY_WITH_SETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ABSTRACT_PROPERTY_WITH_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyAccessor> ABSTRACT_PROPERTY_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyAccessor> ABSTRACT_PROPERTY_WITH_SETTER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetPropertyDelegate> ABSTRACT_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyAccessor> ACCESSOR_FOR_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyDelegate> DELEGATED_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyDelegate> LOCAL_VARIABLE_WITH_DELEGATE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyDelegate> ABSTRACT_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyAccessor> ACCESSOR_FOR_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyDelegate> DELEGATED_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyDelegate> LOCAL_VARIABLE_WITH_DELEGATE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetProperty> PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtProperty> PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetProperty> MUST_BE_INITIALIZED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetProperty> MUST_BE_INITIALIZED_OR_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtProperty> MUST_BE_INITIALIZED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtProperty> MUST_BE_INITIALIZED_OR_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetExpression> EXTENSION_PROPERTY_WITH_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> PROPERTY_INITIALIZER_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetProperty> FINAL_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, FINAL_MODIFIER);
|
||||
DiagnosticFactory0<JetProperty> PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER);
|
||||
DiagnosticFactory0<JetProperty> BACKING_FIELD_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtExpression> EXTENSION_PROPERTY_WITH_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> PROPERTY_INITIALIZER_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtProperty> FINAL_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, FINAL_MODIFIER);
|
||||
DiagnosticFactory0<KtProperty> PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER);
|
||||
DiagnosticFactory0<KtProperty> BACKING_FIELD_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_OLD_SYNTAX = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> BACKING_FIELD_USAGE_FORBIDDEN = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> BACKING_FIELD_OLD_SYNTAX = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> BACKING_FIELD_USAGE_FORBIDDEN = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, String> INAPPLICABLE_LATEINIT_MODIFIER = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<JetModifierListOwner, String, ClassDescriptor> ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS = DiagnosticFactory2.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory2<KtModifierListOwner, String, ClassDescriptor> ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS = DiagnosticFactory2.create(ERROR, ABSTRACT_MODIFIER);
|
||||
|
||||
DiagnosticFactory0<JetPropertyAccessor> VAL_WITH_SETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyAccessor> VAL_WITH_SETTER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> SETTER_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> SETTER_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Function-specific
|
||||
|
||||
DiagnosticFactory2<JetFunction, String, ClassDescriptor> ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS = DiagnosticFactory2.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory2<KtFunction, String, ClassDescriptor> ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS = DiagnosticFactory2.create(ERROR, ABSTRACT_MODIFIER);
|
||||
|
||||
DiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> ABSTRACT_FUNCTION_WITH_BODY = DiagnosticFactory1.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> NON_ABSTRACT_FUNCTION_WITH_NO_BODY =
|
||||
DiagnosticFactory1<KtFunction, SimpleFunctionDescriptor> ABSTRACT_FUNCTION_WITH_BODY = DiagnosticFactory1.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory1<KtFunction, SimpleFunctionDescriptor> NON_ABSTRACT_FUNCTION_WITH_NO_BODY =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> FINAL_FUNCTION_WITH_NO_BODY = DiagnosticFactory1.create(ERROR, FINAL_MODIFIER);
|
||||
DiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> PRIVATE_FUNCTION_WITH_NO_BODY = DiagnosticFactory1.create(ERROR, PRIVATE_MODIFIER);
|
||||
DiagnosticFactory1<KtFunction, SimpleFunctionDescriptor> FINAL_FUNCTION_WITH_NO_BODY = DiagnosticFactory1.create(ERROR, FINAL_MODIFIER);
|
||||
DiagnosticFactory1<KtFunction, SimpleFunctionDescriptor> PRIVATE_FUNCTION_WITH_NO_BODY = DiagnosticFactory1.create(ERROR, PRIVATE_MODIFIER);
|
||||
|
||||
DiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> NON_MEMBER_FUNCTION_NO_BODY =
|
||||
DiagnosticFactory1<KtFunction, SimpleFunctionDescriptor> NON_MEMBER_FUNCTION_NO_BODY =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetFunction> FUNCTION_DECLARATION_WITH_NO_NAME = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtFunction> FUNCTION_DECLARATION_WITH_NO_NAME = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<PsiElement> FUNCTION_EXPRESSION_WITH_NAME = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetParameter> VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetNamedFunction> NO_TAIL_CALLS_FOUND = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtNamedFunction> NO_TAIL_CALLS_FOUND = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetParameter> FUNCTION_EXPRESSION_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
||||
DiagnosticFactory0<KtParameter> FUNCTION_EXPRESSION_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
||||
|
||||
DiagnosticFactory0<JetParameter> USELESS_VARARG_ON_PARAMETER = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtParameter> USELESS_VARARG_ON_PARAMETER = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Named parameters
|
||||
|
||||
DiagnosticFactory0<JetParameter> DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
||||
DiagnosticFactory0<KtParameter> DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);
|
||||
|
||||
DiagnosticFactory1<JetParameter, ValueParameterDescriptor> MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtParameter, ValueParameterDescriptor> MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetClassOrObject, ValueParameterDescriptor> MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE =
|
||||
DiagnosticFactory1<KtClassOrObject, ValueParameterDescriptor> MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory2<JetParameter, ClassDescriptor, ValueParameterDescriptor> PARAMETER_NAME_CHANGED_ON_OVERRIDE =
|
||||
DiagnosticFactory2<KtParameter, ClassDescriptor, ValueParameterDescriptor> PARAMETER_NAME_CHANGED_ON_OVERRIDE =
|
||||
DiagnosticFactory2.create(WARNING, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory2<JetClassOrObject, Collection<? extends CallableMemberDescriptor>, Integer> DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES =
|
||||
DiagnosticFactory2<KtClassOrObject, Collection<? extends CallableMemberDescriptor>, Integer> DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES =
|
||||
DiagnosticFactory2.create(WARNING, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory0<JetReferenceExpression> NAME_FOR_AMBIGUOUS_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtReferenceExpression> NAME_FOR_AMBIGUOUS_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> DATA_CLASS_WITHOUT_PARAMETERS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetParameter> DATA_CLASS_VARARG_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetParameter> DATA_CLASS_NOT_PROPERTY_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> DATA_CLASS_VARARG_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> DATA_CLASS_NOT_PROPERTY_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -426,13 +426,13 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, String> NAME_SHADOWING = DiagnosticFactory1.create(WARNING, PositioningStrategies.FOR_REDECLARATION);
|
||||
DiagnosticFactory0<PsiElement> ACCESSOR_PARAMETER_NAME_SHADOWING = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<JetExpression> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Checking call arguments
|
||||
|
||||
DiagnosticFactory0<PsiElement> MIXING_NAMED_AND_POSITIONED_ARGUMENTS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetReferenceExpression> ARGUMENT_PASSED_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetReferenceExpression, JetReferenceExpression> NAMED_PARAMETER_NOT_FOUND =
|
||||
DiagnosticFactory0<KtReferenceExpression> ARGUMENT_PASSED_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtReferenceExpression, KtReferenceExpression> NAMED_PARAMETER_NOT_FOUND =
|
||||
DiagnosticFactory1.create(ERROR, FOR_UNRESOLVED_REFERENCE);
|
||||
DiagnosticFactory1<PsiElement, BadNamedArgumentsTarget> NAMED_ARGUMENTS_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
@@ -441,46 +441,46 @@ public interface Errors {
|
||||
INVOKE_ON_FUNCTION_TYPE
|
||||
}
|
||||
|
||||
DiagnosticFactory0<JetExpression> VARARG_OUTSIDE_PARENTHESES = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> VARARG_OUTSIDE_PARENTHESES = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<LeafPsiElement> NON_VARARG_SPREAD = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> MANY_FUNCTION_LITERAL_ARGUMENTS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> MANY_FUNCTION_LITERAL_ARGUMENTS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> TOO_MANY_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS);
|
||||
DiagnosticFactory1<KtElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS);
|
||||
|
||||
DiagnosticFactory1<JetExpression, JetType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Call resolution
|
||||
|
||||
DiagnosticFactory1<JetExpression, String> ILLEGAL_SELECTOR = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, String> ILLEGAL_SELECTOR = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> SAFE_CALL_IN_QUALIFIER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<JetExpression, JetExpression, JetType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<JetExpression, JetExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
||||
DiagnosticFactory2<KtExpression, KtExpression, KtType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KtExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_TAIL_RECURSIVE_CALL = DiagnosticFactory0.create(WARNING, CALL_EXPRESSION);
|
||||
DiagnosticFactory0<PsiElement> TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED = DiagnosticFactory0.create(WARNING, CALL_EXPRESSION);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NO_CONSTRUCTOR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> OVERLOAD_RESOLUTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> CANNOT_COMPLETE_RESOLVE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> UNRESOLVED_REFERENCE_WRONG_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetExpression> INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtExpression> INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Type inference
|
||||
|
||||
DiagnosticFactory0<JetParameter> CANNOT_INFER_PARAMETER_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> CANNOT_INFER_PARAMETER_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR);
|
||||
@@ -489,74 +489,74 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetElement, JetType, JetType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Reflection
|
||||
|
||||
DiagnosticFactory1<JetExpression, CallableMemberDescriptor> EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_TO_OBJECT_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, CallableMemberDescriptor> EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CALLABLE_REFERENCE_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CALLABLE_REFERENCE_TO_OBJECT_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> CLASS_LITERAL_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CLASS_LITERAL_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Multi-declarations
|
||||
|
||||
DiagnosticFactory0<JetMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<JetExpression, Name, JetType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<JetExpression, Name, Collection<? extends ResolvedCall<?>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory3<JetExpression, Name, JetType, JetType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory0<KtMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, KtType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, Collection<? extends ResolvedCall<?>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory3<KtExpression, Name, KtType, KtType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
|
||||
|
||||
// Super calls
|
||||
|
||||
DiagnosticFactory1<JetSuperExpression, String> SUPER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetSuperExpression, String> SUPER_CANT_BE_EXTENSION_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetSuperExpression> SUPER_NOT_AVAILABLE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetSuperExpression> SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetSuperExpression> AMBIGUOUS_SUPER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ABSTRACT_SUPER_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> NOT_A_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtSuperExpression, String> SUPER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSuperExpression, String> SUPER_CANT_BE_EXTENSION_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtSuperExpression> SUPER_NOT_AVAILABLE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSuperExpression> SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSuperExpression> AMBIGUOUS_SUPER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ABSTRACT_SUPER_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> NOT_A_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Conventions
|
||||
|
||||
DiagnosticFactory0<JetArrayAccessExpression> NO_GET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
||||
DiagnosticFactory0<JetArrayAccessExpression> NO_SET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
||||
DiagnosticFactory0<KtArrayAccessExpression> NO_GET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
||||
DiagnosticFactory0<KtArrayAccessExpression> NO_SET_METHOD = DiagnosticFactory0.create(ERROR, ARRAY_ACCESS);
|
||||
|
||||
DiagnosticFactory2<JetUnaryExpression, FunctionDescriptor, String> DEPRECATED_UNARY_PLUS_MINUS = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtUnaryExpression, FunctionDescriptor, String> DEPRECATED_UNARY_PLUS_MINUS = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<JetSimpleNameExpression> INC_DEC_SHOULD_NOT_RETURN_UNIT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<JetSimpleNameExpression, DeclarationDescriptor, JetSimpleNameExpression> ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT =
|
||||
DiagnosticFactory0<KtSimpleNameExpression> INC_DEC_SHOULD_NOT_RETURN_UNIT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtSimpleNameExpression, DeclarationDescriptor, KtSimpleNameExpression> ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT =
|
||||
DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>>
|
||||
ASSIGN_OPERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetSimpleNameExpression> EQUALS_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<JetBinaryExpression, JetSimpleNameExpression, JetType, JetType> EQUALITY_NOT_APPLICABLE =
|
||||
DiagnosticFactory0<KtSimpleNameExpression> EQUALS_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<KtBinaryExpression, KtSimpleNameExpression, KtType, KtType> EQUALITY_NOT_APPLICABLE =
|
||||
DiagnosticFactory3.create(ERROR);
|
||||
|
||||
|
||||
DiagnosticFactory1<JetExpression, JetType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetExpression, JetType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> ITERATOR_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> ITERATOR_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<JetExpression, String, JetType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, JetType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory2<JetExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<JetExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<JetExpression, String, JetType, JetType> DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory2<JetExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_PD_METHOD_NONE_APPLICABLE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, String, KtType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, KtType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_PD_METHOD_NONE_APPLICABLE = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<JetSimpleNameExpression, JetType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, KtType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> UNDERSCORE_IS_RESERVED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, String> INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR);
|
||||
@@ -565,177 +565,177 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_INFIX_MODIFIER = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<PsiElement, FunctionDescriptor, String> OPERATOR_MODIFIER_REQUIRED = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetOperationReferenceExpression, FunctionDescriptor, String> INFIX_MODIFIER_REQUIRED = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtOperationReferenceExpression, FunctionDescriptor, String> INFIX_MODIFIER_REQUIRED = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
// Labels
|
||||
|
||||
DiagnosticFactory0<JetSimpleNameExpression> LABEL_NAME_CLASH = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> AMBIGUOUS_LABEL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> LABEL_NAME_CLASH = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> AMBIGUOUS_LABEL = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpressionWithLabel> BREAK_OR_CONTINUE_OUTSIDE_A_LOOP = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpressionWithLabel> BREAK_OR_CONTINUE_IN_WHEN = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpressionWithLabel> BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetExpressionWithLabel, String> NOT_A_LOOP_LABEL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetReturnExpression, String> NOT_A_RETURN_LABEL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpressionWithLabel> BREAK_OR_CONTINUE_OUTSIDE_A_LOOP = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpressionWithLabel> BREAK_OR_CONTINUE_IN_WHEN = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpressionWithLabel> BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtExpressionWithLabel, String> NOT_A_LOOP_LABEL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtReturnExpression, String> NOT_A_RETURN_LABEL = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Control flow / Data flow
|
||||
|
||||
DiagnosticFactory1<JetElement, List<TextRange>> UNREACHABLE_CODE = DiagnosticFactory1.create(
|
||||
DiagnosticFactory1<KtElement, List<TextRange>> UNREACHABLE_CODE = DiagnosticFactory1.create(
|
||||
WARNING, PositioningStrategies.UNREACHABLE_CODE);
|
||||
|
||||
DiagnosticFactory0<JetVariableDeclaration> VARIABLE_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory0.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory0<KtVariableDeclaration> VARIABLE_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory0.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory1<JetSimpleNameExpression, VariableDescriptor> UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetSimpleNameExpression, ValueParameterDescriptor> UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, VariableDescriptor> UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, ValueParameterDescriptor> UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetNamedDeclaration, VariableDescriptor> UNUSED_VARIABLE = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||
DiagnosticFactory1<JetParameter, VariableDescriptor> UNUSED_PARAMETER = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||
DiagnosticFactory1<KtNamedDeclaration, VariableDescriptor> UNUSED_VARIABLE = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||
DiagnosticFactory1<KtParameter, VariableDescriptor> UNUSED_PARAMETER = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory1<JetNamedDeclaration, VariableDescriptor> ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE =
|
||||
DiagnosticFactory1<KtNamedDeclaration, VariableDescriptor> ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE =
|
||||
DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||
DiagnosticFactory1<JetExpression, DeclarationDescriptor> VARIABLE_WITH_REDUNDANT_INITIALIZER = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory2<JetBinaryExpression, JetElement, DeclarationDescriptor> UNUSED_VALUE = DiagnosticFactory2.create(WARNING, PositioningStrategies.UNUSED_VALUE);
|
||||
DiagnosticFactory1<JetElement, JetElement> UNUSED_CHANGED_VALUE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<JetElement> UNUSED_EXPRESSION = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetFunctionLiteralExpression> UNUSED_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> VARIABLE_WITH_REDUNDANT_INITIALIZER = DiagnosticFactory1.create(WARNING);
|
||||
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_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<JetExpression, DeclarationDescriptor> VAL_REASSIGNMENT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, DeclarationDescriptor> SETTER_PROJECTED_OUT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> VAL_REASSIGNMENT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> SETTER_PROJECTED_OUT = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetExpression, DeclarationDescriptor> INITIALIZATION_BEFORE_DECLARATION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, DeclarationDescriptor> INITIALIZATION_BEFORE_DECLARATION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> VARIABLE_EXPECTED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> VARIABLE_EXPECTED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<JetBinaryExpression, JetBinaryExpression, Boolean> SENSELESS_COMPARISON = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtBinaryExpression, KtBinaryExpression, Boolean> SENSELESS_COMPARISON = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<JetElement> SENSELESS_NULL_IN_WHEN = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtElement> SENSELESS_NULL_IN_WHEN = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<JetIfExpression> INVALID_IF_AS_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtIfExpression> INVALID_IF_AS_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Nullability
|
||||
|
||||
DiagnosticFactory1<PsiElement, JetType> UNSAFE_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<JetExpression, String, String, String> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNSAFE_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, String, String> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> UNEXPECTED_SAFE_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<JetBinaryExpression, JetType> USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS);
|
||||
DiagnosticFactory1<KtBinaryExpression, KtType> USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS);
|
||||
DiagnosticFactory0<PsiElement> USELESS_ELVIS_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Compile-time values
|
||||
|
||||
DiagnosticFactory0<JetExpression> DIVISION_BY_ZERO = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetExpression> INTEGER_OVERFLOW = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetConstantExpression> WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX);
|
||||
DiagnosticFactory0<JetConstantExpression> INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetConstantExpression> FLOAT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<JetConstantExpression, String, JetType> CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<JetConstantExpression> INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetConstantExpression> EMPTY_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetConstantExpression, JetConstantExpression> TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetElement, JetElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES);
|
||||
DiagnosticFactory1<JetConstantExpression, JetType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetEscapeStringTemplateEntry> ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> DIVISION_BY_ZERO = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtExpression> INTEGER_OVERFLOW = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtConstantExpression> WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX);
|
||||
DiagnosticFactory0<KtConstantExpression> INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> FLOAT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtConstantExpression, String, KtType> CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> EMPTY_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtConstantExpression, KtConstantExpression> TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KtElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES);
|
||||
DiagnosticFactory1<KtConstantExpression, KtType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtEscapeStringTemplateEntry> ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Casts and is-checks
|
||||
|
||||
DiagnosticFactory1<JetElement, JetType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetBinaryExpressionWithTypeRHS, JetType, JetType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<KtElement, KtType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KtType, KtType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<JetBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||
DiagnosticFactory0<JetSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> IS_ENUM_ENTRY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> IS_ENUM_ENTRY = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetExpression, JetType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtExpression, KtType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<JetExpression, JetType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KtType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetNullableType> USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory0<KtNullableType> USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
|
||||
// Properties / locals
|
||||
|
||||
DiagnosticFactory0<JetTypeReference> LOCAL_EXTENSION_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyAccessor> LOCAL_VARIABLE_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetPropertyAccessor> LOCAL_VARIABLE_WITH_SETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> LOCAL_EXTENSION_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyAccessor> LOCAL_VARIABLE_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtPropertyAccessor> LOCAL_VARIABLE_WITH_SETTER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory3<JetExpression, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_SETTER = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_SETTER = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_LOOP_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_FUN_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_CATCH_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtKeywordToken> VAL_OR_VAR_ON_LOOP_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtKeywordToken> VAL_OR_VAR_ON_FUN_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtKeywordToken> VAL_OR_VAR_ON_CATCH_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtKeywordToken> VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Backing fields
|
||||
|
||||
DiagnosticFactory0<JetElement> NO_BACKING_FIELD_ABSTRACT_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetElement> NO_BACKING_FIELD_CUSTOM_ACCESSORS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetElement> INACCESSIBLE_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetElement> NOT_PROPERTY_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> NO_BACKING_FIELD_ABSTRACT_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> NO_BACKING_FIELD_CUSTOM_ACCESSORS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> INACCESSIBLE_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> NOT_PROPERTY_BACKING_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// When expressions
|
||||
|
||||
DiagnosticFactory0<JetWhenCondition> EXPECTED_CONDITION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetWhenEntry> ELSE_MISPLACED_IN_WHEN = DiagnosticFactory0.create(ERROR, ELSE_ENTRY);
|
||||
DiagnosticFactory0<JetWhenExpression> NO_ELSE_IN_WHEN = DiagnosticFactory0.create(ERROR, WHEN_EXPRESSION);
|
||||
DiagnosticFactory0<JetWhenExpression> NON_EXHAUSTIVE_WHEN = DiagnosticFactory0.create(WARNING, WHEN_EXPRESSION);
|
||||
DiagnosticFactory0<KtWhenCondition> EXPECTED_CONDITION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtWhenEntry> ELSE_MISPLACED_IN_WHEN = DiagnosticFactory0.create(ERROR, ELSE_ENTRY);
|
||||
DiagnosticFactory0<KtWhenExpression> NO_ELSE_IN_WHEN = DiagnosticFactory0.create(ERROR, WHEN_EXPRESSION);
|
||||
DiagnosticFactory0<KtWhenExpression> NON_EXHAUSTIVE_WHEN = DiagnosticFactory0.create(WARNING, WHEN_EXPRESSION);
|
||||
|
||||
// Type mismatch
|
||||
|
||||
DiagnosticFactory2<JetExpression, JetType, JetType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, JetType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetBinaryExpression, JetType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<JetElement, JetType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<JetExpression, String, JetType, JetType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory0<JetWhenConditionInRange> TYPE_MISMATCH_IN_RANGE = DiagnosticFactory0.create(ERROR, WHEN_CONDITION_IN_RANGE);
|
||||
DiagnosticFactory2<KtExpression, KtType, KtType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtBinaryExpression, KtType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KtType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory0<KtWhenConditionInRange> TYPE_MISMATCH_IN_RANGE = DiagnosticFactory0.create(ERROR, WHEN_CONDITION_IN_RANGE);
|
||||
|
||||
DiagnosticFactory1<JetParameter, JetType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetFunction, Integer, List<JetType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||
DiagnosticFactory1<KtParameter, KtType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtFunction, Integer, List<KtType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||
DiagnosticFactory2.create(ERROR, FUNCTION_PARAMETERS);
|
||||
|
||||
DiagnosticFactory2<JetElement, JetType, JetType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> IMPLICIT_NOTHING_RETURN_TYPE = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Context tracking
|
||||
|
||||
DiagnosticFactory1<JetExpression, JetExpression> EXPRESSION_EXPECTED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetBinaryExpression> ASSIGNMENT_IN_EXPRESSION_CONTEXT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetDeclaration> DECLARATION_IN_ILLEGAL_CONTEXT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtExpression> EXPRESSION_EXPECTED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtBinaryExpression> ASSIGNMENT_IN_EXPRESSION_CONTEXT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDeclaration> DECLARATION_IN_ILLEGAL_CONTEXT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetSimpleNameExpression> EXPRESSION_EXPECTED_PACKAGE_FOUND = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> EXPRESSION_EXPECTED_PACKAGE_FOUND = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetReturnExpression> RETURN_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetReturnExpression> RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetDeclarationWithBody>
|
||||
DiagnosticFactory0<KtReturnExpression> RETURN_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtReturnExpression> RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtDeclarationWithBody>
|
||||
NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_WITH_BODY);
|
||||
|
||||
DiagnosticFactory0<JetClassInitializer> ANONYMOUS_INITIALIZER_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtClassInitializer> ANONYMOUS_INITIALIZER_IN_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetThisExpression> NO_THIS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetRootPackageExpression> PACKAGE_IS_NOT_AN_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetSimpleNameExpression, ClassifierDescriptor> NO_COMPANION_OBJECT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_ON_LHS_OF_DOT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, ClassDescriptor> NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetExpression, ClassDescriptor, String> NESTED_CLASS_SHOULD_BE_QUALIFIED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtThisExpression> NO_THIS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtRootPackageExpression> PACKAGE_IS_NOT_AN_EXPRESSION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, ClassifierDescriptor> NO_COMPANION_OBJECT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_ON_LHS_OF_DOT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, ClassDescriptor> NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, ClassDescriptor, String> NESTED_CLASS_SHOULD_BE_QUALIFIED = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, ClassDescriptor> INACCESSIBLE_OUTER_CLASS_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetClass> NESTED_CLASS_NOT_ALLOWED = DiagnosticFactory0.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory0<KtClass> NESTED_CLASS_NOT_ALLOWED = DiagnosticFactory0.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
//Inline and inlinable parameters
|
||||
DiagnosticFactory2<JetElement, DeclarationDescriptor, DeclarationDescriptor> INVISIBLE_MEMBER_FROM_INLINE = DiagnosticFactory2.create(ERROR, CALL_ELEMENT);
|
||||
DiagnosticFactory3<JetElement, JetElement, DeclarationDescriptor, DeclarationDescriptor> NON_LOCAL_RETURN_NOT_ALLOWED = DiagnosticFactory3.create(ERROR, CALL_ELEMENT);
|
||||
DiagnosticFactory2<JetElement, JetNamedDeclaration, DeclarationDescriptor> NOT_YET_SUPPORTED_IN_INLINE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, DeclarationDescriptor, DeclarationDescriptor> INVISIBLE_MEMBER_FROM_INLINE = DiagnosticFactory2.create(ERROR, CALL_ELEMENT);
|
||||
DiagnosticFactory3<KtElement, KtElement, DeclarationDescriptor, DeclarationDescriptor> NON_LOCAL_RETURN_NOT_ALLOWED = DiagnosticFactory3.create(ERROR, CALL_ELEMENT);
|
||||
DiagnosticFactory2<KtElement, KtNamedDeclaration, DeclarationDescriptor> NOT_YET_SUPPORTED_IN_INLINE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, DeclarationDescriptor> NOTHING_TO_INLINE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory2<JetElement, JetExpression, DeclarationDescriptor> USAGE_IS_NOT_INLINABLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<JetElement, JetElement, DeclarationDescriptor> NULLABLE_INLINE_PARAMETER = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<JetElement, JetElement, DeclarationDescriptor> RECURSION_IN_INLINE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<JetElement> DECLARATION_CANT_BE_INLINED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtExpression, DeclarationDescriptor> USAGE_IS_NOT_INLINABLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtElement, DeclarationDescriptor> NULLABLE_INLINE_PARAMETER = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtElement, DeclarationDescriptor> RECURSION_IN_INLINE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> DECLARATION_CANT_BE_INLINED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> INLINE_CALL_CYCLE = DiagnosticFactory1.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory0<PsiElement> NON_LOCAL_RETURN_IN_DISABLED_INLINE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
@@ -20,20 +20,20 @@ import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.kotlin.JetNodeTypes
|
||||
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
public object PositioningStrategies {
|
||||
private open class DeclarationHeader<T : JetDeclaration> : PositioningStrategy<T>() {
|
||||
private open class DeclarationHeader<T : KtDeclaration> : PositioningStrategy<T>() {
|
||||
override fun isValid(element: T): Boolean {
|
||||
if (element is JetNamedDeclaration &&
|
||||
element !is JetObjectDeclaration &&
|
||||
element !is JetSecondaryConstructor &&
|
||||
element !is JetFunction
|
||||
if (element is KtNamedDeclaration &&
|
||||
element !is KtObjectDeclaration &&
|
||||
element !is KtSecondaryConstructor &&
|
||||
element !is KtFunction
|
||||
) {
|
||||
if (element.getNameIdentifier() == null) {
|
||||
return false
|
||||
@@ -46,7 +46,7 @@ public object PositioningStrategies {
|
||||
public val DEFAULT: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
when (element) {
|
||||
is JetObjectLiteralExpression -> {
|
||||
is KtObjectLiteralExpression -> {
|
||||
val objectDeclaration = element.getObjectDeclaration()
|
||||
val objectKeyword = objectDeclaration.getObjectKeyword()
|
||||
val delegationSpecifierList = objectDeclaration.getDelegationSpecifierList()
|
||||
@@ -55,13 +55,13 @@ public object PositioningStrategies {
|
||||
}
|
||||
return markRange(objectKeyword, delegationSpecifierList)
|
||||
}
|
||||
is JetObjectDeclaration -> {
|
||||
is KtObjectDeclaration -> {
|
||||
return markRange(
|
||||
element.getObjectKeyword(),
|
||||
element.getNameIdentifier() ?: element.getObjectKeyword()
|
||||
)
|
||||
}
|
||||
is JetConstructorDelegationCall -> {
|
||||
is KtConstructorDelegationCall -> {
|
||||
return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(element)
|
||||
}
|
||||
else -> {
|
||||
@@ -71,19 +71,19 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val DECLARATION_RETURN_TYPE: PositioningStrategy<JetDeclaration> = object : PositioningStrategy<JetDeclaration>() {
|
||||
override fun mark(element: JetDeclaration): List<TextRange> {
|
||||
public val DECLARATION_RETURN_TYPE: PositioningStrategy<KtDeclaration> = object : PositioningStrategy<KtDeclaration>() {
|
||||
override fun mark(element: KtDeclaration): List<TextRange> {
|
||||
return markElement(getElementToMark(element))
|
||||
}
|
||||
|
||||
override fun isValid(element: JetDeclaration): Boolean {
|
||||
override fun isValid(element: KtDeclaration): Boolean {
|
||||
return !hasSyntaxErrors(getElementToMark(element))
|
||||
}
|
||||
|
||||
private fun getElementToMark(declaration: JetDeclaration): PsiElement {
|
||||
private fun getElementToMark(declaration: KtDeclaration): PsiElement {
|
||||
val (returnTypeRef, nameIdentifierOrPlaceholder) = when (declaration) {
|
||||
is JetCallableDeclaration -> Pair(declaration.getTypeReference(), declaration.getNameIdentifier())
|
||||
is JetPropertyAccessor -> Pair(declaration.getReturnTypeReference(), declaration.getNamePlaceholder())
|
||||
is KtCallableDeclaration -> Pair(declaration.getTypeReference(), declaration.getNameIdentifier())
|
||||
is KtPropertyAccessor -> Pair(declaration.getReturnTypeReference(), declaration.getNamePlaceholder())
|
||||
else -> Pair(null, null)
|
||||
}
|
||||
|
||||
@@ -93,43 +93,43 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val DECLARATION_NAME: PositioningStrategy<JetNamedDeclaration> = object : DeclarationHeader<JetNamedDeclaration>() {
|
||||
override fun mark(element: JetNamedDeclaration): List<TextRange> {
|
||||
public val DECLARATION_NAME: PositioningStrategy<KtNamedDeclaration> = object : DeclarationHeader<KtNamedDeclaration>() {
|
||||
override fun mark(element: KtNamedDeclaration): List<TextRange> {
|
||||
val nameIdentifier = element.getNameIdentifier()
|
||||
if (nameIdentifier != null) {
|
||||
if (element is JetClassOrObject) {
|
||||
if (element is KtClassOrObject) {
|
||||
val startElement =
|
||||
element.getModifierList()?.getModifier(JetTokens.ENUM_KEYWORD)
|
||||
?: element.getNode().findChildByType(TokenSet.create(JetTokens.CLASS_KEYWORD, JetTokens.OBJECT_KEYWORD))?.getPsi()
|
||||
element.getModifierList()?.getModifier(KtTokens.ENUM_KEYWORD)
|
||||
?: element.getNode().findChildByType(TokenSet.create(KtTokens.CLASS_KEYWORD, KtTokens.OBJECT_KEYWORD))?.getPsi()
|
||||
?: element
|
||||
|
||||
return markRange(startElement, nameIdentifier)
|
||||
}
|
||||
return markElement(nameIdentifier)
|
||||
}
|
||||
if (element is JetNamedFunction) {
|
||||
if (element is KtNamedFunction) {
|
||||
return DECLARATION_SIGNATURE.mark(element)
|
||||
}
|
||||
return DEFAULT.mark(element)
|
||||
}
|
||||
}
|
||||
|
||||
public val DECLARATION_SIGNATURE: PositioningStrategy<JetDeclaration> = object : DeclarationHeader<JetDeclaration>() {
|
||||
override fun mark(element: JetDeclaration): List<TextRange> {
|
||||
public val DECLARATION_SIGNATURE: PositioningStrategy<KtDeclaration> = object : DeclarationHeader<KtDeclaration>() {
|
||||
override fun mark(element: KtDeclaration): List<TextRange> {
|
||||
when (element) {
|
||||
is JetConstructor<*> -> {
|
||||
is KtConstructor<*> -> {
|
||||
val begin = element.getConstructorKeyword() ?: element.getValueParameterList() ?: return markElement(element)
|
||||
val end = element.getValueParameterList() ?: element.getConstructorKeyword() ?: return markElement(element)
|
||||
return markRange(begin, end)
|
||||
}
|
||||
is JetFunction -> {
|
||||
is KtFunction -> {
|
||||
val endOfSignatureElement =
|
||||
element.getTypeReference()
|
||||
?: element.getValueParameterList()
|
||||
?: element.getNameIdentifier()
|
||||
?: element
|
||||
val startElement
|
||||
= if (element is JetFunctionLiteral) {
|
||||
= if (element is KtFunctionLiteral) {
|
||||
element.getReceiverTypeReference()
|
||||
?: element.getValueParameterList()
|
||||
?: element
|
||||
@@ -137,11 +137,11 @@ public object PositioningStrategies {
|
||||
else element
|
||||
return markRange(startElement, endOfSignatureElement)
|
||||
}
|
||||
is JetProperty -> {
|
||||
is KtProperty -> {
|
||||
val endOfSignatureElement = element.getTypeReference() ?: element.getNameIdentifier() ?: element
|
||||
return markRange(element, endOfSignatureElement)
|
||||
}
|
||||
is JetPropertyAccessor -> {
|
||||
is KtPropertyAccessor -> {
|
||||
val endOfSignatureElement =
|
||||
element.getReturnTypeReference()
|
||||
?: element.getRightParenthesis()?.getPsi()
|
||||
@@ -149,12 +149,12 @@ public object PositioningStrategies {
|
||||
|
||||
return markRange(element, endOfSignatureElement)
|
||||
}
|
||||
is JetClass -> {
|
||||
is KtClass -> {
|
||||
val nameAsDeclaration = element.getNameIdentifier() ?: return markElement(element)
|
||||
val primaryConstructorParameterList = element.getPrimaryConstructorParameterList() ?: return markElement(nameAsDeclaration)
|
||||
return markRange(nameAsDeclaration, primaryConstructorParameterList)
|
||||
}
|
||||
is JetObjectDeclaration -> {
|
||||
is KtObjectDeclaration -> {
|
||||
return DECLARATION_NAME.mark(element)
|
||||
}
|
||||
}
|
||||
@@ -164,23 +164,23 @@ public object PositioningStrategies {
|
||||
|
||||
public val DECLARATION_SIGNATURE_OR_DEFAULT: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
return if (element is JetDeclaration)
|
||||
return if (element is KtDeclaration)
|
||||
DECLARATION_SIGNATURE.mark(element)
|
||||
else
|
||||
DEFAULT.mark(element)
|
||||
}
|
||||
|
||||
override fun isValid(element: PsiElement): Boolean {
|
||||
return if (element is JetDeclaration)
|
||||
return if (element is KtDeclaration)
|
||||
DECLARATION_SIGNATURE.isValid(element)
|
||||
else
|
||||
DEFAULT.isValid(element)
|
||||
}
|
||||
}
|
||||
|
||||
public val TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE: PositioningStrategy<JetDeclaration> = object : PositioningStrategy<JetDeclaration>() {
|
||||
override fun mark(element: JetDeclaration): List<TextRange> {
|
||||
if (element is JetTypeParameterListOwner) {
|
||||
public val TYPE_PARAMETERS_OR_DECLARATION_SIGNATURE: PositioningStrategy<KtDeclaration> = object : PositioningStrategy<KtDeclaration>() {
|
||||
override fun mark(element: KtDeclaration): List<TextRange> {
|
||||
if (element is KtTypeParameterListOwner) {
|
||||
val jetTypeParameterList = element.getTypeParameterList()
|
||||
if (jetTypeParameterList != null) {
|
||||
return markElement(jetTypeParameterList)
|
||||
@@ -190,32 +190,32 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val ABSTRACT_MODIFIER: PositioningStrategy<JetModifierListOwner> = modifierSetPosition(JetTokens.ABSTRACT_KEYWORD)
|
||||
public val ABSTRACT_MODIFIER: PositioningStrategy<KtModifierListOwner> = modifierSetPosition(KtTokens.ABSTRACT_KEYWORD)
|
||||
|
||||
public val OVERRIDE_MODIFIER: PositioningStrategy<JetModifierListOwner> = modifierSetPosition(JetTokens.OVERRIDE_KEYWORD)
|
||||
public val OVERRIDE_MODIFIER: PositioningStrategy<KtModifierListOwner> = modifierSetPosition(KtTokens.OVERRIDE_KEYWORD)
|
||||
|
||||
public val FINAL_MODIFIER: PositioningStrategy<JetModifierListOwner> = modifierSetPosition(JetTokens.FINAL_KEYWORD)
|
||||
public val FINAL_MODIFIER: PositioningStrategy<KtModifierListOwner> = modifierSetPosition(KtTokens.FINAL_KEYWORD)
|
||||
|
||||
public val PRIVATE_MODIFIER: PositioningStrategy<JetModifierListOwner> = modifierSetPosition(JetTokens.PRIVATE_KEYWORD)
|
||||
public val PRIVATE_MODIFIER: PositioningStrategy<KtModifierListOwner> = modifierSetPosition(KtTokens.PRIVATE_KEYWORD)
|
||||
|
||||
public val VARIANCE_MODIFIER: PositioningStrategy<JetModifierListOwner> = modifierSetPosition(JetTokens.IN_KEYWORD, JetTokens.OUT_KEYWORD)
|
||||
public val VARIANCE_MODIFIER: PositioningStrategy<KtModifierListOwner> = modifierSetPosition(KtTokens.IN_KEYWORD, KtTokens.OUT_KEYWORD)
|
||||
|
||||
public val FOR_REDECLARATION: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
val nameIdentifier = when (element) {
|
||||
is JetNamedDeclaration -> element.getNameIdentifier()
|
||||
is JetFile -> element.getPackageDirective()!!.getNameIdentifier()
|
||||
is KtNamedDeclaration -> element.getNameIdentifier()
|
||||
is KtFile -> element.getPackageDirective()!!.getNameIdentifier()
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (nameIdentifier == null && element is JetObjectDeclaration) return DEFAULT.mark(element)
|
||||
if (nameIdentifier == null && element is KtObjectDeclaration) return DEFAULT.mark(element)
|
||||
|
||||
return markElement(nameIdentifier ?: element)
|
||||
}
|
||||
}
|
||||
public val FOR_UNRESOLVED_REFERENCE: PositioningStrategy<JetReferenceExpression> = object : PositioningStrategy<JetReferenceExpression>() {
|
||||
override fun mark(element: JetReferenceExpression): List<TextRange> {
|
||||
if (element is JetArrayAccessExpression) {
|
||||
public val FOR_UNRESOLVED_REFERENCE: PositioningStrategy<KtReferenceExpression> = object : PositioningStrategy<KtReferenceExpression>() {
|
||||
override fun mark(element: KtReferenceExpression): List<TextRange> {
|
||||
if (element is KtArrayAccessExpression) {
|
||||
val ranges = element.getBracketRanges()
|
||||
if (!ranges.isEmpty()) {
|
||||
return ranges
|
||||
@@ -226,9 +226,9 @@ public object PositioningStrategies {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun modifierSetPosition(vararg tokens: JetModifierKeywordToken): PositioningStrategy<JetModifierListOwner> {
|
||||
return object : PositioningStrategy<JetModifierListOwner>() {
|
||||
override fun mark(element: JetModifierListOwner): List<TextRange> {
|
||||
public fun modifierSetPosition(vararg tokens: KtModifierKeywordToken): PositioningStrategy<KtModifierListOwner> {
|
||||
return object : PositioningStrategy<KtModifierListOwner>() {
|
||||
override fun mark(element: KtModifierListOwner): List<TextRange> {
|
||||
val modifierList = element.getModifierList().sure { "No modifier list, but modifier has been found by the analyzer" }
|
||||
|
||||
for (token in tokens) {
|
||||
@@ -242,15 +242,15 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val ARRAY_ACCESS: PositioningStrategy<JetArrayAccessExpression> = object : PositioningStrategy<JetArrayAccessExpression>() {
|
||||
override fun mark(element: JetArrayAccessExpression): List<TextRange> {
|
||||
public val ARRAY_ACCESS: PositioningStrategy<KtArrayAccessExpression> = object : PositioningStrategy<KtArrayAccessExpression>() {
|
||||
override fun mark(element: KtArrayAccessExpression): List<TextRange> {
|
||||
return markElement(element.getIndicesNode())
|
||||
}
|
||||
}
|
||||
|
||||
public val VISIBILITY_MODIFIER: PositioningStrategy<JetModifierListOwner> = object : PositioningStrategy<JetModifierListOwner>() {
|
||||
override fun mark(element: JetModifierListOwner): List<TextRange> {
|
||||
val visibilityTokens = listOf(JetTokens.PRIVATE_KEYWORD, JetTokens.PROTECTED_KEYWORD, JetTokens.PUBLIC_KEYWORD, JetTokens.INTERNAL_KEYWORD)
|
||||
public val VISIBILITY_MODIFIER: PositioningStrategy<KtModifierListOwner> = object : PositioningStrategy<KtModifierListOwner>() {
|
||||
override fun mark(element: KtModifierListOwner): List<TextRange> {
|
||||
val visibilityTokens = listOf(KtTokens.PRIVATE_KEYWORD, KtTokens.PROTECTED_KEYWORD, KtTokens.PUBLIC_KEYWORD, KtTokens.INTERNAL_KEYWORD)
|
||||
val modifierList = element.getModifierList()
|
||||
|
||||
val result = visibilityTokens.map { modifierList?.getModifier(it)?.getTextRange() }.filterNotNull()
|
||||
@@ -265,9 +265,9 @@ public object PositioningStrategies {
|
||||
}
|
||||
|
||||
val elementToMark = when (element) {
|
||||
is JetObjectDeclaration -> element.getObjectKeyword()
|
||||
is JetPropertyAccessor -> element.getNamePlaceholder()
|
||||
is JetClassInitializer -> element
|
||||
is KtObjectDeclaration -> element.getObjectKeyword()
|
||||
is KtPropertyAccessor -> element.getNamePlaceholder()
|
||||
is KtClassInitializer -> element
|
||||
else -> throw IllegalArgumentException(
|
||||
"Can't find text range for element '${element.javaClass.getCanonicalName()}' with the text '${element.getText()}'")
|
||||
}
|
||||
@@ -275,104 +275,104 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val VARIANCE_IN_PROJECTION: PositioningStrategy<JetTypeProjection> = object : PositioningStrategy<JetTypeProjection>() {
|
||||
override fun mark(element: JetTypeProjection): List<TextRange> {
|
||||
public val VARIANCE_IN_PROJECTION: PositioningStrategy<KtTypeProjection> = object : PositioningStrategy<KtTypeProjection>() {
|
||||
override fun mark(element: KtTypeProjection): List<TextRange> {
|
||||
return markElement(element.getProjectionToken()!!)
|
||||
}
|
||||
}
|
||||
|
||||
public val PARAMETER_DEFAULT_VALUE: PositioningStrategy<JetParameter> = object : PositioningStrategy<JetParameter>() {
|
||||
override fun mark(element: JetParameter): List<TextRange> {
|
||||
public val PARAMETER_DEFAULT_VALUE: PositioningStrategy<KtParameter> = object : PositioningStrategy<KtParameter>() {
|
||||
override fun mark(element: KtParameter): List<TextRange> {
|
||||
return markNode(element.getDefaultValue()!!.getNode())
|
||||
}
|
||||
}
|
||||
|
||||
public val CALL_ELEMENT: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
return markElement((element as? JetCallElement)?.getCalleeExpression() ?: element)
|
||||
return markElement((element as? KtCallElement)?.getCalleeExpression() ?: element)
|
||||
}
|
||||
}
|
||||
|
||||
public val DECLARATION_WITH_BODY: PositioningStrategy<JetDeclarationWithBody> = object : PositioningStrategy<JetDeclarationWithBody>() {
|
||||
override fun mark(element: JetDeclarationWithBody): List<TextRange> {
|
||||
val lastBracketRange = (element.getBodyExpression() as? JetBlockExpression)?.getLastBracketRange()
|
||||
public val DECLARATION_WITH_BODY: PositioningStrategy<KtDeclarationWithBody> = object : PositioningStrategy<KtDeclarationWithBody>() {
|
||||
override fun mark(element: KtDeclarationWithBody): List<TextRange> {
|
||||
val lastBracketRange = (element.getBodyExpression() as? KtBlockExpression)?.getLastBracketRange()
|
||||
return if (lastBracketRange != null)
|
||||
markRange(lastBracketRange)
|
||||
else
|
||||
markElement(element)
|
||||
}
|
||||
|
||||
override fun isValid(element: JetDeclarationWithBody): Boolean {
|
||||
return super.isValid(element) && (element.getBodyExpression() as? JetBlockExpression)?.getLastBracketRange() != null
|
||||
override fun isValid(element: KtDeclarationWithBody): Boolean {
|
||||
return super.isValid(element) && (element.getBodyExpression() as? KtBlockExpression)?.getLastBracketRange() != null
|
||||
}
|
||||
}
|
||||
|
||||
public val VAL_OR_VAR_NODE: PositioningStrategy<JetNamedDeclaration> = object : PositioningStrategy<JetNamedDeclaration>() {
|
||||
override fun mark(element: JetNamedDeclaration): List<TextRange> {
|
||||
public val VAL_OR_VAR_NODE: PositioningStrategy<KtNamedDeclaration> = object : PositioningStrategy<KtNamedDeclaration>() {
|
||||
override fun mark(element: KtNamedDeclaration): List<TextRange> {
|
||||
return when (element) {
|
||||
is JetParameter -> markElement(element.valOrVarKeyword ?: element)
|
||||
is JetProperty -> markElement(element.valOrVarKeyword)
|
||||
is KtParameter -> markElement(element.valOrVarKeyword ?: element)
|
||||
is KtProperty -> markElement(element.valOrVarKeyword)
|
||||
else -> error("Declaration is neither a parameter nor a property: " + element.getElementTextWithContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public val ELSE_ENTRY: PositioningStrategy<JetWhenEntry> = object : PositioningStrategy<JetWhenEntry>() {
|
||||
override fun mark(element: JetWhenEntry): List<TextRange> {
|
||||
public val ELSE_ENTRY: PositioningStrategy<KtWhenEntry> = object : PositioningStrategy<KtWhenEntry>() {
|
||||
override fun mark(element: KtWhenEntry): List<TextRange> {
|
||||
return markElement(element.getElseKeyword()!!)
|
||||
}
|
||||
}
|
||||
|
||||
public val WHEN_EXPRESSION: PositioningStrategy<JetWhenExpression> = object : PositioningStrategy<JetWhenExpression>() {
|
||||
override fun mark(element: JetWhenExpression): List<TextRange> {
|
||||
public val WHEN_EXPRESSION: PositioningStrategy<KtWhenExpression> = object : PositioningStrategy<KtWhenExpression>() {
|
||||
override fun mark(element: KtWhenExpression): List<TextRange> {
|
||||
return markElement(element.getWhenKeyword())
|
||||
}
|
||||
}
|
||||
|
||||
public val WHEN_CONDITION_IN_RANGE: PositioningStrategy<JetWhenConditionInRange> = object : PositioningStrategy<JetWhenConditionInRange>() {
|
||||
override fun mark(element: JetWhenConditionInRange): List<TextRange> {
|
||||
public val WHEN_CONDITION_IN_RANGE: PositioningStrategy<KtWhenConditionInRange> = object : PositioningStrategy<KtWhenConditionInRange>() {
|
||||
override fun mark(element: KtWhenConditionInRange): List<TextRange> {
|
||||
return markElement(element.getOperationReference())
|
||||
}
|
||||
}
|
||||
|
||||
public val NULLABLE_TYPE: PositioningStrategy<JetNullableType> = object : PositioningStrategy<JetNullableType>() {
|
||||
override fun mark(element: JetNullableType): List<TextRange> {
|
||||
public val NULLABLE_TYPE: PositioningStrategy<KtNullableType> = object : PositioningStrategy<KtNullableType>() {
|
||||
override fun mark(element: KtNullableType): List<TextRange> {
|
||||
return markNode(element.getQuestionMarkNode())
|
||||
}
|
||||
}
|
||||
|
||||
public val CALL_EXPRESSION: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
if (element is JetCallExpression) {
|
||||
if (element is KtCallExpression) {
|
||||
return markRange(element, element.getTypeArgumentList() ?: element.getCalleeExpression() ?: element)
|
||||
}
|
||||
return markElement(element)
|
||||
}
|
||||
}
|
||||
|
||||
public val VALUE_ARGUMENTS: PositioningStrategy<JetElement> = object : PositioningStrategy<JetElement>() {
|
||||
override fun mark(element: JetElement): List<TextRange> {
|
||||
return markElement((element as? JetValueArgumentList)?.getRightParenthesis() ?: element)
|
||||
public val VALUE_ARGUMENTS: PositioningStrategy<KtElement> = object : PositioningStrategy<KtElement>() {
|
||||
override fun mark(element: KtElement): List<TextRange> {
|
||||
return markElement((element as? KtValueArgumentList)?.getRightParenthesis() ?: element)
|
||||
}
|
||||
}
|
||||
|
||||
public val FUNCTION_PARAMETERS: PositioningStrategy<JetFunction> = object : PositioningStrategy<JetFunction>() {
|
||||
override fun mark(element: JetFunction): List<TextRange> {
|
||||
public val FUNCTION_PARAMETERS: PositioningStrategy<KtFunction> = object : PositioningStrategy<KtFunction>() {
|
||||
override fun mark(element: KtFunction): List<TextRange> {
|
||||
val valueParameterList = element.getValueParameterList()
|
||||
if (valueParameterList != null) {
|
||||
return markElement(valueParameterList)
|
||||
}
|
||||
if (element is JetFunctionLiteral) {
|
||||
if (element is KtFunctionLiteral) {
|
||||
return markNode(element.getLBrace().getNode())
|
||||
}
|
||||
return DECLARATION_SIGNATURE_OR_DEFAULT.mark(element)
|
||||
}
|
||||
}
|
||||
|
||||
public val CUT_CHAR_QUOTES: PositioningStrategy<JetElement> = object : PositioningStrategy<JetElement>() {
|
||||
override fun mark(element: JetElement): List<TextRange> {
|
||||
if (element is JetConstantExpression) {
|
||||
if (element.getNode().getElementType() == JetNodeTypes.CHARACTER_CONSTANT) {
|
||||
public val CUT_CHAR_QUOTES: PositioningStrategy<KtElement> = object : PositioningStrategy<KtElement>() {
|
||||
override fun mark(element: KtElement): List<TextRange> {
|
||||
if (element is KtConstantExpression) {
|
||||
if (element.getNode().getElementType() == KtNodeTypes.CHARACTER_CONSTANT) {
|
||||
val elementTextRange = element.getTextRange()
|
||||
return listOf(TextRange.create(elementTextRange.getStartOffset() + 1, elementTextRange.getEndOffset() - 1))
|
||||
}
|
||||
@@ -381,10 +381,10 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val LONG_LITERAL_SUFFIX: PositioningStrategy<JetElement> = object : PositioningStrategy<JetElement>() {
|
||||
override fun mark(element: JetElement): List<TextRange> {
|
||||
if (element is JetConstantExpression) {
|
||||
if (element.getNode().getElementType() == JetNodeTypes.INTEGER_CONSTANT) {
|
||||
public val LONG_LITERAL_SUFFIX: PositioningStrategy<KtElement> = object : PositioningStrategy<KtElement>() {
|
||||
override fun mark(element: KtElement): List<TextRange> {
|
||||
if (element is KtConstantExpression) {
|
||||
if (element.getNode().getElementType() == KtNodeTypes.INTEGER_CONSTANT) {
|
||||
val endOffset = element.endOffset
|
||||
return listOf(TextRange.create(endOffset - 1, endOffset))
|
||||
}
|
||||
@@ -399,26 +399,26 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val AS_TYPE: PositioningStrategy<JetBinaryExpressionWithTypeRHS> = object : PositioningStrategy<JetBinaryExpressionWithTypeRHS>() {
|
||||
override fun mark(element: JetBinaryExpressionWithTypeRHS): List<TextRange> {
|
||||
public val AS_TYPE: PositioningStrategy<KtBinaryExpressionWithTypeRHS> = object : PositioningStrategy<KtBinaryExpressionWithTypeRHS>() {
|
||||
override fun mark(element: KtBinaryExpressionWithTypeRHS): List<TextRange> {
|
||||
return markRange(element.getOperationReference(), element)
|
||||
}
|
||||
}
|
||||
|
||||
public val COMPANION_OBJECT: PositioningStrategy<JetObjectDeclaration> = object : PositioningStrategy<JetObjectDeclaration>() {
|
||||
override fun mark(element: JetObjectDeclaration): List<TextRange> {
|
||||
if (element.hasModifier(JetTokens.COMPANION_KEYWORD)) {
|
||||
return modifierSetPosition(JetTokens.COMPANION_KEYWORD).mark(element)
|
||||
public val COMPANION_OBJECT: PositioningStrategy<KtObjectDeclaration> = object : PositioningStrategy<KtObjectDeclaration>() {
|
||||
override fun mark(element: KtObjectDeclaration): List<TextRange> {
|
||||
if (element.hasModifier(KtTokens.COMPANION_KEYWORD)) {
|
||||
return modifierSetPosition(KtTokens.COMPANION_KEYWORD).mark(element)
|
||||
}
|
||||
return DEFAULT.mark(element)
|
||||
}
|
||||
}
|
||||
|
||||
public val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: PositioningStrategy<JetConstructorDelegationCall> =
|
||||
object : PositioningStrategy<JetConstructorDelegationCall>() {
|
||||
override fun mark(element: JetConstructorDelegationCall): List<TextRange> {
|
||||
public val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: PositioningStrategy<KtConstructorDelegationCall> =
|
||||
object : PositioningStrategy<KtConstructorDelegationCall>() {
|
||||
override fun mark(element: KtConstructorDelegationCall): List<TextRange> {
|
||||
if (element.isImplicit()) {
|
||||
val constructor = element.getStrictParentOfType<JetSecondaryConstructor>()!!
|
||||
val constructor = element.getStrictParentOfType<KtSecondaryConstructor>()!!
|
||||
val valueParameterList = constructor.getValueParameterList() ?: return markElement(constructor)
|
||||
return markRange(constructor.getConstructorKeyword(), valueParameterList.getLastChild())
|
||||
}
|
||||
@@ -426,30 +426,30 @@ public object PositioningStrategies {
|
||||
}
|
||||
}
|
||||
|
||||
public val DELEGATOR_SUPER_CALL: PositioningStrategy<JetEnumEntry> = object: PositioningStrategy<JetEnumEntry>() {
|
||||
override fun mark(element: JetEnumEntry): List<TextRange> {
|
||||
public val DELEGATOR_SUPER_CALL: PositioningStrategy<KtEnumEntry> = object: PositioningStrategy<KtEnumEntry>() {
|
||||
override fun mark(element: KtEnumEntry): List<TextRange> {
|
||||
val specifiers = element.getDelegationSpecifiers()
|
||||
return markElement(if (specifiers.isEmpty()) element else specifiers[0])
|
||||
}
|
||||
}
|
||||
|
||||
public val UNUSED_VALUE: PositioningStrategy<JetBinaryExpression> = object: PositioningStrategy<JetBinaryExpression>() {
|
||||
override fun mark(element: JetBinaryExpression): List<TextRange> {
|
||||
public val UNUSED_VALUE: PositioningStrategy<KtBinaryExpression> = object: PositioningStrategy<KtBinaryExpression>() {
|
||||
override fun mark(element: KtBinaryExpression): List<TextRange> {
|
||||
return listOf(TextRange(element.getLeft()!!.startOffset, element.getOperationReference().endOffset))
|
||||
}
|
||||
}
|
||||
|
||||
public val USELESS_ELVIS: PositioningStrategy<JetBinaryExpression> = object: PositioningStrategy<JetBinaryExpression>() {
|
||||
override fun mark(element: JetBinaryExpression): List<TextRange> {
|
||||
public val USELESS_ELVIS: PositioningStrategy<KtBinaryExpression> = object: PositioningStrategy<KtBinaryExpression>() {
|
||||
override fun mark(element: KtBinaryExpression): List<TextRange> {
|
||||
return listOf(TextRange(element.getOperationReference().startOffset, element.endOffset))
|
||||
}
|
||||
}
|
||||
|
||||
public val IMPORT_ALIAS: PositioningStrategy<JetImportDirective> = object: PositioningStrategy<JetImportDirective>() {
|
||||
override fun mark(element: JetImportDirective): List<TextRange> {
|
||||
public val IMPORT_ALIAS: PositioningStrategy<KtImportDirective> = object: PositioningStrategy<KtImportDirective>() {
|
||||
override fun mark(element: KtImportDirective): List<TextRange> {
|
||||
element.aliasNameNode?.let { return markNode(it) }
|
||||
element.importedReference?.let {
|
||||
if (it is JetQualifiedExpression) {
|
||||
if (it is KtQualifiedExpression) {
|
||||
it.selectorExpression?.let { return markElement(it) }
|
||||
}
|
||||
return markElement(it)
|
||||
|
||||
+12
-12
@@ -25,15 +25,15 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.kotlin.psi.JetTypeConstraint;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression;
|
||||
import org.jetbrains.kotlin.psi.KtTypeConstraint;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
|
||||
import org.jetbrains.kotlin.renderer.MultiRenderer;
|
||||
import org.jetbrains.kotlin.renderer.Renderer;
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
|
||||
@@ -387,10 +387,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(IMPLICIT_CAST_TO_UNIT_OR_ANY, "Type is cast to ''{0}''. Please specify ''{0}'' as expected type, if you mean such cast",
|
||||
RENDER_TYPE);
|
||||
MAP.put(EXPRESSION_EXPECTED, "{0} is not an expression, and only expressions are allowed here", new Renderer<JetExpression>() {
|
||||
MAP.put(EXPRESSION_EXPECTED, "{0} is not an expression, and only expressions are allowed here", new Renderer<KtExpression>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull JetExpression expression) {
|
||||
public String render(@NotNull KtExpression expression) {
|
||||
String expressionType = expression.toString();
|
||||
return expressionType.substring(0, 1) +
|
||||
expressionType.substring(1).toLowerCase();
|
||||
@@ -477,10 +477,10 @@ public class DefaultErrorMessages {
|
||||
MAP.put(UNEXPECTED_SAFE_CALL, "Safe-call is not allowed here");
|
||||
MAP.put(UNNECESSARY_NOT_NULL_ASSERTION, "Unnecessary non-null assertion (!!) on a non-null receiver of type {0}", RENDER_TYPE);
|
||||
MAP.put(NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL, "Non-null assertion (!!) is called on function literal");
|
||||
MAP.put(NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER, "{0} does not refer to a type parameter of {1}", new Renderer<JetTypeConstraint>() {
|
||||
MAP.put(NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER, "{0} does not refer to a type parameter of {1}", new Renderer<KtTypeConstraint>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull JetTypeConstraint typeConstraint) {
|
||||
public String render(@NotNull KtTypeConstraint typeConstraint) {
|
||||
//noinspection ConstantConditions
|
||||
return typeConstraint.getSubjectTypeParameterName().getReferencedName();
|
||||
}
|
||||
@@ -525,10 +525,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(INCONSISTENT_TYPE_PARAMETER_VALUES, "Type parameter {0} of ''{1}'' has inconsistent values: {2}", NAME, NAME, RENDER_COLLECTION_OF_TYPES);
|
||||
|
||||
MAP.put(EQUALITY_NOT_APPLICABLE, "Operator ''{0}'' cannot be applied to ''{1}'' and ''{2}''", new Renderer<JetSimpleNameExpression>() {
|
||||
MAP.put(EQUALITY_NOT_APPLICABLE, "Operator ''{0}'' cannot be applied to ''{1}'' and ''{2}''", new Renderer<KtSimpleNameExpression>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull JetSimpleNameExpression nameExpression) {
|
||||
public String render(@NotNull KtSimpleNameExpression nameExpression) {
|
||||
//noinspection ConstantConditions
|
||||
return nameExpression.getReferencedName();
|
||||
}
|
||||
@@ -565,10 +565,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
||||
ELEMENT_TEXT, new Renderer<JetType>() {
|
||||
ELEMENT_TEXT, new Renderer<KtType>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull JetType type) {
|
||||
public String render(@NotNull KtType type) {
|
||||
if (type.isError()) return "";
|
||||
return " of type '" + RENDER_TYPE.render(type) + "'";
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.newTable
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.newText
|
||||
import org.jetbrains.kotlin.psi.JetClass
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject
|
||||
import org.jetbrains.kotlin.psi.JetNamedDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.renderer.Renderer
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
@@ -41,10 +41,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
|
||||
@@ -83,17 +83,17 @@ public object Renderers {
|
||||
|
||||
public val ELEMENT_TEXT: Renderer<PsiElement> = Renderer { it.getText() }
|
||||
|
||||
public val DECLARATION_NAME: Renderer<JetNamedDeclaration> = Renderer { it.getNameAsSafeName().asString() }
|
||||
public val DECLARATION_NAME: Renderer<KtNamedDeclaration> = Renderer { it.getNameAsSafeName().asString() }
|
||||
|
||||
public val RENDER_CLASS_OR_OBJECT: Renderer<JetClassOrObject> = Renderer {
|
||||
classOrObject: JetClassOrObject ->
|
||||
public val RENDER_CLASS_OR_OBJECT: Renderer<KtClassOrObject> = Renderer {
|
||||
classOrObject: KtClassOrObject ->
|
||||
val name = if (classOrObject.getName() != null) " '" + classOrObject.getName() + "'" else ""
|
||||
if (classOrObject is JetClass) "Class" + name else "Object" + name
|
||||
if (classOrObject is KtClass) "Class" + name else "Object" + name
|
||||
}
|
||||
|
||||
public val RENDER_CLASS_OR_OBJECT_NAME: Renderer<ClassDescriptor> = Renderer { it.renderKindWithName() }
|
||||
|
||||
public val RENDER_TYPE: Renderer<JetType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
|
||||
public val RENDER_TYPE: Renderer<KtType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
|
||||
|
||||
public val RENDER_POSITION_VARIANCE: Renderer<Variance> = Renderer {
|
||||
variance: Variance ->
|
||||
@@ -179,18 +179,18 @@ public object Renderers {
|
||||
val receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getExtensionReceiverParameter())
|
||||
|
||||
val errorPositions = Sets.newHashSet<ConstraintPosition>()
|
||||
val parameterTypes = Lists.newArrayList<JetType>()
|
||||
val parameterTypes = Lists.newArrayList<KtType>()
|
||||
for (valueParameterDescriptor in substitutedDescriptor.getValueParameters()) {
|
||||
parameterTypes.add(valueParameterDescriptor.getType())
|
||||
if (valueParameterDescriptor.getIndex() >= inferenceErrorData.valueArgumentsTypes.size()) continue
|
||||
val actualType = inferenceErrorData.valueArgumentsTypes.get(valueParameterDescriptor.getIndex())
|
||||
if (!JetTypeChecker.DEFAULT.isSubtypeOf(actualType, valueParameterDescriptor.getType())) {
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(actualType, valueParameterDescriptor.getType())) {
|
||||
errorPositions.add(VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex()))
|
||||
}
|
||||
}
|
||||
|
||||
if (receiverType != null && inferenceErrorData.receiverArgumentType != null
|
||||
&& !JetTypeChecker.DEFAULT.isSubtypeOf(inferenceErrorData.receiverArgumentType, receiverType)) {
|
||||
&& !KotlinTypeChecker.DEFAULT.isSubtypeOf(inferenceErrorData.receiverArgumentType, receiverType)) {
|
||||
errorPositions.add(RECEIVER_POSITION.position())
|
||||
}
|
||||
|
||||
@@ -279,11 +279,11 @@ public object Renderers {
|
||||
.table(newTable()
|
||||
.descriptor(inferenceErrorData.descriptor))
|
||||
|
||||
var violatedUpperBound: JetType? = null
|
||||
var violatedUpperBound: KtType? = null
|
||||
for (upperBound in typeParameterDescriptor.getUpperBounds()) {
|
||||
val upperBoundWithSubstitutedInferredTypes = systemWithoutWeakConstraints.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT)
|
||||
if (upperBoundWithSubstitutedInferredTypes != null
|
||||
&& !JetTypeChecker.DEFAULT.isSubtypeOf(inferredValueForTypeParameter, upperBoundWithSubstitutedInferredTypes)) {
|
||||
&& !KotlinTypeChecker.DEFAULT.isSubtypeOf(inferredValueForTypeParameter, upperBoundWithSubstitutedInferredTypes)) {
|
||||
violatedUpperBound = upperBoundWithSubstitutedInferredTypes
|
||||
break
|
||||
}
|
||||
@@ -356,9 +356,9 @@ public object Renderers {
|
||||
}.toString()
|
||||
}
|
||||
|
||||
private fun renderTypes(types: Collection<JetType>) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ")
|
||||
private fun renderTypes(types: Collection<KtType>) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ")
|
||||
|
||||
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<JetType>> = Renderer { renderTypes(it) }
|
||||
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<KtType>> = Renderer { renderTypes(it) }
|
||||
|
||||
private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer<TypeBounds>): String {
|
||||
val typeVariables = constraintSystem.getTypeVariables()
|
||||
|
||||
+11
-11
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.TextR
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.renderer.Renderer;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -50,11 +50,11 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
public static class FunctionArgumentsRow implements TableRow {
|
||||
public final JetType receiverType;
|
||||
public final List<JetType> argumentTypes;
|
||||
public final KtType receiverType;
|
||||
public final List<KtType> argumentTypes;
|
||||
public final Predicate<ConstraintPosition> isErrorPosition;
|
||||
|
||||
public FunctionArgumentsRow(JetType receiverType, List<JetType> argumentTypes, Predicate<ConstraintPosition> isErrorPosition) {
|
||||
public FunctionArgumentsRow(KtType receiverType, List<KtType> argumentTypes, Predicate<ConstraintPosition> isErrorPosition) {
|
||||
this.receiverType = receiverType;
|
||||
this.argumentTypes = argumentTypes;
|
||||
this.isErrorPosition = isErrorPosition;
|
||||
@@ -68,13 +68,13 @@ public class TabledDescriptorRenderer {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableRenderer functionArgumentTypeList(@Nullable JetType receiverType, @NotNull List<JetType> argumentTypes) {
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType, @NotNull List<KtType> argumentTypes) {
|
||||
|
||||
return functionArgumentTypeList(receiverType, argumentTypes, Predicates.<ConstraintPosition>alwaysFalse());
|
||||
}
|
||||
|
||||
public TableRenderer functionArgumentTypeList(@Nullable JetType receiverType,
|
||||
@NotNull List<JetType> argumentTypes,
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> argumentTypes,
|
||||
@NotNull Predicate<ConstraintPosition> isErrorPosition) {
|
||||
rows.add(new FunctionArgumentsRow(receiverType, argumentTypes, isErrorPosition));
|
||||
return this;
|
||||
@@ -156,7 +156,7 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Renderer<JetType> getTypeRenderer() {
|
||||
public Renderer<KtType> getTypeRenderer() {
|
||||
return Renderers.RENDER_TYPE;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFunctionArguments(@Nullable JetType receiverType, @NotNull List<JetType> argumentTypes, StringBuilder result) {
|
||||
private void renderFunctionArguments(@Nullable KtType receiverType, @NotNull List<KtType> argumentTypes, StringBuilder result) {
|
||||
boolean hasReceiver = receiverType != null;
|
||||
if (hasReceiver) {
|
||||
result.append("receiver: ");
|
||||
@@ -196,8 +196,8 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
result.append("(");
|
||||
for (Iterator<JetType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||
JetType argumentType = iterator.next();
|
||||
for (Iterator<KtType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType argumentType = iterator.next();
|
||||
String renderedArgument = getTypeRenderer().render(argumentType);
|
||||
|
||||
result.append(renderedArgument);
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.extensions
|
||||
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
public interface ExternalDeclarationsProvider {
|
||||
companion object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>(
|
||||
@@ -26,5 +26,5 @@ public interface ExternalDeclarationsProvider {
|
||||
javaClass<ExternalDeclarationsProvider>()
|
||||
)
|
||||
|
||||
public fun getExternalDeclarations(moduleInfo: ModuleInfo?): Collection<JetFile>
|
||||
public fun getExternalDeclarations(moduleInfo: ModuleInfo?): Collection<KtFile>
|
||||
}
|
||||
+3
-3
@@ -23,9 +23,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class JetFileType extends LanguageFileType {
|
||||
public class KotlinFileType extends LanguageFileType {
|
||||
public static final String EXTENSION = "kt";
|
||||
public static final JetFileType INSTANCE = new JetFileType();
|
||||
public static final KotlinFileType INSTANCE = new KotlinFileType();
|
||||
|
||||
private final NotNullLazyValue<Icon> myIcon = new NotNullLazyValue<Icon>() {
|
||||
@NotNull
|
||||
@@ -35,7 +35,7 @@ public class JetFileType extends LanguageFileType {
|
||||
}
|
||||
};
|
||||
|
||||
private JetFileType() {
|
||||
private KotlinFileType() {
|
||||
super(KotlinLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ 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.psi.JetAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
@@ -36,14 +36,14 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class MainFunctionDetector {
|
||||
private final NotNullFunction<JetNamedFunction, FunctionDescriptor> getFunctionDescriptor;
|
||||
private final NotNullFunction<KtNamedFunction, FunctionDescriptor> getFunctionDescriptor;
|
||||
|
||||
/** Assumes that the function declaration is already resolved and the descriptor can be found in the {@code bindingContext}. */
|
||||
public MainFunctionDetector(@NotNull final BindingContext bindingContext) {
|
||||
this.getFunctionDescriptor = new NotNullFunction<JetNamedFunction, FunctionDescriptor>() {
|
||||
this.getFunctionDescriptor = new NotNullFunction<KtNamedFunction, FunctionDescriptor>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public FunctionDescriptor fun(JetNamedFunction function) {
|
||||
public FunctionDescriptor fun(KtNamedFunction function) {
|
||||
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, function);
|
||||
if (functionDescriptor == null) {
|
||||
throw new IllegalStateException("No descriptor resolved for " + function + " " + function.getText());
|
||||
@@ -53,15 +53,15 @@ public class MainFunctionDetector {
|
||||
};
|
||||
}
|
||||
|
||||
public MainFunctionDetector(@NotNull NotNullFunction<JetNamedFunction, FunctionDescriptor> functionResolver) {
|
||||
public MainFunctionDetector(@NotNull NotNullFunction<KtNamedFunction, FunctionDescriptor> functionResolver) {
|
||||
this.getFunctionDescriptor = functionResolver;
|
||||
}
|
||||
|
||||
public boolean hasMain(@NotNull List<JetDeclaration> declarations) {
|
||||
public boolean hasMain(@NotNull List<KtDeclaration> declarations) {
|
||||
return findMainFunction(declarations) != null;
|
||||
}
|
||||
|
||||
public boolean isMain(@NotNull JetNamedFunction function) {
|
||||
public boolean isMain(@NotNull KtNamedFunction function) {
|
||||
if (function.isLocal()) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,13 +89,13 @@ public class MainFunctionDetector {
|
||||
if (parameters.size() != 1) return false;
|
||||
|
||||
ValueParameterDescriptor parameter = parameters.get(0);
|
||||
JetType parameterType = parameter.getType();
|
||||
KtType parameterType = parameter.getType();
|
||||
if (!KotlinBuiltIns.isArray(parameterType)) return false;
|
||||
|
||||
List<TypeProjection> typeArguments = parameterType.getArguments();
|
||||
if (typeArguments.size() != 1) return false;
|
||||
|
||||
JetType typeArgument = typeArguments.get(0).getType();
|
||||
KtType typeArgument = typeArguments.get(0).getType();
|
||||
if (!KotlinBuiltIns.isString(typeArgument)) {
|
||||
return false;
|
||||
}
|
||||
@@ -112,9 +112,9 @@ public class MainFunctionDetector {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetNamedFunction getMainFunction(@NotNull Collection<JetFile> files) {
|
||||
for (JetFile file : files) {
|
||||
JetNamedFunction mainFunction = findMainFunction(file.getDeclarations());
|
||||
public KtNamedFunction getMainFunction(@NotNull Collection<KtFile> files) {
|
||||
for (KtFile file : files) {
|
||||
KtNamedFunction mainFunction = findMainFunction(file.getDeclarations());
|
||||
if (mainFunction != null) {
|
||||
return mainFunction;
|
||||
}
|
||||
@@ -123,10 +123,10 @@ public class MainFunctionDetector {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JetNamedFunction findMainFunction(@NotNull List<JetDeclaration> declarations) {
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
if (declaration instanceof JetNamedFunction) {
|
||||
JetNamedFunction candidateFunction = (JetNamedFunction) declaration;
|
||||
private KtNamedFunction findMainFunction(@NotNull List<KtDeclaration> declarations) {
|
||||
for (KtDeclaration declaration : declarations) {
|
||||
if (declaration instanceof KtNamedFunction) {
|
||||
KtNamedFunction candidateFunction = (KtNamedFunction) declaration;
|
||||
if (isMain(candidateFunction)) {
|
||||
return candidateFunction;
|
||||
}
|
||||
@@ -145,8 +145,8 @@ public class MainFunctionDetector {
|
||||
return functionDescriptor.getName().asString();
|
||||
}
|
||||
|
||||
private static boolean hasAnnotationWithExactNumberOfArguments(@NotNull JetNamedFunction function, int number) {
|
||||
for (JetAnnotationEntry entry : function.getAnnotationEntries()) {
|
||||
private static boolean hasAnnotationWithExactNumberOfArguments(@NotNull KtNamedFunction function, int number) {
|
||||
for (KtAnnotationEntry entry : function.getAnnotationEntries()) {
|
||||
if (entry.getValueArguments().size() == number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
package org.jetbrains.kotlin.incremental
|
||||
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
|
||||
class KotlinLookupLocation(val element: JetElement) : LookupLocation
|
||||
class KotlinLookupLocation(val element: KtElement) : LookupLocation
|
||||
|
||||
@@ -26,9 +26,9 @@ import org.jetbrains.kotlin.incremental.components.ScopeKind
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.doNotAnalyze
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
|
||||
public fun LookupTracker.record(from: LookupLocation, inScope: JetScope, name: Name) {
|
||||
public fun LookupTracker.record(from: LookupLocation, inScope: KtScope, name: Name) {
|
||||
if (this == LookupTracker.DO_NOTHING || from is NoLookupLocation) return
|
||||
|
||||
if (from !is KotlinLookupLocation) throw AssertionError("Unexpected location type: ${from.javaClass}")
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.kdoc.lexer;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.lexer.JetToken;
|
||||
import org.jetbrains.kotlin.lexer.KtToken;
|
||||
|
||||
public class KDocToken extends JetToken {
|
||||
public class KDocToken extends KtToken {
|
||||
public KDocToken(@NotNull @NonNls String debugName) {
|
||||
super(debugName);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import java.lang.Character;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import com.intellij.lang.PsiParser
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.lang.PsiBuilder
|
||||
import com.intellij.lang.ASTNode
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.JetLexer
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.lexer.KotlinLexer
|
||||
import com.intellij.lang.PsiBuilderFactory
|
||||
import kotlin.platform.*
|
||||
|
||||
@@ -36,7 +36,7 @@ class KDocLinkParser(): PsiParser {
|
||||
val project = parentElement.getProject()
|
||||
val builder = PsiBuilderFactory.getInstance().createBuilder(project,
|
||||
chameleon,
|
||||
JetLexer(),
|
||||
KotlinLexer(),
|
||||
root.getLanguage(),
|
||||
chameleon.getText())
|
||||
val parser = KDocLinkParser()
|
||||
@@ -47,19 +47,19 @@ class KDocLinkParser(): PsiParser {
|
||||
|
||||
override fun parse(root: IElementType, builder: PsiBuilder): ASTNode {
|
||||
val rootMarker = builder.mark()
|
||||
val hasLBracket = builder.getTokenType() == JetTokens.LBRACKET
|
||||
val hasLBracket = builder.getTokenType() == KtTokens.LBRACKET
|
||||
if (hasLBracket) {
|
||||
builder.advanceLexer()
|
||||
}
|
||||
parseQualifiedName(builder)
|
||||
if (hasLBracket) {
|
||||
if (!builder.eof() && builder.getTokenType() != JetTokens.RBRACKET) {
|
||||
if (!builder.eof() && builder.getTokenType() != KtTokens.RBRACKET) {
|
||||
builder.error("Closing bracket expected")
|
||||
while (!builder.eof() && builder.getTokenType() != JetTokens.RBRACKET) {
|
||||
while (!builder.eof() && builder.getTokenType() != KtTokens.RBRACKET) {
|
||||
builder.advanceLexer()
|
||||
}
|
||||
}
|
||||
if (builder.getTokenType() == JetTokens.RBRACKET) {
|
||||
if (builder.getTokenType() == KtTokens.RBRACKET) {
|
||||
builder.advanceLexer()
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class KDocLinkParser(): PsiParser {
|
||||
}
|
||||
builder.advanceLexer()
|
||||
marker.done(KDocElementTypes.KDOC_NAME)
|
||||
if (builder.getTokenType() != JetTokens.DOT) {
|
||||
if (builder.getTokenType() != KtTokens.DOT) {
|
||||
break
|
||||
}
|
||||
marker = marker.precede()
|
||||
@@ -94,5 +94,5 @@ class KDocLinkParser(): PsiParser {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isName(tokenType: IElementType?) = tokenType == JetTokens.IDENTIFIER || tokenType in JetTokens.KEYWORDS
|
||||
private fun isName(tokenType: IElementType?) = tokenType == KtTokens.IDENTIFIER || tokenType in KtTokens.KEYWORDS
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ package org.jetbrains.kotlin.kdoc.psi.api
|
||||
|
||||
import com.intellij.psi.PsiComment
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
|
||||
|
||||
// Don't implement JetElement (or it will be treated as statement)
|
||||
public interface KDoc : PsiComment {
|
||||
public fun getOwner(): JetDeclaration?
|
||||
public fun getOwner(): KtDeclaration?
|
||||
public fun getDefaultSection(): KDocSection
|
||||
public fun findSectionByName(name: String): KDocSection?
|
||||
public fun findSectionByTag(tag: KDocKnownTag): KDocSection?
|
||||
|
||||
@@ -22,8 +22,8 @@ import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
|
||||
@@ -35,9 +35,9 @@ public class KDocImpl(buffer: CharSequence?) : LazyParseablePsiElement(KDocToken
|
||||
|
||||
override fun toString(): String = getNode().getElementType().toString()
|
||||
|
||||
override fun getTokenType(): IElementType = JetTokens.DOC_COMMENT
|
||||
override fun getTokenType(): IElementType = KtTokens.DOC_COMMENT
|
||||
|
||||
override fun getOwner(): JetDeclaration? = getParentOfType<JetDeclaration>(true)
|
||||
override fun getOwner(): KtDeclaration? = getParentOfType<KtDeclaration>(true)
|
||||
|
||||
override fun getDefaultSection(): KDocSection = getChildOfType<KDocSection>()!!
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ import com.intellij.lang.ASTNode
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry
|
||||
import org.jetbrains.kotlin.psi.JetElementImpl
|
||||
import org.jetbrains.kotlin.psi.KtElementImpl
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
public class KDocLink(node: ASTNode) : JetElementImpl(node) {
|
||||
public class KDocLink(node: ASTNode) : KtElementImpl(node) {
|
||||
public fun getLinkText(): String = getLinkTextRange().substring(getText())
|
||||
|
||||
public fun getLinkTextRange(): TextRange {
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
package org.jetbrains.kotlin.kdoc.psi.impl
|
||||
|
||||
import com.intellij.lang.ASTNode
|
||||
import org.jetbrains.kotlin.psi.JetElementImpl
|
||||
import org.jetbrains.kotlin.psi.KtElementImpl
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
||||
|
||||
/**
|
||||
* A single part of a qualified name in the tag subject or link.
|
||||
*/
|
||||
public class KDocName(node: ASTNode): JetElementImpl(node) {
|
||||
public class KDocName(node: ASTNode): KtElementImpl(node) {
|
||||
public fun getContainingDoc(): KDoc {
|
||||
val kdoc = getStrictParentOfType<KDoc>()
|
||||
return kdoc ?: throw IllegalStateException("KDocName must be inside a KDoc")
|
||||
@@ -45,7 +45,7 @@ public class KDocName(node: ASTNode): JetElementImpl(node) {
|
||||
* the range of the element excluding the qualifier and dot, if present).
|
||||
*/
|
||||
public fun getNameTextRange(): TextRange {
|
||||
val dot = getNode().findChildByType(JetTokens.DOT)
|
||||
val dot = getNode().findChildByType(KtTokens.DOT)
|
||||
val textRange = getTextRange()
|
||||
val nameStart = if (dot != null) dot.getTextRange().getEndOffset() - textRange.getStartOffset() else 0
|
||||
return TextRange(nameStart, textRange.getLength())
|
||||
|
||||
@@ -1,245 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.lexer;
|
||||
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens;
|
||||
|
||||
public interface JetTokens {
|
||||
JetToken EOF = new JetToken("EOF");
|
||||
|
||||
JetToken BLOCK_COMMENT = new JetToken("BLOCK_COMMENT");
|
||||
JetToken EOL_COMMENT = new JetToken("EOL_COMMENT");
|
||||
JetToken SHEBANG_COMMENT = new JetToken("SHEBANG_COMMENT");
|
||||
|
||||
//JetToken DOC_COMMENT = new JetToken("DOC_COMMENT");
|
||||
IElementType DOC_COMMENT = KDocTokens.KDOC;
|
||||
|
||||
IElementType WHITE_SPACE = TokenType.WHITE_SPACE;
|
||||
|
||||
JetToken INTEGER_LITERAL = new JetToken("INTEGER_LITERAL");
|
||||
JetToken FLOAT_LITERAL = new JetToken("FLOAT_CONSTANT");
|
||||
JetToken CHARACTER_LITERAL = new JetToken("CHARACTER_LITERAL");
|
||||
|
||||
JetToken CLOSING_QUOTE = new JetToken("CLOSING_QUOTE");
|
||||
JetToken OPEN_QUOTE = new JetToken("OPEN_QUOTE");
|
||||
JetToken REGULAR_STRING_PART = new JetToken("REGULAR_STRING_PART");
|
||||
JetToken ESCAPE_SEQUENCE = new JetToken("ESCAPE_SEQUENCE");
|
||||
JetToken SHORT_TEMPLATE_ENTRY_START = new JetToken("SHORT_TEMPLATE_ENTRY_START");
|
||||
JetToken LONG_TEMPLATE_ENTRY_START = new JetToken("LONG_TEMPLATE_ENTRY_START");
|
||||
JetToken LONG_TEMPLATE_ENTRY_END = new JetToken("LONG_TEMPLATE_ENTRY_END");
|
||||
JetToken DANGLING_NEWLINE = new JetToken("DANGLING_NEWLINE");
|
||||
|
||||
JetKeywordToken PACKAGE_KEYWORD = JetKeywordToken.keyword("package");
|
||||
JetKeywordToken AS_KEYWORD = JetKeywordToken.keyword("as");
|
||||
JetKeywordToken TYPE_ALIAS_KEYWORD = JetKeywordToken.keyword("typealias");
|
||||
JetKeywordToken CLASS_KEYWORD = JetKeywordToken.keyword("class");
|
||||
JetKeywordToken THIS_KEYWORD = JetKeywordToken.keyword("this");
|
||||
JetKeywordToken SUPER_KEYWORD = JetKeywordToken.keyword("super");
|
||||
JetKeywordToken VAL_KEYWORD = JetKeywordToken.keyword("val");
|
||||
JetKeywordToken VAR_KEYWORD = JetKeywordToken.keyword("var");
|
||||
JetKeywordToken FUN_KEYWORD = JetKeywordToken.keyword("fun");
|
||||
JetKeywordToken FOR_KEYWORD = JetKeywordToken.keyword("for");
|
||||
JetKeywordToken NULL_KEYWORD = JetKeywordToken.keyword("null");
|
||||
JetKeywordToken TRUE_KEYWORD = JetKeywordToken.keyword("true");
|
||||
JetKeywordToken FALSE_KEYWORD = JetKeywordToken.keyword("false");
|
||||
JetKeywordToken IS_KEYWORD = JetKeywordToken.keyword("is");
|
||||
JetModifierKeywordToken IN_KEYWORD = JetModifierKeywordToken.keywordModifier("in");
|
||||
JetKeywordToken THROW_KEYWORD = JetKeywordToken.keyword("throw");
|
||||
JetKeywordToken RETURN_KEYWORD = JetKeywordToken.keyword("return");
|
||||
JetKeywordToken BREAK_KEYWORD = JetKeywordToken.keyword("break");
|
||||
JetKeywordToken CONTINUE_KEYWORD = JetKeywordToken.keyword("continue");
|
||||
JetKeywordToken OBJECT_KEYWORD = JetKeywordToken.keyword("object");
|
||||
JetKeywordToken IF_KEYWORD = JetKeywordToken.keyword("if");
|
||||
JetKeywordToken TRY_KEYWORD = JetKeywordToken.keyword("try");
|
||||
JetKeywordToken ELSE_KEYWORD = JetKeywordToken.keyword("else");
|
||||
JetKeywordToken WHILE_KEYWORD = JetKeywordToken.keyword("while");
|
||||
JetKeywordToken DO_KEYWORD = JetKeywordToken.keyword("do");
|
||||
JetKeywordToken WHEN_KEYWORD = JetKeywordToken.keyword("when");
|
||||
JetKeywordToken INTERFACE_KEYWORD = JetKeywordToken.keyword("interface");
|
||||
// TODO: Discuss "This" keyword
|
||||
JetKeywordToken CAPITALIZED_THIS_KEYWORD = JetKeywordToken.keyword("This");
|
||||
|
||||
|
||||
JetToken AS_SAFE = JetKeywordToken.keyword("AS_SAFE");//new JetToken("as?");
|
||||
|
||||
JetToken IDENTIFIER = new JetToken("IDENTIFIER");
|
||||
|
||||
JetToken FIELD_IDENTIFIER = new JetToken("FIELD_IDENTIFIER");
|
||||
JetSingleValueToken LBRACKET = new JetSingleValueToken("LBRACKET", "[");
|
||||
JetSingleValueToken RBRACKET = new JetSingleValueToken("RBRACKET", "]");
|
||||
JetSingleValueToken LBRACE = new JetSingleValueToken("LBRACE", "{");
|
||||
JetSingleValueToken RBRACE = new JetSingleValueToken("RBRACE", "}");
|
||||
JetSingleValueToken LPAR = new JetSingleValueToken("LPAR", "(");
|
||||
JetSingleValueToken RPAR = new JetSingleValueToken("RPAR", ")");
|
||||
JetSingleValueToken DOT = new JetSingleValueToken("DOT", ".");
|
||||
JetSingleValueToken PLUSPLUS = new JetSingleValueToken("PLUSPLUS", "++");
|
||||
JetSingleValueToken MINUSMINUS = new JetSingleValueToken("MINUSMINUS", "--");
|
||||
JetSingleValueToken MUL = new JetSingleValueToken("MUL", "*");
|
||||
JetSingleValueToken PLUS = new JetSingleValueToken("PLUS", "+");
|
||||
JetSingleValueToken MINUS = new JetSingleValueToken("MINUS", "-");
|
||||
JetSingleValueToken EXCL = new JetSingleValueToken("EXCL", "!");
|
||||
JetSingleValueToken DIV = new JetSingleValueToken("DIV", "/");
|
||||
JetSingleValueToken PERC = new JetSingleValueToken("PERC", "%");
|
||||
JetSingleValueToken LT = new JetSingleValueToken("LT", "<");
|
||||
JetSingleValueToken GT = new JetSingleValueToken("GT", ">");
|
||||
JetSingleValueToken LTEQ = new JetSingleValueToken("LTEQ", "<=");
|
||||
JetSingleValueToken GTEQ = new JetSingleValueToken("GTEQ", ">=");
|
||||
JetSingleValueToken EQEQEQ = new JetSingleValueToken("EQEQEQ", "===");
|
||||
JetSingleValueToken ARROW = new JetSingleValueToken("ARROW", "->");
|
||||
JetSingleValueToken DOUBLE_ARROW = new JetSingleValueToken("DOUBLE_ARROW", "=>");
|
||||
JetSingleValueToken EXCLEQEQEQ = new JetSingleValueToken("EXCLEQEQEQ", "!==");
|
||||
JetSingleValueToken EQEQ = new JetSingleValueToken("EQEQ", "==");
|
||||
JetSingleValueToken EXCLEQ = new JetSingleValueToken("EXCLEQ", "!=");
|
||||
JetSingleValueToken EXCLEXCL = new JetSingleValueToken("EXCLEXCL", "!!");
|
||||
JetSingleValueToken ANDAND = new JetSingleValueToken("ANDAND", "&&");
|
||||
JetSingleValueToken OROR = new JetSingleValueToken("OROR", "||");
|
||||
JetSingleValueToken SAFE_ACCESS = new JetSingleValueToken("SAFE_ACCESS", "?.");
|
||||
JetSingleValueToken ELVIS = new JetSingleValueToken("ELVIS", "?:");
|
||||
JetSingleValueToken QUEST = new JetSingleValueToken("QUEST", "?");
|
||||
JetSingleValueToken COLONCOLON = new JetSingleValueToken("COLONCOLON", "::");
|
||||
JetSingleValueToken COLON = new JetSingleValueToken("COLON", ":");
|
||||
JetSingleValueToken SEMICOLON = new JetSingleValueToken("SEMICOLON", ";");
|
||||
JetSingleValueToken DOUBLE_SEMICOLON = new JetSingleValueToken("DOUBLE_SEMICOLON", ";;");
|
||||
JetSingleValueToken RANGE = new JetSingleValueToken("RANGE", "..");
|
||||
JetSingleValueToken EQ = new JetSingleValueToken("EQ", "=");
|
||||
JetSingleValueToken MULTEQ = new JetSingleValueToken("MULTEQ", "*=");
|
||||
JetSingleValueToken DIVEQ = new JetSingleValueToken("DIVEQ", "/=");
|
||||
JetSingleValueToken PERCEQ = new JetSingleValueToken("PERCEQ", "%=");
|
||||
JetSingleValueToken PLUSEQ = new JetSingleValueToken("PLUSEQ", "+=");
|
||||
JetSingleValueToken MINUSEQ = new JetSingleValueToken("MINUSEQ", "-=");
|
||||
JetKeywordToken NOT_IN = JetKeywordToken.keyword("NOT_IN", "!in");
|
||||
JetKeywordToken NOT_IS = JetKeywordToken.keyword("NOT_IS", "!is");
|
||||
JetSingleValueToken HASH = new JetSingleValueToken("HASH", "#");
|
||||
JetSingleValueToken AT = new JetSingleValueToken("AT", "@");
|
||||
|
||||
JetSingleValueToken COMMA = new JetSingleValueToken("COMMA", ",");
|
||||
|
||||
JetToken EOL_OR_SEMICOLON = new JetToken("EOL_OR_SEMICOLON");
|
||||
JetKeywordToken FILE_KEYWORD = JetKeywordToken.softKeyword("file");
|
||||
JetKeywordToken FIELD_KEYWORD = JetKeywordToken.softKeyword("field");
|
||||
JetKeywordToken PROPERTY_KEYWORD = JetKeywordToken.softKeyword("property");
|
||||
JetKeywordToken RECEIVER_KEYWORD = JetKeywordToken.softKeyword("receiver");
|
||||
JetKeywordToken PARAM_KEYWORD = JetKeywordToken.softKeyword("param");
|
||||
JetKeywordToken SETPARAM_KEYWORD = JetKeywordToken.softKeyword("setparam");
|
||||
JetKeywordToken IMPORT_KEYWORD = JetKeywordToken.softKeyword("import");
|
||||
JetKeywordToken WHERE_KEYWORD = JetKeywordToken.softKeyword("where");
|
||||
JetKeywordToken BY_KEYWORD = JetKeywordToken.softKeyword("by");
|
||||
JetKeywordToken GET_KEYWORD = JetKeywordToken.softKeyword("get");
|
||||
JetKeywordToken SET_KEYWORD = JetKeywordToken.softKeyword("set");
|
||||
JetKeywordToken CONSTRUCTOR_KEYWORD = JetKeywordToken.softKeyword("constructor");
|
||||
JetKeywordToken INIT_KEYWORD = JetKeywordToken.softKeyword("init");
|
||||
|
||||
JetModifierKeywordToken ABSTRACT_KEYWORD = JetModifierKeywordToken.softKeywordModifier("abstract");
|
||||
JetModifierKeywordToken ENUM_KEYWORD = JetModifierKeywordToken.softKeywordModifier("enum");
|
||||
JetModifierKeywordToken OPEN_KEYWORD = JetModifierKeywordToken.softKeywordModifier("open");
|
||||
JetModifierKeywordToken INNER_KEYWORD = JetModifierKeywordToken.softKeywordModifier("inner");
|
||||
JetModifierKeywordToken OVERRIDE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("override");
|
||||
JetModifierKeywordToken PRIVATE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("private");
|
||||
JetModifierKeywordToken PUBLIC_KEYWORD = JetModifierKeywordToken.softKeywordModifier("public");
|
||||
JetModifierKeywordToken INTERNAL_KEYWORD = JetModifierKeywordToken.softKeywordModifier("internal");
|
||||
JetModifierKeywordToken PROTECTED_KEYWORD = JetModifierKeywordToken.softKeywordModifier("protected");
|
||||
JetKeywordToken CATCH_KEYWORD = JetKeywordToken.softKeyword("catch");
|
||||
JetModifierKeywordToken OUT_KEYWORD = JetModifierKeywordToken.softKeywordModifier("out");
|
||||
JetModifierKeywordToken VARARG_KEYWORD = JetModifierKeywordToken.softKeywordModifier("vararg");
|
||||
JetModifierKeywordToken REIFIED_KEYWORD = JetModifierKeywordToken.softKeywordModifier("reified");
|
||||
JetKeywordToken DYNAMIC_KEYWORD = JetKeywordToken.softKeyword("dynamic");
|
||||
JetModifierKeywordToken COMPANION_KEYWORD = JetModifierKeywordToken.softKeywordModifier("companion");
|
||||
JetModifierKeywordToken SEALED_KEYWORD = JetModifierKeywordToken.softKeywordModifier("sealed");
|
||||
|
||||
JetModifierKeywordToken DEFAULT_VISIBILITY_KEYWORD = PUBLIC_KEYWORD;
|
||||
|
||||
JetKeywordToken FINALLY_KEYWORD = JetKeywordToken.softKeyword("finally");
|
||||
JetModifierKeywordToken FINAL_KEYWORD = JetModifierKeywordToken.softKeywordModifier("final");
|
||||
|
||||
JetModifierKeywordToken LATEINIT_KEYWORD = JetModifierKeywordToken.softKeywordModifier("lateinit");
|
||||
|
||||
JetModifierKeywordToken DATA_KEYWORD = JetModifierKeywordToken.softKeywordModifier("data");
|
||||
JetModifierKeywordToken INLINE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("inline");
|
||||
JetModifierKeywordToken NOINLINE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("noinline");
|
||||
JetModifierKeywordToken TAILREC_KEYWORD = JetModifierKeywordToken.softKeywordModifier("tailrec");
|
||||
JetModifierKeywordToken EXTERNAL_KEYWORD = JetModifierKeywordToken.softKeywordModifier("external");
|
||||
JetModifierKeywordToken ANNOTATION_KEYWORD = JetModifierKeywordToken.softKeywordModifier("annotation");
|
||||
JetModifierKeywordToken CROSSINLINE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("crossinline");
|
||||
JetModifierKeywordToken OPERATOR_KEYWORD = JetModifierKeywordToken.softKeywordModifier("operator");
|
||||
JetModifierKeywordToken INFIX_KEYWORD = JetModifierKeywordToken.softKeywordModifier("infix");
|
||||
|
||||
JetModifierKeywordToken CONST_KEYWORD = JetModifierKeywordToken.softKeywordModifier("const");
|
||||
|
||||
TokenSet KEYWORDS = TokenSet.create(PACKAGE_KEYWORD, AS_KEYWORD, TYPE_ALIAS_KEYWORD, CLASS_KEYWORD, INTERFACE_KEYWORD,
|
||||
THIS_KEYWORD, SUPER_KEYWORD, VAL_KEYWORD, VAR_KEYWORD, FUN_KEYWORD, FOR_KEYWORD,
|
||||
NULL_KEYWORD,
|
||||
TRUE_KEYWORD, FALSE_KEYWORD, IS_KEYWORD,
|
||||
IN_KEYWORD, THROW_KEYWORD, RETURN_KEYWORD, BREAK_KEYWORD, CONTINUE_KEYWORD, OBJECT_KEYWORD, IF_KEYWORD,
|
||||
ELSE_KEYWORD, WHILE_KEYWORD, DO_KEYWORD, TRY_KEYWORD, WHEN_KEYWORD,
|
||||
NOT_IN, NOT_IS, CAPITALIZED_THIS_KEYWORD, AS_SAFE
|
||||
);
|
||||
|
||||
TokenSet SOFT_KEYWORDS = TokenSet.create(FILE_KEYWORD, IMPORT_KEYWORD, WHERE_KEYWORD, BY_KEYWORD, GET_KEYWORD,
|
||||
SET_KEYWORD, ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD,
|
||||
OVERRIDE_KEYWORD, PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD,
|
||||
CATCH_KEYWORD, FINALLY_KEYWORD, OUT_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD, REIFIED_KEYWORD,
|
||||
DYNAMIC_KEYWORD, COMPANION_KEYWORD, CONSTRUCTOR_KEYWORD, INIT_KEYWORD, SEALED_KEYWORD,
|
||||
FIELD_KEYWORD, PROPERTY_KEYWORD, RECEIVER_KEYWORD, PARAM_KEYWORD, SETPARAM_KEYWORD,
|
||||
LATEINIT_KEYWORD,
|
||||
DATA_KEYWORD, INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD,
|
||||
ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD, CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD
|
||||
);
|
||||
|
||||
/*
|
||||
This array is used in stub serialization:
|
||||
1. Do not change order.
|
||||
2. If you add an entry or change order, increase stub version.
|
||||
*/
|
||||
JetModifierKeywordToken[] MODIFIER_KEYWORDS_ARRAY =
|
||||
new JetModifierKeywordToken[] {
|
||||
ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD,
|
||||
PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, OUT_KEYWORD, IN_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD,
|
||||
REIFIED_KEYWORD, COMPANION_KEYWORD, SEALED_KEYWORD, LATEINIT_KEYWORD,
|
||||
DATA_KEYWORD, INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD, ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD,
|
||||
CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD
|
||||
};
|
||||
|
||||
TokenSet MODIFIER_KEYWORDS = TokenSet.create(MODIFIER_KEYWORDS_ARRAY);
|
||||
|
||||
TokenSet VISIBILITY_MODIFIERS = TokenSet.create(PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD);
|
||||
|
||||
TokenSet WHITESPACES = TokenSet.create(TokenType.WHITE_SPACE);
|
||||
|
||||
/**
|
||||
* Don't add KDocTokens to COMMENTS TokenSet, because it is used in JetParserDefinition.getCommentTokens(),
|
||||
* and therefor all COMMENTS tokens will be ignored by PsiBuilder.
|
||||
*
|
||||
* @see org.jetbrains.kotlin.psi.JetPsiUtil#isInComment(com.intellij.psi.PsiElement)
|
||||
*/
|
||||
TokenSet COMMENTS = TokenSet.create(EOL_COMMENT, BLOCK_COMMENT, DOC_COMMENT, SHEBANG_COMMENT);
|
||||
TokenSet WHITE_SPACE_OR_COMMENT_BIT_SET = TokenSet.orSet(COMMENTS, TokenSet.create(WHITE_SPACE));
|
||||
|
||||
TokenSet STRINGS = TokenSet.create(CHARACTER_LITERAL, REGULAR_STRING_PART);
|
||||
TokenSet OPERATIONS = TokenSet.create(AS_KEYWORD, AS_SAFE, IS_KEYWORD, IN_KEYWORD, DOT, PLUSPLUS, MINUSMINUS, EXCLEXCL, MUL, PLUS,
|
||||
MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR,
|
||||
SAFE_ACCESS, ELVIS,
|
||||
// MAP, FILTER,
|
||||
RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
NOT_IN, NOT_IS,
|
||||
IDENTIFIER);
|
||||
|
||||
TokenSet AUGMENTED_ASSIGNMENTS = TokenSet.create(PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
|
||||
TokenSet ALL_ASSIGNMENTS = TokenSet.create(EQ, PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
|
||||
}
|
||||
+2
-2
@@ -20,8 +20,8 @@ import com.intellij.lexer.FlexAdapter;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
public class JetLexer extends FlexAdapter {
|
||||
public JetLexer() {
|
||||
public class KotlinLexer extends FlexAdapter {
|
||||
public KotlinLexer() {
|
||||
super(new _JetLexer((Reader) null));
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -19,29 +19,29 @@ package org.jetbrains.kotlin.lexer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JetKeywordToken extends JetSingleValueToken {
|
||||
public class KtKeywordToken extends KtSingleValueToken {
|
||||
|
||||
/**
|
||||
* Generate keyword (identifier that has a keyword meaning in all possible contexts)
|
||||
*/
|
||||
public static JetKeywordToken keyword(String value) {
|
||||
public static KtKeywordToken keyword(String value) {
|
||||
return keyword(value, value);
|
||||
}
|
||||
|
||||
public static JetKeywordToken keyword(String debugName, String value) {
|
||||
return new JetKeywordToken(debugName, value, false);
|
||||
public static KtKeywordToken keyword(String debugName, String value) {
|
||||
return new KtKeywordToken(debugName, value, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate soft keyword (identifier that has a keyword meaning only in some contexts)
|
||||
*/
|
||||
public static JetKeywordToken softKeyword(String value) {
|
||||
return new JetKeywordToken(value, value, true);
|
||||
public static KtKeywordToken softKeyword(String value) {
|
||||
return new KtKeywordToken(value, value, true);
|
||||
}
|
||||
|
||||
private final boolean myIsSoft;
|
||||
|
||||
protected JetKeywordToken(@NotNull @NonNls String debugName, @NotNull @NonNls String value, boolean isSoft) {
|
||||
protected KtKeywordToken(@NotNull @NonNls String debugName, @NotNull @NonNls String value, boolean isSoft) {
|
||||
super(debugName, value);
|
||||
myIsSoft = isSoft;
|
||||
}
|
||||
+6
-6
@@ -20,23 +20,23 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/* Modifier keyword is a keyword that can be used in annotation position as part of modifier list.*/
|
||||
public final class JetModifierKeywordToken extends JetKeywordToken {
|
||||
public final class KtModifierKeywordToken extends KtKeywordToken {
|
||||
|
||||
/**
|
||||
* Generate keyword (identifier that has a keyword meaning in all possible contexts)
|
||||
*/
|
||||
public static JetModifierKeywordToken keywordModifier(String value) {
|
||||
return new JetModifierKeywordToken(value, value, false);
|
||||
public static KtModifierKeywordToken keywordModifier(String value) {
|
||||
return new KtModifierKeywordToken(value, value, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate soft keyword (identifier that has a keyword meaning only in some contexts)
|
||||
*/
|
||||
public static JetModifierKeywordToken softKeywordModifier(String value) {
|
||||
return new JetModifierKeywordToken(value, value, true);
|
||||
public static KtModifierKeywordToken softKeywordModifier(String value) {
|
||||
return new KtModifierKeywordToken(value, value, true);
|
||||
}
|
||||
|
||||
private JetModifierKeywordToken(@NotNull @NonNls String debugName, @NotNull @NonNls String value, boolean isSoft) {
|
||||
private KtModifierKeywordToken(@NotNull @NonNls String debugName, @NotNull @NonNls String value, boolean isSoft) {
|
||||
super(debugName, value, isSoft);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -19,11 +19,11 @@ package org.jetbrains.kotlin.lexer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JetSingleValueToken extends JetToken {
|
||||
public class KtSingleValueToken extends KtToken {
|
||||
|
||||
private final String myValue;
|
||||
|
||||
public JetSingleValueToken(@NotNull @NonNls String debugName, @NotNull @NonNls String value) {
|
||||
public KtSingleValueToken(@NotNull @NonNls String debugName, @NotNull @NonNls String value) {
|
||||
super(debugName);
|
||||
myValue = value;
|
||||
}
|
||||
+2
-2
@@ -21,8 +21,8 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
|
||||
public class JetToken extends IElementType {
|
||||
public JetToken(@NotNull @NonNls String debugName) {
|
||||
public class KtToken extends IElementType {
|
||||
public KtToken(@NotNull @NonNls String debugName) {
|
||||
super(debugName, KotlinLanguage.INSTANCE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.lexer;
|
||||
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens;
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil;
|
||||
|
||||
public interface KtTokens {
|
||||
KtToken EOF = new KtToken("EOF");
|
||||
|
||||
KtToken BLOCK_COMMENT = new KtToken("BLOCK_COMMENT");
|
||||
KtToken EOL_COMMENT = new KtToken("EOL_COMMENT");
|
||||
KtToken SHEBANG_COMMENT = new KtToken("SHEBANG_COMMENT");
|
||||
|
||||
//KtToken DOC_COMMENT = new KtToken("DOC_COMMENT");
|
||||
IElementType DOC_COMMENT = KDocTokens.KDOC;
|
||||
|
||||
IElementType WHITE_SPACE = TokenType.WHITE_SPACE;
|
||||
|
||||
KtToken INTEGER_LITERAL = new KtToken("INTEGER_LITERAL");
|
||||
KtToken FLOAT_LITERAL = new KtToken("FLOAT_CONSTANT");
|
||||
KtToken CHARACTER_LITERAL = new KtToken("CHARACTER_LITERAL");
|
||||
|
||||
KtToken CLOSING_QUOTE = new KtToken("CLOSING_QUOTE");
|
||||
KtToken OPEN_QUOTE = new KtToken("OPEN_QUOTE");
|
||||
KtToken REGULAR_STRING_PART = new KtToken("REGULAR_STRING_PART");
|
||||
KtToken ESCAPE_SEQUENCE = new KtToken("ESCAPE_SEQUENCE");
|
||||
KtToken SHORT_TEMPLATE_ENTRY_START = new KtToken("SHORT_TEMPLATE_ENTRY_START");
|
||||
KtToken LONG_TEMPLATE_ENTRY_START = new KtToken("LONG_TEMPLATE_ENTRY_START");
|
||||
KtToken LONG_TEMPLATE_ENTRY_END = new KtToken("LONG_TEMPLATE_ENTRY_END");
|
||||
KtToken DANGLING_NEWLINE = new KtToken("DANGLING_NEWLINE");
|
||||
|
||||
KtKeywordToken PACKAGE_KEYWORD = KtKeywordToken.keyword("package");
|
||||
KtKeywordToken AS_KEYWORD = KtKeywordToken.keyword("as");
|
||||
KtKeywordToken TYPE_ALIAS_KEYWORD = KtKeywordToken.keyword("typealias");
|
||||
KtKeywordToken CLASS_KEYWORD = KtKeywordToken.keyword("class");
|
||||
KtKeywordToken THIS_KEYWORD = KtKeywordToken.keyword("this");
|
||||
KtKeywordToken SUPER_KEYWORD = KtKeywordToken.keyword("super");
|
||||
KtKeywordToken VAL_KEYWORD = KtKeywordToken.keyword("val");
|
||||
KtKeywordToken VAR_KEYWORD = KtKeywordToken.keyword("var");
|
||||
KtKeywordToken FUN_KEYWORD = KtKeywordToken.keyword("fun");
|
||||
KtKeywordToken FOR_KEYWORD = KtKeywordToken.keyword("for");
|
||||
KtKeywordToken NULL_KEYWORD = KtKeywordToken.keyword("null");
|
||||
KtKeywordToken TRUE_KEYWORD = KtKeywordToken.keyword("true");
|
||||
KtKeywordToken FALSE_KEYWORD = KtKeywordToken.keyword("false");
|
||||
KtKeywordToken IS_KEYWORD = KtKeywordToken.keyword("is");
|
||||
KtModifierKeywordToken IN_KEYWORD = KtModifierKeywordToken.keywordModifier("in");
|
||||
KtKeywordToken THROW_KEYWORD = KtKeywordToken.keyword("throw");
|
||||
KtKeywordToken RETURN_KEYWORD = KtKeywordToken.keyword("return");
|
||||
KtKeywordToken BREAK_KEYWORD = KtKeywordToken.keyword("break");
|
||||
KtKeywordToken CONTINUE_KEYWORD = KtKeywordToken.keyword("continue");
|
||||
KtKeywordToken OBJECT_KEYWORD = KtKeywordToken.keyword("object");
|
||||
KtKeywordToken IF_KEYWORD = KtKeywordToken.keyword("if");
|
||||
KtKeywordToken TRY_KEYWORD = KtKeywordToken.keyword("try");
|
||||
KtKeywordToken ELSE_KEYWORD = KtKeywordToken.keyword("else");
|
||||
KtKeywordToken WHILE_KEYWORD = KtKeywordToken.keyword("while");
|
||||
KtKeywordToken DO_KEYWORD = KtKeywordToken.keyword("do");
|
||||
KtKeywordToken WHEN_KEYWORD = KtKeywordToken.keyword("when");
|
||||
KtKeywordToken INTERFACE_KEYWORD = KtKeywordToken.keyword("interface");
|
||||
// TODO: Discuss "This" keyword
|
||||
KtKeywordToken CAPITALIZED_THIS_KEYWORD = KtKeywordToken.keyword("This");
|
||||
|
||||
|
||||
KtToken AS_SAFE = KtKeywordToken.keyword("AS_SAFE");//new KtToken("as?");
|
||||
|
||||
KtToken IDENTIFIER = new KtToken("IDENTIFIER");
|
||||
|
||||
KtToken FIELD_IDENTIFIER = new KtToken("FIELD_IDENTIFIER");
|
||||
KtSingleValueToken LBRACKET = new KtSingleValueToken("LBRACKET", "[");
|
||||
KtSingleValueToken RBRACKET = new KtSingleValueToken("RBRACKET", "]");
|
||||
KtSingleValueToken LBRACE = new KtSingleValueToken("LBRACE", "{");
|
||||
KtSingleValueToken RBRACE = new KtSingleValueToken("RBRACE", "}");
|
||||
KtSingleValueToken LPAR = new KtSingleValueToken("LPAR", "(");
|
||||
KtSingleValueToken RPAR = new KtSingleValueToken("RPAR", ")");
|
||||
KtSingleValueToken DOT = new KtSingleValueToken("DOT", ".");
|
||||
KtSingleValueToken PLUSPLUS = new KtSingleValueToken("PLUSPLUS", "++");
|
||||
KtSingleValueToken MINUSMINUS = new KtSingleValueToken("MINUSMINUS", "--");
|
||||
KtSingleValueToken MUL = new KtSingleValueToken("MUL", "*");
|
||||
KtSingleValueToken PLUS = new KtSingleValueToken("PLUS", "+");
|
||||
KtSingleValueToken MINUS = new KtSingleValueToken("MINUS", "-");
|
||||
KtSingleValueToken EXCL = new KtSingleValueToken("EXCL", "!");
|
||||
KtSingleValueToken DIV = new KtSingleValueToken("DIV", "/");
|
||||
KtSingleValueToken PERC = new KtSingleValueToken("PERC", "%");
|
||||
KtSingleValueToken LT = new KtSingleValueToken("LT", "<");
|
||||
KtSingleValueToken GT = new KtSingleValueToken("GT", ">");
|
||||
KtSingleValueToken LTEQ = new KtSingleValueToken("LTEQ", "<=");
|
||||
KtSingleValueToken GTEQ = new KtSingleValueToken("GTEQ", ">=");
|
||||
KtSingleValueToken EQEQEQ = new KtSingleValueToken("EQEQEQ", "===");
|
||||
KtSingleValueToken ARROW = new KtSingleValueToken("ARROW", "->");
|
||||
KtSingleValueToken DOUBLE_ARROW = new KtSingleValueToken("DOUBLE_ARROW", "=>");
|
||||
KtSingleValueToken EXCLEQEQEQ = new KtSingleValueToken("EXCLEQEQEQ", "!==");
|
||||
KtSingleValueToken EQEQ = new KtSingleValueToken("EQEQ", "==");
|
||||
KtSingleValueToken EXCLEQ = new KtSingleValueToken("EXCLEQ", "!=");
|
||||
KtSingleValueToken EXCLEXCL = new KtSingleValueToken("EXCLEXCL", "!!");
|
||||
KtSingleValueToken ANDAND = new KtSingleValueToken("ANDAND", "&&");
|
||||
KtSingleValueToken OROR = new KtSingleValueToken("OROR", "||");
|
||||
KtSingleValueToken SAFE_ACCESS = new KtSingleValueToken("SAFE_ACCESS", "?.");
|
||||
KtSingleValueToken ELVIS = new KtSingleValueToken("ELVIS", "?:");
|
||||
KtSingleValueToken QUEST = new KtSingleValueToken("QUEST", "?");
|
||||
KtSingleValueToken COLONCOLON = new KtSingleValueToken("COLONCOLON", "::");
|
||||
KtSingleValueToken COLON = new KtSingleValueToken("COLON", ":");
|
||||
KtSingleValueToken SEMICOLON = new KtSingleValueToken("SEMICOLON", ";");
|
||||
KtSingleValueToken DOUBLE_SEMICOLON = new KtSingleValueToken("DOUBLE_SEMICOLON", ";;");
|
||||
KtSingleValueToken RANGE = new KtSingleValueToken("RANGE", "..");
|
||||
KtSingleValueToken EQ = new KtSingleValueToken("EQ", "=");
|
||||
KtSingleValueToken MULTEQ = new KtSingleValueToken("MULTEQ", "*=");
|
||||
KtSingleValueToken DIVEQ = new KtSingleValueToken("DIVEQ", "/=");
|
||||
KtSingleValueToken PERCEQ = new KtSingleValueToken("PERCEQ", "%=");
|
||||
KtSingleValueToken PLUSEQ = new KtSingleValueToken("PLUSEQ", "+=");
|
||||
KtSingleValueToken MINUSEQ = new KtSingleValueToken("MINUSEQ", "-=");
|
||||
KtKeywordToken NOT_IN = KtKeywordToken.keyword("NOT_IN", "!in");
|
||||
KtKeywordToken NOT_IS = KtKeywordToken.keyword("NOT_IS", "!is");
|
||||
KtSingleValueToken HASH = new KtSingleValueToken("HASH", "#");
|
||||
KtSingleValueToken AT = new KtSingleValueToken("AT", "@");
|
||||
|
||||
KtSingleValueToken COMMA = new KtSingleValueToken("COMMA", ",");
|
||||
|
||||
KtToken EOL_OR_SEMICOLON = new KtToken("EOL_OR_SEMICOLON");
|
||||
KtKeywordToken FILE_KEYWORD = KtKeywordToken.softKeyword("file");
|
||||
KtKeywordToken FIELD_KEYWORD = KtKeywordToken.softKeyword("field");
|
||||
KtKeywordToken PROPERTY_KEYWORD = KtKeywordToken.softKeyword("property");
|
||||
KtKeywordToken RECEIVER_KEYWORD = KtKeywordToken.softKeyword("receiver");
|
||||
KtKeywordToken PARAM_KEYWORD = KtKeywordToken.softKeyword("param");
|
||||
KtKeywordToken SETPARAM_KEYWORD = KtKeywordToken.softKeyword("setparam");
|
||||
KtKeywordToken IMPORT_KEYWORD = KtKeywordToken.softKeyword("import");
|
||||
KtKeywordToken WHERE_KEYWORD = KtKeywordToken.softKeyword("where");
|
||||
KtKeywordToken BY_KEYWORD = KtKeywordToken.softKeyword("by");
|
||||
KtKeywordToken GET_KEYWORD = KtKeywordToken.softKeyword("get");
|
||||
KtKeywordToken SET_KEYWORD = KtKeywordToken.softKeyword("set");
|
||||
KtKeywordToken CONSTRUCTOR_KEYWORD = KtKeywordToken.softKeyword("constructor");
|
||||
KtKeywordToken INIT_KEYWORD = KtKeywordToken.softKeyword("init");
|
||||
|
||||
KtModifierKeywordToken ABSTRACT_KEYWORD = KtModifierKeywordToken.softKeywordModifier("abstract");
|
||||
KtModifierKeywordToken ENUM_KEYWORD = KtModifierKeywordToken.softKeywordModifier("enum");
|
||||
KtModifierKeywordToken OPEN_KEYWORD = KtModifierKeywordToken.softKeywordModifier("open");
|
||||
KtModifierKeywordToken INNER_KEYWORD = KtModifierKeywordToken.softKeywordModifier("inner");
|
||||
KtModifierKeywordToken OVERRIDE_KEYWORD = KtModifierKeywordToken.softKeywordModifier("override");
|
||||
KtModifierKeywordToken PRIVATE_KEYWORD = KtModifierKeywordToken.softKeywordModifier("private");
|
||||
KtModifierKeywordToken PUBLIC_KEYWORD = KtModifierKeywordToken.softKeywordModifier("public");
|
||||
KtModifierKeywordToken INTERNAL_KEYWORD = KtModifierKeywordToken.softKeywordModifier("internal");
|
||||
KtModifierKeywordToken PROTECTED_KEYWORD = KtModifierKeywordToken.softKeywordModifier("protected");
|
||||
KtKeywordToken CATCH_KEYWORD = KtKeywordToken.softKeyword("catch");
|
||||
KtModifierKeywordToken OUT_KEYWORD = KtModifierKeywordToken.softKeywordModifier("out");
|
||||
KtModifierKeywordToken VARARG_KEYWORD = KtModifierKeywordToken.softKeywordModifier("vararg");
|
||||
KtModifierKeywordToken REIFIED_KEYWORD = KtModifierKeywordToken.softKeywordModifier("reified");
|
||||
KtKeywordToken DYNAMIC_KEYWORD = KtKeywordToken.softKeyword("dynamic");
|
||||
KtModifierKeywordToken COMPANION_KEYWORD = KtModifierKeywordToken.softKeywordModifier("companion");
|
||||
KtModifierKeywordToken SEALED_KEYWORD = KtModifierKeywordToken.softKeywordModifier("sealed");
|
||||
|
||||
KtModifierKeywordToken DEFAULT_VISIBILITY_KEYWORD = PUBLIC_KEYWORD;
|
||||
|
||||
KtKeywordToken FINALLY_KEYWORD = KtKeywordToken.softKeyword("finally");
|
||||
KtModifierKeywordToken FINAL_KEYWORD = KtModifierKeywordToken.softKeywordModifier("final");
|
||||
|
||||
KtModifierKeywordToken LATEINIT_KEYWORD = KtModifierKeywordToken.softKeywordModifier("lateinit");
|
||||
|
||||
KtModifierKeywordToken DATA_KEYWORD = KtModifierKeywordToken.softKeywordModifier("data");
|
||||
KtModifierKeywordToken INLINE_KEYWORD = KtModifierKeywordToken.softKeywordModifier("inline");
|
||||
KtModifierKeywordToken NOINLINE_KEYWORD = KtModifierKeywordToken.softKeywordModifier("noinline");
|
||||
KtModifierKeywordToken TAILREC_KEYWORD = KtModifierKeywordToken.softKeywordModifier("tailrec");
|
||||
KtModifierKeywordToken EXTERNAL_KEYWORD = KtModifierKeywordToken.softKeywordModifier("external");
|
||||
KtModifierKeywordToken ANNOTATION_KEYWORD = KtModifierKeywordToken.softKeywordModifier("annotation");
|
||||
KtModifierKeywordToken CROSSINLINE_KEYWORD = KtModifierKeywordToken.softKeywordModifier("crossinline");
|
||||
KtModifierKeywordToken OPERATOR_KEYWORD = KtModifierKeywordToken.softKeywordModifier("operator");
|
||||
KtModifierKeywordToken INFIX_KEYWORD = KtModifierKeywordToken.softKeywordModifier("infix");
|
||||
|
||||
KtModifierKeywordToken CONST_KEYWORD = KtModifierKeywordToken.softKeywordModifier("const");
|
||||
|
||||
TokenSet KEYWORDS = TokenSet.create(PACKAGE_KEYWORD, AS_KEYWORD, TYPE_ALIAS_KEYWORD, CLASS_KEYWORD, INTERFACE_KEYWORD,
|
||||
THIS_KEYWORD, SUPER_KEYWORD, VAL_KEYWORD, VAR_KEYWORD, FUN_KEYWORD, FOR_KEYWORD,
|
||||
NULL_KEYWORD,
|
||||
TRUE_KEYWORD, FALSE_KEYWORD, IS_KEYWORD,
|
||||
IN_KEYWORD, THROW_KEYWORD, RETURN_KEYWORD, BREAK_KEYWORD, CONTINUE_KEYWORD, OBJECT_KEYWORD, IF_KEYWORD,
|
||||
ELSE_KEYWORD, WHILE_KEYWORD, DO_KEYWORD, TRY_KEYWORD, WHEN_KEYWORD,
|
||||
NOT_IN, NOT_IS, CAPITALIZED_THIS_KEYWORD, AS_SAFE
|
||||
);
|
||||
|
||||
TokenSet SOFT_KEYWORDS = TokenSet.create(FILE_KEYWORD, IMPORT_KEYWORD, WHERE_KEYWORD, BY_KEYWORD, GET_KEYWORD,
|
||||
SET_KEYWORD, ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD,
|
||||
OVERRIDE_KEYWORD, PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD,
|
||||
CATCH_KEYWORD, FINALLY_KEYWORD, OUT_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD, REIFIED_KEYWORD,
|
||||
DYNAMIC_KEYWORD, COMPANION_KEYWORD, CONSTRUCTOR_KEYWORD, INIT_KEYWORD, SEALED_KEYWORD,
|
||||
FIELD_KEYWORD, PROPERTY_KEYWORD, RECEIVER_KEYWORD, PARAM_KEYWORD, SETPARAM_KEYWORD,
|
||||
LATEINIT_KEYWORD,
|
||||
DATA_KEYWORD, INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD,
|
||||
ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD, CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD
|
||||
);
|
||||
|
||||
/*
|
||||
This array is used in stub serialization:
|
||||
1. Do not change order.
|
||||
2. If you add an entry or change order, increase stub version.
|
||||
*/
|
||||
KtModifierKeywordToken[] MODIFIER_KEYWORDS_ARRAY =
|
||||
new KtModifierKeywordToken[] {
|
||||
ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD,
|
||||
PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, OUT_KEYWORD, IN_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD,
|
||||
REIFIED_KEYWORD, COMPANION_KEYWORD, SEALED_KEYWORD, LATEINIT_KEYWORD,
|
||||
DATA_KEYWORD, INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD, ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD,
|
||||
CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD
|
||||
};
|
||||
|
||||
TokenSet MODIFIER_KEYWORDS = TokenSet.create(MODIFIER_KEYWORDS_ARRAY);
|
||||
|
||||
TokenSet VISIBILITY_MODIFIERS = TokenSet.create(PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD);
|
||||
|
||||
TokenSet WHITESPACES = TokenSet.create(TokenType.WHITE_SPACE);
|
||||
|
||||
/**
|
||||
* Don't add KDocTokens to COMMENTS TokenSet, because it is used in JetParserDefinition.getCommentTokens(),
|
||||
* and therefor all COMMENTS tokens will be ignored by PsiBuilder.
|
||||
*
|
||||
* @see KtPsiUtil#isInComment(com.intellij.psi.PsiElement)
|
||||
*/
|
||||
TokenSet COMMENTS = TokenSet.create(EOL_COMMENT, BLOCK_COMMENT, DOC_COMMENT, SHEBANG_COMMENT);
|
||||
TokenSet WHITE_SPACE_OR_COMMENT_BIT_SET = TokenSet.orSet(COMMENTS, TokenSet.create(WHITE_SPACE));
|
||||
|
||||
TokenSet STRINGS = TokenSet.create(CHARACTER_LITERAL, REGULAR_STRING_PART);
|
||||
TokenSet OPERATIONS = TokenSet.create(AS_KEYWORD, AS_SAFE, IS_KEYWORD, IN_KEYWORD, DOT, PLUSPLUS, MINUSMINUS, EXCLEXCL, MUL, PLUS,
|
||||
MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR,
|
||||
SAFE_ACCESS, ELVIS,
|
||||
// MAP, FILTER,
|
||||
RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
NOT_IN, NOT_IS,
|
||||
IDENTIFIER);
|
||||
|
||||
TokenSet AUGMENTED_ASSIGNMENTS = TokenSet.create(PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
|
||||
TokenSet ALL_ASSIGNMENTS = TokenSet.create(EQ, PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
|
||||
}
|
||||
@@ -611,9 +611,9 @@ class _JetLexer implements FlexLexer {
|
||||
private IElementType commentStateToTokenType(int state) {
|
||||
switch (state) {
|
||||
case BLOCK_COMMENT:
|
||||
return JetTokens.BLOCK_COMMENT;
|
||||
return KtTokens.BLOCK_COMMENT;
|
||||
case DOC_COMMENT:
|
||||
return JetTokens.DOC_COMMENT;
|
||||
return KtTokens.DOC_COMMENT;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unexpected state: " + state);
|
||||
}
|
||||
@@ -864,188 +864,188 @@ class _JetLexer implements FlexLexer {
|
||||
|
||||
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
|
||||
case 102:
|
||||
{ return JetTokens.TYPE_ALIAS_KEYWORD ;
|
||||
{ return KtTokens.TYPE_ALIAS_KEYWORD ;
|
||||
}
|
||||
case 104: break;
|
||||
case 3:
|
||||
{ return JetTokens.IDENTIFIER;
|
||||
{ return KtTokens.IDENTIFIER;
|
||||
}
|
||||
case 105: break;
|
||||
case 11:
|
||||
{ pushState(STRING); return JetTokens.OPEN_QUOTE;
|
||||
{ pushState(STRING); return KtTokens.OPEN_QUOTE;
|
||||
}
|
||||
case 106: break;
|
||||
case 78:
|
||||
{ return JetTokens.FOR_KEYWORD ;
|
||||
{ return KtTokens.FOR_KEYWORD ;
|
||||
}
|
||||
case 107: break;
|
||||
case 98:
|
||||
{ return JetTokens.RETURN_KEYWORD ;
|
||||
{ return KtTokens.RETURN_KEYWORD ;
|
||||
}
|
||||
case 108: break;
|
||||
case 103:
|
||||
{ return JetTokens.INTERFACE_KEYWORD ;
|
||||
{ return KtTokens.INTERFACE_KEYWORD ;
|
||||
}
|
||||
case 109: break;
|
||||
case 88:
|
||||
{ return JetTokens.NULL_KEYWORD ;
|
||||
{ return KtTokens.NULL_KEYWORD ;
|
||||
}
|
||||
case 110: break;
|
||||
case 35:
|
||||
{ if (lBraceCount == 0) {
|
||||
popState();
|
||||
return JetTokens.LONG_TEMPLATE_ENTRY_END;
|
||||
return KtTokens.LONG_TEMPLATE_ENTRY_END;
|
||||
}
|
||||
lBraceCount--;
|
||||
return JetTokens.RBRACE;
|
||||
return KtTokens.RBRACE;
|
||||
}
|
||||
case 111: break;
|
||||
case 18:
|
||||
{ return JetTokens.LT ;
|
||||
{ return KtTokens.LT ;
|
||||
}
|
||||
case 112: break;
|
||||
case 52:
|
||||
{ return JetTokens.DO_KEYWORD ;
|
||||
{ return KtTokens.DO_KEYWORD ;
|
||||
}
|
||||
case 113: break;
|
||||
case 17:
|
||||
{ return JetTokens.PLUS ;
|
||||
{ return KtTokens.PLUS ;
|
||||
}
|
||||
case 114: break;
|
||||
case 55:
|
||||
{ return JetTokens.PLUSEQ ;
|
||||
{ return KtTokens.PLUSEQ ;
|
||||
}
|
||||
case 115: break;
|
||||
case 91:
|
||||
{ popState(); return JetTokens.THIS_KEYWORD;
|
||||
{ popState(); return KtTokens.THIS_KEYWORD;
|
||||
}
|
||||
case 116: break;
|
||||
case 27:
|
||||
{ return JetTokens.COMMA ;
|
||||
{ return KtTokens.COMMA ;
|
||||
}
|
||||
case 117: break;
|
||||
case 19:
|
||||
{ return JetTokens.GT ;
|
||||
{ return KtTokens.GT ;
|
||||
}
|
||||
case 118: break;
|
||||
case 4:
|
||||
{ return JetTokens.WHITE_SPACE;
|
||||
{ return KtTokens.WHITE_SPACE;
|
||||
}
|
||||
case 119: break;
|
||||
case 25:
|
||||
{ return JetTokens.RPAR ;
|
||||
{ return KtTokens.RPAR ;
|
||||
}
|
||||
case 120: break;
|
||||
case 54:
|
||||
{ return JetTokens.DOUBLE_ARROW;
|
||||
{ return KtTokens.DOUBLE_ARROW;
|
||||
}
|
||||
case 121: break;
|
||||
case 86:
|
||||
{ return JetTokens.TRUE_KEYWORD ;
|
||||
{ return KtTokens.TRUE_KEYWORD ;
|
||||
}
|
||||
case 122: break;
|
||||
case 37:
|
||||
{ return JetTokens.FIELD_IDENTIFIER;
|
||||
{ return KtTokens.FIELD_IDENTIFIER;
|
||||
}
|
||||
case 123: break;
|
||||
case 59:
|
||||
{ return JetTokens.ANDAND ;
|
||||
{ return KtTokens.ANDAND ;
|
||||
}
|
||||
case 124: break;
|
||||
case 65:
|
||||
{ pushState(LONG_TEMPLATE_ENTRY); return JetTokens.LONG_TEMPLATE_ENTRY_START;
|
||||
{ pushState(LONG_TEMPLATE_ENTRY); return KtTokens.LONG_TEMPLATE_ENTRY_START;
|
||||
}
|
||||
case 125: break;
|
||||
case 36:
|
||||
{ return JetTokens.FLOAT_LITERAL;
|
||||
{ return KtTokens.FLOAT_LITERAL;
|
||||
}
|
||||
case 126: break;
|
||||
case 38:
|
||||
{ return JetTokens.EOL_COMMENT;
|
||||
{ return KtTokens.EOL_COMMENT;
|
||||
}
|
||||
case 127: break;
|
||||
case 89:
|
||||
{ return JetTokens.WHEN_KEYWORD ;
|
||||
{ return KtTokens.WHEN_KEYWORD ;
|
||||
}
|
||||
case 128: break;
|
||||
case 74:
|
||||
{ pushState(RAW_STRING); return JetTokens.OPEN_QUOTE;
|
||||
{ pushState(RAW_STRING); return KtTokens.OPEN_QUOTE;
|
||||
}
|
||||
case 129: break;
|
||||
case 21:
|
||||
{ return JetTokens.COLON ;
|
||||
{ return KtTokens.COLON ;
|
||||
}
|
||||
case 130: break;
|
||||
case 57:
|
||||
{ return JetTokens.LTEQ ;
|
||||
{ return KtTokens.LTEQ ;
|
||||
}
|
||||
case 131: break;
|
||||
case 46:
|
||||
{ return JetTokens.ARROW ;
|
||||
{ return KtTokens.ARROW ;
|
||||
}
|
||||
case 132: break;
|
||||
case 32:
|
||||
{ popState(); return JetTokens.IDENTIFIER;
|
||||
{ popState(); return KtTokens.IDENTIFIER;
|
||||
}
|
||||
case 133: break;
|
||||
case 22:
|
||||
{ return JetTokens.LBRACKET ;
|
||||
{ return KtTokens.LBRACKET ;
|
||||
}
|
||||
case 134: break;
|
||||
case 69:
|
||||
{ yypushback(2); return JetTokens.INTEGER_LITERAL;
|
||||
{ yypushback(2); return KtTokens.INTEGER_LITERAL;
|
||||
}
|
||||
case 135: break;
|
||||
case 10:
|
||||
{ return JetTokens.CHARACTER_LITERAL;
|
||||
{ return KtTokens.CHARACTER_LITERAL;
|
||||
}
|
||||
case 136: break;
|
||||
case 80:
|
||||
{ return JetTokens.VAR_KEYWORD ;
|
||||
{ return KtTokens.VAR_KEYWORD ;
|
||||
}
|
||||
case 137: break;
|
||||
case 58:
|
||||
{ return JetTokens.GTEQ ;
|
||||
{ return KtTokens.GTEQ ;
|
||||
}
|
||||
case 138: break;
|
||||
case 2:
|
||||
{ return JetTokens.INTEGER_LITERAL;
|
||||
{ return KtTokens.INTEGER_LITERAL;
|
||||
}
|
||||
case 139: break;
|
||||
case 13:
|
||||
{ return JetTokens.RBRACE ;
|
||||
{ return KtTokens.RBRACE ;
|
||||
}
|
||||
case 140: break;
|
||||
case 95:
|
||||
{ return JetTokens.CLASS_KEYWORD ;
|
||||
{ return KtTokens.CLASS_KEYWORD ;
|
||||
}
|
||||
case 141: break;
|
||||
case 75:
|
||||
{ return JetTokens.TRY_KEYWORD ;
|
||||
{ return KtTokens.TRY_KEYWORD ;
|
||||
}
|
||||
case 142: break;
|
||||
case 7:
|
||||
{ return JetTokens.EXCL ;
|
||||
{ return KtTokens.EXCL ;
|
||||
}
|
||||
case 143: break;
|
||||
case 42:
|
||||
{ return JetTokens.EXCLEQ ;
|
||||
{ return KtTokens.EXCLEQ ;
|
||||
}
|
||||
case 144: break;
|
||||
case 45:
|
||||
{ return JetTokens.MINUSEQ ;
|
||||
{ return KtTokens.MINUSEQ ;
|
||||
}
|
||||
case 145: break;
|
||||
case 100:
|
||||
{ return JetTokens.PACKAGE_KEYWORD ;
|
||||
{ return KtTokens.PACKAGE_KEYWORD ;
|
||||
}
|
||||
case 146: break;
|
||||
case 92:
|
||||
{ return JetTokens.THROW_KEYWORD ;
|
||||
{ return KtTokens.THROW_KEYWORD ;
|
||||
}
|
||||
case 147: break;
|
||||
case 93:
|
||||
{ return JetTokens.SUPER_KEYWORD ;
|
||||
{ return KtTokens.SUPER_KEYWORD ;
|
||||
}
|
||||
case 148: break;
|
||||
case 68:
|
||||
@@ -1061,47 +1061,47 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
case 149: break;
|
||||
case 97:
|
||||
{ return JetTokens.WHILE_KEYWORD ;
|
||||
{ return KtTokens.WHILE_KEYWORD ;
|
||||
}
|
||||
case 150: break;
|
||||
case 44:
|
||||
{ return JetTokens.MINUSMINUS;
|
||||
{ return KtTokens.MINUSMINUS;
|
||||
}
|
||||
case 151: break;
|
||||
case 101:
|
||||
{ return JetTokens.CONTINUE_KEYWORD ;
|
||||
{ return KtTokens.CONTINUE_KEYWORD ;
|
||||
}
|
||||
case 152: break;
|
||||
case 72:
|
||||
{ return JetTokens.NOT_IN;
|
||||
{ return KtTokens.NOT_IN;
|
||||
}
|
||||
case 153: break;
|
||||
case 63:
|
||||
{ return JetTokens.DOUBLE_SEMICOLON;
|
||||
{ return KtTokens.DOUBLE_SEMICOLON;
|
||||
}
|
||||
case 154: break;
|
||||
case 5:
|
||||
{ return JetTokens.DIV ;
|
||||
{ return KtTokens.DIV ;
|
||||
}
|
||||
case 155: break;
|
||||
case 82:
|
||||
{ int length = yytext().length();
|
||||
if (length <= 3) { // closing """
|
||||
popState();
|
||||
return JetTokens.CLOSING_QUOTE;
|
||||
return KtTokens.CLOSING_QUOTE;
|
||||
}
|
||||
else { // some quotes at the end of a string, e.g. """ "foo""""
|
||||
yypushback(3); // return the closing quotes (""") to the stream
|
||||
return JetTokens.REGULAR_STRING_PART;
|
||||
return KtTokens.REGULAR_STRING_PART;
|
||||
}
|
||||
}
|
||||
case 156: break;
|
||||
case 29:
|
||||
{ return JetTokens.REGULAR_STRING_PART;
|
||||
{ return KtTokens.REGULAR_STRING_PART;
|
||||
}
|
||||
case 157: break;
|
||||
case 16:
|
||||
{ return JetTokens.QUEST ;
|
||||
{ return KtTokens.QUEST ;
|
||||
}
|
||||
case 158: break;
|
||||
case 70:
|
||||
@@ -1111,23 +1111,23 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
case 159: break;
|
||||
case 60:
|
||||
{ return JetTokens.OROR ;
|
||||
{ return KtTokens.OROR ;
|
||||
}
|
||||
case 160: break;
|
||||
case 20:
|
||||
{ return JetTokens.PERC ;
|
||||
{ return KtTokens.PERC ;
|
||||
}
|
||||
case 161: break;
|
||||
case 73:
|
||||
{ return JetTokens.EXCLEQEQEQ;
|
||||
{ return KtTokens.EXCLEQEQEQ;
|
||||
}
|
||||
case 162: break;
|
||||
case 61:
|
||||
{ return JetTokens.PERCEQ ;
|
||||
{ return KtTokens.PERCEQ ;
|
||||
}
|
||||
case 163: break;
|
||||
case 43:
|
||||
{ return JetTokens.RANGE ;
|
||||
{ return KtTokens.RANGE ;
|
||||
}
|
||||
case 164: break;
|
||||
case 1:
|
||||
@@ -1137,23 +1137,23 @@ class _JetLexer implements FlexLexer {
|
||||
case 64:
|
||||
{ pushState(SHORT_TEMPLATE_ENTRY);
|
||||
yypushback(yylength() - 1);
|
||||
return JetTokens.SHORT_TEMPLATE_ENTRY_START;
|
||||
return KtTokens.SHORT_TEMPLATE_ENTRY_START;
|
||||
}
|
||||
case 166: break;
|
||||
case 71:
|
||||
{ return JetTokens.NOT_IS;
|
||||
{ return KtTokens.NOT_IS;
|
||||
}
|
||||
case 167: break;
|
||||
case 14:
|
||||
{ return JetTokens.MUL ;
|
||||
{ return KtTokens.MUL ;
|
||||
}
|
||||
case 168: break;
|
||||
case 23:
|
||||
{ return JetTokens.RBRACKET ;
|
||||
{ return KtTokens.RBRACKET ;
|
||||
}
|
||||
case 169: break;
|
||||
case 56:
|
||||
{ return JetTokens.PLUSPLUS ;
|
||||
{ return KtTokens.PLUSPLUS ;
|
||||
}
|
||||
case 170: break;
|
||||
case 39:
|
||||
@@ -1163,51 +1163,51 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
case 171: break;
|
||||
case 85:
|
||||
{ return JetTokens.THIS_KEYWORD ;
|
||||
{ return KtTokens.THIS_KEYWORD ;
|
||||
}
|
||||
case 172: break;
|
||||
case 8:
|
||||
{ return JetTokens.DOT ;
|
||||
{ return KtTokens.DOT ;
|
||||
}
|
||||
case 173: break;
|
||||
case 26:
|
||||
{ return JetTokens.SEMICOLON ;
|
||||
{ return KtTokens.SEMICOLON ;
|
||||
}
|
||||
case 174: break;
|
||||
case 49:
|
||||
{ return JetTokens.IF_KEYWORD ;
|
||||
{ return KtTokens.IF_KEYWORD ;
|
||||
}
|
||||
case 175: break;
|
||||
case 66:
|
||||
{ return JetTokens.ESCAPE_SEQUENCE;
|
||||
{ return KtTokens.ESCAPE_SEQUENCE;
|
||||
}
|
||||
case 176: break;
|
||||
case 31:
|
||||
{ popState(); return JetTokens.CLOSING_QUOTE;
|
||||
{ popState(); return KtTokens.CLOSING_QUOTE;
|
||||
}
|
||||
case 177: break;
|
||||
case 15:
|
||||
{ return JetTokens.EQ ;
|
||||
{ return KtTokens.EQ ;
|
||||
}
|
||||
case 178: break;
|
||||
case 28:
|
||||
{ return JetTokens.AT ;
|
||||
{ return KtTokens.AT ;
|
||||
}
|
||||
case 179: break;
|
||||
case 76:
|
||||
{ return JetTokens.AS_SAFE;
|
||||
{ return KtTokens.AS_SAFE;
|
||||
}
|
||||
case 180: break;
|
||||
case 24:
|
||||
{ return JetTokens.LPAR ;
|
||||
{ return KtTokens.LPAR ;
|
||||
}
|
||||
case 181: break;
|
||||
case 9:
|
||||
{ return JetTokens.MINUS ;
|
||||
{ return KtTokens.MINUS ;
|
||||
}
|
||||
case 182: break;
|
||||
case 94:
|
||||
{ return JetTokens.FALSE_KEYWORD ;
|
||||
{ return KtTokens.FALSE_KEYWORD ;
|
||||
}
|
||||
case 183: break;
|
||||
case 67:
|
||||
@@ -1215,89 +1215,89 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
case 184: break;
|
||||
case 77:
|
||||
{ return JetTokens.FUN_KEYWORD ;
|
||||
{ return KtTokens.FUN_KEYWORD ;
|
||||
}
|
||||
case 185: break;
|
||||
case 47:
|
||||
{ return JetTokens.IS_KEYWORD ;
|
||||
{ return KtTokens.IS_KEYWORD ;
|
||||
}
|
||||
case 186: break;
|
||||
case 30:
|
||||
{ popState(); yypushback(1); return JetTokens.DANGLING_NEWLINE;
|
||||
{ popState(); yypushback(1); return KtTokens.DANGLING_NEWLINE;
|
||||
}
|
||||
case 187: break;
|
||||
case 34:
|
||||
{ lBraceCount++; return JetTokens.LBRACE;
|
||||
{ lBraceCount++; return KtTokens.LBRACE;
|
||||
}
|
||||
case 188: break;
|
||||
case 84:
|
||||
{ yypushback(3); return JetTokens.EXCL;
|
||||
{ yypushback(3); return KtTokens.EXCL;
|
||||
}
|
||||
case 189: break;
|
||||
case 40:
|
||||
{ return JetTokens.DIVEQ ;
|
||||
{ return KtTokens.DIVEQ ;
|
||||
}
|
||||
case 190: break;
|
||||
case 87:
|
||||
{ return JetTokens.ELSE_KEYWORD ;
|
||||
{ return KtTokens.ELSE_KEYWORD ;
|
||||
}
|
||||
case 191: break;
|
||||
case 51:
|
||||
{ return JetTokens.AS_KEYWORD ;
|
||||
{ return KtTokens.AS_KEYWORD ;
|
||||
}
|
||||
case 192: break;
|
||||
case 48:
|
||||
{ return JetTokens.IN_KEYWORD ;
|
||||
{ return KtTokens.IN_KEYWORD ;
|
||||
}
|
||||
case 193: break;
|
||||
case 53:
|
||||
{ return JetTokens.EQEQ ;
|
||||
{ return KtTokens.EQEQ ;
|
||||
}
|
||||
case 194: break;
|
||||
case 81:
|
||||
{ return JetTokens.EQEQEQ ;
|
||||
{ return KtTokens.EQEQEQ ;
|
||||
}
|
||||
case 195: break;
|
||||
case 79:
|
||||
{ return JetTokens.VAL_KEYWORD ;
|
||||
{ return KtTokens.VAL_KEYWORD ;
|
||||
}
|
||||
case 196: break;
|
||||
case 90:
|
||||
{ return JetTokens.CAPITALIZED_THIS_KEYWORD ;
|
||||
{ return KtTokens.CAPITALIZED_THIS_KEYWORD ;
|
||||
}
|
||||
case 197: break;
|
||||
case 50:
|
||||
{ return JetTokens.MULTEQ ;
|
||||
{ return KtTokens.MULTEQ ;
|
||||
}
|
||||
case 198: break;
|
||||
case 41:
|
||||
{ if (zzCurrentPos == 0) {
|
||||
return JetTokens.SHEBANG_COMMENT;
|
||||
return KtTokens.SHEBANG_COMMENT;
|
||||
}
|
||||
else {
|
||||
yypushback(yylength() - 1);
|
||||
return JetTokens.HASH;
|
||||
return KtTokens.HASH;
|
||||
}
|
||||
}
|
||||
case 199: break;
|
||||
case 12:
|
||||
{ return JetTokens.LBRACE ;
|
||||
{ return KtTokens.LBRACE ;
|
||||
}
|
||||
case 200: break;
|
||||
case 99:
|
||||
{ return JetTokens.OBJECT_KEYWORD ;
|
||||
{ return KtTokens.OBJECT_KEYWORD ;
|
||||
}
|
||||
case 201: break;
|
||||
case 96:
|
||||
{ return JetTokens.BREAK_KEYWORD ;
|
||||
{ return KtTokens.BREAK_KEYWORD ;
|
||||
}
|
||||
case 202: break;
|
||||
case 83:
|
||||
{ return JetTokens.BLOCK_COMMENT;
|
||||
{ return KtTokens.BLOCK_COMMENT;
|
||||
}
|
||||
case 203: break;
|
||||
case 62:
|
||||
{ return JetTokens.COLONCOLON;
|
||||
{ return KtTokens.COLONCOLON;
|
||||
}
|
||||
case 204: break;
|
||||
case 33:
|
||||
@@ -1305,7 +1305,7 @@ class _JetLexer implements FlexLexer {
|
||||
}
|
||||
case 205: break;
|
||||
case 6:
|
||||
{ return JetTokens.HASH ;
|
||||
{ return KtTokens.HASH ;
|
||||
}
|
||||
case 206: break;
|
||||
default:
|
||||
|
||||
@@ -22,31 +22,31 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.kotlin.lexer.JetKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.JetToken;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.utils.strings.StringsKt;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
|
||||
/*package*/ abstract class AbstractJetParsing {
|
||||
private static final Map<String, JetKeywordToken> SOFT_KEYWORD_TEXTS = new HashMap<String, JetKeywordToken>();
|
||||
private static final Map<String, KtKeywordToken> SOFT_KEYWORD_TEXTS = new HashMap<String, KtKeywordToken>();
|
||||
|
||||
static {
|
||||
for (IElementType type : JetTokens.SOFT_KEYWORDS.getTypes()) {
|
||||
JetKeywordToken keywordToken = (JetKeywordToken) type;
|
||||
for (IElementType type : KtTokens.SOFT_KEYWORDS.getTypes()) {
|
||||
KtKeywordToken keywordToken = (KtKeywordToken) type;
|
||||
assert keywordToken.isSoft();
|
||||
SOFT_KEYWORD_TEXTS.put(keywordToken.getValue(), keywordToken);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
for (IElementType token : JetTokens.KEYWORDS.getTypes()) {
|
||||
assert token instanceof JetKeywordToken : "Must be JetKeywordToken: " + token;
|
||||
assert !((JetKeywordToken) token).isSoft() : "Must not be soft: " + token;
|
||||
for (IElementType token : KtTokens.KEYWORDS.getTypes()) {
|
||||
assert token instanceof KtKeywordToken : "Must be KtKeywordToken: " + token;
|
||||
assert !((KtKeywordToken) token).isSoft() : "Must not be soft: " + token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
return myBuilder.rawLookup(-i);
|
||||
}
|
||||
|
||||
protected boolean expect(JetToken expectation, String message) {
|
||||
protected boolean expect(KtToken expectation, String message) {
|
||||
return expect(expectation, message, null);
|
||||
}
|
||||
|
||||
@@ -77,13 +77,13 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
myBuilder.error(message);
|
||||
}
|
||||
|
||||
protected boolean expect(JetToken expectation, String message, TokenSet recoverySet) {
|
||||
protected boolean expect(KtToken expectation, String message, TokenSet recoverySet) {
|
||||
if (at(expectation)) {
|
||||
advance(); // expectation
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expectation == JetTokens.IDENTIFIER && "`".equals(myBuilder.getTokenText())) {
|
||||
if (expectation == KtTokens.IDENTIFIER && "`".equals(myBuilder.getTokenText())) {
|
||||
advance();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean expectNoAdvance(JetToken expectation, String message) {
|
||||
protected boolean expectNoAdvance(KtToken expectation, String message) {
|
||||
if (at(expectation)) {
|
||||
advance(); // expectation
|
||||
return true;
|
||||
@@ -171,15 +171,15 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
protected boolean at(IElementType expectation) {
|
||||
if (_at(expectation)) return true;
|
||||
IElementType token = tt();
|
||||
if (token == IDENTIFIER && expectation instanceof JetKeywordToken) {
|
||||
JetKeywordToken expectedKeyword = (JetKeywordToken) expectation;
|
||||
if (token == IDENTIFIER && expectation instanceof KtKeywordToken) {
|
||||
KtKeywordToken expectedKeyword = (KtKeywordToken) expectation;
|
||||
if (expectedKeyword.isSoft() && expectedKeyword.getValue().equals(myBuilder.getTokenText())) {
|
||||
myBuilder.remapCurrentToken(expectation);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (expectation == IDENTIFIER && token instanceof JetKeywordToken) {
|
||||
JetKeywordToken keywordToken = (JetKeywordToken) token;
|
||||
if (expectation == IDENTIFIER && token instanceof KtKeywordToken) {
|
||||
KtKeywordToken keywordToken = (KtKeywordToken) token;
|
||||
if (keywordToken.isSoft()) {
|
||||
myBuilder.remapCurrentToken(IDENTIFIER);
|
||||
return true;
|
||||
@@ -217,7 +217,7 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
if (_atSet(set)) return true;
|
||||
IElementType token = tt();
|
||||
if (token == IDENTIFIER) {
|
||||
JetKeywordToken keywordToken = SOFT_KEYWORD_TEXTS.get(myBuilder.getTokenText());
|
||||
KtKeywordToken keywordToken = SOFT_KEYWORD_TEXTS.get(myBuilder.getTokenText());
|
||||
if (keywordToken != null && set.contains(keywordToken)) {
|
||||
myBuilder.remapCurrentToken(keywordToken);
|
||||
return true;
|
||||
@@ -225,8 +225,8 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
}
|
||||
else {
|
||||
// We know at this point that <code>set</code> does not contain <code>token</code>
|
||||
if (set.contains(IDENTIFIER) && token instanceof JetKeywordToken) {
|
||||
if (((JetKeywordToken) token).isSoft()) {
|
||||
if (set.contains(IDENTIFIER) && token instanceof KtKeywordToken) {
|
||||
if (((KtKeywordToken) token).isSoft()) {
|
||||
myBuilder.remapCurrentToken(IDENTIFIER);
|
||||
return true;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
return myBuilder.lookAhead(k);
|
||||
}
|
||||
|
||||
protected void consumeIf(JetToken token) {
|
||||
protected void consumeIf(KtToken token) {
|
||||
if (at(token)) advance(); // token
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.parsing
|
||||
|
||||
import com.intellij.lang.WhitespacesAndCommentsBinder
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
|
||||
object PrecedingCommentsBinder : WhitespacesAndCommentsBinder {
|
||||
@@ -28,7 +28,7 @@ object PrecedingCommentsBinder : WhitespacesAndCommentsBinder {
|
||||
|
||||
// 1. bind doc comment
|
||||
for (idx in tokens.indices.reversed()) {
|
||||
if (tokens[idx] == JetTokens.DOC_COMMENT) return idx
|
||||
if (tokens[idx] == KtTokens.DOC_COMMENT) return idx
|
||||
}
|
||||
|
||||
// 2. bind plain comments
|
||||
@@ -36,10 +36,10 @@ object PrecedingCommentsBinder : WhitespacesAndCommentsBinder {
|
||||
tokens@ for (idx in tokens.indices.reversed()) {
|
||||
val tokenType = tokens[idx]
|
||||
when (tokenType) {
|
||||
JetTokens.WHITE_SPACE -> if (StringUtil.getLineBreakCount(getter[idx]) > 1) break@tokens
|
||||
KtTokens.WHITE_SPACE -> if (StringUtil.getLineBreakCount(getter[idx]) > 1) break@tokens
|
||||
|
||||
in JetTokens.COMMENTS -> {
|
||||
if (idx == 0 || tokens[idx - 1] == JetTokens.WHITE_SPACE && StringUtil.containsLineBreak(getter[idx - 1])) {
|
||||
in KtTokens.COMMENTS -> {
|
||||
if (idx == 0 || tokens[idx - 1] == KtTokens.WHITE_SPACE && StringUtil.containsLineBreak(getter[idx - 1])) {
|
||||
result = idx
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ object PrecedingDocCommentsBinder : WhitespacesAndCommentsBinder {
|
||||
if (tokens.isEmpty()) return 0
|
||||
|
||||
for (idx in tokens.indices.reversed()) {
|
||||
if (tokens[idx] == JetTokens.DOC_COMMENT) return idx
|
||||
if (tokens[idx] == KtTokens.DOC_COMMENT) return idx
|
||||
}
|
||||
|
||||
return tokens.size()
|
||||
@@ -75,9 +75,9 @@ object TrailingCommentsBinder : WhitespacesAndCommentsBinder {
|
||||
tokens@ for (idx in tokens.indices) {
|
||||
val tokenType = tokens[idx]
|
||||
when (tokenType) {
|
||||
JetTokens.WHITE_SPACE -> if (StringUtil.containsLineBreak(getter[idx])) break@tokens
|
||||
KtTokens.WHITE_SPACE -> if (StringUtil.containsLineBreak(getter[idx])) break@tokens
|
||||
|
||||
JetTokens.EOL_COMMENT, JetTokens.BLOCK_COMMENT -> result = idx + 1
|
||||
KtTokens.EOL_COMMENT, KtTokens.BLOCK_COMMENT -> result = idx + 1
|
||||
|
||||
else -> break@tokens
|
||||
}
|
||||
|
||||
@@ -21,18 +21,18 @@ import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.JetNodeType;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.JetToken;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.KtNodeType;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.KtToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.parsing.JetParsing.NameParsingMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.kotlin.JetNodeTypes.*;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
import static org.jetbrains.kotlin.KtNodeTypes.*;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
import static org.jetbrains.kotlin.parsing.JetParsing.AnnotationParsingMode.DEFAULT;
|
||||
import static org.jetbrains.kotlin.parsing.JetParsing.DeclarationParsingMode.LOCAL;
|
||||
|
||||
@@ -41,12 +41,12 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
private static final TokenSet WHEN_CONDITION_RECOVERY_SET_WITH_ARROW = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD, ARROW, DOT);
|
||||
|
||||
|
||||
private static final ImmutableMap<String, JetToken> KEYWORD_TEXTS = tokenSetToMap(KEYWORDS);
|
||||
private static final ImmutableMap<String, KtToken> KEYWORD_TEXTS = tokenSetToMap(KEYWORDS);
|
||||
|
||||
private static ImmutableMap<String, JetToken> tokenSetToMap(TokenSet tokens) {
|
||||
ImmutableMap.Builder<String, JetToken> builder = ImmutableMap.builder();
|
||||
private static ImmutableMap<String, KtToken> tokenSetToMap(TokenSet tokens) {
|
||||
ImmutableMap.Builder<String, KtToken> builder = ImmutableMap.builder();
|
||||
for (IElementType token : tokens.getTypes()) {
|
||||
builder.put(token.toString(), (JetToken) token);
|
||||
builder.put(token.toString(), (KtToken) token);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
AS(AS_KEYWORD, AS_SAFE) {
|
||||
@Override
|
||||
public JetNodeType parseRightHandSide(IElementType operation, JetExpressionParsing parser) {
|
||||
public KtNodeType parseRightHandSide(IElementType operation, JetExpressionParsing parser) {
|
||||
parser.myJetParsing.parseTypeRef();
|
||||
return BINARY_WITH_TYPE;
|
||||
}
|
||||
@@ -162,12 +162,12 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
MULTIPLICATIVE(MUL, DIV, PERC),
|
||||
ADDITIVE(PLUS, MINUS),
|
||||
RANGE(JetTokens.RANGE),
|
||||
RANGE(KtTokens.RANGE),
|
||||
SIMPLE_NAME(IDENTIFIER),
|
||||
ELVIS(JetTokens.ELVIS),
|
||||
ELVIS(KtTokens.ELVIS),
|
||||
IN_OR_IS(IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS) {
|
||||
@Override
|
||||
public JetNodeType parseRightHandSide(IElementType operation, JetExpressionParsing parser) {
|
||||
public KtNodeType parseRightHandSide(IElementType operation, JetExpressionParsing parser) {
|
||||
if (operation == IS_KEYWORD || operation == NOT_IS) {
|
||||
parser.myJetParsing.parseTypeRef();
|
||||
return IS_EXPRESSION;
|
||||
@@ -180,7 +180,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
EQUALITY(EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ),
|
||||
CONJUNCTION(ANDAND),
|
||||
DISJUNCTION(OROR),
|
||||
// ARROW(JetTokens.ARROW),
|
||||
// ARROW(KtTokens.ARROW),
|
||||
ASSIGNMENT(EQ, PLUSEQ, MINUSEQ, MULTEQ, DIVEQ, PERCEQ),
|
||||
;
|
||||
|
||||
@@ -210,7 +210,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* @param parser the parser object
|
||||
* @return node type of the result
|
||||
*/
|
||||
public JetNodeType parseRightHandSide(IElementType operation, JetExpressionParsing parser) {
|
||||
public KtNodeType parseRightHandSide(IElementType operation, JetExpressionParsing parser) {
|
||||
parseHigherPrecedence(parser);
|
||||
return BINARY_EXPRESSION;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
parseOperationReference();
|
||||
|
||||
JetNodeType resultType = precedence.parseRightHandSide(operation, this);
|
||||
KtNodeType resultType = precedence.parseRightHandSide(operation, this);
|
||||
expression.done(resultType);
|
||||
expression = expression.precede();
|
||||
}
|
||||
@@ -763,7 +763,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
thisExpression.done(THIS_EXPRESSION);
|
||||
}
|
||||
else {
|
||||
JetToken keyword = KEYWORD_TEXTS.get(myBuilder.getTokenText());
|
||||
KtToken keyword = KEYWORD_TEXTS.get(myBuilder.getTokenText());
|
||||
if (keyword != null) {
|
||||
myBuilder.remapCurrentToken(keyword);
|
||||
errorAndAdvance("Keyword cannot be used as a reference");
|
||||
@@ -1041,7 +1041,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
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 != JetNodeTypes.PROPERTY && declType != JetNodeTypes.MULTI_VARIABLE_DECLARATION);
|
||||
declType != KtNodeTypes.PROPERTY && declType != KtNodeTypes.MULTI_VARIABLE_DECLARATION);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -1128,7 +1128,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
}
|
||||
|
||||
private boolean rollbackOrDrop(PsiBuilder.Marker rollbackMarker,
|
||||
JetToken expected, String expectMessage,
|
||||
KtToken expected, String expectMessage,
|
||||
IElementType validForDrop) {
|
||||
if (at(expected)) {
|
||||
advance(); // dropAt
|
||||
@@ -1527,7 +1527,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* : "continue" getEntryPoint?
|
||||
* : "break" getEntryPoint?
|
||||
*/
|
||||
private void parseJump(JetNodeType type) {
|
||||
private void parseJump(KtNodeType type) {
|
||||
assert _at(BREAK_KEYWORD) || _at(CONTINUE_KEYWORD);
|
||||
|
||||
PsiBuilder.Marker marker = mark();
|
||||
@@ -1770,7 +1770,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
literal.done(OBJECT_LITERAL);
|
||||
}
|
||||
|
||||
private void parseOneTokenExpression(JetNodeType type) {
|
||||
private void parseOneTokenExpression(KtNodeType type) {
|
||||
PsiBuilder.Marker mark = mark();
|
||||
advance();
|
||||
mark.done(type);
|
||||
|
||||
@@ -30,17 +30,17 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.JetNodeType;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.KtNodeType;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens;
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocElementType;
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocLink;
|
||||
import org.jetbrains.kotlin.lexer.JetLexer;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementType;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
|
||||
import org.jetbrains.kotlin.lexer.KotlinLexer;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementType;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
|
||||
public class JetParserDefinition implements ParserDefinition {
|
||||
public static final String STD_SCRIPT_SUFFIX = "kts";
|
||||
@@ -61,7 +61,7 @@ public class JetParserDefinition implements ParserDefinition {
|
||||
@Override
|
||||
@NotNull
|
||||
public Lexer createLexer(Project project) {
|
||||
return new JetLexer();
|
||||
return new KotlinLexer();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,25 +71,25 @@ public class JetParserDefinition implements ParserDefinition {
|
||||
|
||||
@Override
|
||||
public IFileElementType getFileNodeType() {
|
||||
return JetStubElementTypes.FILE;
|
||||
return KtStubElementTypes.FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public TokenSet getWhitespaceTokens() {
|
||||
return JetTokens.WHITESPACES;
|
||||
return KtTokens.WHITESPACES;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public TokenSet getCommentTokens() {
|
||||
return JetTokens.COMMENTS;
|
||||
return KtTokens.COMMENTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public TokenSet getStringLiteralElements() {
|
||||
return JetTokens.STRINGS;
|
||||
return KtTokens.STRINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,12 +97,12 @@ public class JetParserDefinition implements ParserDefinition {
|
||||
public PsiElement createElement(ASTNode astNode) {
|
||||
IElementType elementType = astNode.getElementType();
|
||||
|
||||
if (elementType instanceof JetStubElementType) {
|
||||
return ((JetStubElementType) elementType).createPsiFromAst(astNode);
|
||||
if (elementType instanceof KtStubElementType) {
|
||||
return ((KtStubElementType) elementType).createPsiFromAst(astNode);
|
||||
}
|
||||
else if (elementType == JetNodeTypes.TYPE_CODE_FRAGMENT ||
|
||||
elementType == JetNodeTypes.EXPRESSION_CODE_FRAGMENT ||
|
||||
elementType == JetNodeTypes.BLOCK_CODE_FRAGMENT) {
|
||||
else if (elementType == KtNodeTypes.TYPE_CODE_FRAGMENT ||
|
||||
elementType == KtNodeTypes.EXPRESSION_CODE_FRAGMENT ||
|
||||
elementType == KtNodeTypes.BLOCK_CODE_FRAGMENT) {
|
||||
return new ASTWrapperPsiElement(astNode);
|
||||
}
|
||||
else if (elementType instanceof KDocElementType) {
|
||||
@@ -112,19 +112,19 @@ public class JetParserDefinition implements ParserDefinition {
|
||||
return new KDocLink(astNode);
|
||||
}
|
||||
else {
|
||||
return ((JetNodeType) elementType).createPsi(astNode);
|
||||
return ((KtNodeType) elementType).createPsi(astNode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiFile createFile(FileViewProvider fileViewProvider) {
|
||||
return new JetFile(fileViewProvider, false);
|
||||
return new KtFile(fileViewProvider, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode astNode, ASTNode astNode1) {
|
||||
IElementType rightTokenType = astNode1.getElementType();
|
||||
if (rightTokenType == JetTokens.GET_KEYWORD || rightTokenType == JetTokens.SET_KEYWORD) {
|
||||
if (rightTokenType == KtTokens.GET_KEYWORD || rightTokenType == KtTokens.SET_KEYWORD) {
|
||||
return SpaceRequirements.MUST_LINE_BREAK;
|
||||
}
|
||||
return SpaceRequirements.MAY;
|
||||
|
||||
@@ -22,15 +22,15 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.JetNodeType;
|
||||
import org.jetbrains.kotlin.lexer.JetKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.KtNodeType;
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.kotlin.JetNodeTypes.*;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
import static org.jetbrains.kotlin.KtNodeTypes.*;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
import static org.jetbrains.kotlin.parsing.JetParsing.AnnotationParsingMode.*;
|
||||
import static org.jetbrains.kotlin.parsing.JetParsing.DeclarationParsingMode.*;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
public static final Map<String, IElementType> MODIFIER_KEYWORD_MAP = new HashMap<String, IElementType>();
|
||||
static {
|
||||
for (IElementType softKeyword : MODIFIER_KEYWORDS.getTypes()) {
|
||||
MODIFIER_KEYWORD_MAP.put(((JetKeywordToken) softKeyword).getValue(), softKeyword);
|
||||
MODIFIER_KEYWORD_MAP.put(((KtKeywordToken) softKeyword).getValue(), softKeyword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
return true;
|
||||
}
|
||||
|
||||
JetKeywordToken targetKeyword = atTargetKeyword();
|
||||
KtKeywordToken targetKeyword = atTargetKeyword();
|
||||
if (mode == FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED && !(targetKeyword == FILE_KEYWORD && lookahead(1) == COLON)) {
|
||||
return false;
|
||||
}
|
||||
@@ -665,7 +665,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void parseAnnotationTarget(AnnotationParsingMode mode, JetKeywordToken keyword) {
|
||||
private void parseAnnotationTarget(AnnotationParsingMode mode, KtKeywordToken keyword) {
|
||||
if (keyword == FILE_KEYWORD && !mode.isFileAnnotationParsingMode && at(keyword) && lookahead(1) == COLON) {
|
||||
errorAndAdvance(AT.getValue() + keyword.getValue() + " annotations are only allowed before package declaration", 2);
|
||||
return;
|
||||
@@ -686,9 +686,9 @@ public class JetParsing extends AbstractJetParsing {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JetKeywordToken atTargetKeyword() {
|
||||
private KtKeywordToken atTargetKeyword() {
|
||||
for (IElementType target : ANNOTATION_TARGETS.getTypes()) {
|
||||
if (at(target)) return (JetKeywordToken) target;
|
||||
if (at(target)) return (KtKeywordToken) target;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
* : modifiers "typealias" SimpleName (typeParameters typeConstraints)? "=" type
|
||||
* ;
|
||||
*/
|
||||
JetNodeType parseTypeAlias() {
|
||||
KtNodeType parseTypeAlias() {
|
||||
assert _at(TYPE_ALIAS_KEYWORD);
|
||||
|
||||
advance(); // TYPE_ALIAS_KEYWORD
|
||||
@@ -2242,10 +2242,10 @@ public class JetParsing extends AbstractJetParsing {
|
||||
|
||||
@Override
|
||||
public void consume(IElementType item) {
|
||||
if (item == JetTokens.ENUM_KEYWORD) {
|
||||
if (item == KtTokens.ENUM_KEYWORD) {
|
||||
enumDetected = true;
|
||||
}
|
||||
else if (item == JetTokens.COMPANION_KEYWORD) {
|
||||
else if (item == KtTokens.COMPANION_KEYWORD) {
|
||||
defaultDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
|
||||
|
||||
import java.util.*;
|
||||
@@ -40,7 +40,7 @@ public class JetScriptDefinitionProvider {
|
||||
addScriptDefinition(standardScript);
|
||||
}
|
||||
|
||||
public void markFileAsScript(JetFile file) {
|
||||
public void markFileAsScript(KtFile file) {
|
||||
scriptsFiles.add(file);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -25,9 +25,9 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.*;
|
||||
import static org.jetbrains.kotlin.lexer.KtTokens.*;
|
||||
|
||||
public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder {
|
||||
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS, EXCLEXCL);
|
||||
@@ -77,9 +77,9 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
|
||||
for (int i = 1; i <= getCurrentOffset(); i++) {
|
||||
IElementType previousToken = rawLookup(-i);
|
||||
|
||||
if (previousToken == JetTokens.BLOCK_COMMENT
|
||||
|| previousToken == JetTokens.DOC_COMMENT
|
||||
|| previousToken == JetTokens.EOL_COMMENT
|
||||
if (previousToken == KtTokens.BLOCK_COMMENT
|
||||
|| previousToken == KtTokens.DOC_COMMENT
|
||||
|| previousToken == KtTokens.EOL_COMMENT
|
||||
|| previousToken == SHEBANG_COMMENT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ public interface Call {
|
||||
ReceiverValue getDispatchReceiver();
|
||||
|
||||
@Nullable
|
||||
JetExpression getCalleeExpression();
|
||||
KtExpression getCalleeExpression();
|
||||
|
||||
@Nullable
|
||||
JetValueArgumentList getValueArgumentList();
|
||||
KtValueArgumentList getValueArgumentList();
|
||||
|
||||
@ReadOnly
|
||||
@NotNull
|
||||
@@ -52,13 +52,13 @@ public interface Call {
|
||||
|
||||
@ReadOnly
|
||||
@NotNull
|
||||
List<JetTypeProjection> getTypeArguments();
|
||||
List<KtTypeProjection> getTypeArguments();
|
||||
|
||||
@Nullable
|
||||
JetTypeArgumentList getTypeArgumentList();
|
||||
KtTypeArgumentList getTypeArgumentList();
|
||||
|
||||
@NotNull
|
||||
JetElement getCallElement();
|
||||
KtElement getCallElement();
|
||||
|
||||
enum CallType {
|
||||
DEFAULT, ARRAY_GET_METHOD, ARRAY_SET_METHOD, INVOKE
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
package org.jetbrains.kotlin.psi.debugText
|
||||
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
|
||||
// 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
|
||||
// this defaults to get text if the element is not stubbed
|
||||
public fun JetElement.getDebugText(): String {
|
||||
if (this !is JetElementImplStub<*> || this.getStub() == null) {
|
||||
public fun KtElement.getDebugText(): String {
|
||||
if (this !is KtElementImplStub<*> || this.getStub() == null) {
|
||||
return getText()
|
||||
}
|
||||
if (this is JetPackageDirective) {
|
||||
if (this is KtPackageDirective) {
|
||||
val fqName = getFqName()
|
||||
if (fqName.isRoot()) {
|
||||
return ""
|
||||
@@ -38,22 +38,22 @@ public fun JetElement.getDebugText(): String {
|
||||
}
|
||||
|
||||
|
||||
private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
private object DebugTextBuildingVisitor : KtVisitor<String, Unit>() {
|
||||
|
||||
private val LOG = Logger.getInstance(this.javaClass)
|
||||
|
||||
override fun visitJetFile(file: JetFile, data: Unit?): String? {
|
||||
override fun visitJetFile(file: KtFile, data: Unit?): String? {
|
||||
return "STUB file: ${file.getName()}"
|
||||
}
|
||||
|
||||
override fun visitJetElement(element: JetElement, data: Unit?): String? {
|
||||
if (element is JetElementImplStub<*>) {
|
||||
override fun visitJetElement(element: KtElement, data: Unit?): String? {
|
||||
if (element is KtElementImplStub<*>) {
|
||||
LOG.error("getDebugText() is not defined for ${element.javaClass}")
|
||||
}
|
||||
return element.getText()
|
||||
}
|
||||
|
||||
override fun visitImportDirective(importDirective: JetImportDirective, data: Unit?): String? {
|
||||
override fun visitImportDirective(importDirective: KtImportDirective, data: Unit?): String? {
|
||||
val importPath = importDirective.getImportPath()
|
||||
if (importPath == null) {
|
||||
return "import <invalid>"
|
||||
@@ -62,67 +62,67 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
return "import ${importPath.getPathStr()}" + aliasStr
|
||||
}
|
||||
|
||||
override fun visitImportList(importList: JetImportList, data: Unit?): String? {
|
||||
override fun visitImportList(importList: KtImportList, data: Unit?): String? {
|
||||
return renderChildren(importList, separator = "\n")
|
||||
}
|
||||
|
||||
override fun visitAnnotationEntry(annotationEntry: JetAnnotationEntry, data: Unit?): String? {
|
||||
override fun visitAnnotationEntry(annotationEntry: KtAnnotationEntry, data: Unit?): String? {
|
||||
return render(annotationEntry, annotationEntry.getCalleeExpression(), annotationEntry.getTypeArgumentList())
|
||||
}
|
||||
|
||||
override fun visitTypeReference(typeReference: JetTypeReference, data: Unit?): String? {
|
||||
override fun visitTypeReference(typeReference: KtTypeReference, data: Unit?): String? {
|
||||
return renderChildren(typeReference, " ")
|
||||
}
|
||||
|
||||
override fun visitTypeArgumentList(typeArgumentList: JetTypeArgumentList, data: Unit?): String? {
|
||||
override fun visitTypeArgumentList(typeArgumentList: KtTypeArgumentList, data: Unit?): String? {
|
||||
return renderChildren(typeArgumentList, ", ", "<", ">")
|
||||
}
|
||||
|
||||
override fun visitTypeConstraintList(list: JetTypeConstraintList, data: Unit?): String? {
|
||||
override fun visitTypeConstraintList(list: KtTypeConstraintList, data: Unit?): String? {
|
||||
return renderChildren(list, ", ", "where ", "")
|
||||
}
|
||||
|
||||
override fun visitUserType(userType: JetUserType, data: Unit?): String? {
|
||||
override fun visitUserType(userType: KtUserType, data: Unit?): String? {
|
||||
return render(userType, userType.getQualifier(), userType.getReferenceExpression(), userType.getTypeArgumentList())
|
||||
}
|
||||
|
||||
override fun visitDynamicType(type: JetDynamicType, data: Unit?): String? {
|
||||
override fun visitDynamicType(type: KtDynamicType, data: Unit?): String? {
|
||||
return "dynamic"
|
||||
}
|
||||
|
||||
override fun visitAnnotation(annotation: JetAnnotation, data: Unit?): String? {
|
||||
override fun visitAnnotation(annotation: KtAnnotation, data: Unit?): String? {
|
||||
return renderChildren(annotation, " ", "[", "]")
|
||||
}
|
||||
|
||||
override fun visitConstructorCalleeExpression(constructorCalleeExpression: JetConstructorCalleeExpression, data: Unit?): String? {
|
||||
override fun visitConstructorCalleeExpression(constructorCalleeExpression: KtConstructorCalleeExpression, data: Unit?): String? {
|
||||
return render(constructorCalleeExpression, constructorCalleeExpression.getConstructorReferenceExpression())
|
||||
}
|
||||
|
||||
override fun visitDelegationSpecifier(specifier: JetDelegationSpecifier, data: Unit?): String? {
|
||||
override fun visitDelegationSpecifier(specifier: KtDelegationSpecifier, data: Unit?): String? {
|
||||
return render(specifier, specifier.getTypeReference())
|
||||
}
|
||||
|
||||
override fun visitDelegationSpecifierList(list: JetDelegationSpecifierList, data: Unit?): String? {
|
||||
override fun visitDelegationSpecifierList(list: KtDelegationSpecifierList, data: Unit?): String? {
|
||||
return renderChildren(list, ", ")
|
||||
}
|
||||
|
||||
override fun visitTypeParameterList(list: JetTypeParameterList, data: Unit?): String? {
|
||||
override fun visitTypeParameterList(list: KtTypeParameterList, data: Unit?): String? {
|
||||
return renderChildren(list, ", ", "<", ">")
|
||||
}
|
||||
|
||||
override fun visitDotQualifiedExpression(expression: JetDotQualifiedExpression, data: Unit?): String? {
|
||||
override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression, data: Unit?): String? {
|
||||
return renderChildren(expression, ".")
|
||||
}
|
||||
|
||||
override fun visitInitializerList(list: JetInitializerList, data: Unit?): String? {
|
||||
override fun visitInitializerList(list: KtInitializerList, data: Unit?): String? {
|
||||
return renderChildren(list, ", ")
|
||||
}
|
||||
|
||||
override fun visitParameterList(list: JetParameterList, data: Unit?): String? {
|
||||
override fun visitParameterList(list: KtParameterList, data: Unit?): String? {
|
||||
return renderChildren(list, ", ", "(", ")")
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: JetEnumEntry, data: Unit?): String? {
|
||||
override fun visitEnumEntry(enumEntry: KtEnumEntry, data: Unit?): String? {
|
||||
return buildText {
|
||||
append("STUB: ")
|
||||
appendInn(enumEntry.getModifierList(), suffix = " ")
|
||||
@@ -132,7 +132,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitFunctionType(functionType: JetFunctionType, data: Unit?): String? {
|
||||
override fun visitFunctionType(functionType: KtFunctionType, data: Unit?): String? {
|
||||
return buildText {
|
||||
appendInn(functionType.getReceiverTypeReference(), suffix = ".")
|
||||
appendInn(functionType.getParameterList())
|
||||
@@ -140,7 +140,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitTypeParameter(parameter: JetTypeParameter, data: Unit?): String? {
|
||||
override fun visitTypeParameter(parameter: KtTypeParameter, data: Unit?): String? {
|
||||
return buildText {
|
||||
appendInn(parameter.getModifierList(), suffix = " ")
|
||||
appendInn(parameter.getNameAsName())
|
||||
@@ -148,7 +148,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitTypeProjection(typeProjection: JetTypeProjection, data: Unit?): String? {
|
||||
override fun visitTypeProjection(typeProjection: KtTypeProjection, data: Unit?): String? {
|
||||
return buildText {
|
||||
val token = typeProjection.getProjectionKind().getToken()
|
||||
appendInn(token?.getValue())
|
||||
@@ -160,10 +160,10 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitModifierList(list: JetModifierList, data: Unit?): String? {
|
||||
override fun visitModifierList(list: KtModifierList, data: Unit?): String? {
|
||||
return buildText {
|
||||
var first = true
|
||||
for (modifierKeywordToken in JetTokens.MODIFIER_KEYWORDS_ARRAY) {
|
||||
for (modifierKeywordToken in KtTokens.MODIFIER_KEYWORDS_ARRAY) {
|
||||
if (list.hasModifier(modifierKeywordToken)) {
|
||||
if (!first) {
|
||||
append(" ")
|
||||
@@ -175,31 +175,31 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitSimpleNameExpression(expression: JetSimpleNameExpression, data: Unit?): String? {
|
||||
override fun visitSimpleNameExpression(expression: KtSimpleNameExpression, data: Unit?): String? {
|
||||
return expression.getReferencedName()
|
||||
}
|
||||
|
||||
override fun visitNullableType(nullableType: JetNullableType, data: Unit?): String? {
|
||||
override fun visitNullableType(nullableType: KtNullableType, data: Unit?): String? {
|
||||
return renderChildren(nullableType, "", "", "?")
|
||||
}
|
||||
|
||||
override fun visitAnonymousInitializer(initializer: JetClassInitializer, data: Unit?): String? {
|
||||
val containingDeclaration = JetStubbedPsiUtil.getContainingDeclaration(initializer)
|
||||
override fun visitAnonymousInitializer(initializer: KtClassInitializer, data: Unit?): String? {
|
||||
val containingDeclaration = KtStubbedPsiUtil.getContainingDeclaration(initializer)
|
||||
return "initializer in " + (containingDeclaration?.getDebugText() ?: "...")
|
||||
}
|
||||
|
||||
override fun visitClassBody(classBody: JetClassBody, data: Unit?): String? {
|
||||
val containingDeclaration = JetStubbedPsiUtil.getContainingDeclaration(classBody)
|
||||
override fun visitClassBody(classBody: KtClassBody, data: Unit?): String? {
|
||||
val containingDeclaration = KtStubbedPsiUtil.getContainingDeclaration(classBody)
|
||||
return "class body for " + (containingDeclaration?.getDebugText() ?: "...")
|
||||
}
|
||||
|
||||
override fun visitPropertyAccessor(accessor: JetPropertyAccessor, data: Unit?): String? {
|
||||
val containingProperty = JetStubbedPsiUtil.getContainingDeclaration(accessor, javaClass<JetProperty>())
|
||||
override fun visitPropertyAccessor(accessor: KtPropertyAccessor, data: Unit?): String? {
|
||||
val containingProperty = KtStubbedPsiUtil.getContainingDeclaration(accessor, javaClass<KtProperty>())
|
||||
val what = (if (accessor.isGetter()) "getter" else "setter")
|
||||
return what + " for " + (if (containingProperty != null) containingProperty.getDebugText() else "...")
|
||||
}
|
||||
|
||||
override fun visitClass(klass: JetClass, data: Unit?): String? {
|
||||
override fun visitClass(klass: KtClass, data: Unit?): String? {
|
||||
return buildText {
|
||||
append("STUB: ")
|
||||
appendInn(klass.getModifierList(), suffix = " ")
|
||||
@@ -212,7 +212,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(function: JetNamedFunction, data: Unit?): String? {
|
||||
override fun visitNamedFunction(function: KtNamedFunction, data: Unit?): String? {
|
||||
return buildText {
|
||||
append("STUB: ")
|
||||
appendInn(function.getModifierList(), suffix = " ")
|
||||
@@ -233,7 +233,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitObjectDeclaration(declaration: JetObjectDeclaration, data: Unit?): String? {
|
||||
override fun visitObjectDeclaration(declaration: KtObjectDeclaration, data: Unit?): String? {
|
||||
return buildText {
|
||||
append("STUB: ")
|
||||
appendInn(declaration.getModifierList(), suffix = " ")
|
||||
@@ -243,7 +243,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitParameter(parameter: JetParameter, data: Unit?): String? {
|
||||
override fun visitParameter(parameter: KtParameter, data: Unit?): String? {
|
||||
return buildText {
|
||||
if (parameter.hasValOrVar()) {
|
||||
if (parameter.isMutable()) append("var ") else append("val ")
|
||||
@@ -258,7 +258,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitProperty(property: JetProperty, data: Unit?): String? {
|
||||
override fun visitProperty(property: KtProperty, data: Unit?): String? {
|
||||
return buildText {
|
||||
append("STUB: ")
|
||||
appendInn(property.getModifierList(), suffix = " ")
|
||||
@@ -268,7 +268,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitTypeConstraint(constraint: JetTypeConstraint, data: Unit?): String? {
|
||||
override fun visitTypeConstraint(constraint: KtTypeConstraint, data: Unit?): String? {
|
||||
return buildText {
|
||||
appendInn(constraint.getSubjectTypeParameterName())
|
||||
appendInn(constraint.getBoundTypeReference(), prefix = " : ")
|
||||
@@ -281,12 +281,12 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
fun renderChildren(element: JetElementImplStub<*>, separator: String, prefix: String = "", postfix: String = ""): String? {
|
||||
val childrenTexts = element.getStub()?.getChildrenStubs()?.map { (it?.getPsi() as? JetElement)?.getDebugText() }
|
||||
fun renderChildren(element: KtElementImplStub<*>, separator: String, prefix: String = "", postfix: String = ""): String? {
|
||||
val childrenTexts = element.getStub()?.getChildrenStubs()?.map { (it?.getPsi() as? KtElement)?.getDebugText() }
|
||||
return childrenTexts?.filterNotNull()?.join(separator, prefix, postfix) ?: element.getText()
|
||||
}
|
||||
|
||||
fun render(element: JetElementImplStub<*>, vararg relevantChildren: JetElement?): String? {
|
||||
fun render(element: KtElementImplStub<*>, vararg relevantChildren: KtElement?): String? {
|
||||
if (element.getStub() == null) return element.getText()
|
||||
return relevantChildren.filterNotNull().map { it.getDebugText() }.join("", "", "")
|
||||
}
|
||||
@@ -296,7 +296,7 @@ private fun StringBuilder.appendInn(target: Any?, prefix: String = "", suffix: S
|
||||
if (target == null) return
|
||||
append(prefix)
|
||||
append(when (target) {
|
||||
is JetElement -> target.getDebugText()
|
||||
is KtElement -> target.getDebugText()
|
||||
else -> target.toString()
|
||||
})
|
||||
append(suffix)
|
||||
|
||||
@@ -18,18 +18,18 @@ package org.jetbrains.kotlin.psi
|
||||
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||
|
||||
internal object EditCommaSeparatedListHelper {
|
||||
public fun <TItem: JetElement> addItem(list: JetElement, allItems: List<TItem>, item: TItem): TItem {
|
||||
public fun <TItem: KtElement> addItem(list: KtElement, allItems: List<TItem>, item: TItem): TItem {
|
||||
return addItemBefore(list, allItems, item, null)
|
||||
}
|
||||
|
||||
public fun <TItem: JetElement> addItemAfter(list: JetElement, allItems: List<TItem>, item: TItem, anchor: TItem?): TItem {
|
||||
public fun <TItem: KtElement> addItemAfter(list: KtElement, allItems: List<TItem>, item: TItem, anchor: TItem?): TItem {
|
||||
assert(anchor == null || anchor.getParent() == list)
|
||||
if (allItems.isEmpty()) {
|
||||
if (list.getFirstChild().getNode().getElementType() == JetTokens.LPAR) {
|
||||
if (list.getFirstChild().getNode().getElementType() == KtTokens.LPAR) {
|
||||
return list.addAfter(item, list.getFirstChild()) as TItem
|
||||
}
|
||||
else {
|
||||
@@ -37,7 +37,7 @@ internal object EditCommaSeparatedListHelper {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var comma = JetPsiFactory(list).createComma()
|
||||
var comma = KtPsiFactory(list).createComma()
|
||||
if (anchor != null) {
|
||||
comma = list.addAfter(comma, anchor)
|
||||
return list.addAfter(item, comma) as TItem
|
||||
@@ -49,7 +49,7 @@ internal object EditCommaSeparatedListHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public fun <TItem: JetElement> addItemBefore(list: JetElement, allItems: List<TItem>, item: TItem, anchor: TItem?): TItem {
|
||||
public fun <TItem: KtElement> addItemBefore(list: KtElement, allItems: List<TItem>, item: TItem, anchor: TItem?): TItem {
|
||||
val anchorAfter: TItem?
|
||||
if (allItems.isEmpty()) {
|
||||
assert(anchor == null)
|
||||
@@ -68,11 +68,11 @@ internal object EditCommaSeparatedListHelper {
|
||||
return addItemAfter(list, allItems, item, anchorAfter)
|
||||
}
|
||||
|
||||
public fun <TItem: JetElement> removeItem(item: TItem) {
|
||||
public fun <TItem: KtElement> removeItem(item: TItem) {
|
||||
var comma = item.siblings(withItself = false).firstOrNull { it !is PsiWhiteSpace && it !is PsiComment }
|
||||
if (comma?.getNode()?.getElementType() != JetTokens.COMMA) {
|
||||
if (comma?.getNode()?.getElementType() != KtTokens.COMMA) {
|
||||
comma = item.siblings(forward = false, withItself = false).firstOrNull { it !is PsiWhiteSpace && it !is PsiComment }
|
||||
if (comma?.getNode()?.getElementType() != JetTokens.COMMA) {
|
||||
if (comma?.getNode()?.getElementType() != KtTokens.COMMA) {
|
||||
comma = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi.findDocComment
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import com.intellij.psi.PsiComment
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
|
||||
fun findDocComment(declaration: JetDeclaration): KDoc? {
|
||||
fun findDocComment(declaration: KtDeclaration): KDoc? {
|
||||
return declaration.allChildren
|
||||
.dropWhile { it !is KDoc && (it is PsiWhiteSpace || it is PsiComment) }
|
||||
.first() as? KDoc
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.psi
|
||||
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import org.jetbrains.kotlin.JetNodeType
|
||||
|
||||
public abstract class JetExpressionImpl(node: ASTNode) : JetElementImpl(node), JetExpression {
|
||||
|
||||
override fun <R, D> accept(visitor: JetVisitor<R, D>, data: D) = visitor.visitExpression(this, data)
|
||||
|
||||
protected fun findExpressionUnder(type: JetNodeType): JetExpression? {
|
||||
val containerNode = findChildByType<JetContainerNode>(type) ?: return null
|
||||
return containerNode.findChildByClass<JetExpression>(javaClass())
|
||||
}
|
||||
|
||||
override fun replace(newElement: PsiElement): PsiElement {
|
||||
return replaceExpression(this, newElement, { super<JetElementImpl>.replace(it) })
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun replaceExpression(expression: JetExpression, newElement: PsiElement, rawReplaceHandler: (PsiElement) -> PsiElement): PsiElement {
|
||||
val parent = expression.getParent()
|
||||
|
||||
if (newElement is JetExpression) {
|
||||
when (parent) {
|
||||
is JetExpression -> {
|
||||
if (JetPsiUtil.areParenthesesNecessary(newElement, expression, parent)) {
|
||||
return rawReplaceHandler(JetPsiFactory(expression).createExpressionByPattern("($0)", newElement))
|
||||
}
|
||||
}
|
||||
|
||||
is JetSimpleNameStringTemplateEntry -> {
|
||||
if (newElement !is JetSimpleNameExpression) {
|
||||
val newEntry = parent.replace(JetPsiFactory(expression).createBlockStringTemplateEntry(newElement)) as JetBlockStringTemplateEntry
|
||||
return newEntry.getExpression()!!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rawReplaceHandler(newElement)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,448 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.psi;
|
||||
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JetVisitor<R, D> extends PsiElementVisitor {
|
||||
public R visitJetElement(@NotNull JetElement element, D data) {
|
||||
visitElement(element);
|
||||
return null;
|
||||
}
|
||||
|
||||
public R visitDeclaration(@NotNull JetDeclaration dcl, D data) {
|
||||
return visitExpression(dcl, data);
|
||||
}
|
||||
|
||||
public R visitClass(@NotNull JetClass klass, D data) {
|
||||
return visitClassOrObject(klass, data);
|
||||
}
|
||||
|
||||
public R visitObjectDeclaration(@NotNull JetObjectDeclaration declaration, D data) {
|
||||
return visitClassOrObject(declaration, data);
|
||||
}
|
||||
|
||||
public R visitClassOrObject(@NotNull JetClassOrObject classOrObject, D data) {
|
||||
return visitNamedDeclaration(classOrObject, data);
|
||||
}
|
||||
|
||||
public R visitSecondaryConstructor(@NotNull JetSecondaryConstructor constructor, D data) {
|
||||
return visitDeclaration(constructor, data);
|
||||
}
|
||||
|
||||
public R visitPrimaryConstructor(@NotNull JetPrimaryConstructor constructor, D data) {
|
||||
return visitDeclaration(constructor, data);
|
||||
}
|
||||
|
||||
public R visitNamedFunction(@NotNull JetNamedFunction function, D data) {
|
||||
return visitNamedDeclaration(function, data);
|
||||
}
|
||||
|
||||
public R visitProperty(@NotNull JetProperty property, D data) {
|
||||
return visitNamedDeclaration(property, data);
|
||||
}
|
||||
|
||||
public R visitMultiDeclaration(@NotNull JetMultiDeclaration multiDeclaration, D data) {
|
||||
return visitDeclaration(multiDeclaration, data);
|
||||
}
|
||||
|
||||
public R visitMultiDeclarationEntry(@NotNull JetMultiDeclarationEntry multiDeclarationEntry, D data) {
|
||||
return visitNamedDeclaration(multiDeclarationEntry, data);
|
||||
}
|
||||
|
||||
public R visitTypedef(@NotNull JetTypedef typedef, D data) {
|
||||
return visitNamedDeclaration(typedef, data);
|
||||
}
|
||||
|
||||
public R visitJetFile(@NotNull JetFile file, D data) {
|
||||
visitFile(file);
|
||||
return null;
|
||||
}
|
||||
|
||||
public R visitScript(@NotNull JetScript script, D data) {
|
||||
return visitDeclaration(script, data);
|
||||
}
|
||||
|
||||
public R visitImportDirective(@NotNull JetImportDirective importDirective, D data) {
|
||||
return visitJetElement(importDirective, data);
|
||||
}
|
||||
|
||||
public R visitImportList(@NotNull JetImportList importList, D data) {
|
||||
return visitJetElement(importList, data);
|
||||
}
|
||||
|
||||
public R visitFileAnnotationList(@NotNull JetFileAnnotationList fileAnnotationList, D data) {
|
||||
return visitJetElement(fileAnnotationList, data);
|
||||
}
|
||||
|
||||
public R visitClassBody(@NotNull JetClassBody classBody, D data) {
|
||||
return visitJetElement(classBody, data);
|
||||
}
|
||||
|
||||
public R visitModifierList(@NotNull JetModifierList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitAnnotation(@NotNull JetAnnotation annotation, D data) {
|
||||
return visitJetElement(annotation, data);
|
||||
}
|
||||
|
||||
public R visitAnnotationEntry(@NotNull JetAnnotationEntry annotationEntry, D data) {
|
||||
return visitJetElement(annotationEntry, data);
|
||||
}
|
||||
|
||||
public R visitAnnotationUseSiteTarget(@NotNull JetAnnotationUseSiteTarget annotationTarget, D data) {
|
||||
return visitJetElement(annotationTarget, data);
|
||||
}
|
||||
|
||||
public R visitConstructorCalleeExpression(@NotNull JetConstructorCalleeExpression constructorCalleeExpression, D data) {
|
||||
return visitJetElement(constructorCalleeExpression, data);
|
||||
}
|
||||
|
||||
public R visitTypeParameterList(@NotNull JetTypeParameterList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitTypeParameter(@NotNull JetTypeParameter parameter, D data) {
|
||||
return visitNamedDeclaration(parameter, data);
|
||||
}
|
||||
|
||||
public R visitEnumEntry(@NotNull JetEnumEntry enumEntry, D data) {
|
||||
return visitClass(enumEntry, data);
|
||||
}
|
||||
|
||||
public R visitParameterList(@NotNull JetParameterList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitParameter(@NotNull JetParameter parameter, D data) {
|
||||
return visitNamedDeclaration(parameter, data);
|
||||
}
|
||||
|
||||
public R visitDelegationSpecifierList(@NotNull JetDelegationSpecifierList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitDelegationSpecifier(@NotNull JetDelegationSpecifier specifier, D data) {
|
||||
return visitJetElement(specifier, data);
|
||||
}
|
||||
|
||||
public R visitDelegationByExpressionSpecifier(@NotNull JetDelegatorByExpressionSpecifier specifier, D data) {
|
||||
return visitDelegationSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
public R visitDelegationToSuperCallSpecifier(@NotNull JetDelegatorToSuperCall call, D data) {
|
||||
return visitDelegationSpecifier(call, data);
|
||||
}
|
||||
|
||||
public R visitDelegationToSuperClassSpecifier(@NotNull JetDelegatorToSuperClass specifier, D data) {
|
||||
return visitDelegationSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
public R visitConstructorDelegationCall(@NotNull JetConstructorDelegationCall call, D data) {
|
||||
return visitJetElement(call, data);
|
||||
}
|
||||
|
||||
public R visitPropertyDelegate(@NotNull JetPropertyDelegate delegate, D data) {
|
||||
return visitJetElement(delegate, data);
|
||||
}
|
||||
|
||||
public R visitTypeReference(@NotNull JetTypeReference typeReference, D data) {
|
||||
return visitJetElement(typeReference, data);
|
||||
}
|
||||
|
||||
public R visitValueArgumentList(@NotNull JetValueArgumentList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitArgument(@NotNull JetValueArgument argument, D data) {
|
||||
return visitJetElement(argument, data);
|
||||
}
|
||||
|
||||
public R visitExpression(@NotNull JetExpression expression, D data) {
|
||||
return visitJetElement(expression, data);
|
||||
}
|
||||
|
||||
public R visitLoopExpression(@NotNull JetLoopExpression loopExpression, D data) {
|
||||
return visitExpression(loopExpression, data);
|
||||
}
|
||||
|
||||
public R visitConstantExpression(@NotNull JetConstantExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression, D data) {
|
||||
return visitReferenceExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitReferenceExpression(@NotNull JetReferenceExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitLabeledExpression(@NotNull JetLabeledExpression expression, D data) {
|
||||
return visitExpressionWithLabel(expression, data);
|
||||
}
|
||||
|
||||
public R visitPrefixExpression(@NotNull JetPrefixExpression expression, D data) {
|
||||
return visitUnaryExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitPostfixExpression(@NotNull JetPostfixExpression expression, D data) {
|
||||
return visitUnaryExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitUnaryExpression(@NotNull JetUnaryExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitBinaryExpression(@NotNull JetBinaryExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitReturnExpression(@NotNull JetReturnExpression expression, D data) {
|
||||
return visitExpressionWithLabel(expression, data);
|
||||
}
|
||||
|
||||
public R visitExpressionWithLabel(@NotNull JetExpressionWithLabel expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitThrowExpression(@NotNull JetThrowExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitBreakExpression(@NotNull JetBreakExpression expression, D data) {
|
||||
return visitExpressionWithLabel(expression, data);
|
||||
}
|
||||
|
||||
public R visitContinueExpression(@NotNull JetContinueExpression expression, D data) {
|
||||
return visitExpressionWithLabel(expression, data);
|
||||
}
|
||||
|
||||
public R visitIfExpression(@NotNull JetIfExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitWhenExpression(@NotNull JetWhenExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitTryExpression(@NotNull JetTryExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitForExpression(@NotNull JetForExpression expression, D data) {
|
||||
return visitLoopExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitWhileExpression(@NotNull JetWhileExpression expression, D data) {
|
||||
return visitLoopExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitDoWhileExpression(@NotNull JetDoWhileExpression expression, D data) {
|
||||
return visitLoopExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitAnnotatedExpression(@NotNull JetAnnotatedExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitCallExpression(@NotNull JetCallExpression expression, D data) {
|
||||
return visitReferenceExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitArrayAccessExpression(@NotNull JetArrayAccessExpression expression, D data) {
|
||||
return visitReferenceExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitQualifiedExpression(@NotNull JetQualifiedExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitDoubleColonExpression(@NotNull JetDoubleColonExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitCallableReferenceExpression(@NotNull JetCallableReferenceExpression expression, D data) {
|
||||
return visitDoubleColonExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitClassLiteralExpression(@NotNull JetClassLiteralExpression expression, D data) {
|
||||
return visitDoubleColonExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitDotQualifiedExpression(@NotNull JetDotQualifiedExpression expression, D data) {
|
||||
return visitQualifiedExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitSafeQualifiedExpression(@NotNull JetSafeQualifiedExpression expression, D data) {
|
||||
return visitQualifiedExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitObjectLiteralExpression(@NotNull JetObjectLiteralExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitRootPackageExpression(@NotNull JetRootPackageExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitBlockExpression(@NotNull JetBlockExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitCatchSection(@NotNull JetCatchClause catchClause, D data) {
|
||||
return visitJetElement(catchClause, data);
|
||||
}
|
||||
|
||||
public R visitFinallySection(@NotNull JetFinallySection finallySection, D data) {
|
||||
return visitJetElement(finallySection, data);
|
||||
}
|
||||
|
||||
public R visitTypeArgumentList(@NotNull JetTypeArgumentList typeArgumentList, D data) {
|
||||
return visitJetElement(typeArgumentList, data);
|
||||
}
|
||||
|
||||
public R visitThisExpression(@NotNull JetThisExpression expression, D data) {
|
||||
return visitExpressionWithLabel(expression, data);
|
||||
}
|
||||
|
||||
public R visitSuperExpression(@NotNull JetSuperExpression expression, D data) {
|
||||
return visitExpressionWithLabel(expression, data);
|
||||
}
|
||||
|
||||
public R visitParenthesizedExpression(@NotNull JetParenthesizedExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitInitializerList(@NotNull JetInitializerList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitAnonymousInitializer(@NotNull JetClassInitializer initializer, D data) {
|
||||
return visitDeclaration(initializer, data);
|
||||
}
|
||||
|
||||
public R visitPropertyAccessor(@NotNull JetPropertyAccessor accessor, D data) {
|
||||
return visitDeclaration(accessor, data);
|
||||
}
|
||||
|
||||
public R visitTypeConstraintList(@NotNull JetTypeConstraintList list, D data) {
|
||||
return visitJetElement(list, data);
|
||||
}
|
||||
|
||||
public R visitTypeConstraint(@NotNull JetTypeConstraint constraint, D data) {
|
||||
return visitJetElement(constraint, data);
|
||||
}
|
||||
|
||||
private R visitTypeElement(@NotNull JetTypeElement type, D data) {
|
||||
return visitJetElement(type, data);
|
||||
}
|
||||
|
||||
public R visitUserType(@NotNull JetUserType type, D data) {
|
||||
return visitTypeElement(type, data);
|
||||
}
|
||||
|
||||
public R visitDynamicType(@NotNull JetDynamicType type, D data) {
|
||||
return visitTypeElement(type, data);
|
||||
}
|
||||
|
||||
public R visitFunctionType(@NotNull JetFunctionType type, D data) {
|
||||
return visitTypeElement(type, data);
|
||||
}
|
||||
|
||||
public R visitSelfType(@NotNull JetSelfType type, D data) {
|
||||
return visitTypeElement(type, data);
|
||||
}
|
||||
|
||||
public R visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionWithTypeRHS expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitStringTemplateExpression(@NotNull JetStringTemplateExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitNamedDeclaration(@NotNull JetNamedDeclaration declaration, D data) {
|
||||
return visitDeclaration(declaration, data);
|
||||
}
|
||||
|
||||
public R visitNullableType(@NotNull JetNullableType nullableType, D data) {
|
||||
return visitTypeElement(nullableType, data);
|
||||
}
|
||||
|
||||
public R visitTypeProjection(@NotNull JetTypeProjection typeProjection, D data) {
|
||||
return visitJetElement(typeProjection, data);
|
||||
}
|
||||
|
||||
public R visitWhenEntry(@NotNull JetWhenEntry jetWhenEntry, D data) {
|
||||
return visitJetElement(jetWhenEntry, data);
|
||||
}
|
||||
|
||||
public R visitIsExpression(@NotNull JetIsExpression expression, D data) {
|
||||
return visitExpression(expression, data);
|
||||
}
|
||||
|
||||
public R visitWhenConditionIsPattern(@NotNull JetWhenConditionIsPattern condition, D data) {
|
||||
return visitJetElement(condition, data);
|
||||
}
|
||||
|
||||
public R visitWhenConditionInRange(@NotNull JetWhenConditionInRange condition, D data) {
|
||||
return visitJetElement(condition, data);
|
||||
}
|
||||
|
||||
public R visitWhenConditionWithExpression(@NotNull JetWhenConditionWithExpression condition, D data) {
|
||||
return visitJetElement(condition, data);
|
||||
}
|
||||
|
||||
public R visitObjectDeclarationName(@NotNull JetObjectDeclarationName declarationName, D data) {
|
||||
return visitExpression(declarationName, data);
|
||||
}
|
||||
|
||||
public R visitStringTemplateEntry(@NotNull JetStringTemplateEntry entry, D data) {
|
||||
return visitJetElement(entry, data);
|
||||
}
|
||||
|
||||
public R visitStringTemplateEntryWithExpression(@NotNull JetStringTemplateEntryWithExpression entry, D data) {
|
||||
return visitStringTemplateEntry(entry, data);
|
||||
}
|
||||
|
||||
public R visitBlockStringTemplateEntry(@NotNull JetBlockStringTemplateEntry entry, D data) {
|
||||
return visitStringTemplateEntryWithExpression(entry, data);
|
||||
}
|
||||
|
||||
public R visitSimpleNameStringTemplateEntry(@NotNull JetSimpleNameStringTemplateEntry entry, D data) {
|
||||
return visitStringTemplateEntryWithExpression(entry, data);
|
||||
}
|
||||
|
||||
public R visitLiteralStringTemplateEntry(@NotNull JetLiteralStringTemplateEntry entry, D data) {
|
||||
return visitStringTemplateEntry(entry, data);
|
||||
}
|
||||
|
||||
public R visitEscapeStringTemplateEntry(@NotNull JetEscapeStringTemplateEntry entry, D data) {
|
||||
return visitStringTemplateEntry(entry, data);
|
||||
}
|
||||
|
||||
public R visitPackageDirective(@NotNull JetPackageDirective directive, D data) {
|
||||
return visitJetElement(directive, data);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,6 @@
|
||||
package org.jetbrains.kotlin.psi
|
||||
|
||||
public interface KotlinDeclarationNavigationPolicy {
|
||||
public fun getOriginalElement(declaration: JetDeclaration): JetElement
|
||||
public fun getNavigationElement(declaration: JetDeclaration): JetElement
|
||||
public fun getOriginalElement(declaration: KtDeclaration): KtElement
|
||||
public fun getNavigationElement(declaration: KtDeclaration): KtElement
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import gnu.trove.TIntArrayList
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getContentRange
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isSingleQuoted
|
||||
|
||||
public class KotlinStringLiteralTextEscaper(host: JetStringTemplateExpression): LiteralTextEscaper<JetStringTemplateExpression>(host) {
|
||||
public class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression): LiteralTextEscaper<KtStringTemplateExpression>(host) {
|
||||
private var sourceOffsets: IntArray? = null
|
||||
|
||||
override fun decode(rangeInsideHost: TextRange, outChars: StringBuilder): Boolean {
|
||||
@@ -38,14 +38,14 @@ public class KotlinStringLiteralTextEscaper(host: JetStringTemplateExpression):
|
||||
continue
|
||||
}
|
||||
when (child) {
|
||||
is JetLiteralStringTemplateEntry -> {
|
||||
is KtLiteralStringTemplateEntry -> {
|
||||
val textRange = rangeInsideHost.intersection(childRange)!!.shiftRight(-childRange.getStartOffset())
|
||||
outChars.append(child.getText(), textRange.getStartOffset(), textRange.getEndOffset())
|
||||
repeat(textRange.length) {
|
||||
sourceOffsetsList.add(sourceOffset++)
|
||||
}
|
||||
}
|
||||
is JetEscapeStringTemplateEntry -> {
|
||||
is KtEscapeStringTemplateEntry -> {
|
||||
if (!rangeInsideHost.contains(childRange)) {
|
||||
//don't allow injection if its range starts or ends inside escaped sequence
|
||||
return false
|
||||
|
||||
+3
-3
@@ -20,10 +20,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface JetAnnotated extends JetElement {
|
||||
public interface KtAnnotated extends KtElement {
|
||||
@NotNull
|
||||
List<JetAnnotation> getAnnotations();
|
||||
List<KtAnnotation> getAnnotations();
|
||||
|
||||
@NotNull
|
||||
List<JetAnnotationEntry> getAnnotationEntries();
|
||||
List<KtAnnotationEntry> getAnnotationEntries();
|
||||
}
|
||||
+9
-9
@@ -19,35 +19,35 @@ package org.jetbrains.kotlin.psi;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.JetPsiUtilKt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JetAnnotatedExpression extends JetExpressionImpl implements JetAnnotated, JetAnnotationsContainer {
|
||||
public JetAnnotatedExpression(@NotNull ASTNode node) {
|
||||
public class KtAnnotatedExpression extends KtExpressionImpl implements KtAnnotated, KtAnnotationsContainer {
|
||||
public KtAnnotatedExpression(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitAnnotatedExpression(this, data);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetExpression getBaseExpression() {
|
||||
return findChildByClass(JetExpression.class);
|
||||
public KtExpression getBaseExpression() {
|
||||
return findChildByClass(KtExpression.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<JetAnnotation> getAnnotations() {
|
||||
return findChildrenByType(JetNodeTypes.ANNOTATION);
|
||||
public List<KtAnnotation> getAnnotations() {
|
||||
return findChildrenByType(KtNodeTypes.ANNOTATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<JetAnnotationEntry> getAnnotationEntries() {
|
||||
public List<KtAnnotationEntry> getAnnotationEntries() {
|
||||
return JetPsiUtilKt.collectAnnotationEntriesFromStubOrPsi(this);
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -20,35 +20,35 @@ import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JetAnnotation extends JetElementImplStub<KotlinPlaceHolderStub<JetAnnotation>> {
|
||||
public class KtAnnotation extends KtElementImplStub<KotlinPlaceHolderStub<KtAnnotation>> {
|
||||
|
||||
public JetAnnotation(@NotNull ASTNode node) {
|
||||
public KtAnnotation(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public JetAnnotation(KotlinPlaceHolderStub<JetAnnotation> stub) {
|
||||
super(stub, JetStubElementTypes.ANNOTATION);
|
||||
public KtAnnotation(KotlinPlaceHolderStub<KtAnnotation> stub) {
|
||||
super(stub, KtStubElementTypes.ANNOTATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitAnnotation(this, data);
|
||||
}
|
||||
|
||||
public List<JetAnnotationEntry> getEntries() {
|
||||
return getStubOrPsiChildrenAsList(JetStubElementTypes.ANNOTATION_ENTRY);
|
||||
public List<KtAnnotationEntry> getEntries() {
|
||||
return getStubOrPsiChildrenAsList(KtStubElementTypes.ANNOTATION_ENTRY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetAnnotationUseSiteTarget getUseSiteTarget() {
|
||||
return getStubOrPsiChild(JetStubElementTypes.ANNOTATION_TARGET);
|
||||
public KtAnnotationUseSiteTarget getUseSiteTarget() {
|
||||
return getStubOrPsiChild(KtStubElementTypes.ANNOTATION_TARGET);
|
||||
}
|
||||
|
||||
public void removeEntry(@NotNull JetAnnotationEntry entry) {
|
||||
public void removeEntry(@NotNull KtAnnotationEntry entry) {
|
||||
if (getEntries().size() > 1) {
|
||||
entry.delete();
|
||||
}
|
||||
+29
-29
@@ -20,32 +20,32 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationEntryStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class JetAnnotationEntry extends JetElementImplStub<KotlinAnnotationEntryStub> implements JetCallElement {
|
||||
public JetAnnotationEntry(@NotNull ASTNode node) {
|
||||
public class KtAnnotationEntry extends KtElementImplStub<KotlinAnnotationEntryStub> implements KtCallElement {
|
||||
public KtAnnotationEntry(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public JetAnnotationEntry(@NotNull KotlinAnnotationEntryStub stub) {
|
||||
super(stub, JetStubElementTypes.ANNOTATION_ENTRY);
|
||||
public KtAnnotationEntry(@NotNull KotlinAnnotationEntryStub stub) {
|
||||
super(stub, KtStubElementTypes.ANNOTATION_ENTRY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitAnnotationEntry(this, data);
|
||||
}
|
||||
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public JetTypeReference getTypeReference() {
|
||||
JetConstructorCalleeExpression calleeExpression = getCalleeExpression();
|
||||
public KtTypeReference getTypeReference() {
|
||||
KtConstructorCalleeExpression calleeExpression = getCalleeExpression();
|
||||
if (calleeExpression == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -53,36 +53,36 @@ public class JetAnnotationEntry extends JetElementImplStub<KotlinAnnotationEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetConstructorCalleeExpression getCalleeExpression() {
|
||||
return getStubOrPsiChild(JetStubElementTypes.CONSTRUCTOR_CALLEE);
|
||||
public KtConstructorCalleeExpression getCalleeExpression() {
|
||||
return getStubOrPsiChild(KtStubElementTypes.CONSTRUCTOR_CALLEE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetValueArgumentList getValueArgumentList() {
|
||||
public KtValueArgumentList getValueArgumentList() {
|
||||
KotlinAnnotationEntryStub stub = getStub();
|
||||
if (stub != null && !stub.hasValueArguments()) {
|
||||
return null;
|
||||
}
|
||||
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
||||
return (KtValueArgumentList) findChildByType(KtNodeTypes.VALUE_ARGUMENT_LIST);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends ValueArgument> getValueArguments() {
|
||||
JetValueArgumentList list = getValueArgumentList();
|
||||
return list != null ? list.getArguments() : Collections.<JetValueArgument>emptyList();
|
||||
KtValueArgumentList list = getValueArgumentList();
|
||||
return list != null ? list.getArguments() : Collections.<KtValueArgument>emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetFunctionLiteralArgument> getFunctionLiteralArguments() {
|
||||
public List<KtFunctionLiteralArgument> getFunctionLiteralArguments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetTypeProjection> getTypeArguments() {
|
||||
JetTypeArgumentList typeArgumentList = getTypeArgumentList();
|
||||
public List<KtTypeProjection> getTypeArguments() {
|
||||
KtTypeArgumentList typeArgumentList = getTypeArgumentList();
|
||||
if (typeArgumentList == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -90,14 +90,14 @@ public class JetAnnotationEntry extends JetElementImplStub<KotlinAnnotationEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeArgumentList getTypeArgumentList() {
|
||||
JetTypeReference typeReference = getTypeReference();
|
||||
public KtTypeArgumentList getTypeArgumentList() {
|
||||
KtTypeReference typeReference = getTypeReference();
|
||||
if (typeReference == null) {
|
||||
return null;
|
||||
}
|
||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||
if (typeElement instanceof JetUserType) {
|
||||
JetUserType userType = (JetUserType) typeElement;
|
||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||
if (typeElement instanceof KtUserType) {
|
||||
KtUserType userType = (KtUserType) typeElement;
|
||||
return userType.getTypeArgumentList();
|
||||
}
|
||||
return null;
|
||||
@@ -105,17 +105,17 @@ public class JetAnnotationEntry extends JetElementImplStub<KotlinAnnotationEntry
|
||||
|
||||
@Nullable
|
||||
public PsiElement getAtSymbol() {
|
||||
return findChildByType(JetTokens.AT);
|
||||
return findChildByType(KtTokens.AT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetAnnotationUseSiteTarget getUseSiteTarget() {
|
||||
JetAnnotationUseSiteTarget target = getStubOrPsiChild(JetStubElementTypes.ANNOTATION_TARGET);
|
||||
public KtAnnotationUseSiteTarget getUseSiteTarget() {
|
||||
KtAnnotationUseSiteTarget target = getStubOrPsiChild(KtStubElementTypes.ANNOTATION_TARGET);
|
||||
|
||||
if (target == null) {
|
||||
PsiElement parent = getParentByStub();
|
||||
if (parent instanceof JetAnnotation) {
|
||||
return ((JetAnnotation) parent).getUseSiteTarget();
|
||||
if (parent instanceof KtAnnotation) {
|
||||
return ((KtAnnotation) parent).getUseSiteTarget();
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -19,20 +19,20 @@ package org.jetbrains.kotlin.psi
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.impl.source.tree.TreeElement
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.lexer.JetKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationEntryStub
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinAnnotationUseSiteTargetStub
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
|
||||
public class JetAnnotationUseSiteTarget : JetElementImplStub<KotlinAnnotationUseSiteTargetStub> {
|
||||
public class KtAnnotationUseSiteTarget : KtElementImplStub<KotlinAnnotationUseSiteTargetStub> {
|
||||
|
||||
constructor(node: ASTNode) : super(node)
|
||||
|
||||
constructor(stub: KotlinAnnotationUseSiteTargetStub) : super(stub, JetStubElementTypes.ANNOTATION_TARGET)
|
||||
constructor(stub: KotlinAnnotationUseSiteTargetStub) : super(stub, KtStubElementTypes.ANNOTATION_TARGET)
|
||||
|
||||
override fun <R, D> accept(visitor: JetVisitor<R, D>, data: D) = visitor.visitAnnotationUseSiteTarget(this, data)
|
||||
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D) = visitor.visitAnnotationUseSiteTarget(this, data)
|
||||
|
||||
public fun getAnnotationUseSiteTarget(): AnnotationUseSiteTarget {
|
||||
val targetString = stub?.getUseSiteTarget()
|
||||
@@ -46,14 +46,14 @@ public class JetAnnotationUseSiteTarget : JetElementImplStub<KotlinAnnotationUse
|
||||
|
||||
val node = getFirstChild().getNode()
|
||||
return when (node.getElementType()) {
|
||||
JetTokens.FIELD_KEYWORD -> AnnotationUseSiteTarget.FIELD
|
||||
JetTokens.FILE_KEYWORD -> AnnotationUseSiteTarget.FILE
|
||||
JetTokens.PROPERTY_KEYWORD -> AnnotationUseSiteTarget.PROPERTY
|
||||
JetTokens.GET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_GETTER
|
||||
JetTokens.SET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_SETTER
|
||||
JetTokens.RECEIVER_KEYWORD -> AnnotationUseSiteTarget.RECEIVER
|
||||
JetTokens.PARAM_KEYWORD -> AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
|
||||
JetTokens.SETPARAM_KEYWORD -> AnnotationUseSiteTarget.SETTER_PARAMETER
|
||||
KtTokens.FIELD_KEYWORD -> AnnotationUseSiteTarget.FIELD
|
||||
KtTokens.FILE_KEYWORD -> AnnotationUseSiteTarget.FILE
|
||||
KtTokens.PROPERTY_KEYWORD -> AnnotationUseSiteTarget.PROPERTY
|
||||
KtTokens.GET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_GETTER
|
||||
KtTokens.SET_KEYWORD -> AnnotationUseSiteTarget.PROPERTY_SETTER
|
||||
KtTokens.RECEIVER_KEYWORD -> AnnotationUseSiteTarget.RECEIVER
|
||||
KtTokens.PARAM_KEYWORD -> AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
|
||||
KtTokens.SETPARAM_KEYWORD -> AnnotationUseSiteTarget.SETTER_PARAMETER
|
||||
else -> throw IllegalStateException("Unknown annotation target " + node.getText())
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,5 +16,5 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi;
|
||||
|
||||
public interface JetAnnotationsContainer extends JetElement {
|
||||
public interface KtAnnotationsContainer extends KtElement {
|
||||
}
|
||||
+13
-13
@@ -23,35 +23,35 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class JetArrayAccessExpression extends JetExpressionImpl implements JetReferenceExpression {
|
||||
public JetArrayAccessExpression(@NotNull ASTNode node) {
|
||||
public class KtArrayAccessExpression extends KtExpressionImpl implements KtReferenceExpression {
|
||||
public KtArrayAccessExpression(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitArrayAccessExpression(this, data);
|
||||
}
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public JetExpression getArrayExpression() {
|
||||
return findChildByClass(JetExpression.class);
|
||||
public KtExpression getArrayExpression() {
|
||||
return findChildByClass(KtExpression.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JetExpression> getIndexExpressions() {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(getIndicesNode(), JetExpression.class);
|
||||
public List<KtExpression> getIndexExpressions() {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(getIndicesNode(), KtExpression.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetContainerNode getIndicesNode() {
|
||||
JetContainerNode indicesNode = findChildByType(JetNodeTypes.INDICES);
|
||||
public KtContainerNode getIndicesNode() {
|
||||
KtContainerNode indicesNode = findChildByType(KtNodeTypes.INDICES);
|
||||
assert indicesNode != null : "Can't be null because of parser";
|
||||
return indicesNode;
|
||||
}
|
||||
@@ -68,11 +68,11 @@ public class JetArrayAccessExpression extends JetExpressionImpl implements JetRe
|
||||
|
||||
@Nullable
|
||||
public PsiElement getLeftBracket() {
|
||||
return getIndicesNode().findChildByType(JetTokens.LBRACKET);
|
||||
return getIndicesNode().findChildByType(KtTokens.LBRACKET);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getRightBracket() {
|
||||
return getIndicesNode().findChildByType(JetTokens.RBRACKET);
|
||||
return getIndicesNode().findChildByType(KtTokens.RBRACKET);
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -21,25 +21,25 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
|
||||
public class JetBinaryExpression extends JetExpressionImpl implements JetOperationExpression {
|
||||
public JetBinaryExpression(@NotNull ASTNode node) {
|
||||
public class KtBinaryExpression extends KtExpressionImpl implements KtOperationExpression {
|
||||
public KtBinaryExpression(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitBinaryExpression(this, data);
|
||||
}
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public JetExpression getLeft() {
|
||||
public KtExpression getLeft() {
|
||||
ASTNode node = getOperationReference().getNode().getTreePrev();
|
||||
while (node != null) {
|
||||
PsiElement psi = node.getPsi();
|
||||
if (psi instanceof JetExpression) {
|
||||
return (JetExpression) psi;
|
||||
if (psi instanceof KtExpression) {
|
||||
return (KtExpression) psi;
|
||||
}
|
||||
node = node.getTreePrev();
|
||||
}
|
||||
@@ -48,12 +48,12 @@ public class JetBinaryExpression extends JetExpressionImpl implements JetOperati
|
||||
}
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public JetExpression getRight() {
|
||||
public KtExpression getRight() {
|
||||
ASTNode node = getOperationReference().getNode().getTreeNext();
|
||||
while (node != null) {
|
||||
PsiElement psi = node.getPsi();
|
||||
if (psi instanceof JetExpression) {
|
||||
return (JetExpression) psi;
|
||||
if (psi instanceof KtExpression) {
|
||||
return (KtExpression) psi;
|
||||
}
|
||||
node = node.getTreeNext();
|
||||
}
|
||||
@@ -63,8 +63,8 @@ public class JetBinaryExpression extends JetExpressionImpl implements JetOperati
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetSimpleNameExpression getOperationReference() {
|
||||
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
|
||||
public KtSimpleNameExpression getOperationReference() {
|
||||
return (KtSimpleNameExpression) findChildByType(KtNodeTypes.OPERATION_REFERENCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
+11
-11
@@ -20,32 +20,32 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.JetNodeTypes;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
|
||||
public class JetBinaryExpressionWithTypeRHS extends JetExpressionImpl implements JetOperationExpression {
|
||||
public JetBinaryExpressionWithTypeRHS(@NotNull ASTNode node) {
|
||||
public class KtBinaryExpressionWithTypeRHS extends KtExpressionImpl implements KtOperationExpression {
|
||||
public KtBinaryExpressionWithTypeRHS(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitBinaryWithTypeRHSExpression(this, data);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetExpression getLeft() {
|
||||
JetExpression left = findChildByClass(JetExpression.class);
|
||||
public KtExpression getLeft() {
|
||||
KtExpression left = findChildByClass(KtExpression.class);
|
||||
assert left != null;
|
||||
return left;
|
||||
}
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public JetTypeReference getRight() {
|
||||
public KtTypeReference getRight() {
|
||||
ASTNode node = getOperationReference().getNode();
|
||||
while (node != null) {
|
||||
PsiElement psi = node.getPsi();
|
||||
if (psi instanceof JetTypeReference) {
|
||||
return (JetTypeReference) psi;
|
||||
if (psi instanceof KtTypeReference) {
|
||||
return (KtTypeReference) psi;
|
||||
}
|
||||
node = node.getTreeNext();
|
||||
}
|
||||
@@ -55,8 +55,8 @@ public class JetBinaryExpressionWithTypeRHS extends JetExpressionImpl implements
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetSimpleNameExpression getOperationReference() {
|
||||
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
|
||||
public KtSimpleNameExpression getOperationReference() {
|
||||
return (KtSimpleNameExpression) findChildByType(KtNodeTypes.OPERATION_REFERENCE);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -18,16 +18,16 @@ package org.jetbrains.kotlin.psi
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.JetNodeTypes
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
|
||||
public class JetBlockCodeFragment(
|
||||
public class KtBlockCodeFragment(
|
||||
project: Project,
|
||||
name: String,
|
||||
text: CharSequence,
|
||||
imports: String?,
|
||||
context: PsiElement?
|
||||
) : JetCodeFragment(project, name, text, imports, JetNodeTypes.BLOCK_CODE_FRAGMENT, context) {
|
||||
) : KtCodeFragment(project, name, text, imports, KtNodeTypes.BLOCK_CODE_FRAGMENT, context) {
|
||||
|
||||
override fun getContentElement() = findChildByClass(javaClass<JetBlockExpression>())
|
||||
override fun getContentElement() = findChildByClass(javaClass<KtBlockExpression>())
|
||||
?: throw IllegalStateException("Block expression should be parsed for BlockCodeFragment")
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user