Skip to content

Commit aefce18

Browse files
committed
sync with master
1 parent 398b065 commit aefce18

17 files changed

+69
-248
lines changed

build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ plugins {
1313

1414

1515
group = "com.emberjs"
16-
version = "2021.3.11"
16+
version = "2020.3.30"
1717

1818
// Configure project's dependencies
1919
repositories {
2020
mavenCentral()
2121
}
2222
dependencies {
23-
testImplementation("org.assertj:assertj-core:3.21.0")
24-
testImplementation(kotlin("test"))
23+
testImplementation("org.jetbrains.kotlin:kotlin-test")
24+
testImplementation("org.assertj:assertj-core:3.22.0")
25+
implementation(kotlin("test"))
2526
}
2627

2728
// Configure gradle-intellij-plugin plugin.
@@ -31,7 +32,7 @@ intellij {
3132

3233
// see https://www.jetbrains.com/intellij-repository/releases/
3334
// and https://www.jetbrains.com/intellij-repository/snapshots/
34-
version.set("2021.3")
35+
version.set("2020.3")
3536
type.set("IU")
3637

3738
downloadSources.set(!System.getenv().containsKey("CI"))
@@ -41,7 +42,7 @@ intellij {
4142
// Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
4243
//
4344
// com.dmarcotte.handlebars: see https://plugins.jetbrains.com/plugin/6884-handlebars-mustache/versions
44-
plugins.set(listOf("JavaScriptLanguage", "CSS", "yaml", "com.dmarcotte.handlebars:213.5744.190"))
45+
plugins.set(listOf("JavaScriptLanguage", "CSS", "yaml", "com.dmarcotte.handlebars:203.5981.152"))
4546

4647
sandboxDir.set(project.rootDir.canonicalPath + "/.sandbox")
4748
}
@@ -60,6 +61,9 @@ tasks {
6061
token.set(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken"))
6162
}
6263

64+
buildSearchableOptions {
65+
onlyIf {false}
66+
}
6367
}
6468

6569
tasks.test {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class EmberAttributeDescriptor(val context: XmlTag, value: String, isYield: Bool
105105
return null
106106
}
107107
if (this.values.isNotEmpty() && value != null) {
108-
if (value.startsWith("{{") || value.startsWith("\"{{")) {
108+
if (value == "" || value.startsWith("{{") || value.startsWith("\"{{")) {
109109
return null;
110110
}
111111
if (this.values.contains(value)) {

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

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11

2-
import com.intellij.ide.actionsOnSave.ActionOnSaveBackedByOwnConfigurable
3-
import com.intellij.ide.actionsOnSave.ActionOnSaveContext
42
import com.intellij.lang.javascript.linter.JSLinterConfigurable
53
import com.intellij.lang.javascript.linter.JSLinterView
64
import com.intellij.openapi.project.Project
7-
import com.intellij.ui.components.ActionLink
85

96
class TemplateLintConfigurable(project: Project, fullModeDialog: Boolean = false) :
107
JSLinterConfigurable<TemplateLintState>(
@@ -28,45 +25,4 @@ class TemplateLintConfigurable(project: Project, fullModeDialog: Boolean = false
2825
return TemplateLintBundle.message("hbs.lint.configurable.name")
2926
}
3027

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-
}
28+
}

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

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,40 @@ 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
98
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()
1314
private val myPackage: JSLinterPackage = JSLinterPackage(project, TemplateLintUtil.PACKAGE_NAME)
1415

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

20-
return state.copy(
21-
myInterpreterRef = this.myPackage.interpreter,
22-
myTemplateLintPackage = constantPackage
23-
)
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
2427
}
2528

2629
override fun savePrivateSettings(state: TemplateLintState) {
2730
this.myPackage.force(state.interpreterRef, state.templateLintPackage)
2831
}
2932

3033
override fun toXml(state: TemplateLintState): Element? {
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)
34+
return null
4235
}
4336

4437
override fun getDefaultState(): TemplateLintState {
45-
return TemplateLintState.DEFAULT
38+
return DEFAULT_STATE
4639
}
4740

4841
override fun getInspectionClass(): Class<out JSLinterInspection> {
4942
return TemplateLintInspection::class.java
5043
}
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-
}
44+
}

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

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

5657
fun templateLintEnabled(project: Project, enabled: Boolean) {
57-
TemplateLintConfiguration.getInstance(project).isEnabled = enabled
58+
getInstance(project, TemplateLintConfiguration::class.java).isEnabled = enabled
5859
}
5960

6061
fun notifyEnabled(project: Project, dependency: String) {
@@ -71,4 +72,4 @@ class TemplateLintEnabler : DirectoryProjectConfigurator {
7172
}).notify(project)
7273
}
7374
}
74-
}
75+
}

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).highlight(input)
30+
return TemplateLintExternalRunner(this.isOnTheFly).execute(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+
}

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ class TemplateLintExternalRunner(private val myIsOnTheFly: Boolean = false) {
2727
companion object {
2828
private val LOG = Logger.getInstance(TemplateLintExternalRunner::class.java)
2929

30-
private fun templateLint(input: JSLinterInput<TemplateLintState>, sessionData: TemplateLintSessionData): JSLinterAnnotationResult {
30+
private fun templateLint(input: JSLinterInput<TemplateLintState>, sessionData: TemplateLintSessionData): JSLinterAnnotationResult? {
3131
val startNanoTime = System.nanoTime()
3232
val result = runProcess(input, sessionData)
3333
logEnd(startNanoTime, result.errors.size)
3434
return result
3535
}
3636

3737
private fun runProcess(input: JSLinterInput<TemplateLintState>, sessionData: TemplateLintSessionData): JSLinterAnnotationResult {
38+
var result: JSLinterAnnotationResult?
3839
try {
3940
val commandLine = createCommandLine(sessionData)
4041
logStart(sessionData, commandLine)
@@ -62,13 +63,14 @@ class TemplateLintExternalRunner(private val myIsOnTheFly: Boolean = false) {
6263
}
6364
return createFileLevelWarning(stdout, input, commandLine, processHandler, output)
6465
}
65-
return JSLinterAnnotationResult.createLinterResult(input, errors, null as VirtualFile?)
66+
result = JSLinterAnnotationResult.createLinterResult(input, errors, null as VirtualFile?)
6667
} catch (exception: Exception) {
6768
return createFileLevelWarning(exception.message!!, input, commandLine, processHandler, output)
6869
}
6970
} catch (executionException: ExecutionException) {
7071
return createFileLevelWarning(executionException.message!!, input)
7172
}
73+
return result!!
7274
}
7375

7476
@Throws(IOException::class)
@@ -127,10 +129,6 @@ class TemplateLintExternalRunner(private val myIsOnTheFly: Boolean = false) {
127129
}
128130
// TODO: else case?
129131

130-
if (sessionData.fix) {
131-
commandLine.addParameter("--fix")
132-
}
133-
134132
NodeCommandLineConfigurator
135133
.find(sessionData.interpreter)
136134
.configure(commandLine)
@@ -172,15 +170,7 @@ class TemplateLintExternalRunner(private val myIsOnTheFly: Boolean = false) {
172170
}
173171
}
174172

