Skip to content

Commit fb6df41

Browse files
committed
JCV Assistant
Related issues: #4 #5 #6
1 parent 47e7eb2 commit fb6df41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2319
-596
lines changed

.editorconfig

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[*]
2-
indent_size = 2
3-
4-
[*.{kt, kts}]
1+
[*.{kt,kts}]
52
disabled_rules = import-ordering
3+
indent_size = 2

README.md

+32-22
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,35 @@ IntelliJ IDEA plugin for an enhanced coding experience on JCV based projects.
88

99
## Table of contents
1010

11-
* [JCV autocomplete](#jcv-autocomplete)
12-
* [Validators covered](#validators-covered)
13-
* [How it works](#how-it-works)
14-
* [Live templates](#live-templates)
15-
* [Macros](#macros)
16-
17-
## JCV autocomplete
11+
* [Syntax Highlighting](#syntax-highlighting)
12+
* [Validator auto-completion](#validator-auto-completion)
13+
* [Replacement suggestions](#replacement-suggestions)
14+
15+
## Syntax Highlighting
16+
17+
It provides template colors and information about known JCV validators:
18+
19+
![](./screenshots/jcv-syntax_highlighting.png)
20+
21+
It will also detect invalid usages and give quick-fixes when possible:
22+
23+
![](./screenshots/jcv-validation-unexpected_whitespaces.png)
24+
25+
![](./screenshots/jcv-validation-unexpected_param.png)
26+
27+
![](./screenshots/jcv-validation-empty_param.png)
28+
29+
## Validator auto-completion
30+
31+
It provides autocompletion for jcv validators in json files.
32+
33+
Just start typing "{#" or any jcv validator id and press ctrl+space to see all the suggested validators:
34+
35+
![](./screenshots/jcv-autocomplete_all.png)
36+
37+
It also works for templated validators with suggested values:
38+
39+
![](./screenshots/jcv-autocomplete_param.png)
1840

1941
### Validators covered
2042
[JCV](https://github.com/ekino/jcv) is a library allowing you to compare JSON contents with embedded validation.
@@ -26,20 +48,8 @@ designed to cover the most common needs when validating data with non-predictabl
2648

2749
This plugin offers autocompletion on all the validators of these two projects to date.
2850

29-
### How it works
30-
31-
#### Live templates
32-
The plugin uses [live templates](https://www.jetbrains.com/help/idea/using-live-templates.html) to offer autocompletion
33-
on validators (including the ones with parameters).
34-
35-
It will generate two sets of live templates in your IDEA configuration:
36-
![](./screenshots/live_templates.png)
51+
## Replacement suggestions
3752

38-
#### Macros
39-
JCV plugin will generate two macros that are used in the JCV live templates (macros are functions that can be used in
40-
[live template variables](https://www.jetbrains.com/help/idea/template-variables.html)). They are common to all the live templates,
41-
so you can use these new ones for other purposes too.
53+
It will suggest smart replacements of json value to matching validators:
4254

43-
These macros are:
44-
* `dateFormats()`: it returns a list of date-time formats, with `iso_instant` as its default value
45-
* `languages()`: it returns a list of available languages (based on `java.util.Locale`), with `fr` as its default value
55+
![](./screenshots/jcv-suggestion-date_time_format.png)

build.gradle.kts

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import com.ekino.oss.jcv.idea_plugin.autocomplete.template_generator.TemplateGeneratorTask
21
import org.jetbrains.intellij.tasks.PublishTask
32
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
43

54
plugins {
6-
kotlin("jvm") version "1.3.72"
7-
id("org.jetbrains.intellij") version "0.4.21"
5+
kotlin("jvm") version "1.4.20"
6+
id("org.jetbrains.intellij") version "0.6.4"
87
}
98

109
intellij {
11-
version = "IC-2020.1" //IntelliJ IDEA 2020.1 dependency; for a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
10+
version =
11+
"IC-2020.1" //IntelliJ IDEA 2020.1 dependency; for a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
1212
pluginName = "JCV"
1313
updateSinceUntilBuild = false //Disables updating since-build attribute in plugin.xml
1414
}
@@ -18,17 +18,31 @@ repositories {
1818
}
1919

2020
dependencies {
21+
implementation("org.apache.commons:commons-text:1.9")
22+
2123
testImplementation("com.willowtreeapps.assertk:assertk-jvm:${property("assertk-jvm.version")}")
2224
testImplementation("org.junit.jupiter:junit-jupiter:${property("junit.version")}")
25+
testImplementation("junit:junit:4.13")
26+
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${property("junit.version")}")
2327
}
2428

2529
tasks {
2630
withType<KotlinCompile> {
2731
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
32+
kotlinOptions.apiVersion = "1.3"
2833
}
2934

3035
withType<Test> {
31-
useJUnitPlatform()
36+
useJUnitPlatform {
37+
includeEngines = setOf("junit-jupiter", "junit-vintage")
38+
}
39+
jvmArgs(
40+
"-Djunit.jupiter.testinstance.lifecycle.default=per_class",
41+
"-Duser.language=en"
42+
)
43+
testLogging {
44+
events("passed", "skipped", "failed")
45+
}
3246
}
3347

3448
withType<PublishTask> {
@@ -61,15 +75,6 @@ tasks {
6175
println(version)
6276
}
6377
}
64-
65-
create(name = "generateTemplates", type = TemplateGeneratorTask::class) {
66-
resourceFiles = setOf("jcv", "jcv-db")
67-
.associateWith { file("$buildDir/resources/main/$it.xml") }
68-
}
69-
70-
named("jar").configure {
71-
dependsOn("generateTemplates")
72-
}
7378
}
7479

7580
fun prop(name: String): String? =

buildSrc/build.gradle.kts

-30
This file was deleted.

buildSrc/gradle.properties

-5
This file was deleted.

buildSrc/settings.gradle

Whitespace-only changes.

buildSrc/src/main/kotlin/com/ekino/oss/jcv/idea_plugin/autocomplete/template_generator/JcvValidator.kt

-27
This file was deleted.

buildSrc/src/main/kotlin/com/ekino/oss/jcv/idea_plugin/autocomplete/template_generator/TemplateGeneratorTask.kt

-25
This file was deleted.

buildSrc/src/main/kotlin/com/ekino/oss/jcv/idea_plugin/autocomplete/template_generator/TemplateSet.kt

-64
This file was deleted.

buildSrc/src/main/kotlin/com/ekino/oss/jcv/idea_plugin/autocomplete/template_generator/TemplateSetGenerator.kt

-38
This file was deleted.

buildSrc/src/main/resources/jcv-db-validators.yml

-7
This file was deleted.

0 commit comments

Comments
 (0)