User: rednesto Date: 13 Sep 24 11:14 Revision: 57713466832bc2000d193087556e4f7673622d27 Summary: Fix deprecated JavaLexer.isKeyword usage TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9683&personal=false Index: src/main/kotlin/creator/custom/BuiltinValidations.kt =================================================================== --- src/main/kotlin/creator/custom/BuiltinValidations.kt (revision 07d1a7ce5b993571687cb3ba839bc22a37082296) +++ src/main/kotlin/creator/custom/BuiltinValidations.kt (revision 57713466832bc2000d193087556e4f7673622d27) @@ -23,13 +23,12 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.platform.fabric.util.FabricVersions import com.demonwav.mcdev.util.SemanticVersion -import com.intellij.lang.java.lexer.JavaLexer +import com.demonwav.mcdev.util.isJavaKeyword import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.ValidationInfo import com.intellij.openapi.ui.validation.DialogValidation import com.intellij.openapi.ui.validation.validationErrorIf import com.intellij.openapi.util.text.StringUtil -import com.intellij.pom.java.LanguageLevel import javax.swing.JComponent object BuiltinValidations { @@ -61,7 +60,7 @@ val validClassFqn = validationErrorIf(MCDevBundle("creator.validation.class_fqn")) { it.isBlank() || it.split('.').any { part -> - !StringUtil.isJavaIdentifier(part) || JavaLexer.isKeyword(part, LanguageLevel.HIGHEST) + !StringUtil.isJavaIdentifier(part) || part.isJavaKeyword() } } Index: src/main/kotlin/creator/field-validation.kt =================================================================== --- src/main/kotlin/creator/field-validation.kt (revision 07d1a7ce5b993571687cb3ba839bc22a37082296) +++ src/main/kotlin/creator/field-validation.kt (revision 57713466832bc2000d193087556e4f7673622d27) @@ -20,7 +20,7 @@ package com.demonwav.mcdev.creator -import com.demonwav.mcdev.util.isJavaKeyword +import com.demonwav.mcdev.util.isJavaSoftKeyword fun isValidClassName(className: String): Boolean { // default package @@ -42,5 +42,5 @@ return false } // keyword identifier - return !fieldNameSplit.any { it.isJavaKeyword() } + return !fieldNameSplit.any { it.isJavaSoftKeyword() } } Index: src/main/kotlin/util/Parameter.kt =================================================================== --- src/main/kotlin/util/Parameter.kt (revision 07d1a7ce5b993571687cb3ba839bc22a37082296) +++ src/main/kotlin/util/Parameter.kt (revision 57713466832bc2000d193087556e4f7673622d27) @@ -27,6 +27,6 @@ constructor(parameter: PsiParameter) : this(parameter.name, parameter.type) init { - assert(name?.isJavaKeyword() != true) + assert(name?.isJavaSoftKeyword() != true) } } Index: src/main/kotlin/util/utils.kt =================================================================== --- src/main/kotlin/util/utils.kt (revision 07d1a7ce5b993571687cb3ba839bc22a37082296) +++ src/main/kotlin/util/utils.kt (revision 57713466832bc2000d193087556e4f7673622d27) @@ -299,14 +299,16 @@ return distance + bonus } -fun String.isJavaKeyword() = PsiUtil.isSoftKeyword(this, LanguageLevel.HIGHEST) +fun String.isJavaKeyword() = PsiUtil.isKeyword(this, LanguageLevel.HIGHEST) +fun String.isJavaSoftKeyword() = PsiUtil.isSoftKeyword(this, LanguageLevel.HIGHEST) + fun String.toJavaIdentifier(allowDollars: Boolean = true): String { if (this.isEmpty()) { return "_" } - if (this.isJavaKeyword()) { + if (this.isJavaSoftKeyword()) { return "_$this" }