Skip to content

Commit 16d0c68

Browse files
committed
fix: ClassNotFoundException: kotlin.test.Assertions
1 parent ac264c5 commit 16d0c68

21 files changed

+246
-65
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Changelog
44
===============================================================================
5+
## 2021.3.10
6+
- fix: ClassNotFoundException: kotlin.test.Assertions
7+
58
## 2021.3.9
69
- fix: sometimes no autocompletion for data tags (@xxx)
710

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ plugins {
55
// Java support
66
id("java")
77
// Kotlin support
8-
id("org.jetbrains.kotlin.jvm") version "1.6.10"
8+
id("org.jetbrains.kotlin.jvm") version "1.6.20"
99
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
10-
id("org.jetbrains.intellij") version "1.3.1"
10+
id("org.jetbrains.intellij") version "1.5.2"
1111
}
1212

1313

1414

1515
group = "com.emberjs"
16-
version = "2021.3.9"
16+
version = "2021.3.10"
1717

1818
// Configure project's dependencies
1919
repositories {

src/main/kotlin/com/emberjs/EmberAttributeDescriptor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class EmberAttributeDescriptor(val context: XmlTag, value: String, isYield: Bool
4545
if (ref != null) {
4646
val type = PsiTreeUtil.collectElementsOfType(ref.element, TypeScriptPropertySignatureImpl::class.java).firstOrNull()
4747
val types = (type?.jsType?.asRecordType()?.sourceElement as? TypeScriptUnionOrIntersectionTypeImpl?)?.types
48-
val typesStr = types?.map { it.castSafelyTo<TypeScriptLiteralType>()?.let { it.innerText } }?.filterNotNull() ?: arrayListOf()
48+
val typesStr = types?.map { (it as? TypeScriptLiteralType?)?.let { it.innerText } }?.filterNotNull() ?: arrayListOf()
4949
val isOptional = (type?.isOptional ?: true) || typesStr.isEmpty() || (typesStr.contains("undefined") || typesStr.contains("null") || typesStr.contains("*"))
5050
this.isRequired = !isOptional
5151
this.values = typesStr

src/main/kotlin/com/emberjs/configuration/serve/EmberServeConfigurationFactory.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class EmberServeConfigurationFactory(type: ConfigurationType) : ConfigurationFac
1616
return FACTORY_NAME
1717
}
1818

19+
override fun getId(): String {
20+
return "Ember Serve"
21+
}
22+
1923
companion object {
2024
private val FACTORY_NAME = "Ember serve configuration factory"
2125
}

src/main/kotlin/com/emberjs/configuration/test/EmberTestConfigurationFactory.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ class EmberTestConfigurationFactory(type: ConfigurationType) : ConfigurationFact
1212
}
1313

1414
override fun getName(): String {
15-
return FACTORY_NAME;
15+
return FACTORY_NAME
16+
}
17+
18+
override fun getId(): String {
19+
return "Ember Test"
1620
}
1721

1822
companion object {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import com.intellij.ide.actionsOnSave.impl.ActionsOnSaveFileDocumentManagerListener.ActionOnSave
2+
import com.intellij.lang.javascript.linter.eslint.standardjs.StandardJSConfiguration
3+
import com.intellij.openapi.editor.Document
4+
import com.intellij.openapi.fileEditor.FileDocumentManager
5+
import com.intellij.openapi.project.Project
6+
import com.intellij.openapi.roots.ProjectFileIndex
7+
8+
class TemplateLintActionOnSave : ActionOnSave() {
9+
override fun isEnabledForProject(project: Project): Boolean = isFixOnSaveEnabled(project)
10+
11+
override fun processDocuments(project: Project, documents: Array<out Document>) {
12+
if (!this.isEnabledForProject(project)) return
13+
14+
val manager = FileDocumentManager.getInstance()
15+
val fileIndex = ProjectFileIndex.getInstance(project)
16+
val files = documents
17+
.mapNotNull { manager.getFile(it) }
18+
.filter { it.isInLocalFileSystem && fileIndex.isInContent(it) }
19+
.toTypedArray()
20+
if (files.isNotEmpty()) {
21+
TemplateLintFixAction().processFiles(project, files, false, true)
22+
}
23+
}
24+
25+
companion object {
26+
fun isFixOnSaveEnabled(project: Project): Boolean {
27+
val config = TemplateLintConfiguration.getInstance(project)
28+
return config.isEnabled && config.extendedState.state.isRunOnSave
29+
}
30+
}
31+
}

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintConfigurable.kt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

2+
import com.intellij.ide.actionsOnSave.ActionOnSaveBackedByOwnConfigurable
3+
import com.intellij.ide.actionsOnSave.ActionOnSaveContext
24
import com.intellij.lang.javascript.linter.JSLinterConfigurable
35
import com.intellij.lang.javascript.linter.JSLinterView
46
import com.intellij.openapi.project.Project
7+
import com.intellij.ui.components.ActionLink
58

69
class TemplateLintConfigurable(project: Project, fullModeDialog: Boolean = false) :
710
JSLinterConfigurable<TemplateLintState>(
@@ -25,4 +28,45 @@ class TemplateLintConfigurable(project: Project, fullModeDialog: Boolean = false
2528
return TemplateLintBundle.message("hbs.lint.configurable.name")
2629
}
2730

28-
}
31+
override fun getView(): TemplateLintView? {
32+
return super.getView() as TemplateLintView?
33+
}
34+
35+
class TemplateLintOnSaveActionInfo(context: ActionOnSaveContext) :
36+
ActionOnSaveBackedByOwnConfigurable<TemplateLintConfigurable>(
37+
context, ID, TemplateLintConfigurable::class.java) {
38+
39+
override fun getActionOnSaveName(): String {
40+
return TemplateLintBundle.message("hbs.lint.run.on.save.checkbox.on.actions.on.save.page")
41+
}
42+
43+
override fun setActionOnSaveEnabled(configurable: TemplateLintConfigurable, enabled: Boolean) {
44+
val view = configurable.view
45+
if (view != null) {
46+
view.myRunOnSaveCheckBox.isSelected = enabled
47+
}
48+
}
49+
50+
override fun isApplicableAccordingToStoredState(): Boolean {
51+
return TemplateLintConfiguration.getInstance(this.project).isEnabled
52+
}
53+
54+
override fun isApplicableAccordingToUiState(configurable: TemplateLintConfigurable): Boolean {
55+
val checkbox = configurable.view?.myRunOnSaveCheckBox
56+
return checkbox != null && checkbox.isVisible && checkbox.isEnabled
57+
}
58+
59+
override fun isActionOnSaveEnabledAccordingToStoredState(): Boolean {
60+
return TemplateLintActionOnSave.isFixOnSaveEnabled(this.project)
61+
}
62+
63+
override fun isActionOnSaveEnabledAccordingToUiState(configurable: TemplateLintConfigurable): Boolean {
64+
val checkbox = configurable.view?.myRunOnSaveCheckBox
65+
return checkbox != null && checkbox.isVisible && checkbox.isEnabled && checkbox.isSelected
66+
}
67+
68+
override fun getActionLinks(): MutableList<out ActionLink> {
69+
return mutableListOf(createGoToPageInSettingsLink(ID))
70+
}
71+
}
72+
}

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintConfiguration.kt

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,53 @@ import com.intellij.lang.javascript.linter.JSLinterInspection
55
import com.intellij.openapi.components.State
66
import com.intellij.openapi.components.Storage
77
import com.intellij.openapi.project.Project
8+
import com.intellij.openapi.util.JDOMExternalizerUtil
89
import org.jdom.Element
9-
import kotlin.test.assertNotNull
1010

1111
@State(name = "TemplateLintConfiguration", storages = [Storage("emberLinters/templatelint.xml")])
1212
class TemplateLintConfiguration(project: Project) : JSLinterConfiguration<TemplateLintState>(project) {
13-
private val DEFAULT_STATE = TemplateLintState()
1413
private val myPackage: JSLinterPackage = JSLinterPackage(project, TemplateLintUtil.PACKAGE_NAME)
1514

1615
override fun loadPrivateSettings(state: TemplateLintState): TemplateLintState {
1716
this.myPackage.readOrDetect()
1817
val constantPackage = myPackage.getPackage().constantPackage
18+
?: throw AssertionError("TemplateLint does not support non-constant node package refs")
1919

20-
assertNotNull(constantPackage, "TemplateLint does not support non-constant node package refs")
21-
22-
return TemplateLintState(this.myPackage.interpreter, constantPackage)
23-
}
24-
25-
override fun fromXml(element: Element): TemplateLintState {
26-
return this.defaultState
20+
return state.copy(
21+
myInterpreterRef = this.myPackage.interpreter,
22+
myTemplateLintPackage = constantPackage
23+
)
2724
}
2825

2926
override fun savePrivateSettings(state: TemplateLintState) {
3027
this.myPackage.force(state.interpreterRef, state.templateLintPackage)
3128
}
3229

3330
override fun toXml(state: TemplateLintState): Element? {
34-
return null
31+
if (state == defaultState) {
32+
return null
33+
}
34+
val parent = Element(TemplateLintUtil.PACKAGE_NAME)
35+
JDOMExternalizerUtil.writeField(parent, TAG_RUN_ON_SAVE, state.isRunOnSave.toString(), false.toString())
36+
return parent
37+
}
38+
39+
override fun fromXml(element: Element): TemplateLintState {
40+
val isRunOnSave = JDOMExternalizerUtil.readField(element, TAG_RUN_ON_SAVE, false.toString()).toBoolean()
41+
return this.defaultState.copy(isRunOnSave = isRunOnSave)
3542
}
3643

3744
override fun getDefaultState(): TemplateLintState {
38-
return DEFAULT_STATE
45+
return TemplateLintState.DEFAULT
3946
}
4047

4148
override fun getInspectionClass(): Class<out JSLinterInspection> {
4249
return TemplateLintInspection::class.java
4350
}
44-
}
51+
52+
companion object {
53+
private const val TAG_RUN_ON_SAVE = "fix-on-save"
54+
55+
fun getInstance(project: Project) = getInstance(project, TemplateLintConfiguration::class.java)
56+
}
57+
}

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintEnabler.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import com.intellij.javascript.nodejs.PackageJsonData
22
import com.intellij.lang.javascript.JSBundle
3-
import com.intellij.lang.javascript.linter.JSLinterConfiguration.getInstance
43
import com.intellij.lang.javascript.linter.JSLinterGuesser
54
import com.intellij.lang.javascript.linter.JSLinterUtil
65
import com.intellij.notification.Notification
@@ -55,7 +54,7 @@ class TemplateLintEnabler : DirectoryProjectConfigurator {
5554
}
5655

