Cleanup: apply RemoveRedundantQualifierNameInspection to idea
This commit is contained in:
@@ -188,7 +188,7 @@ class FirExplorerToolWindow(private val project: Project, private val toolWindow
|
|||||||
|
|
||||||
override fun getChildren(): Array<SimpleNode> {
|
override fun getChildren(): Array<SimpleNode> {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return SimpleNode.NO_CHILDREN
|
return NO_CHILDREN
|
||||||
} else {
|
} else {
|
||||||
val classOfData = data::class
|
val classOfData = data::class
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ class FirExplorerToolWindow(private val project: Project, private val toolWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getChildren(): Array<SimpleNode> {
|
override fun getChildren(): Array<SimpleNode> {
|
||||||
if (data == null) return SimpleNode.NO_CHILDREN
|
if (data == null) return NO_CHILDREN
|
||||||
|
|
||||||
|
|
||||||
return data.mapIndexed { index, any ->
|
return data.mapIndexed { index, any ->
|
||||||
|
|||||||
@@ -16,31 +16,29 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings
|
|||||||
import com.intellij.psi.impl.source.tree.TreeUtil
|
import com.intellij.psi.impl.source.tree.TreeUtil
|
||||||
import com.intellij.psi.tree.IElementType
|
import com.intellij.psi.tree.IElementType
|
||||||
import com.intellij.psi.tree.TokenSet
|
import com.intellij.psi.tree.TokenSet
|
||||||
import org.jetbrains.kotlin.KtNodeTypes
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||||
import org.jetbrains.kotlin.idea.formatter.NodeIndentStrategy.Companion.strategy
|
import org.jetbrains.kotlin.idea.formatter.NodeIndentStrategy.Companion.strategy
|
||||||
import org.jetbrains.kotlin.idea.util.requireNode
|
import org.jetbrains.kotlin.idea.util.requireNode
|
||||||
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens
|
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens
|
||||||
import org.jetbrains.kotlin.kdoc.parser.KDocElementTypes
|
import org.jetbrains.kotlin.kdoc.parser.KDocElementTypes
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
|
|
||||||
private val QUALIFIED_OPERATION = TokenSet.create(DOT, SAFE_ACCESS)
|
private val QUALIFIED_OPERATION = TokenSet.create(DOT, SAFE_ACCESS)
|
||||||
private val QUALIFIED_EXPRESSIONS = TokenSet.create(KtNodeTypes.DOT_QUALIFIED_EXPRESSION, KtNodeTypes.SAFE_ACCESS_EXPRESSION)
|
private val QUALIFIED_EXPRESSIONS = TokenSet.create(DOT_QUALIFIED_EXPRESSION, SAFE_ACCESS_EXPRESSION)
|
||||||
private val ELVIS_SET = TokenSet.create(KtTokens.ELVIS)
|
private val ELVIS_SET = TokenSet.create(ELVIS)
|
||||||
|
|
||||||
private const val KDOC_COMMENT_INDENT = 1
|
private const val KDOC_COMMENT_INDENT = 1
|
||||||
|
|
||||||
private val BINARY_EXPRESSIONS = TokenSet.create(KtNodeTypes.BINARY_EXPRESSION, KtNodeTypes.BINARY_WITH_TYPE, KtNodeTypes.IS_EXPRESSION)
|
private val BINARY_EXPRESSIONS = TokenSet.create(BINARY_EXPRESSION, BINARY_WITH_TYPE, IS_EXPRESSION)
|
||||||
private val KDOC_CONTENT = TokenSet.create(KDocTokens.KDOC, KDocElementTypes.KDOC_SECTION, KDocElementTypes.KDOC_TAG)
|
private val KDOC_CONTENT = TokenSet.create(KDocTokens.KDOC, KDocElementTypes.KDOC_SECTION, KDocElementTypes.KDOC_TAG)
|
||||||
|
|
||||||
private val CODE_BLOCKS = TokenSet.create(KtNodeTypes.BLOCK, KtNodeTypes.CLASS_BODY, KtNodeTypes.FUNCTION_LITERAL)
|
private val CODE_BLOCKS = TokenSet.create(BLOCK, CLASS_BODY, FUNCTION_LITERAL)
|
||||||
|
|
||||||
private val ALIGN_FOR_BINARY_OPERATIONS = TokenSet.create(MUL, DIV, PERC, PLUS, MINUS, ELVIS, LT, GT, LTEQ, GTEQ, ANDAND, OROR)
|
private val ALIGN_FOR_BINARY_OPERATIONS = TokenSet.create(MUL, DIV, PERC, PLUS, MINUS, ELVIS, LT, GT, LTEQ, GTEQ, ANDAND, OROR)
|
||||||
private val ANNOTATIONS = TokenSet.create(KtNodeTypes.ANNOTATION_ENTRY, KtNodeTypes.ANNOTATION)
|
private val ANNOTATIONS = TokenSet.create(ANNOTATION_ENTRY, ANNOTATION)
|
||||||
|
|
||||||
typealias WrappingStrategy = (childElement: ASTNode) -> Wrap?
|
typealias WrappingStrategy = (childElement: ASTNode) -> Wrap?
|
||||||
|
|
||||||
@@ -112,7 +110,7 @@ abstract class KotlinCommonBlock(
|
|||||||
nodeSubBlocks = splitSubBlocksOnDot(nodeSubBlocks)
|
nodeSubBlocks = splitSubBlocksOnDot(nodeSubBlocks)
|
||||||
} else {
|
} else {
|
||||||
val psi = node.psi
|
val psi = node.psi
|
||||||
if (psi is KtBinaryExpression && psi.operationToken == KtTokens.ELVIS) {
|
if (psi is KtBinaryExpression && psi.operationToken == ELVIS) {
|
||||||
nodeSubBlocks = splitSubBlocksOnElvis(nodeSubBlocks)
|
nodeSubBlocks = splitSubBlocksOnElvis(nodeSubBlocks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +160,7 @@ abstract class KotlinCommonBlock(
|
|||||||
null, indent, wrap, spacingBuilder
|
null, indent, wrap, spacingBuilder
|
||||||
) {
|
) {
|
||||||
val parent = it.treeParent ?: node
|
val parent = it.treeParent ?: node
|
||||||
val skipOperationNodeParent = if (parent.elementType === KtNodeTypes.OPERATION_REFERENCE) {
|
val skipOperationNodeParent = if (parent.elementType === OPERATION_REFERENCE) {
|
||||||
parent.treeParent ?: parent
|
parent.treeParent ?: parent
|
||||||
} else {
|
} else {
|
||||||
parent
|
parent
|
||||||
@@ -187,16 +185,16 @@ abstract class KotlinCommonBlock(
|
|||||||
|
|
||||||
private fun isCallBlock(astBlock: ASTBlock): Boolean {
|
private fun isCallBlock(astBlock: ASTBlock): Boolean {
|
||||||
val node = astBlock.requireNode()
|
val node = astBlock.requireNode()
|
||||||
return node.elementType in QUALIFIED_EXPRESSIONS && node.lastChildNode?.elementType == KtNodeTypes.CALL_EXPRESSION
|
return node.elementType in QUALIFIED_EXPRESSIONS && node.lastChildNode?.elementType == CALL_EXPRESSION
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canWrapCallChain(node: ASTNode): Boolean {
|
private fun canWrapCallChain(node: ASTNode): Boolean {
|
||||||
val callChainParent = node.parents().firstOrNull { it.elementType !in QUALIFIED_EXPRESSIONS } ?: return true
|
val callChainParent = node.parents().firstOrNull { it.elementType !in QUALIFIED_EXPRESSIONS } ?: return true
|
||||||
return callChainParent.elementType in CODE_BLOCKS ||
|
return callChainParent.elementType in CODE_BLOCKS ||
|
||||||
callChainParent.elementType == KtNodeTypes.PROPERTY ||
|
callChainParent.elementType == PROPERTY ||
|
||||||
(callChainParent.elementType == KtNodeTypes.BINARY_EXPRESSION &&
|
(callChainParent.elementType == BINARY_EXPRESSION &&
|
||||||
(callChainParent.psi as KtBinaryExpression).operationToken in KtTokens.ALL_ASSIGNMENTS) ||
|
(callChainParent.psi as KtBinaryExpression).operationToken in ALL_ASSIGNMENTS) ||
|
||||||
callChainParent.elementType == KtNodeTypes.RETURN
|
callChainParent.elementType == RETURN
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun splitSubBlocksOnElvis(nodeSubBlocks: List<ASTBlock>): List<ASTBlock> {
|
private fun splitSubBlocksOnElvis(nodeSubBlocks: List<ASTBlock>): List<ASTBlock> {
|
||||||
@@ -244,7 +242,7 @@ abstract class KotlinCommonBlock(
|
|||||||
if (childParent != null) {
|
if (childParent != null) {
|
||||||
val parentType = childParent.elementType
|
val parentType = childParent.elementType
|
||||||
|
|
||||||
if (parentType === VALUE_PARAMETER_LIST || parentType === KtNodeTypes.VALUE_ARGUMENT_LIST) {
|
if (parentType === VALUE_PARAMETER_LIST || parentType === VALUE_ARGUMENT_LIST) {
|
||||||
val prev = getPrevWithoutWhitespace(child)
|
val prev = getPrevWithoutWhitespace(child)
|
||||||
if (childType === RPAR && (prev == null || prev.elementType !== TokenType.ERROR_ELEMENT)) {
|
if (childType === RPAR && (prev == null || prev.elementType !== TokenType.ERROR_ELEMENT)) {
|
||||||
return Indent.getNoneIndent()
|
return Indent.getNoneIndent()
|
||||||
@@ -256,7 +254,7 @@ abstract class KotlinCommonBlock(
|
|||||||
Indent.getNormalIndent()
|
Indent.getNormalIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentType === KtNodeTypes.TYPE_PARAMETER_LIST || parentType === KtNodeTypes.TYPE_ARGUMENT_LIST) {
|
if (parentType === TYPE_PARAMETER_LIST || parentType === TYPE_ARGUMENT_LIST) {
|
||||||
return Indent.getContinuationWithoutFirstIndent()
|
return Indent.getContinuationWithoutFirstIndent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,15 +265,15 @@ abstract class KotlinCommonBlock(
|
|||||||
private fun isInCodeChunk(node: ASTNode): Boolean {
|
private fun isInCodeChunk(node: ASTNode): Boolean {
|
||||||
val parent = node.treeParent ?: return false
|
val parent = node.treeParent ?: return false
|
||||||
|
|
||||||
if (node.elementType != KtNodeTypes.BLOCK) {
|
if (node.elementType != BLOCK) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val parentType = parent.elementType
|
val parentType = parent.elementType
|
||||||
return parentType == KtNodeTypes.SCRIPT
|
return parentType == SCRIPT
|
||||||
|| parentType == KtNodeTypes.BLOCK_CODE_FRAGMENT
|
|| parentType == BLOCK_CODE_FRAGMENT
|
||||||
|| parentType == KtNodeTypes.EXPRESSION_CODE_FRAGMENT
|
|| parentType == EXPRESSION_CODE_FRAGMENT
|
||||||
|| parentType == KtNodeTypes.TYPE_CODE_FRAGMENT
|
|| parentType == TYPE_CODE_FRAGMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getChildAttributes(newChildIndex: Int): ChildAttributes {
|
fun getChildAttributes(newChildIndex: Int): ChildAttributes {
|
||||||
@@ -287,14 +285,14 @@ abstract class KotlinCommonBlock(
|
|||||||
|
|
||||||
if (type == IF) {
|
if (type == IF) {
|
||||||
val elseBlock = mySubBlocks?.getOrNull(newChildIndex)
|
val elseBlock = mySubBlocks?.getOrNull(newChildIndex)
|
||||||
if (elseBlock != null && elseBlock.requireNode().elementType == KtTokens.ELSE_KEYWORD) {
|
if (elseBlock != null && elseBlock.requireNode().elementType == ELSE_KEYWORD) {
|
||||||
return ChildAttributes.DELEGATE_TO_NEXT_CHILD
|
return ChildAttributes.DELEGATE_TO_NEXT_CHILD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newChildIndex > 0) {
|
if (newChildIndex > 0) {
|
||||||
val prevBlock = mySubBlocks?.get(newChildIndex - 1)
|
val prevBlock = mySubBlocks?.get(newChildIndex - 1)
|
||||||
if (prevBlock?.node?.elementType == KtNodeTypes.MODIFIER_LIST) {
|
if (prevBlock?.node?.elementType == MODIFIER_LIST) {
|
||||||
return ChildAttributes(Indent.getNoneIndent(), null)
|
return ChildAttributes(Indent.getNoneIndent(), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,7 +307,7 @@ abstract class KotlinCommonBlock(
|
|||||||
|
|
||||||
in QUALIFIED_EXPRESSIONS -> ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null)
|
in QUALIFIED_EXPRESSIONS -> ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null)
|
||||||
|
|
||||||
VALUE_PARAMETER_LIST, KtNodeTypes.VALUE_ARGUMENT_LIST -> {
|
VALUE_PARAMETER_LIST, VALUE_ARGUMENT_LIST -> {
|
||||||
val subBlocks = getSubBlocks()
|
val subBlocks = getSubBlocks()
|
||||||
if (newChildIndex != 1 && newChildIndex != 0 && newChildIndex < subBlocks.size) {
|
if (newChildIndex != 1 && newChildIndex != 0 && newChildIndex < subBlocks.size) {
|
||||||
val block = subBlocks[newChildIndex]
|
val block = subBlocks[newChildIndex]
|
||||||
@@ -317,7 +315,7 @@ abstract class KotlinCommonBlock(
|
|||||||
} else {
|
} else {
|
||||||
val indent =
|
val indent =
|
||||||
if ((type == VALUE_PARAMETER_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) ||
|
if ((type == VALUE_PARAMETER_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) ||
|
||||||
(type == KtNodeTypes.VALUE_ARGUMENT_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_ARGUMENT_LISTS)
|
(type == VALUE_ARGUMENT_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_ARGUMENT_LISTS)
|
||||||
) {
|
) {
|
||||||
Indent.getNormalIndent()
|
Indent.getNormalIndent()
|
||||||
} else {
|
} else {
|
||||||
@@ -364,26 +362,26 @@ abstract class KotlinCommonBlock(
|
|||||||
return when {
|
return when {
|
||||||
parentType === VALUE_PARAMETER_LIST ->
|
parentType === VALUE_PARAMETER_LIST ->
|
||||||
getAlignmentForChildInParenthesis(
|
getAlignmentForChildInParenthesis(
|
||||||
kotlinCommonSettings.ALIGN_MULTILINE_PARAMETERS, KtNodeTypes.VALUE_PARAMETER, COMMA,
|
kotlinCommonSettings.ALIGN_MULTILINE_PARAMETERS, VALUE_PARAMETER, COMMA,
|
||||||
kotlinCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR
|
kotlinCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR
|
||||||
)
|
)
|
||||||
|
|
||||||
parentType === KtNodeTypes.VALUE_ARGUMENT_LIST ->
|
parentType === VALUE_ARGUMENT_LIST ->
|
||||||
getAlignmentForChildInParenthesis(
|
getAlignmentForChildInParenthesis(
|
||||||
kotlinCommonSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS, KtNodeTypes.VALUE_ARGUMENT, COMMA,
|
kotlinCommonSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS, VALUE_ARGUMENT, COMMA,
|
||||||
kotlinCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR
|
kotlinCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR
|
||||||
)
|
)
|
||||||
|
|
||||||
parentType === WHEN ->
|
parentType === WHEN ->
|
||||||
getAlignmentForCaseBranch(kotlinCustomSettings.ALIGN_IN_COLUMNS_CASE_BRANCH)
|
getAlignmentForCaseBranch(kotlinCustomSettings.ALIGN_IN_COLUMNS_CASE_BRANCH)
|
||||||
|
|
||||||
parentType === KtNodeTypes.WHEN_ENTRY ->
|
parentType === WHEN_ENTRY ->
|
||||||
alignmentStrategy
|
alignmentStrategy
|
||||||
|
|
||||||
parentType in BINARY_EXPRESSIONS && getOperationType(node) in ALIGN_FOR_BINARY_OPERATIONS ->
|
parentType in BINARY_EXPRESSIONS && getOperationType(node) in ALIGN_FOR_BINARY_OPERATIONS ->
|
||||||
createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment())
|
createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment())
|
||||||
|
|
||||||
parentType === KtNodeTypes.SUPER_TYPE_LIST ->
|
parentType === SUPER_TYPE_LIST ->
|
||||||
createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_EXTENDS_LIST, getAlignment())
|
createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_EXTENDS_LIST, getAlignment())
|
||||||
|
|
||||||
parentType === PARENTHESIZED ->
|
parentType === PARENTHESIZED ->
|
||||||
@@ -407,7 +405,7 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parentType == KtNodeTypes.TYPE_CONSTRAINT_LIST ->
|
parentType == TYPE_CONSTRAINT_LIST ->
|
||||||
createAlignmentStrategy(true, getAlignment())
|
createAlignmentStrategy(true, getAlignment())
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
@@ -425,7 +423,7 @@ abstract class KotlinCommonBlock(
|
|||||||
val childWrap = wrappingStrategy(child)
|
val childWrap = wrappingStrategy(child)
|
||||||
|
|
||||||
// Skip one sub-level for operators, so type of block node is an element type of operator
|
// Skip one sub-level for operators, so type of block node is an element type of operator
|
||||||
if (child.elementType === KtNodeTypes.OPERATION_REFERENCE) {
|
if (child.elementType === OPERATION_REFERENCE) {
|
||||||
val operationNode = child.firstChildNode
|
val operationNode = child.firstChildNode
|
||||||
if (operationNode != null) {
|
if (operationNode != null) {
|
||||||
return createBlock(
|
return createBlock(
|
||||||
@@ -449,7 +447,7 @@ abstract class KotlinCommonBlock(
|
|||||||
|
|
||||||
val childNodes = when {
|
val childNodes = when {
|
||||||
overrideChildren != null -> overrideChildren.asSequence()
|
overrideChildren != null -> overrideChildren.asSequence()
|
||||||
node.elementType == KtNodeTypes.BINARY_EXPRESSION -> {
|
node.elementType == BINARY_EXPRESSION -> {
|
||||||
val binaryExpression = node.psi as? KtBinaryExpression
|
val binaryExpression = node.psi as? KtBinaryExpression
|
||||||
if (binaryExpression != null && ALL_ASSIGNMENTS.contains(binaryExpression.operationToken)) {
|
if (binaryExpression != null && ALL_ASSIGNMENTS.contains(binaryExpression.operationToken)) {
|
||||||
node.children()
|
node.children()
|
||||||
@@ -473,14 +471,14 @@ abstract class KotlinCommonBlock(
|
|||||||
childrenAlignmentStrategy: CommonAlignmentStrategy,
|
childrenAlignmentStrategy: CommonAlignmentStrategy,
|
||||||
wrappingStrategy: WrappingStrategy
|
wrappingStrategy: WrappingStrategy
|
||||||
): Sequence<ASTBlock> {
|
): Sequence<ASTBlock> {
|
||||||
if (node.elementType == KtNodeTypes.FUN && false /* TODO fix tests and restore */) {
|
if (node.elementType == FUN && false /* TODO fix tests and restore */) {
|
||||||
val filteredChildren = node.children().filter {
|
val filteredChildren = node.children().filter {
|
||||||
it.textRange.length > 0 && it.elementType != TokenType.WHITE_SPACE
|
it.textRange.length > 0 && it.elementType != TokenType.WHITE_SPACE
|
||||||
}
|
}
|
||||||
val significantChildren = filteredChildren.dropWhile { it.elementType == KtTokens.EOL_COMMENT }
|
val significantChildren = filteredChildren.dropWhile { it.elementType == EOL_COMMENT }
|
||||||
val funIndent = extractIndent(significantChildren.first())
|
val funIndent = extractIndent(significantChildren.first())
|
||||||
val eolComments = filteredChildren.takeWhile {
|
val eolComments = filteredChildren.takeWhile {
|
||||||
it.elementType == KtTokens.EOL_COMMENT && extractIndent(it) != funIndent
|
it.elementType == EOL_COMMENT && extractIndent(it) != funIndent
|
||||||
}.toList()
|
}.toList()
|
||||||
val remainingChildren = filteredChildren.drop(eolComments.size)
|
val remainingChildren = filteredChildren.drop(eolComments.size)
|
||||||
|
|
||||||
@@ -495,7 +493,7 @@ abstract class KotlinCommonBlock(
|
|||||||
|
|
||||||
private fun collectBinaryExpressionChildren(node: ASTNode, result: MutableList<ASTNode>) {
|
private fun collectBinaryExpressionChildren(node: ASTNode, result: MutableList<ASTNode>) {
|
||||||
for (child in node.children()) {
|
for (child in node.children()) {
|
||||||
if (child.elementType == KtNodeTypes.BINARY_EXPRESSION) {
|
if (child.elementType == BINARY_EXPRESSION) {
|
||||||
collectBinaryExpressionChildren(child, result)
|
collectBinaryExpressionChildren(child, result)
|
||||||
} else {
|
} else {
|
||||||
result.add(child)
|
result.add(child)
|
||||||
@@ -510,23 +508,23 @@ abstract class KotlinCommonBlock(
|
|||||||
val nodePsi = node.psi
|
val nodePsi = node.psi
|
||||||
|
|
||||||
when {
|
when {
|
||||||
elementType === KtNodeTypes.VALUE_ARGUMENT_LIST -> {
|
elementType === VALUE_ARGUMENT_LIST -> {
|
||||||
val wrapSetting = commonSettings.CALL_PARAMETERS_WRAP
|
val wrapSetting = commonSettings.CALL_PARAMETERS_WRAP
|
||||||
if ((wrapSetting == CommonCodeStyleSettings.WRAP_AS_NEEDED || wrapSetting == CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM) &&
|
if ((wrapSetting == CommonCodeStyleSettings.WRAP_AS_NEEDED || wrapSetting == CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM) &&
|
||||||
!needWrapArgumentList(nodePsi)
|
!needWrapArgumentList(nodePsi)
|
||||||
) {
|
) {
|
||||||
return ::noWrapping
|
return ::noWrapping
|
||||||
}
|
}
|
||||||
return getWrappingStrategyForItemList(wrapSetting, KtNodeTypes.VALUE_ARGUMENT)
|
return getWrappingStrategyForItemList(wrapSetting, VALUE_ARGUMENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
elementType === VALUE_PARAMETER_LIST -> {
|
elementType === VALUE_PARAMETER_LIST -> {
|
||||||
if (parentElementType === KtNodeTypes.FUN ||
|
if (parentElementType === FUN ||
|
||||||
parentElementType === KtNodeTypes.PRIMARY_CONSTRUCTOR ||
|
parentElementType === PRIMARY_CONSTRUCTOR ||
|
||||||
parentElementType === KtNodeTypes.SECONDARY_CONSTRUCTOR) {
|
parentElementType === SECONDARY_CONSTRUCTOR) {
|
||||||
val wrap = Wrap.createWrap(commonSettings.METHOD_PARAMETERS_WRAP, false)
|
val wrap = Wrap.createWrap(commonSettings.METHOD_PARAMETERS_WRAP, false)
|
||||||
return { childElement ->
|
return { childElement ->
|
||||||
if (childElement.elementType === KtNodeTypes.VALUE_PARAMETER && !childElement.startsWithAnnotation())
|
if (childElement.elementType === VALUE_PARAMETER && !childElement.startsWithAnnotation())
|
||||||
wrap
|
wrap
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
@@ -534,15 +532,15 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elementType === KtNodeTypes.SUPER_TYPE_LIST -> {
|
elementType === SUPER_TYPE_LIST -> {
|
||||||
val wrap = Wrap.createWrap(commonSettings.EXTENDS_LIST_WRAP, false)
|
val wrap = Wrap.createWrap(commonSettings.EXTENDS_LIST_WRAP, false)
|
||||||
return { childElement -> if (childElement.psi is KtSuperTypeListEntry) wrap else null }
|
return { childElement -> if (childElement.psi is KtSuperTypeListEntry) wrap else null }
|
||||||
}
|
}
|
||||||
|
|
||||||
elementType === KtNodeTypes.CLASS_BODY ->
|
elementType === CLASS_BODY ->
|
||||||
return getWrappingStrategyForItemList(commonSettings.ENUM_CONSTANTS_WRAP, KtNodeTypes.ENUM_ENTRY)
|
return getWrappingStrategyForItemList(commonSettings.ENUM_CONSTANTS_WRAP, ENUM_ENTRY)
|
||||||
|
|
||||||
elementType === KtNodeTypes.MODIFIER_LIST -> {
|
elementType === MODIFIER_LIST -> {
|
||||||
val parent = node.treeParent.psi
|
val parent = node.treeParent.psi
|
||||||
when (parent) {
|
when (parent) {
|
||||||
is KtParameter ->
|
is KtParameter ->
|
||||||
@@ -574,7 +572,7 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elementType === KtNodeTypes.VALUE_PARAMETER ->
|
elementType === VALUE_PARAMETER ->
|
||||||
return wrapAfterAnnotation(commonSettings.PARAMETER_ANNOTATION_WRAP)
|
return wrapAfterAnnotation(commonSettings.PARAMETER_ANNOTATION_WRAP)
|
||||||
|
|
||||||
nodePsi is KtClassOrObject || nodePsi is KtTypeAlias ->
|
nodePsi is KtClassOrObject || nodePsi is KtTypeAlias ->
|
||||||
@@ -585,7 +583,7 @@ abstract class KotlinCommonBlock(
|
|||||||
getWrapAfterAnnotation(childElement, commonSettings.METHOD_ANNOTATION_WRAP)?.let {
|
getWrapAfterAnnotation(childElement, commonSettings.METHOD_ANNOTATION_WRAP)?.let {
|
||||||
return@wrap it
|
return@wrap it
|
||||||
}
|
}
|
||||||
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == KtTokens.EQ) {
|
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == EQ) {
|
||||||
return@wrap Wrap.createWrap(settings.kotlinCustomSettings.WRAP_EXPRESSION_BODY_FUNCTIONS, true)
|
return@wrap Wrap.createWrap(settings.kotlinCustomSettings.WRAP_EXPRESSION_BODY_FUNCTIONS, true)
|
||||||
}
|
}
|
||||||
null
|
null
|
||||||
@@ -598,25 +596,25 @@ abstract class KotlinCommonBlock(
|
|||||||
getWrapAfterAnnotation(childElement, wrapSetting)?.let {
|
getWrapAfterAnnotation(childElement, wrapSetting)?.let {
|
||||||
return@wrap it
|
return@wrap it
|
||||||
}
|
}
|
||||||
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == KtTokens.EQ) {
|
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == EQ) {
|
||||||
return@wrap Wrap.createWrap(settings.kotlinCommonSettings.ASSIGNMENT_WRAP, true)
|
return@wrap Wrap.createWrap(settings.kotlinCommonSettings.ASSIGNMENT_WRAP, true)
|
||||||
}
|
}
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
nodePsi is KtBinaryExpression -> {
|
nodePsi is KtBinaryExpression -> {
|
||||||
if (nodePsi.operationToken == KtTokens.EQ) {
|
if (nodePsi.operationToken == EQ) {
|
||||||
return { childElement ->
|
return { childElement ->
|
||||||
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == KtNodeTypes.OPERATION_REFERENCE) {
|
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == OPERATION_REFERENCE) {
|
||||||
Wrap.createWrap(settings.kotlinCommonSettings.ASSIGNMENT_WRAP, true)
|
Wrap.createWrap(settings.kotlinCommonSettings.ASSIGNMENT_WRAP, true)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nodePsi.operationToken == KtTokens.ELVIS) {
|
if (nodePsi.operationToken == ELVIS) {
|
||||||
return { childElement ->
|
return { childElement ->
|
||||||
if (childElement.elementType == KtNodeTypes.OPERATION_REFERENCE) {
|
if (childElement.elementType == OPERATION_REFERENCE) {
|
||||||
Wrap.createWrap(settings.kotlinCustomSettings.WRAP_ELVIS_EXPRESSIONS, true)
|
Wrap.createWrap(settings.kotlinCustomSettings.WRAP_ELVIS_EXPRESSIONS, true)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -631,9 +629,9 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ASTNode.startsWithAnnotation() = firstChildNode?.firstChildNode?.elementType == KtNodeTypes.ANNOTATION_ENTRY
|
private fun ASTNode.startsWithAnnotation() = firstChildNode?.firstChildNode?.elementType == ANNOTATION_ENTRY
|
||||||
|
|
||||||
private fun ASTNode.isFirstParameter(): Boolean = treePrev?.elementType == KtTokens.LPAR
|
private fun ASTNode.isFirstParameter(): Boolean = treePrev?.elementType == LPAR
|
||||||
|
|
||||||
private fun wrapAfterAnnotation(wrapType: Int): WrappingStrategy {
|
private fun wrapAfterAnnotation(wrapType: Int): WrappingStrategy {
|
||||||
return { childElement -> getWrapAfterAnnotation(childElement, wrapType) }
|
return { childElement -> getWrapAfterAnnotation(childElement, wrapType) }
|
||||||
@@ -645,7 +643,7 @@ private fun getWrapAfterAnnotation(childElement: ASTNode, wrapType: Int): Wrap?
|
|||||||
while (prevLeaf?.elementType == TokenType.WHITE_SPACE) {
|
while (prevLeaf?.elementType == TokenType.WHITE_SPACE) {
|
||||||
prevLeaf = prevLeaf.treePrev
|
prevLeaf = prevLeaf.treePrev
|
||||||
}
|
}
|
||||||
if (prevLeaf?.elementType == KtNodeTypes.MODIFIER_LIST) {
|
if (prevLeaf?.elementType == MODIFIER_LIST) {
|
||||||
if (prevLeaf?.lastChildNode?.elementType in ANNOTATIONS) {
|
if (prevLeaf?.lastChildNode?.elementType in ANNOTATIONS) {
|
||||||
return Wrap.createWrap(wrapType, true)
|
return Wrap.createWrap(wrapType, true)
|
||||||
}
|
}
|
||||||
@@ -682,34 +680,34 @@ fun NodeIndentStrategy.PositionStrategy.continuationIf(
|
|||||||
|
|
||||||
private val INDENT_RULES = arrayOf(
|
private val INDENT_RULES = arrayOf(
|
||||||
strategy("No indent for braces in blocks")
|
strategy("No indent for braces in blocks")
|
||||||
.within(KtNodeTypes.BLOCK, KtNodeTypes.CLASS_BODY, KtNodeTypes.FUNCTION_LITERAL)
|
.within(BLOCK, CLASS_BODY, FUNCTION_LITERAL)
|
||||||
.forType(RBRACE, LBRACE)
|
.forType(RBRACE, LBRACE)
|
||||||
.set(Indent.getNoneIndent()),
|
.set(Indent.getNoneIndent()),
|
||||||
|
|
||||||
strategy("Indent for block content")
|
strategy("Indent for block content")
|
||||||
.within(KtNodeTypes.BLOCK, KtNodeTypes.CLASS_BODY, KtNodeTypes.FUNCTION_LITERAL)
|
.within(BLOCK, CLASS_BODY, FUNCTION_LITERAL)
|
||||||
.notForType(RBRACE, LBRACE, KtNodeTypes.BLOCK)
|
.notForType(RBRACE, LBRACE, BLOCK)
|
||||||
.set(Indent.getNormalIndent(false)),
|
.set(Indent.getNormalIndent(false)),
|
||||||
|
|
||||||
strategy("Indent for property accessors")
|
strategy("Indent for property accessors")
|
||||||
.within(KtNodeTypes.PROPERTY).forType(KtNodeTypes.PROPERTY_ACCESSOR)
|
.within(PROPERTY).forType(PROPERTY_ACCESSOR)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("For a single statement in 'for'")
|
strategy("For a single statement in 'for'")
|
||||||
.within(KtNodeTypes.BODY).notForType(KtNodeTypes.BLOCK)
|
.within(BODY).notForType(BLOCK)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("For WHEN content")
|
strategy("For WHEN content")
|
||||||
.within(KtNodeTypes.WHEN)
|
.within(WHEN)
|
||||||
.notForType(RBRACE, LBRACE, WHEN_KEYWORD)
|
.notForType(RBRACE, LBRACE, WHEN_KEYWORD)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("For single statement in THEN and ELSE")
|
strategy("For single statement in THEN and ELSE")
|
||||||
.within(KtNodeTypes.THEN, KtNodeTypes.ELSE).notForType(KtNodeTypes.BLOCK)
|
.within(THEN, ELSE).notForType(BLOCK)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("Expression body")
|
strategy("Expression body")
|
||||||
.within(KtNodeTypes.FUN)
|
.within(FUN)
|
||||||
.forElement {
|
.forElement {
|
||||||
(it.psi is KtExpression && it.psi !is KtBlockExpression)
|
(it.psi is KtExpression && it.psi !is KtBlockExpression)
|
||||||
}
|
}
|
||||||
@@ -728,7 +726,7 @@ private val INDENT_RULES = arrayOf(
|
|||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES, indentFirst = true),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES, indentFirst = true),
|
||||||
|
|
||||||
strategy("If condition")
|
strategy("If condition")
|
||||||
.within(KtNodeTypes.CONDITION)
|
.within(CONDITION)
|
||||||
.set { settings ->
|
.set { settings ->
|
||||||
val indentType = if (settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_IF_CONDITIONS)
|
val indentType = if (settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_IF_CONDITIONS)
|
||||||
Indent.Type.CONTINUATION
|
Indent.Type.CONTINUATION
|
||||||
@@ -738,33 +736,33 @@ private val INDENT_RULES = arrayOf(
|
|||||||
},
|
},
|
||||||
|
|
||||||
strategy("Property accessor expression body")
|
strategy("Property accessor expression body")
|
||||||
.within(KtNodeTypes.PROPERTY_ACCESSOR)
|
.within(PROPERTY_ACCESSOR)
|
||||||
.forElement {
|
.forElement {
|
||||||
it.psi is KtExpression && it.psi !is KtBlockExpression
|
it.psi is KtExpression && it.psi !is KtBlockExpression
|
||||||
}
|
}
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("Property initializer")
|
strategy("Property initializer")
|
||||||
.within(KtNodeTypes.PROPERTY)
|
.within(PROPERTY)
|
||||||
.forElement {
|
.forElement {
|
||||||
it.psi is KtExpression
|
it.psi is KtExpression
|
||||||
}
|
}
|
||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES),
|
||||||
|
|
||||||
strategy("Destructuring declaration")
|
strategy("Destructuring declaration")
|
||||||
.within(KtNodeTypes.DESTRUCTURING_DECLARATION)
|
.within(DESTRUCTURING_DECLARATION)
|
||||||
.forElement {
|
.forElement {
|
||||||
it.psi is KtExpression
|
it.psi is KtExpression
|
||||||
}
|
}
|
||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES),
|
||||||
|
|
||||||
strategy("Assignment expressions")
|
strategy("Assignment expressions")
|
||||||
.within(KtNodeTypes.BINARY_EXPRESSION)
|
.within(BINARY_EXPRESSION)
|
||||||
.within {
|
.within {
|
||||||
val binaryExpression = it.psi as? KtBinaryExpression
|
val binaryExpression = it.psi as? KtBinaryExpression
|
||||||
?: return@within false
|
?: return@within false
|
||||||
|
|
||||||
return@within KtTokens.ALL_ASSIGNMENTS.contains(binaryExpression.operationToken)
|
return@within ALL_ASSIGNMENTS.contains(binaryExpression.operationToken)
|
||||||
}
|
}
|
||||||
.forElement {
|
.forElement {
|
||||||
val psi = it.psi
|
val psi = it.psi
|
||||||
@@ -774,31 +772,31 @@ private val INDENT_RULES = arrayOf(
|
|||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES),
|
||||||
|
|
||||||
strategy("Indent for parts")
|
strategy("Indent for parts")
|
||||||
.within(KtNodeTypes.PROPERTY, KtNodeTypes.FUN, KtNodeTypes.DESTRUCTURING_DECLARATION, KtNodeTypes.SECONDARY_CONSTRUCTOR)
|
.within(PROPERTY, FUN, DESTRUCTURING_DECLARATION, SECONDARY_CONSTRUCTOR)
|
||||||
.notForType(
|
.notForType(
|
||||||
KtNodeTypes.BLOCK, FUN_KEYWORD, VAL_KEYWORD, VAR_KEYWORD, CONSTRUCTOR_KEYWORD, KtTokens.RPAR,
|
BLOCK, FUN_KEYWORD, VAL_KEYWORD, VAR_KEYWORD, CONSTRUCTOR_KEYWORD, RPAR,
|
||||||
KtTokens.EOL_COMMENT
|
EOL_COMMENT
|
||||||
)
|
)
|
||||||
.set(Indent.getContinuationWithoutFirstIndent()),
|
.set(Indent.getContinuationWithoutFirstIndent()),
|
||||||
|
|
||||||
strategy("Chained calls")
|
strategy("Chained calls")
|
||||||
.within(QUALIFIED_EXPRESSIONS)
|
.within(QUALIFIED_EXPRESSIONS)
|
||||||
.notForType(KtTokens.DOT, KtTokens.SAFE_ACCESS)
|
.notForType(DOT, SAFE_ACCESS)
|
||||||
.forElement { it.treeParent.firstChildNode != it }
|
.forElement { it.treeParent.firstChildNode != it }
|
||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_CHAINED_CALLS),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_CHAINED_CALLS),
|
||||||
|
|
||||||
strategy("Colon of delegation list")
|
strategy("Colon of delegation list")
|
||||||
.within(KtNodeTypes.CLASS, KtNodeTypes.OBJECT_DECLARATION)
|
.within(CLASS, OBJECT_DECLARATION)
|
||||||
.forType(KtTokens.COLON)
|
.forType(COLON)
|
||||||
.set(Indent.getNormalIndent(false)),
|
.set(Indent.getNormalIndent(false)),
|
||||||
|
|
||||||
strategy("Delegation list")
|
strategy("Delegation list")
|
||||||
.within(KtNodeTypes.SUPER_TYPE_LIST)
|
.within(SUPER_TYPE_LIST)
|
||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_SUPERTYPE_LISTS, indentFirst = true),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_SUPERTYPE_LISTS, indentFirst = true),
|
||||||
|
|
||||||
strategy("Indices")
|
strategy("Indices")
|
||||||
.within(KtNodeTypes.INDICES)
|
.within(INDICES)
|
||||||
.notForType(KtTokens.RBRACKET)
|
.notForType(RBRACKET)
|
||||||
.set(Indent.getContinuationIndent(false)),
|
.set(Indent.getContinuationIndent(false)),
|
||||||
|
|
||||||
strategy("Binary expressions")
|
strategy("Binary expressions")
|
||||||
@@ -814,19 +812,19 @@ private val INDENT_RULES = arrayOf(
|
|||||||
|
|
||||||
strategy("Opening parenthesis for conditions")
|
strategy("Opening parenthesis for conditions")
|
||||||
.forType(LPAR)
|
.forType(LPAR)
|
||||||
.within(IF, KtNodeTypes.WHEN_ENTRY, WHILE, DO_WHILE)
|
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE)
|
||||||
.set(Indent.getContinuationWithoutFirstIndent(true)),
|
.set(Indent.getContinuationWithoutFirstIndent(true)),
|
||||||
|
|
||||||
strategy("Closing parenthesis for conditions")
|
strategy("Closing parenthesis for conditions")
|
||||||
.forType(RPAR)
|
.forType(RPAR)
|
||||||
.forElement { node -> !hasErrorElementBefore(node) }
|
.forElement { node -> !hasErrorElementBefore(node) }
|
||||||
.within(IF, KtNodeTypes.WHEN_ENTRY, WHILE, DO_WHILE)
|
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE)
|
||||||
.set(Indent.getNoneIndent()),
|
.set(Indent.getNoneIndent()),
|
||||||
|
|
||||||
strategy("Closing parenthesis for incomplete conditions")
|
strategy("Closing parenthesis for incomplete conditions")
|
||||||
.forType(RPAR)
|
.forType(RPAR)
|
||||||
.forElement { node -> hasErrorElementBefore(node) }
|
.forElement { node -> hasErrorElementBefore(node) }
|
||||||
.within(IF, KtNodeTypes.WHEN_ENTRY, WHILE, DO_WHILE)
|
.within(IF, WHEN_ENTRY, WHILE, DO_WHILE)
|
||||||
.set(Indent.getContinuationWithoutFirstIndent()),
|
.set(Indent.getContinuationWithoutFirstIndent()),
|
||||||
|
|
||||||
strategy("KDoc comment indent")
|
strategy("KDoc comment indent")
|
||||||
@@ -835,12 +833,12 @@ private val INDENT_RULES = arrayOf(
|
|||||||
.set(Indent.getSpaceIndent(KDOC_COMMENT_INDENT)),
|
.set(Indent.getSpaceIndent(KDOC_COMMENT_INDENT)),
|
||||||
|
|
||||||
strategy("Block in when entry")
|
strategy("Block in when entry")
|
||||||
.within(KtNodeTypes.WHEN_ENTRY)
|
.within(WHEN_ENTRY)
|
||||||
.notForType(
|
.notForType(
|
||||||
KtNodeTypes.BLOCK,
|
BLOCK,
|
||||||
KtNodeTypes.WHEN_CONDITION_EXPRESSION,
|
WHEN_CONDITION_EXPRESSION,
|
||||||
KtNodeTypes.WHEN_CONDITION_IN_RANGE,
|
WHEN_CONDITION_IN_RANGE,
|
||||||
KtNodeTypes.WHEN_CONDITION_IS_PATTERN,
|
WHEN_CONDITION_IS_PATTERN,
|
||||||
ELSE_KEYWORD,
|
ELSE_KEYWORD,
|
||||||
ARROW
|
ARROW
|
||||||
)
|
)
|
||||||
@@ -848,36 +846,36 @@ private val INDENT_RULES = arrayOf(
|
|||||||
|
|
||||||
strategy("Parameter list")
|
strategy("Parameter list")
|
||||||
.within(VALUE_PARAMETER_LIST)
|
.within(VALUE_PARAMETER_LIST)
|
||||||
.forElement { it.elementType == KtNodeTypes.VALUE_PARAMETER && it.psi.prevSibling != null }
|
.forElement { it.elementType == VALUE_PARAMETER && it.psi.prevSibling != null }
|
||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_PARAMETER_LISTS, indentFirst = true),
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_PARAMETER_LISTS, indentFirst = true),
|
||||||
|
|
||||||
strategy("Where clause")
|
strategy("Where clause")
|
||||||
.within(KtNodeTypes.CLASS, KtNodeTypes.FUN, KtNodeTypes.PROPERTY)
|
.within(CLASS, FUN, PROPERTY)
|
||||||
.forType(KtTokens.WHERE_KEYWORD)
|
.forType(WHERE_KEYWORD)
|
||||||
.set(Indent.getContinuationIndent()),
|
.set(Indent.getContinuationIndent()),
|
||||||
|
|
||||||
strategy("Array literals")
|
strategy("Array literals")
|
||||||
.within(KtNodeTypes.COLLECTION_LITERAL_EXPRESSION)
|
.within(COLLECTION_LITERAL_EXPRESSION)
|
||||||
.notForType(LBRACKET, RBRACKET)
|
.notForType(LBRACKET, RBRACKET)
|
||||||
.set(Indent.getNormalIndent()),
|
.set(Indent.getNormalIndent()),
|
||||||
|
|
||||||
strategy("Type aliases")
|
strategy("Type aliases")
|
||||||
.within(KtNodeTypes.TYPEALIAS)
|
.within(TYPEALIAS)
|
||||||
.notForType(
|
.notForType(
|
||||||
KtTokens.TYPE_ALIAS_KEYWORD, KtTokens.EOL_COMMENT, KtNodeTypes.MODIFIER_LIST, KtTokens.BLOCK_COMMENT,
|
TYPE_ALIAS_KEYWORD, EOL_COMMENT, MODIFIER_LIST, BLOCK_COMMENT,
|
||||||
KtTokens.DOC_COMMENT
|
DOC_COMMENT
|
||||||
)
|
)
|
||||||
.set(Indent.getContinuationIndent()),
|
.set(Indent.getContinuationIndent()),
|
||||||
|
|
||||||
strategy("Default parameter values")
|
strategy("Default parameter values")
|
||||||
.within(KtNodeTypes.VALUE_PARAMETER)
|
.within(VALUE_PARAMETER)
|
||||||
.forElement { node -> node.psi != null && node.psi == (node.psi.parent as? KtParameter)?.defaultValue }
|
.forElement { node -> node.psi != null && node.psi == (node.psi.parent as? KtParameter)?.defaultValue }
|
||||||
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES, indentFirst = true)
|
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES, indentFirst = true)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
private fun getOperationType(node: ASTNode): IElementType? =
|
private fun getOperationType(node: ASTNode): IElementType? =
|
||||||
node.findChildByType(KtNodeTypes.OPERATION_REFERENCE)?.firstChildNode?.elementType
|
node.findChildByType(OPERATION_REFERENCE)?.firstChildNode?.elementType
|
||||||
|
|
||||||
fun hasErrorElementBefore(node: ASTNode): Boolean {
|
fun hasErrorElementBefore(node: ASTNode): Boolean {
|
||||||
val prevSibling = getPrevWithoutWhitespace(node) ?: return false
|
val prevSibling = getPrevWithoutWhitespace(node) ?: return false
|
||||||
@@ -895,7 +893,7 @@ private fun ASTNode.suppressBinaryExpressionIndent(): Boolean {
|
|||||||
while (psi.parent is KtBinaryExpression) {
|
while (psi.parent is KtBinaryExpression) {
|
||||||
psi = psi.parent as KtBinaryExpression
|
psi = psi.parent as KtBinaryExpression
|
||||||
}
|
}
|
||||||
return psi.parent?.node?.elementType == KtNodeTypes.CONDITION || psi.operationToken == KtTokens.ELVIS
|
return psi.parent?.node?.elementType == CONDITION || psi.operationToken == ELVIS
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAlignmentForChildInParenthesis(
|
private fun getAlignmentForChildInParenthesis(
|
||||||
@@ -949,7 +947,7 @@ private fun getWrappingStrategyForItemList(wrapType: Int, itemTypes: TokenSet, w
|
|||||||
val thisType = childElement.elementType
|
val thisType = childElement.elementType
|
||||||
val prevType = getPrevWithoutWhitespace(childElement)?.elementType
|
val prevType = getPrevWithoutWhitespace(childElement)?.elementType
|
||||||
if (thisType in itemTypes || prevType in itemTypes &&
|
if (thisType in itemTypes || prevType in itemTypes &&
|
||||||
thisType != KtTokens.EOL_COMMENT && prevType != KtTokens.EOL_COMMENT)
|
thisType != EOL_COMMENT && prevType != EOL_COMMENT)
|
||||||
itemWrap
|
itemWrap
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ object ProjectCodeStyleImporter {
|
|||||||
fun apply(project: Project, codeStyleStr: String?): Boolean {
|
fun apply(project: Project, codeStyleStr: String?): Boolean {
|
||||||
return when (codeStyleStr) {
|
return when (codeStyleStr) {
|
||||||
KotlinObsoleteCodeStyle.CODE_STYLE_SETTING -> {
|
KotlinObsoleteCodeStyle.CODE_STYLE_SETTING -> {
|
||||||
ProjectCodeStyleImporter.apply(project, KotlinObsoleteCodeStyle.INSTANCE)
|
apply(project, KotlinObsoleteCodeStyle.INSTANCE)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
KotlinStyleGuideCodeStyle.CODE_STYLE_SETTING -> {
|
KotlinStyleGuideCodeStyle.CODE_STYLE_SETTING -> {
|
||||||
ProjectCodeStyleImporter.apply(project, KotlinStyleGuideCodeStyle.INSTANCE)
|
apply(project, KotlinStyleGuideCodeStyle.INSTANCE)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.intellij.util.text.TextRangeUtil
|
|||||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||||
import org.jetbrains.kotlin.idea.formatter.KotlinSpacingBuilder.CustomSpacingBuilder
|
import org.jetbrains.kotlin.idea.formatter.KotlinSpacingBuilder.CustomSpacingBuilder
|
||||||
import org.jetbrains.kotlin.idea.util.requireNode
|
import org.jetbrains.kotlin.idea.util.requireNode
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
import org.jetbrains.kotlin.psi.psiUtil.isObjectLiteral
|
||||||
@@ -41,7 +40,7 @@ fun SpacingBuilder.afterInside(element: IElementType, tokenSet: TokenSet, spacin
|
|||||||
tokenSet.types.forEach { inType -> afterInside(element, inType).spacingFun() }
|
tokenSet.types.forEach { inType -> afterInside(element, inType).spacingFun() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SpacingBuilder.RuleBuilder.spacesNoLineBreak(spaces: Int): SpacingBuilder? =
|
fun RuleBuilder.spacesNoLineBreak(spaces: Int): SpacingBuilder? =
|
||||||
spacing(spaces, spaces, 0, false, 0)
|
spacing(spaces, spaces, 0, false, 0)
|
||||||
|
|
||||||
fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacingBuilderUtil): KotlinSpacingBuilder {
|
fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacingBuilderUtil): KotlinSpacingBuilder {
|
||||||
@@ -143,7 +142,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
|||||||
}
|
}
|
||||||
|
|
||||||
val parameterWithDocCommentRule = { _: ASTBlock, _: ASTBlock, right: ASTBlock ->
|
val parameterWithDocCommentRule = { _: ASTBlock, _: ASTBlock, right: ASTBlock ->
|
||||||
if (right.requireNode().firstChildNode.elementType == KtTokens.DOC_COMMENT) {
|
if (right.requireNode().firstChildNode.elementType == DOC_COMMENT) {
|
||||||
createSpacing(0, minLineFeeds = 1, keepLineBreaks = true, keepBlankLines = settings.KEEP_BLANK_LINES_IN_DECLARATIONS)
|
createSpacing(0, minLineFeeds = 1, keepLineBreaks = true, keepBlankLines = settings.KEEP_BLANK_LINES_IN_DECLARATIONS)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@@ -184,7 +183,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
|||||||
commonCodeStyleSettings.KEEP_LINE_BREAKS,
|
commonCodeStyleSettings.KEEP_LINE_BREAKS,
|
||||||
commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE
|
commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE
|
||||||
)
|
)
|
||||||
left.requireNode().elementType == KtTokens.COMMA -> // incomplete call being edited
|
left.requireNode().elementType == COMMA -> // incomplete call being edited
|
||||||
createSpacing(1)
|
createSpacing(1)
|
||||||
else ->
|
else ->
|
||||||
createSpacing(0)
|
createSpacing(0)
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ interface IdePlatformKindResolution {
|
|||||||
) {
|
) {
|
||||||
private val CACHED_RESOLUTION_SUPPORT by lazy {
|
private val CACHED_RESOLUTION_SUPPORT by lazy {
|
||||||
val allPlatformKinds = IdePlatformKind.ALL_KINDS
|
val allPlatformKinds = IdePlatformKind.ALL_KINDS
|
||||||
val groupedResolution = IdePlatformKindResolution.getInstances().groupBy { it.kind }.mapValues { it.value.single() }
|
val groupedResolution = getInstances().groupBy { it.kind }.mapValues { it.value.single() }
|
||||||
|
|
||||||
for (kind in allPlatformKinds) {
|
for (kind in allPlatformKinds) {
|
||||||
if (kind !in groupedResolution) {
|
if (kind !in groupedResolution) {
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ val Module.externalProjectId: String
|
|||||||
get() = facetSettings?.externalProjectId ?: ""
|
get() = facetSettings?.externalProjectId ?: ""
|
||||||
|
|
||||||
val Module.sourceType: SourceType?
|
val Module.sourceType: SourceType?
|
||||||
get() = facetSettings?.isTestModule?.let { isTest -> if (isTest) SourceType.TEST else PRODUCTION }
|
get() = facetSettings?.isTestModule?.let { isTest -> if (isTest) TEST else PRODUCTION }
|
||||||
|
|
||||||
val Module.isMPPModule: Boolean
|
val Module.isMPPModule: Boolean
|
||||||
get() = facetSettings?.isMPPModule ?: false
|
get() = facetSettings?.isMPPModule ?: false
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ class BuiltInDefinitionFile(
|
|||||||
|
|
||||||
val version = BuiltInsBinaryVersion.readFrom(stream)
|
val version = BuiltInsBinaryVersion.readFrom(stream)
|
||||||
if (!version.isCompatible()) {
|
if (!version.isCompatible()) {
|
||||||
return FileWithMetadata.Incompatible(version)
|
return Incompatible(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
val proto = ProtoBuf.PackageFragment.parseFrom(stream, BuiltInSerializerProtocol.extensionRegistry)
|
val proto = ProtoBuf.PackageFragment.parseFrom(stream, BuiltInSerializerProtocol.extensionRegistry)
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ internal class VariablesHighlightingVisitor(holder: AnnotationHolder, bindingCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitParameter(parameter: KtParameter) {
|
override fun visitParameter(parameter: KtParameter) {
|
||||||
val propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter)
|
val propertyDescriptor = bindingContext.get(PRIMARY_CONSTRUCTOR_PARAMETER, parameter)
|
||||||
if (propertyDescriptor == null) {
|
if (propertyDescriptor == null) {
|
||||||
visitVariableDeclaration(parameter)
|
visitVariableDeclaration(parameter)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ import kotlin.reflect.KClass
|
|||||||
// thus making the original purpose useless.
|
// thus making the original purpose useless.
|
||||||
// The class still can be used, if you want to create a pair for existing intention with additional checker
|
// The class still can be used, if you want to create a pair for existing intention with additional checker
|
||||||
abstract class IntentionBasedInspection<TElement : PsiElement> private constructor(
|
abstract class IntentionBasedInspection<TElement : PsiElement> private constructor(
|
||||||
private val intentionInfo: IntentionBasedInspection.IntentionData<TElement>,
|
private val intentionInfo: IntentionData<TElement>,
|
||||||
protected open val problemText: String?
|
protected open val problemText: String?
|
||||||
) : AbstractKotlinInspection() {
|
) : AbstractKotlinInspection() {
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.intellij.psi.util.CachedValueProvider
|
|||||||
import com.intellij.psi.util.CachedValuesManager
|
import com.intellij.psi.util.CachedValuesManager
|
||||||
import com.intellij.psi.util.PsiModificationTracker
|
import com.intellij.psi.util.PsiModificationTracker
|
||||||
import com.intellij.util.containers.ContainerUtil
|
import com.intellij.util.containers.ContainerUtil
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
|
||||||
import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider
|
import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider
|
||||||
import org.jetbrains.kotlin.container.get
|
import org.jetbrains.kotlin.container.get
|
||||||
import org.jetbrains.kotlin.context.SimpleGlobalContext
|
import org.jetbrains.kotlin.context.SimpleGlobalContext
|
||||||
@@ -34,6 +33,7 @@ import org.jetbrains.kotlin.frontend.di.createContainerForBodyResolve
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.CodeFragmentAnalyzer
|
import org.jetbrains.kotlin.idea.caches.resolve.CodeFragmentAnalyzer
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.util.analyzeControlFlow
|
import org.jetbrains.kotlin.idea.caches.resolve.util.analyzeControlFlow
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
@@ -74,7 +74,7 @@ class ResolveElementCache(
|
|||||||
// drop whole cache after change "out of code block", each entry is checked with own modification stamp
|
// drop whole cache after change "out of code block", each entry is checked with own modification stamp
|
||||||
private val fullResolveCache: CachedValue<MutableMap<KtElement, CachedFullResolve>> =
|
private val fullResolveCache: CachedValue<MutableMap<KtElement, CachedFullResolve>> =
|
||||||
CachedValuesManager.getManager(project).createCachedValue(
|
CachedValuesManager.getManager(project).createCachedValue(
|
||||||
CachedValueProvider<MutableMap<KtElement, ResolveElementCache.CachedFullResolve>> {
|
CachedValueProvider<MutableMap<KtElement, CachedFullResolve>> {
|
||||||
CachedValueProvider.Result.create(
|
CachedValueProvider.Result.create(
|
||||||
ContainerUtil.createConcurrentWeakKeySoftValueMap<KtElement, CachedFullResolve>(),
|
ContainerUtil.createConcurrentWeakKeySoftValueMap<KtElement, CachedFullResolve>(),
|
||||||
PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT,
|
PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT,
|
||||||
@@ -100,7 +100,7 @@ class ResolveElementCache(
|
|||||||
|
|
||||||
private val partialBodyResolveCache: CachedValue<MutableMap<KtExpression, CachedPartialResolve>> =
|
private val partialBodyResolveCache: CachedValue<MutableMap<KtExpression, CachedPartialResolve>> =
|
||||||
CachedValuesManager.getManager(project).createCachedValue(
|
CachedValuesManager.getManager(project).createCachedValue(
|
||||||
CachedValueProvider<MutableMap<KtExpression, ResolveElementCache.CachedPartialResolve>> {
|
CachedValueProvider<MutableMap<KtExpression, CachedPartialResolve>> {
|
||||||
CachedValueProvider.Result.create(
|
CachedValueProvider.Result.create(
|
||||||
ContainerUtil.createConcurrentWeakKeySoftValueMap<KtExpression, CachedPartialResolve>(),
|
ContainerUtil.createConcurrentWeakKeySoftValueMap<KtExpression, CachedPartialResolve>(),
|
||||||
PsiModificationTracker.MODIFICATION_COUNT,
|
PsiModificationTracker.MODIFICATION_COUNT,
|
||||||
|
|||||||
+10
-10
@@ -36,9 +36,9 @@ class KotlinReadWriteAccessDetector : ReadWriteAccessDetector() {
|
|||||||
|
|
||||||
override fun isDeclarationWriteAccess(element: PsiElement) = isReadWriteAccessible(element)
|
override fun isDeclarationWriteAccess(element: PsiElement) = isReadWriteAccessible(element)
|
||||||
|
|
||||||
override fun getReferenceAccess(referencedElement: PsiElement, reference: PsiReference): ReadWriteAccessDetector.Access {
|
override fun getReferenceAccess(referencedElement: PsiElement, reference: PsiReference): Access {
|
||||||
if (!isReadWriteAccessible(referencedElement)) {
|
if (!isReadWriteAccessible(referencedElement)) {
|
||||||
return ReadWriteAccessDetector.Access.Read
|
return Access.Read
|
||||||
}
|
}
|
||||||
|
|
||||||
val refTarget = reference.resolve()
|
val refTarget = reference.resolve()
|
||||||
@@ -48,27 +48,27 @@ class KotlinReadWriteAccessDetector : ReadWriteAccessDetector() {
|
|||||||
is KtPropertyAccessor -> origin.getNonStrictParentOfType<KtProperty>()
|
is KtPropertyAccessor -> origin.getNonStrictParentOfType<KtProperty>()
|
||||||
is KtProperty, is KtParameter -> origin as KtNamedDeclaration
|
is KtProperty, is KtParameter -> origin as KtNamedDeclaration
|
||||||
else -> null
|
else -> null
|
||||||
} ?: return ReadWriteAccessDetector.Access.ReadWrite
|
} ?: return Access.ReadWrite
|
||||||
|
|
||||||
return when (refTarget.name) {
|
return when (refTarget.name) {
|
||||||
JvmAbi.getterName(declaration.name!!) -> return ReadWriteAccessDetector.Access.Read
|
JvmAbi.getterName(declaration.name!!) -> return Access.Read
|
||||||
JvmAbi.setterName(declaration.name!!) -> return ReadWriteAccessDetector.Access.Write
|
JvmAbi.setterName(declaration.name!!) -> return Access.Write
|
||||||
else -> ReadWriteAccessDetector.Access.ReadWrite
|
else -> Access.ReadWrite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getExpressionAccess(reference.element)
|
return getExpressionAccess(reference.element)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExpressionAccess(expression: PsiElement): ReadWriteAccessDetector.Access {
|
override fun getExpressionAccess(expression: PsiElement): Access {
|
||||||
if (expression !is KtExpression) { //TODO: there should be a more correct scheme of access type detection for cross-language references
|
if (expression !is KtExpression) { //TODO: there should be a more correct scheme of access type detection for cross-language references
|
||||||
return JavaReadWriteAccessDetector().getExpressionAccess(expression)
|
return JavaReadWriteAccessDetector().getExpressionAccess(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (expression.readWriteAccess(useResolveForReadWrite = true)) {
|
return when (expression.readWriteAccess(useResolveForReadWrite = true)) {
|
||||||
ReferenceAccess.READ -> ReadWriteAccessDetector.Access.Read
|
ReferenceAccess.READ -> Access.Read
|
||||||
ReferenceAccess.WRITE -> ReadWriteAccessDetector.Access.Write
|
ReferenceAccess.WRITE -> Access.Write
|
||||||
ReferenceAccess.READ_WRITE -> ReadWriteAccessDetector.Access.ReadWrite
|
ReferenceAccess.READ_WRITE -> Access.ReadWrite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -124,10 +124,10 @@ class ExpressionsOfTypeProcessor(
|
|||||||
private val scopesToUsePlainSearch = LinkedHashMap<KtFile, ArrayList<PsiElement>>()
|
private val scopesToUsePlainSearch = LinkedHashMap<KtFile, ArrayList<PsiElement>>()
|
||||||
|
|
||||||
fun run() {
|
fun run() {
|
||||||
val usePlainSearch = when (ExpressionsOfTypeProcessor.mode) {
|
val usePlainSearch = when (mode) {
|
||||||
ExpressionsOfTypeProcessor.Mode.ALWAYS_SMART -> false
|
Mode.ALWAYS_SMART -> false
|
||||||
ExpressionsOfTypeProcessor.Mode.ALWAYS_PLAIN -> true
|
Mode.ALWAYS_PLAIN -> true
|
||||||
ExpressionsOfTypeProcessor.Mode.PLAIN_WHEN_NEEDED -> searchScope is LocalSearchScope // for local scope it's faster to use plain search
|
Mode.PLAIN_WHEN_NEEDED -> searchScope is LocalSearchScope // for local scope it's faster to use plain search
|
||||||
}
|
}
|
||||||
if (usePlainSearch || classToSearch == null) {
|
if (usePlainSearch || classToSearch == null) {
|
||||||
possibleMatchesInScopeHandler(searchScope)
|
possibleMatchesInScopeHandler(searchScope)
|
||||||
|
|||||||
+3
-3
@@ -38,7 +38,7 @@ class KotlinCompletionCharFilter() : CharFilter() {
|
|||||||
val isAutopopup = CompletionService.getCompletionService().currentCompletion?.isAutopopupCompletion ?: return null
|
val isAutopopup = CompletionService.getCompletionService().currentCompletion?.isAutopopupCompletion ?: return null
|
||||||
|
|
||||||
if (Character.isJavaIdentifierPart(c) || c == '@') {
|
if (Character.isJavaIdentifierPart(c) || c == '@') {
|
||||||
return CharFilter.Result.ADD_TO_PREFIX
|
return Result.ADD_TO_PREFIX
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentItem = lookup.currentItem
|
val currentItem = lookup.currentItem
|
||||||
@@ -51,7 +51,7 @@ class KotlinCompletionCharFilter() : CharFilter() {
|
|||||||
if (c == ':') {
|
if (c == ':') {
|
||||||
return when {
|
return when {
|
||||||
currentItem?.getUserData(HIDE_LOOKUP_ON_COLON) != null -> Result.HIDE_LOOKUP
|
currentItem?.getUserData(HIDE_LOOKUP_ON_COLON) != null -> Result.HIDE_LOOKUP
|
||||||
else -> CharFilter.Result.ADD_TO_PREFIX /* used in '::xxx'*/
|
else -> Result.ADD_TO_PREFIX /* used in '::xxx'*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class KotlinCompletionCharFilter() : CharFilter() {
|
|||||||
|
|
||||||
',', ' ', '(', '=', '!' -> Result.SELECT_ITEM_AND_FINISH_LOOKUP
|
',', ' ', '(', '=', '!' -> Result.SELECT_ITEM_AND_FINISH_LOOKUP
|
||||||
|
|
||||||
else -> CharFilter.Result.HIDE_LOOKUP
|
else -> Result.HIDE_LOOKUP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-7
@@ -15,19 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.kotlin.idea.completion
|
package org.jetbrains.kotlin.idea.completion
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.ExcludeFromCompletionLookupActionProvider
|
|
||||||
import com.intellij.codeInsight.daemon.impl.actions.AddImportAction
|
import com.intellij.codeInsight.daemon.impl.actions.AddImportAction
|
||||||
import com.intellij.codeInsight.lookup.Lookup
|
import com.intellij.codeInsight.lookup.Lookup
|
||||||
import com.intellij.codeInsight.lookup.LookupActionProvider
|
import com.intellij.codeInsight.lookup.LookupActionProvider
|
||||||
import com.intellij.codeInsight.lookup.LookupElement
|
import com.intellij.codeInsight.lookup.LookupElement
|
||||||
import com.intellij.codeInsight.lookup.LookupElementAction
|
import com.intellij.codeInsight.lookup.LookupElementAction
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.*
|
|
||||||
import com.intellij.psi.util.PsiUtil
|
|
||||||
import com.intellij.util.Consumer
|
import com.intellij.util.Consumer
|
||||||
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
||||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
|
|
||||||
class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider {
|
class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider {
|
||||||
override fun fillActions(element: LookupElement, lookup: Lookup, consumer: Consumer<LookupElementAction>) {
|
override fun fillActions(element: LookupElement, lookup: Lookup, consumer: Consumer<LookupElementAction>) {
|
||||||
@@ -51,9 +46,9 @@ class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider {
|
|||||||
private val project: Project,
|
private val project: Project,
|
||||||
private val exclude: String
|
private val exclude: String
|
||||||
) : LookupElementAction(null, "Exclude '$exclude' from completion") {
|
) : LookupElementAction(null, "Exclude '$exclude' from completion") {
|
||||||
override fun performLookupAction(): LookupElementAction.Result {
|
override fun performLookupAction(): Result {
|
||||||
AddImportAction.excludeFromImport(project, exclude)
|
AddImportAction.excludeFromImport(project, exclude)
|
||||||
return LookupElementAction.Result.HIDE_LOOKUP
|
return Result.HIDE_LOOKUP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -33,7 +33,6 @@ import org.jetbrains.kotlin.resolve.DataClassDescriptorResolver
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart
|
|
||||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmartForCompiler
|
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmartForCompiler
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ class ReferenceVariantsCollector(
|
|||||||
else
|
else
|
||||||
ShadowedDeclarationsFilter.create(bindingContext, resolutionFacade, nameExpression, callTypeAndReceiver)
|
ShadowedDeclarationsFilter.create(bindingContext, resolutionFacade, nameExpression, callTypeAndReceiver)
|
||||||
|
|
||||||
return ReferenceVariantsCollector.FilterConfiguration(descriptorKindFilter, additionalPropertyNameFilter, shadowedDeclarationsFilter, completeExtensionsFromIndices)
|
return FilterConfiguration(descriptorKindFilter, additionalPropertyNameFilter, shadowedDeclarationsFilter, completeExtensionsFromIndices)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doCollectBasicVariants(filterConfiguration: FilterConfiguration): ReferenceVariants {
|
private fun doCollectBasicVariants(filterConfiguration: FilterConfiguration): ReferenceVariants {
|
||||||
|
|||||||
+2
-2
@@ -19,10 +19,10 @@ import org.jetbrains.kotlin.idea.completion.LookupElementFactory
|
|||||||
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
||||||
import org.jetbrains.kotlin.idea.test.AstAccessControl
|
import org.jetbrains.kotlin.idea.test.AstAccessControl
|
||||||
import org.jetbrains.kotlin.idea.util.module
|
import org.jetbrains.kotlin.idea.util.module
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||||
import org.jetbrains.kotlin.platform.js.isJs
|
import org.jetbrains.kotlin.platform.js.isJs
|
||||||
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
@@ -316,7 +316,7 @@ object ExpectedCompletionUtils {
|
|||||||
map.put(CompletionProposal.MODULE_NAME, it)
|
map.put(CompletionProposal.MODULE_NAME, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(ExpectedCompletionUtils.CompletionProposal(map))
|
result.add(CompletionProposal(map))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,15 +87,15 @@ class ExpectedInfo(
|
|||||||
val expectedName: String?,
|
val expectedName: String?,
|
||||||
val tail: Tail?,
|
val tail: Tail?,
|
||||||
val itemOptions: ItemOptions = ItemOptions.DEFAULT,
|
val itemOptions: ItemOptions = ItemOptions.DEFAULT,
|
||||||
val additionalData: ExpectedInfo.AdditionalData? = null
|
val additionalData: AdditionalData? = null
|
||||||
) {
|
) {
|
||||||
// just a marker interface
|
// just a marker interface
|
||||||
interface AdditionalData {}
|
interface AdditionalData {}
|
||||||
|
|
||||||
constructor(fuzzyType: FuzzyType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null)
|
constructor(fuzzyType: FuzzyType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: AdditionalData? = null)
|
||||||
: this(ByExpectedTypeFilter(fuzzyType), expectedName, tail, itemOptions, additionalData)
|
: this(ByExpectedTypeFilter(fuzzyType), expectedName, tail, itemOptions, additionalData)
|
||||||
|
|
||||||
constructor(type: KotlinType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null)
|
constructor(type: KotlinType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: AdditionalData? = null)
|
||||||
: this(type.toFuzzyType(emptyList()), expectedName, tail, itemOptions, additionalData)
|
: this(type.toFuzzyType(emptyList()), expectedName, tail, itemOptions, additionalData)
|
||||||
|
|
||||||
fun matchingSubstitutor(descriptorType: FuzzyType): TypeSubstitutor? = filter.matchingSubstitutor(descriptorType)
|
fun matchingSubstitutor(descriptorType: FuzzyType): TypeSubstitutor? = filter.matchingSubstitutor(descriptorType)
|
||||||
|
|||||||
@@ -63,12 +63,12 @@ class CollectingNameValidator @JvmOverloads constructor(
|
|||||||
class NewDeclarationNameValidator(
|
class NewDeclarationNameValidator(
|
||||||
private val visibleDeclarationsContext: KtElement?,
|
private val visibleDeclarationsContext: KtElement?,
|
||||||
private val checkDeclarationsIn: Sequence<PsiElement>,
|
private val checkDeclarationsIn: Sequence<PsiElement>,
|
||||||
private val target: NewDeclarationNameValidator.Target,
|
private val target: Target,
|
||||||
private val excludedDeclarations: List<KtDeclaration> = emptyList()
|
private val excludedDeclarations: List<KtDeclaration> = emptyList()
|
||||||
) : (String) -> Boolean {
|
) : (String) -> Boolean {
|
||||||
constructor(container: PsiElement,
|
constructor(container: PsiElement,
|
||||||
anchor: PsiElement?,
|
anchor: PsiElement?,
|
||||||
target: NewDeclarationNameValidator.Target,
|
target: Target,
|
||||||
excludedDeclarations: List<KtDeclaration> = emptyList())
|
excludedDeclarations: List<KtDeclaration> = emptyList())
|
||||||
: this(
|
: this(
|
||||||
(anchor ?: container).parentsWithSelf.firstIsInstanceOrNull<KtElement>(),
|
(anchor ?: container).parentsWithSelf.firstIsInstanceOrNull<KtElement>(),
|
||||||
|
|||||||
+1
-1
@@ -282,7 +282,7 @@ interface ScriptDefinitionContributor {
|
|||||||
ExtensionPointName.create<ScriptDefinitionContributor>("org.jetbrains.kotlin.scriptDefinitionContributor")
|
ExtensionPointName.create<ScriptDefinitionContributor>("org.jetbrains.kotlin.scriptDefinitionContributor")
|
||||||
|
|
||||||
inline fun <reified T> find(project: Project) =
|
inline fun <reified T> find(project: Project) =
|
||||||
Extensions.getArea(project).getExtensionPoint(ScriptDefinitionContributor.EP_NAME).extensions.filterIsInstance<T>().firstOrNull()
|
Extensions.getArea(project).getExtensionPoint(EP_NAME).extensions.filterIsInstance<T>().firstOrNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ class KotlinExplicitMovementProvider : GitCheckinExplicitMovementProvider() {
|
|||||||
project: Project,
|
project: Project,
|
||||||
beforePaths: List<FilePath>,
|
beforePaths: List<FilePath>,
|
||||||
afterPaths: List<FilePath>
|
afterPaths: List<FilePath>
|
||||||
): Collection<GitCheckinExplicitMovementProvider.Movement> {
|
): Collection<Movement> {
|
||||||
val movedChanges = ArrayList<GitCheckinExplicitMovementProvider.Movement>()
|
val movedChanges = ArrayList<Movement>()
|
||||||
for (after in afterPaths) {
|
for (after in afterPaths) {
|
||||||
val pathBeforeJ2K = after.virtualFile?.pathBeforeJ2K
|
val pathBeforeJ2K = after.virtualFile?.pathBeforeJ2K
|
||||||
if (pathBeforeJ2K != null) {
|
if (pathBeforeJ2K != null) {
|
||||||
val before = beforePaths.firstOrNull { it.path == pathBeforeJ2K }
|
val before = beforePaths.firstOrNull { it.path == pathBeforeJ2K }
|
||||||
if (before != null) {
|
if (before != null) {
|
||||||
movedChanges.add(GitCheckinExplicitMovementProvider.Movement(before, after))
|
movedChanges.add(Movement(before, after))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -288,7 +288,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
|||||||
libraryJarDescriptors: List<LibraryJarDescriptor>
|
libraryJarDescriptors: List<LibraryJarDescriptor>
|
||||||
) {
|
) {
|
||||||
val scope = OrderEntryFix.suggestScopeByLocation(module, element)
|
val scope = OrderEntryFix.suggestScopeByLocation(module, element)
|
||||||
KotlinWithGradleConfigurator.addKotlinLibraryToModule(module, scope, library)
|
addKotlinLibraryToModule(module, scope, library)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+7
-8
@@ -5,19 +5,18 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import com.intellij.openapi.roots.*
|
import com.intellij.openapi.roots.DependencyScope
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
|
||||||
import junit.framework.TestCase
|
|
||||||
import org.jetbrains.jps.model.java.JavaResourceRootType
|
import org.jetbrains.jps.model.java.JavaResourceRootType
|
||||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.ResourceKotlinRootType
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.gradle.ExternalSystemImportingTestCase
|
import org.jetbrains.kotlin.config.SourceKotlinRootType
|
||||||
|
import org.jetbrains.kotlin.config.TestResourceKotlinRootType
|
||||||
|
import org.jetbrains.kotlin.config.TestSourceKotlinRootType
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
|
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
|
||||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestRunConfigurationProducer
|
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -29,14 +28,14 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
|
|||||||
fun saveSdksBeforeTest() {
|
fun saveSdksBeforeTest() {
|
||||||
val kotlinSdks = sdkCreationChecker?.getKotlinSdks() ?: emptyList()
|
val kotlinSdks = sdkCreationChecker?.getKotlinSdks() ?: emptyList()
|
||||||
if (kotlinSdks.isNotEmpty()) {
|
if (kotlinSdks.isNotEmpty()) {
|
||||||
ExternalSystemImportingTestCase.fail("Found Kotlin SDK before importing test. Sdk list: $kotlinSdks")
|
fail("Found Kotlin SDK before importing test. Sdk list: $kotlinSdks")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
fun checkSdkCreated() {
|
fun checkSdkCreated() {
|
||||||
if (sdkCreationChecker?.isKotlinSdkCreated() == false) {
|
if (sdkCreationChecker?.isKotlinSdkCreated() == false) {
|
||||||
ExternalSystemImportingTestCase.fail("Kotlin SDK was not created during import of MPP Project.")
|
fail("Kotlin SDK was not created during import of MPP Project.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.copyBean
|
import org.jetbrains.kotlin.cli.common.arguments.copyBean
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||||
import org.jetbrains.kotlin.platform.IdePlatformKind
|
import org.jetbrains.kotlin.platform.IdePlatformKind
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
|
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
||||||
import org.jetbrains.kotlin.platform.compat.toIdePlatform
|
import org.jetbrains.kotlin.platform.compat.toIdePlatform
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
import org.jetbrains.kotlin.utils.DescriptionAware
|
import org.jetbrains.kotlin.utils.DescriptionAware
|
||||||
@@ -107,9 +107,9 @@ sealed class VersionView : DescriptionAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun deserialize(value: String?, isAutoAdvance: Boolean): VersionView {
|
fun deserialize(value: String?, isAutoAdvance: Boolean): VersionView {
|
||||||
if (isAutoAdvance) return VersionView.LatestStable
|
if (isAutoAdvance) return LatestStable
|
||||||
val languageVersion = LanguageVersion.fromVersionString(value)
|
val languageVersion = LanguageVersion.fromVersionString(value)
|
||||||
return if (languageVersion != null) VersionView.Specific(languageVersion) else VersionView.LatestStable
|
return if (languageVersion != null) Specific(languageVersion) else LatestStable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -19,7 +19,10 @@ import com.intellij.openapi.vfs.VfsUtilCore
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.annotations.Contract
|
import org.jetbrains.annotations.Contract
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CliArgumentStringBuilder.replaceLanguageFeature
|
import org.jetbrains.kotlin.cli.common.arguments.CliArgumentStringBuilder.replaceLanguageFeature
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.ApiVersion
|
||||||
|
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion
|
import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion
|
||||||
import org.jetbrains.kotlin.idea.facet.toApiVersion
|
import org.jetbrains.kotlin.idea.facet.toApiVersion
|
||||||
import org.jetbrains.kotlin.idea.framework.ui.CreateLibraryDialogWithModules
|
import org.jetbrains.kotlin.idea.framework.ui.CreateLibraryDialogWithModules
|
||||||
@@ -31,7 +34,6 @@ import org.jetbrains.kotlin.idea.versions.LibraryJarDescriptor
|
|||||||
import org.jetbrains.kotlin.idea.versions.findAllUsedLibraries
|
import org.jetbrains.kotlin.idea.versions.findAllUsedLibraries
|
||||||
import org.jetbrains.kotlin.idea.versions.findKotlinRuntimeLibrary
|
import org.jetbrains.kotlin.idea.versions.findKotlinRuntimeLibrary
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
abstract class KotlinWithLibraryConfigurator protected constructor() : KotlinProjectConfigurator {
|
abstract class KotlinWithLibraryConfigurator protected constructor() : KotlinProjectConfigurator {
|
||||||
protected abstract val libraryName: String
|
protected abstract val libraryName: String
|
||||||
@@ -176,12 +178,12 @@ abstract class KotlinWithLibraryConfigurator protected constructor() : KotlinPro
|
|||||||
libraryJarDescriptor: LibraryJarDescriptor,
|
libraryJarDescriptor: LibraryJarDescriptor,
|
||||||
collector: NotificationMessageCollector
|
collector: NotificationMessageCollector
|
||||||
) {
|
) {
|
||||||
val jarFile = if (jarState == KotlinWithLibraryConfigurator.FileState.DO_NOT_COPY)
|
val jarFile = if (jarState == FileState.DO_NOT_COPY)
|
||||||
libraryJarDescriptor.getPathInPlugin()
|
libraryJarDescriptor.getPathInPlugin()
|
||||||
else
|
else
|
||||||
File(dirToCopyJarTo, libraryJarDescriptor.jarName)
|
File(dirToCopyJarTo, libraryJarDescriptor.jarName)
|
||||||
|
|
||||||
if (jarState == KotlinWithLibraryConfigurator.FileState.COPY) {
|
if (jarState == FileState.COPY) {
|
||||||
copyFileToDir(libraryJarDescriptor.getPathInPlugin(), dirToCopyJarTo, collector)
|
copyFileToDir(libraryJarDescriptor.getPathInPlugin(), dirToCopyJarTo, collector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class JavaFrameworkType : FrameworkTypeEx("kotlin-java-framework-id") {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val instance: JavaFrameworkType
|
val instance: JavaFrameworkType
|
||||||
get() = FrameworkTypeEx.EP_NAME.findExtension(JavaFrameworkType::class.java)
|
get() = EP_NAME.findExtension(JavaFrameworkType::class.java)
|
||||||
?: error("can't find extension 'JavaFrameworkType'")
|
?: error("can't find extension 'JavaFrameworkType'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ class KotlinLanguageInjector(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (injection in configuration.getInjections(org.jetbrains.kotlin.idea.injection.KOTLIN_SUPPORT_ID)) {
|
for (injection in configuration.getInjections(KOTLIN_SUPPORT_ID)) {
|
||||||
for (injectionPlace in injection.injectionPlaces) {
|
for (injectionPlace in injection.injectionPlaces) {
|
||||||
for (targetClassFQN in retrieveKotlinPlaceTargetClassesFQNs(injectionPlace)) {
|
for (targetClassFQN in retrieveKotlinPlaceTargetClassesFQNs(injectionPlace)) {
|
||||||
add(StringUtilRt.getShortName(targetClassFQN))
|
add(StringUtilRt.getShortName(targetClassFQN))
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ object CommonIdePlatformKindTooling : IdePlatformKindTooling() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getTestIcon(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor): Icon? {
|
override fun getTestIcon(declaration: KtNamedDeclaration, descriptor: DeclarationDescriptor): Icon? {
|
||||||
val icons = IdePlatformKindTooling.getInstances()
|
val icons = getInstances()
|
||||||
.filter { it != this }
|
.filter { it != this }
|
||||||
.mapNotNull { it.getTestIcon(declaration, descriptor) }
|
.mapNotNull { it.getTestIcon(declaration, descriptor) }
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
|
||||||
import org.jetbrains.kotlin.idea.configuration.findApplicableConfigurator
|
import org.jetbrains.kotlin.idea.configuration.findApplicableConfigurator
|
||||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
|
||||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
|
||||||
import org.jetbrains.kotlin.idea.roots.invalidateProjectRoots
|
import org.jetbrains.kotlin.idea.roots.invalidateProjectRoots
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
|
||||||
@@ -59,7 +56,7 @@ sealed class ChangeCoroutineSupportFix(
|
|||||||
companion object : FeatureSupportIntentionActionsFactory() {
|
companion object : FeatureSupportIntentionActionsFactory() {
|
||||||
private const val shortFeatureName = "coroutine"
|
private const val shortFeatureName = "coroutine"
|
||||||
|
|
||||||
fun getFixText(state: LanguageFeature.State) = AbstractChangeFeatureSupportLevelFix.getFixText(state, shortFeatureName)
|
fun getFixText(state: LanguageFeature.State) = getFixText(state, shortFeatureName)
|
||||||
|
|
||||||
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
||||||
val module = ModuleUtilCore.findModuleForPsiElement(diagnostic.psiElement) ?: return emptyList()
|
val module = ModuleUtilCore.findModuleForPsiElement(diagnostic.psiElement) ?: return emptyList()
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer<JUnitConfig
|
|||||||
configuration: JUnitConfiguration,
|
configuration: JUnitConfiguration,
|
||||||
context: ConfigurationContext
|
context: ConfigurationContext
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (RunConfigurationProducer.getInstance(PatternConfigurationProducer::class.java).isMultipleElementsSelected(context)) {
|
if (getInstance(PatternConfigurationProducer::class.java).isMultipleElementsSelected(context)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ abstract class ScratchFileLanguageProvider {
|
|||||||
private val EXTENSION = LanguageExtension<ScratchFileLanguageProvider>("org.jetbrains.kotlin.scratchFileLanguageProvider")
|
private val EXTENSION = LanguageExtension<ScratchFileLanguageProvider>("org.jetbrains.kotlin.scratchFileLanguageProvider")
|
||||||
|
|
||||||
fun get(language: Language): ScratchFileLanguageProvider? {
|
fun get(language: Language): ScratchFileLanguageProvider? {
|
||||||
return ScratchFileLanguageProvider.EXTENSION.forLanguage(language)
|
return EXTENSION.forLanguage(language)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun get(fileType: FileType): ScratchFileLanguageProvider? {
|
fun get(fileType: FileType): ScratchFileLanguageProvider? {
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ class BunchFileCheckInHandlerFactory : CheckinHandlerFactory() {
|
|||||||
override fun beforeCheckin(
|
override fun beforeCheckin(
|
||||||
executor: CommitExecutor?,
|
executor: CommitExecutor?,
|
||||||
additionalDataConsumer: PairConsumer<Any, Any>?
|
additionalDataConsumer: PairConsumer<Any, Any>?
|
||||||
): CheckinHandler.ReturnResult {
|
): ReturnResult {
|
||||||
if (!project.bunchFileCheckEnabled) return CheckinHandler.ReturnResult.COMMIT
|
if (!project.bunchFileCheckEnabled) return ReturnResult.COMMIT
|
||||||
|
|
||||||
val extensions = BunchFileUtils.bunchExtension(project)?.toSet() ?: return CheckinHandler.ReturnResult.COMMIT
|
val extensions = BunchFileUtils.bunchExtension(project)?.toSet() ?: return ReturnResult.COMMIT
|
||||||
|
|
||||||
val forgottenFiles = HashSet<File>()
|
val forgottenFiles = HashSet<File>()
|
||||||
val commitFiles = checkInProjectPanel.files.filter { it.isFile }.toSet()
|
val commitFiles = checkInProjectPanel.files.filter { it.isFile }.toSet()
|
||||||
@@ -82,7 +82,7 @@ class BunchFileCheckInHandlerFactory : CheckinHandlerFactory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forgottenFiles.isEmpty()) return CheckinHandler.ReturnResult.COMMIT
|
if (forgottenFiles.isEmpty()) return ReturnResult.COMMIT
|
||||||
|
|
||||||
val projectBaseFile = File(project.basePath)
|
val projectBaseFile = File(project.basePath)
|
||||||
var filePaths = forgottenFiles.map { it.relativeTo(projectBaseFile).path }.sorted()
|
var filePaths = forgottenFiles.map { it.relativeTo(projectBaseFile).path }.sorted()
|
||||||
@@ -96,12 +96,12 @@ class BunchFileCheckInHandlerFactory : CheckinHandlerFactory() {
|
|||||||
"Forgotten Bunch Files", "Review", "Commit", CommonBundle.getCancelButtonText(), Messages.getWarningIcon()
|
"Forgotten Bunch Files", "Review", "Commit", CommonBundle.getCancelButtonText(), Messages.getWarningIcon()
|
||||||
)) {
|
)) {
|
||||||
YES -> {
|
YES -> {
|
||||||
return CheckinHandler.ReturnResult.CLOSE_WINDOW
|
return ReturnResult.CLOSE_WINDOW
|
||||||
}
|
}
|
||||||
NO -> return CheckinHandler.ReturnResult.COMMIT
|
NO -> return ReturnResult.COMMIT
|
||||||
}
|
}
|
||||||
|
|
||||||
return CheckinHandler.ReturnResult.CANCEL
|
return ReturnResult.CANCEL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,11 +257,11 @@ class PomFile private constructor(private val xmlFile: XmlFile, val domModel: Ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPluginExecutionMissing(plugin, "default-compile", "compile")) {
|
if (isPluginExecutionMissing(plugin, "default-compile", "compile")) {
|
||||||
addExecution(javacPlugin, "compile", PomFile.DefaultPhases.Compile, listOf("compile"))
|
addExecution(javacPlugin, "compile", DefaultPhases.Compile, listOf("compile"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPluginExecutionMissing(plugin, "default-testCompile", "testCompile")) {
|
if (isPluginExecutionMissing(plugin, "default-testCompile", "testCompile")) {
|
||||||
addExecution(javacPlugin, "testCompile", PomFile.DefaultPhases.TestCompile, listOf("testCompile"))
|
addExecution(javacPlugin, "testCompile", DefaultPhases.TestCompile, listOf("testCompile"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -30,10 +30,10 @@ import org.jetbrains.kotlin.platform.TargetPlatform
|
|||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
|
|
||||||
class KotlinJavaMavenConfigurator : KotlinMavenConfigurator(
|
class KotlinJavaMavenConfigurator : KotlinMavenConfigurator(
|
||||||
KotlinJavaMavenConfigurator.TEST_LIB_ID,
|
TEST_LIB_ID,
|
||||||
false,
|
false,
|
||||||
KotlinJavaMavenConfigurator.NAME,
|
NAME,
|
||||||
KotlinJavaMavenConfigurator.PRESENTABLE_TEXT
|
PRESENTABLE_TEXT
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun isKotlinModule(module: Module) =
|
override fun isKotlinModule(module: Module) =
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.platform.TargetPlatform
|
|||||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||||
|
|
||||||
class KotlinJavascriptMavenConfigurator :
|
class KotlinJavascriptMavenConfigurator :
|
||||||
KotlinMavenConfigurator(null, false, KotlinJavascriptMavenConfigurator.NAME, KotlinJavascriptMavenConfigurator.PRESENTABLE_TEXT) {
|
KotlinMavenConfigurator(null, false, NAME, PRESENTABLE_TEXT) {
|
||||||
|
|
||||||
override fun getStdlibArtifactId(module: Module, version: String) = MAVEN_JS_STDLIB_ID
|
override fun getStdlibArtifactId(module: Module, version: String) = MAVEN_JS_STDLIB_ID
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -205,7 +205,7 @@ protected constructor(
|
|||||||
forTests: Boolean
|
forTests: Boolean
|
||||||
) {
|
) {
|
||||||
fun doUpdateMavenLanguageVersion(): PsiElement? {
|
fun doUpdateMavenLanguageVersion(): PsiElement? {
|
||||||
val psi = KotlinMavenConfigurator.findModulePomFile(module) as? XmlFile ?: return null
|
val psi = findModulePomFile(module) as? XmlFile ?: return null
|
||||||
val pom = PomFile.forFileOrNull(psi) ?: return null
|
val pom = PomFile.forFileOrNull(psi) ?: return null
|
||||||
return pom.changeLanguageVersion(
|
return pom.changeLanguageVersion(
|
||||||
languageVersion,
|
languageVersion,
|
||||||
@@ -307,7 +307,7 @@ protected constructor(
|
|||||||
messageTitle: String
|
messageTitle: String
|
||||||
): PsiElement? {
|
): PsiElement? {
|
||||||
fun doChangeMavenCoroutineConfiguration(): PsiElement? {
|
fun doChangeMavenCoroutineConfiguration(): PsiElement? {
|
||||||
val psi = KotlinMavenConfigurator.findModulePomFile(module) as? XmlFile ?: return null
|
val psi = findModulePomFile(module) as? XmlFile ?: return null
|
||||||
val pom = PomFile.forFileOrNull(psi) ?: return null
|
val pom = PomFile.forFileOrNull(psi) ?: return null
|
||||||
return pom.changeCoroutineConfiguration(value)
|
return pom.changeCoroutineConfiguration(value)
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ protected constructor(
|
|||||||
state: LanguageFeature.State,
|
state: LanguageFeature.State,
|
||||||
messageTitle: String
|
messageTitle: String
|
||||||
): PsiElement? {
|
): PsiElement? {
|
||||||
val psi = KotlinMavenConfigurator.findModulePomFile(module) as? XmlFile ?: return null
|
val psi = findModulePomFile(module) as? XmlFile ?: return null
|
||||||
val pom = PomFile.forFileOrNull(psi) ?: return null
|
val pom = PomFile.forFileOrNull(psi) ?: return null
|
||||||
val element = pom.changeFeatureConfiguration(feature, state)
|
val element = pom.changeFeatureConfiguration(feature, state)
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CommandHistory {
|
|||||||
listeners.forEach { it.onNewEntry(entry) }
|
listeners.forEach { it.onNewEntry(entry) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun lastUnprocessedEntry(): CommandHistory.Entry? {
|
fun lastUnprocessedEntry(): Entry? {
|
||||||
return if (processedEntriesCount < size) {
|
return if (processedEntriesCount < size) {
|
||||||
get(processedEntriesCount)
|
get(processedEntriesCount)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,8 +309,8 @@ class ReflectionLookup(val classLoader: ClassLoader) {
|
|||||||
Type.BOOLEAN -> java.lang.Boolean.TYPE
|
Type.BOOLEAN -> java.lang.Boolean.TYPE
|
||||||
Type.BYTE -> java.lang.Byte.TYPE
|
Type.BYTE -> java.lang.Byte.TYPE
|
||||||
Type.SHORT -> java.lang.Short.TYPE
|
Type.SHORT -> java.lang.Short.TYPE
|
||||||
Type.CHAR -> java.lang.Character.TYPE
|
Type.CHAR -> Character.TYPE
|
||||||
Type.INT -> java.lang.Integer.TYPE
|
Type.INT -> Integer.TYPE
|
||||||
Type.LONG -> java.lang.Long.TYPE
|
Type.LONG -> java.lang.Long.TYPE
|
||||||
Type.FLOAT -> java.lang.Float.TYPE
|
Type.FLOAT -> java.lang.Float.TYPE
|
||||||
Type.DOUBLE -> java.lang.Double.TYPE
|
Type.DOUBLE -> java.lang.Double.TYPE
|
||||||
|
|||||||
+1
-2
@@ -31,7 +31,6 @@ import com.intellij.openapi.diagnostic.Logger
|
|||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.Key
|
import com.intellij.openapi.util.Key
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiFile
|
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import com.intellij.xdebugger.breakpoints.XBreakpoint
|
import com.intellij.xdebugger.breakpoints.XBreakpoint
|
||||||
import com.sun.jdi.AbsentInformationException
|
import com.sun.jdi.AbsentInformationException
|
||||||
@@ -72,7 +71,7 @@ class KotlinFieldBreakpoint(
|
|||||||
private var breakpointType: BreakpointType = BreakpointType.FIELD
|
private var breakpointType: BreakpointType = BreakpointType.FIELD
|
||||||
|
|
||||||
override fun isValid(): Boolean {
|
override fun isValid(): Boolean {
|
||||||
if (!BreakpointWithHighlighter.isPositionValid(xBreakpoint.sourcePosition)) return false
|
if (!isPositionValid(xBreakpoint.sourcePosition)) return false
|
||||||
|
|
||||||
return runReadAction {
|
return runReadAction {
|
||||||
val field = getField()
|
val field = getField()
|
||||||
|
|||||||
+2
-4
@@ -12,7 +12,6 @@ import com.intellij.debugger.impl.DebuggerContextImpl
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.sun.jdi.*
|
import com.sun.jdi.*
|
||||||
import com.sun.tools.jdi.LocalVariableImpl
|
import com.sun.tools.jdi.LocalVariableImpl
|
||||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
|
|
||||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.asmTypeForAnonymousClass
|
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.asmTypeForAnonymousClass
|
||||||
import org.jetbrains.kotlin.codegen.coroutines.DO_RESUME_METHOD_NAME
|
import org.jetbrains.kotlin.codegen.coroutines.DO_RESUME_METHOD_NAME
|
||||||
import org.jetbrains.kotlin.codegen.coroutines.INVOKE_SUSPEND_METHOD_NAME
|
import org.jetbrains.kotlin.codegen.coroutines.INVOKE_SUSPEND_METHOD_NAME
|
||||||
@@ -20,16 +19,15 @@ import org.jetbrains.kotlin.codegen.coroutines.continuationAsmTypes
|
|||||||
import org.jetbrains.kotlin.codegen.inline.KOTLIN_STRATA_NAME
|
import org.jetbrains.kotlin.codegen.inline.KOTLIN_STRATA_NAME
|
||||||
import org.jetbrains.kotlin.idea.core.KotlinFileTypeFactory
|
import org.jetbrains.kotlin.idea.core.KotlinFileTypeFactory
|
||||||
import org.jetbrains.kotlin.idea.core.util.CodeInsightUtils
|
import org.jetbrains.kotlin.idea.core.util.CodeInsightUtils
|
||||||
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches
|
|
||||||
import org.jetbrains.kotlin.idea.core.util.getLineEndOffset
|
import org.jetbrains.kotlin.idea.core.util.getLineEndOffset
|
||||||
import org.jetbrains.kotlin.idea.core.util.getLineStartOffset
|
import org.jetbrains.kotlin.idea.core.util.getLineStartOffset
|
||||||
|
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinDebuggerCaches
|
||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import org.jetbrains.org.objectweb.asm.Type as AsmType
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun Location.isInKotlinSources(): Boolean {
|
fun Location.isInKotlinSources(): Boolean {
|
||||||
@@ -88,7 +86,7 @@ fun <T : Any> DebugProcessImpl.invokeInManagerThread(f: (DebuggerContextImpl) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun lambdaOrdinalByArgument(elementAt: KtFunction, context: BindingContext): Int {
|
private fun lambdaOrdinalByArgument(elementAt: KtFunction, context: BindingContext): Int {
|
||||||
val type = CodegenBinding.asmTypeForAnonymousClass(context, elementAt)
|
val type = asmTypeForAnonymousClass(context, elementAt)
|
||||||
return type.className.substringAfterLast("$").toInt()
|
return type.className.substringAfterLast("$").toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.idea.debugger.sequence.trace.dsl.KotlinSequenceTypes
|
|||||||
|
|
||||||
class FilterIsInstanceHandler(num: Int, call: IntermediateStreamCall, dsl: Dsl) : HandlerBase.Intermediate(dsl) {
|
class FilterIsInstanceHandler(num: Int, call: IntermediateStreamCall, dsl: Dsl) : HandlerBase.Intermediate(dsl) {
|
||||||
private companion object {
|
private companion object {
|
||||||
fun createHandler(num: Int, call: IntermediateStreamCall, dsl: Dsl): HandlerBase.Intermediate =
|
fun createHandler(num: Int, call: IntermediateStreamCall, dsl: Dsl): Intermediate =
|
||||||
if (call.arguments.isEmpty()) MyWithGenericsHandler(num, call, dsl)
|
if (call.arguments.isEmpty()) MyWithGenericsHandler(num, call, dsl)
|
||||||
else PeekTraceHandler(num, call.name, call.typeBefore, call.typeAfter, dsl)
|
else PeekTraceHandler(num, call.name, call.typeBefore, call.typeAfter, dsl)
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ class FilterIsInstanceHandler(num: Int, call: IntermediateStreamCall, dsl: Dsl)
|
|||||||
/*
|
/*
|
||||||
* Transforms filterIsInstance<ClassName> -> filter { it is ClassName }.map { it as ClassName }
|
* Transforms filterIsInstance<ClassName> -> filter { it is ClassName }.map { it as ClassName }
|
||||||
*/
|
*/
|
||||||
private class MyWithGenericsHandler(num: Int, private val call: IntermediateStreamCall, dsl: Dsl) : HandlerBase.Intermediate(dsl) {
|
private class MyWithGenericsHandler(num: Int, private val call: IntermediateStreamCall, dsl: Dsl) : Intermediate(dsl) {
|
||||||
private val peekHandler = PeekTraceHandler(num, "filterIsInstance", call.typeBefore, call.typeAfter, dsl)
|
private val peekHandler = PeekTraceHandler(num, "filterIsInstance", call.typeBefore, call.typeAfter, dsl)
|
||||||
override fun additionalCallsAfter(): List<IntermediateStreamCall> {
|
override fun additionalCallsAfter(): List<IntermediateStreamCall> {
|
||||||
val mapperType = functionalType(call.typeBefore.genericTypeName, call.typeAfter.genericTypeName)
|
val mapperType = functionalType(call.typeBefore.genericTypeName, call.typeAfter.genericTypeName)
|
||||||
|
|||||||
+1
-2
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.utils.keysToMap
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
import kotlin.jvm.internal.FunctionBase
|
import kotlin.jvm.internal.FunctionBase
|
||||||
import org.jetbrains.org.objectweb.asm.Type as AsmType
|
|
||||||
|
|
||||||
object FileRankingCalculatorForIde : FileRankingCalculator() {
|
object FileRankingCalculatorForIde : FileRankingCalculator() {
|
||||||
override fun analyze(element: KtElement) = element.analyze(BodyResolveMode.PARTIAL)
|
override fun analyze(element: KtElement) = element.analyze(BodyResolveMode.PARTIAL)
|
||||||
@@ -106,7 +105,7 @@ abstract class FileRankingCalculator(private val checkClassFqName: Boolean = tru
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun rankingForClassName(fqName: String, descriptor: ClassDescriptor, bindingContext: BindingContext): Ranking {
|
private fun rankingForClassName(fqName: String, descriptor: ClassDescriptor, bindingContext: BindingContext): Ranking {
|
||||||
if (DescriptorUtils.isLocal(descriptor)) return Ranking.ZERO
|
if (DescriptorUtils.isLocal(descriptor)) return ZERO
|
||||||
|
|
||||||
val expectedFqName = makeTypeMapper(bindingContext).mapType(descriptor).className
|
val expectedFqName = makeTypeMapper(bindingContext).mapType(descriptor).className
|
||||||
return when {
|
return when {
|
||||||
|
|||||||
+2
-2
@@ -28,8 +28,8 @@ import com.intellij.psi.util.CachedValuesManager
|
|||||||
import com.intellij.psi.util.PsiModificationTracker
|
import com.intellij.psi.util.PsiModificationTracker
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import com.intellij.util.containers.MultiMap
|
import com.intellij.util.containers.MultiMap
|
||||||
import org.jetbrains.annotations.TestOnly
|
|
||||||
import org.apache.log4j.Logger
|
import org.apache.log4j.Logger
|
||||||
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.eval4j.Value
|
import org.jetbrains.eval4j.Value
|
||||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||||
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
|
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
|
||||||
@@ -221,7 +221,7 @@ class KotlinDebuggerCaches(project: Project) {
|
|||||||
class ComputedClassNames(val classNames: List<String>, val shouldBeCached: Boolean) {
|
class ComputedClassNames(val classNames: List<String>, val shouldBeCached: Boolean) {
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
companion object {
|
companion object {
|
||||||
val EMPTY = ComputedClassNames.Cached(emptyList())
|
val EMPTY = Cached(emptyList())
|
||||||
|
|
||||||
fun Cached(classNames: List<String>) = ComputedClassNames(classNames, true)
|
fun Cached(classNames: List<String>) = ComputedClassNames(classNames, true)
|
||||||
fun Cached(className: String) = ComputedClassNames(Collections.singletonList(className), true)
|
fun Cached(className: String) = ComputedClassNames(Collections.singletonList(className), true)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class WholeProjectLightClassTest : WholeProjectPerformanceTest(), WholeProjectKo
|
|||||||
var totalNs = 0L
|
var totalNs = 0L
|
||||||
|
|
||||||
val psiFile = file.toPsiFile(project) ?: run {
|
val psiFile = file.toPsiFile(project) ?: run {
|
||||||
return WholeProjectPerformanceTest.PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file")))
|
return PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file")))
|
||||||
}
|
}
|
||||||
|
|
||||||
val errors = mutableListOf<Throwable>()
|
val errors = mutableListOf<Throwable>()
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ abstract class WholeProjectUltraLightClassTest : WholeProjectPerformanceTest(),
|
|||||||
|
|
||||||
override fun doTest(file: VirtualFile): PerFileTestResult {
|
override fun doTest(file: VirtualFile): PerFileTestResult {
|
||||||
val psiFile = file.toPsiFile(project) as? KtFile ?: run {
|
val psiFile = file.toPsiFile(project) as? KtFile ?: run {
|
||||||
return WholeProjectPerformanceTest.PerFileTestResult(mapOf(), 0, listOf(AssertionError("PsiFile not found for $file")))
|
return PerFileTestResult(mapOf(), 0, listOf(AssertionError("PsiFile not found for $file")))
|
||||||
}
|
}
|
||||||
|
|
||||||
val errors = mutableListOf<Throwable>()
|
val errors = mutableListOf<Throwable>()
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ abstract class DeprecatedSymbolUsageFixBase(
|
|||||||
): ReplaceWith? {
|
): ReplaceWith? {
|
||||||
val annotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: return null
|
val annotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: return null
|
||||||
val replaceWithValue =
|
val replaceWithValue =
|
||||||
annotation.argumentValue(kotlin.Deprecated::replaceWith.name)?.safeAs<AnnotationValue>()?.value ?: return null
|
annotation.argumentValue(Deprecated::replaceWith.name)?.safeAs<AnnotationValue>()?.value ?: return null
|
||||||
val pattern = replaceWithValue.argumentValue(kotlin.ReplaceWith::expression.name)?.safeAs<StringValue>()?.value ?: return null
|
val pattern = replaceWithValue.argumentValue(kotlin.ReplaceWith::expression.name)?.safeAs<StringValue>()?.value ?: return null
|
||||||
if (pattern.isEmpty()) return null
|
if (pattern.isEmpty()) return null
|
||||||
val importValues = replaceWithValue.argumentValue(kotlin.ReplaceWith::imports.name)?.safeAs<ArrayValue>()?.value ?: return null
|
val importValues = replaceWithValue.argumentValue(kotlin.ReplaceWith::imports.name)?.safeAs<ArrayValue>()?.value ?: return null
|
||||||
|
|||||||
+1
-2
@@ -21,7 +21,6 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.psi.PsiReference
|
import com.intellij.psi.PsiReference
|
||||||
import com.intellij.refactoring.JavaRefactoringSettings
|
import com.intellij.refactoring.JavaRefactoringSettings
|
||||||
import com.intellij.refactoring.listeners.RefactoringElementListener
|
import com.intellij.refactoring.listeners.RefactoringElementListener
|
||||||
import com.intellij.refactoring.rename.RenamePsiElementProcessor
|
|
||||||
import com.intellij.usageView.UsageInfo
|
import com.intellij.usageView.UsageInfo
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
||||||
@@ -68,7 +67,7 @@ class RenameKotlinClassifierProcessor : RenameKotlinPsiProcessor() {
|
|||||||
if (nameWithoutExtensions == it.name) {
|
if (nameWithoutExtensions == it.name) {
|
||||||
val newFileName = newName + "." + virtualFile.extension
|
val newFileName = newName + "." + virtualFile.extension
|
||||||
allRenames.put(file, newFileName)
|
allRenames.put(file, newFileName)
|
||||||
RenamePsiElementProcessor.forElement(file).prepareRenaming(file, newFileName, allRenames)
|
forElement(file).prepareRenaming(file, newFileName, allRenames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ abstract class AbstractLineMarkersTestInLibrarySources : AbstractLineMarkersTest
|
|||||||
override fun configureModule(module: Module, model: ModifiableRootModel) {
|
override fun configureModule(module: Module, model: ModifiableRootModel) {
|
||||||
super.configureModule(module, model)
|
super.configureModule(module, model)
|
||||||
|
|
||||||
val library = model.moduleLibraryTable.getLibraryByName(SdkAndMockLibraryProjectDescriptor.LIBRARY_NAME)!!
|
val library = model.moduleLibraryTable.getLibraryByName(LIBRARY_NAME)!!
|
||||||
val modifiableModel = library.modifiableModel
|
val modifiableModel = library.modifiableModel
|
||||||
|
|
||||||
modifiableModel.addRoot(LocalFileSystem.getInstance().findFileByIoFile(libraryClean!!)!!, OrderRootType.SOURCES)
|
modifiableModel.addRoot(LocalFileSystem.getInstance().findFileByIoFile(libraryClean!!)!!, OrderRootType.SOURCES)
|
||||||
|
|||||||
@@ -165,9 +165,9 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getPathToJar(runtimeState: FileState, jarFromDist: String, jarFromTemp: String) = when (runtimeState) {
|
private fun getPathToJar(runtimeState: FileState, jarFromDist: String, jarFromTemp: String) = when (runtimeState) {
|
||||||
KotlinWithLibraryConfigurator.FileState.EXISTS -> jarFromDist
|
FileState.EXISTS -> jarFromDist
|
||||||
KotlinWithLibraryConfigurator.FileState.COPY -> jarFromTemp
|
FileState.COPY -> jarFromTemp
|
||||||
KotlinWithLibraryConfigurator.FileState.DO_NOT_COPY -> jarFromDist
|
FileState.DO_NOT_COPY -> jarFromDist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ private object DebuggerMain {
|
|||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
// Wait until debugger is attached
|
// Wait until debugger is attached
|
||||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||||
(lock as java.lang.Object).wait()
|
(lock as Object).wait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -16,10 +16,10 @@ import org.jetbrains.kotlin.idea.completion.test.AbstractJvmBasicCompletionTest
|
|||||||
import org.jetbrains.kotlin.idea.completion.test.testCompletion
|
import org.jetbrains.kotlin.idea.completion.test.testCompletion
|
||||||
import org.jetbrains.kotlin.idea.debugger.getContextElement
|
import org.jetbrains.kotlin.idea.debugger.getContextElement
|
||||||
import org.jetbrains.kotlin.idea.test.SdkAndMockLibraryProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.SdkAndMockLibraryProjectDescriptor
|
||||||
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtFunction
|
import org.jetbrains.kotlin.psi.KtFunction
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
|
||||||
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
|
import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -34,7 +34,7 @@ class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTest() {
|
|||||||
override fun configureModule(module: Module, model: ModifiableRootModel) {
|
override fun configureModule(module: Module, model: ModifiableRootModel) {
|
||||||
super.configureModule(module, model)
|
super.configureModule(module, model)
|
||||||
|
|
||||||
val library = model.moduleLibraryTable.getLibraryByName(SdkAndMockLibraryProjectDescriptor.LIBRARY_NAME)!!
|
val library = model.moduleLibraryTable.getLibraryByName(LIBRARY_NAME)!!
|
||||||
val modifiableModel = library.modifiableModel
|
val modifiableModel = library.modifiableModel
|
||||||
|
|
||||||
modifiableModel.addRoot(findLibrarySourceDir(), OrderRootType.SOURCES)
|
modifiableModel.addRoot(findLibrarySourceDir(), OrderRootType.SOURCES)
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ abstract class AbstractNavigateToLibrarySourceTest : AbstractNavigateToLibraryTe
|
|||||||
abstract class AbstractNavigateToLibrarySourceTestWithJS : AbstractNavigateToLibrarySourceTest() {
|
abstract class AbstractNavigateToLibrarySourceTestWithJS : AbstractNavigateToLibrarySourceTest() {
|
||||||
override fun getProjectDescriptor(): KotlinLightProjectDescriptor = KotlinMultiModuleProjectDescriptor(
|
override fun getProjectDescriptor(): KotlinLightProjectDescriptor = KotlinMultiModuleProjectDescriptor(
|
||||||
"AbstractNavigateToLibrarySourceTestWithJS",
|
"AbstractNavigateToLibrarySourceTestWithJS",
|
||||||
AbstractNavigateToLibrarySourceTest.PROJECT_DESCRIPTOR,
|
PROJECT_DESCRIPTOR,
|
||||||
KotlinStdJSProjectDescriptor
|
KotlinStdJSProjectDescriptor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class KotlinJvmDeclarationSearcherTest : KotlinLightCodeInsightFixtureTestCase()
|
|||||||
|
|
||||||
fun testClassDeclaration() = assertElementsByIdentifier("""
|
fun testClassDeclaration() = assertElementsByIdentifier("""
|
||||||
class Some<caret>Class(val field: String)
|
class Some<caret>Class(val field: String)
|
||||||
""", { it is JvmClass }, { it is com.intellij.lang.jvm.JvmMethod && it.isConstructor })
|
""", { it is JvmClass }, { it is JvmMethod && it.isConstructor })
|
||||||
|
|
||||||
|
|
||||||
fun testLocalObjectDeclaration() = assertElementsByIdentifier("""
|
fun testLocalObjectDeclaration() = assertElementsByIdentifier("""
|
||||||
|
|||||||
@@ -231,14 +231,14 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
|
|||||||
private fun doTestInplaceRename(newName: String?, handler: VariableInplaceRenameHandler = KotlinVariableInplaceRenameHandler()) {
|
private fun doTestInplaceRename(newName: String?, handler: VariableInplaceRenameHandler = KotlinVariableInplaceRenameHandler()) {
|
||||||
configureByFile(getTestName(false) + ".kt")
|
configureByFile(getTestName(false) + ".kt")
|
||||||
val element = TargetElementUtil.findTargetElement(
|
val element = TargetElementUtil.findTargetElement(
|
||||||
LightPlatformCodeInsightTestCase.myEditor,
|
myEditor,
|
||||||
TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
|
TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
|
||||||
)
|
)
|
||||||
|
|
||||||
assertNotNull(element)
|
assertNotNull(element)
|
||||||
|
|
||||||
val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element!!,
|
val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element!!,
|
||||||
LightPlatformCodeInsightTestCase.getCurrentEditorDataContext())
|
getCurrentEditorDataContext())
|
||||||
|
|
||||||
if (newName == null) {
|
if (newName == null) {
|
||||||
assertFalse(handler.isRenaming(dataContext), "In-place rename is allowed for " + element)
|
assertFalse(handler.isRenaming(dataContext), "In-place rename is allowed for " + element)
|
||||||
@@ -246,7 +246,7 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
|
|||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
assertTrue(handler.isRenaming(dataContext), "In-place rename not allowed for " + element)
|
assertTrue(handler.isRenaming(dataContext), "In-place rename not allowed for " + element)
|
||||||
CodeInsightTestUtil.doInlineRename(handler, newName, LightPlatformCodeInsightTestCase.getEditor(), element)
|
CodeInsightTestUtil.doInlineRename(handler, newName, getEditor(), element)
|
||||||
checkResultByFile(getTestName(false) + ".kt.after")
|
checkResultByFile(getTestName(false) + ".kt.after")
|
||||||
} catch (e: BaseRefactoringProcessor.ConflictsInTestsException) {
|
} catch (e: BaseRefactoringProcessor.ConflictsInTestsException) {
|
||||||
val expectedMessage = InTextDirectivesUtils.findStringWithPrefixes(myFile.text, "// SHOULD_FAIL_WITH: ")
|
val expectedMessage = InTextDirectivesUtils.findStringWithPrefixes(myFile.text, "// SHOULD_FAIL_WITH: ")
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ fun createLibraryWithLongPaths(project: Project): Library {
|
|||||||
|
|
||||||
|
|
||||||
private object MockExecutor : DefaultRunExecutor() {
|
private object MockExecutor : DefaultRunExecutor() {
|
||||||
override fun getId() = DefaultRunExecutor.EXECUTOR_ID
|
override fun getId() = EXECUTOR_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
private object MockProfile : RunProfile {
|
private object MockProfile : RunProfile {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import org.intellij.plugins.intelliLang.inject.InjectLanguageAction
|
|||||||
import org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction
|
import org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction
|
||||||
import org.intellij.plugins.intelliLang.references.FileReferenceInjector
|
import org.intellij.plugins.intelliLang.references.FileReferenceInjector
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase
|
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
@@ -28,7 +27,7 @@ abstract class AbstractInjectionTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
return when {
|
return when {
|
||||||
testName.endsWith("WithAnnotation") -> KotlinLightProjectDescriptor.INSTANCE
|
testName.endsWith("WithAnnotation") -> KotlinLightProjectDescriptor.INSTANCE
|
||||||
testName.endsWith("WithRuntime") -> KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
testName.endsWith("WithRuntime") -> KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
else -> KotlinLightCodeInsightFixtureTestCaseBase.JAVA_LATEST
|
else -> JAVA_LATEST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,45 +14,45 @@ import org.junit.runner.RunWith
|
|||||||
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
||||||
class KotlinStdlibInjectionTest : AbstractInjectionTest() {
|
class KotlinStdlibInjectionTest : AbstractInjectionTest() {
|
||||||
fun testOnRegex0() = assertInjectionPresent(
|
fun testOnRegex0() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
val test1 = kotlin.text.Regex("<caret>some")
|
val test1 = Regex("<caret>some")
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testOnRegex1() = assertInjectionPresent(
|
fun testOnRegex1() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
val test1 = kotlin.text.Regex("<caret>some", RegexOption.COMMENTS)
|
val test1 = Regex("<caret>some", RegexOption.COMMENTS)
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testOnRegex2() = assertInjectionPresent(
|
fun testOnRegex2() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
val test1 = kotlin.text.Regex("<caret>some", setOf(RegexOption.COMMENTS))
|
val test1 = Regex("<caret>some", setOf(RegexOption.COMMENTS))
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testToRegex0() = assertInjectionPresent(
|
fun testToRegex0() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
val test = "hi<caret>".toRegex()
|
val test = "hi<caret>".toRegex()
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testToRegex1() = assertInjectionPresent(
|
fun testToRegex1() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
val test = "hi<caret>".toRegex(RegexOption.CANON_EQ)
|
val test = "hi<caret>".toRegex(RegexOption.CANON_EQ)
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
fun testToRegex2() = assertInjectionPresent(
|
fun testToRegex2() = assertInjectionPresent(
|
||||||
"""
|
"""
|
||||||
val test = "hi<caret>".toRegex(setOf(RegexOption.LITERAL))
|
val test = "hi<caret>".toRegex(setOf(RegexOption.LITERAL))
|
||||||
""",
|
""",
|
||||||
RegExpLanguage.INSTANCE.id
|
RegExpLanguage.INSTANCE.id
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun assertInjectionPresent(@Language("kotlin") text: String, languageId: String) {
|
private fun assertInjectionPresent(@Language("kotlin") text: String, languageId: String) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ abstract class AbstractAnnotatedMembersSearchTest : AbstractSearcherTest() {
|
|||||||
PsiBasedClassResolver.trueHits.set(0)
|
PsiBasedClassResolver.trueHits.set(0)
|
||||||
PsiBasedClassResolver.falseHits.set(0)
|
PsiBasedClassResolver.falseHits.set(0)
|
||||||
|
|
||||||
AbstractSearcherTest.checkResult(
|
checkResult(
|
||||||
path,
|
path,
|
||||||
AnnotatedElementsSearch.searchElements(
|
AnnotatedElementsSearch.searchElements(
|
||||||
psiClass,
|
psiClass,
|
||||||
|
|||||||
Reference in New Issue
Block a user