diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f89ae..337920c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ ### Fixed - Fix project opening not working as expected in IntelliJ 2023 builds. +- Fix name validation when renaming symbols. + +## Changed + +- Do not apply spell checking inspection for RuneScript keywords. ## [1.6.0] - 2024-08-30 diff --git a/src/main/kotlin/io/runescript/plugin/ide/refactoring/RsNamesValidator.kt b/src/main/kotlin/io/runescript/plugin/ide/refactoring/RsNamesValidator.kt new file mode 100644 index 0000000..d161f2c --- /dev/null +++ b/src/main/kotlin/io/runescript/plugin/ide/refactoring/RsNamesValidator.kt @@ -0,0 +1,32 @@ +package io.runescript.plugin.ide.refactoring + +import com.intellij.lang.refactoring.NamesValidator +import com.intellij.openapi.project.Project +import io.runescript.plugin.ide.config.RsConfig + +class RsNamesValidator : NamesValidator { + private val keywords = hashSetOf( + "if", + "else", + "while", + "case", + "default", + "return", + "calc", + "return", + "true", + "false", + "null", + *RsConfig.getPrimitiveTypes().map { "def_$it" }.toTypedArray(), + *RsConfig.getPrimitiveTypes().map { "switch_$it" }.toTypedArray(), + *RsConfig.getPrimitiveTypes().map { "${it}array" }.toTypedArray(), + ) + + override fun isKeyword(name: String, project: Project?): Boolean { + return keywords.contains(name) + } + + override fun isIdentifier(name: String, project: Project?): Boolean { + return name.matches(Regex("[a-zA-Z0-9_+.:]+")) + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 98baf99..45250e4 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -34,7 +34,12 @@ + + + + +