15
15
*/
16
16
package org.jetbrains.kotlin.idea.inspections
17
17
18
- import com.intellij.codeInspection.*
18
+ import com.intellij.codeInspection.LocalQuickFix
19
+ import com.intellij.codeInspection.ProblemDescriptor
20
+ import com.intellij.codeInspection.ProblemHighlightType
21
+ import com.intellij.codeInspection.ProblemsHolder
19
22
import com.intellij.lang.ASTNode
20
23
import com.intellij.openapi.project.Project
21
24
import com.intellij.psi.PsiElement
22
25
import com.intellij.psi.PsiElementVisitor
23
26
import com.intellij.psi.impl.source.tree.SharedImplUtil
27
+ import org.jetbrains.kotlin.idea.core.unquote
24
28
import org.jetbrains.kotlin.lexer.KtTokens
25
- import org.jetbrains.kotlin.psi.*
29
+ import org.jetbrains.kotlin.psi.KtElement
30
+ import org.jetbrains.kotlin.psi.KtPsiFactory
31
+ import org.jetbrains.kotlin.psi.KtVisitorVoid
26
32
import org.jetbrains.kotlin.psi.psiUtil.isIdentifier
27
33
28
34
class RemoveRedundantBackticksInspection : AbstractKotlinInspection () {
@@ -44,10 +50,10 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
44
50
}
45
51
46
52
private fun isRedundantBackticks (node : ASTNode ): Boolean {
47
- return ( node.text.startsWith( " ` " ) &&
48
- node. text.endsWith(" `" ) &&
49
- node. text.isIdentifier() &&
50
- ! isKeyword(node.text.removePrefix( " ` " ).removeSuffix( " ` " )) )
53
+ val text = node.text
54
+ if ( ! (text.startsWith( " ` " ) && text.endsWith(" `" ))) return false
55
+ val unquotedText = text.unquote()
56
+ return unquotedText.isIdentifier() && ! isKeyword(unquotedText )
51
57
}
52
58
53
59
private fun registerProblem (holder : ProblemsHolder , element : PsiElement ) {
0 commit comments