175-
fun highlight(input: JSLinterInput<TemplateLintState>): JSLinterAnnotationResult? {
176-
return execute(input, false)
177-
}
178-
179-
fun fixFile(input: JSLinterInput<TemplateLintState>) {
180-
execute(input, true)
181-
}
182-
183-
private fun execute(input: JSLinterInput<TemplateLintState>, fix: Boolean): JSLinterAnnotationResult? {
173+
fun execute(input: JSLinterInput<TemplateLintState>): JSLinterAnnotationResult? {
184174
val fileToLint = input.virtualFile
185175
return if (fileToLint.isValid && fileToLint.parent != null) {
186176
try {
@@ -214,7 +204,7 @@ class TemplateLintExternalRunner(private val myIsOnTheFly: Boolean = false) {
214204
JSLinterAnnotationResult.create(input, error, null as VirtualFile?)
215205
} else {
216206
val templateLintPackage = TemplateLintPackage.fromNodePackage(input.project, state.templateLintPackage)
217-
val sessionData = TemplateLintSessionData(interpreter, templateLintPackage, workingDirectory, fileToLint, input.fileContent, fix)
207+
val sessionData = TemplateLintSessionData(interpreter, templateLintPackage, workingDirectory, fileToLint, input.fileContent)
218208
templateLint(input, sessionData)
219209
}
220210
}
@@ -227,4 +217,4 @@ class TemplateLintExternalRunner(private val myIsOnTheFly: Boolean = false) {
227217
null
228218
}
229219
}
230-
}
220+
}

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

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)