5756
fun templateLintEnabled(project: Project, enabled: Boolean) {
58-
getInstance(project, TemplateLintConfiguration::class.java).isEnabled = enabled
57+
TemplateLintConfiguration.getInstance(project).isEnabled = enabled
5958
}
6059

6160
fun notifyEnabled(project: Project, dependency: String) {
@@ -72,4 +71,4 @@ class TemplateLintEnabler : DirectoryProjectConfigurator {
7271
}).notify(project)
7372
}
7473
}
75-
}
74+
}

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintExternalAnnotator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TemplateLintExternalAnnotator(onTheFly: Boolean = true) : JSLinterExternal
2727
}
2828

2929
override fun annotate(input: JSLinterInput<TemplateLintState>): JSLinterAnnotationResult? {
30-
return TemplateLintExternalRunner(this.isOnTheFly).execute(input)
30+
return TemplateLintExternalRunner(this.isOnTheFly).highlight(input)
3131
}
3232

3333
override fun apply(file: PsiFile, annotationResult: JSLinterAnnotationResult?, holder: AnnotationHolder) {
@@ -72,4 +72,4 @@ class TemplateLintExternalAnnotator(onTheFly: Boolean = true) : JSLinterExternal
7272

7373
return null
7474
}
75-
}
75+
}

0 commit comments

Comments
 (0)