Skip to content

Commit 4b31af7

Browse files
authored
Merge pull request #45 from akefirad/GH-0-prepare-for-release
GH-0 cleanup and release v0.1.0
2 parents 0da7ce5 + 500b82f commit 4b31af7

File tree

5 files changed

+63
-67
lines changed

5 files changed

+63
-67
lines changed

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,41 @@
55
[![Downloads](https://img.shields.io/jetbrains/plugin/d/26269-groom.svg)](https://plugins.jetbrains.com/plugin/26269-groom)
66
[![codecov](https://codecov.io/gh/akefirad/groom/graph/badge.svg?token=ITYIWY5V29)](https://codecov.io/gh/akefirad/groom)
77

8-
## Template ToDo list
9-
- [x] Create a new [IntelliJ Platform Plugin Template][template] project.
10-
- [x] Get familiar with the [template documentation][template].
11-
- [x] Adjust the [pluginGroup](./gradle.properties) and [pluginName](./gradle.properties), as well as the [id](./src/main/resources/META-INF/plugin.xml) and [sources package](./src/main/kotlin).
12-
- [x] Adjust the plugin description in `README` (see [Tips][docs:plugin-description])
13-
- [x] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate).
14-
- [x] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time.
15-
- [x] Set the `26269-groom` in the above README badges. You can obtain it once the plugin is published to JetBrains Marketplace.
16-
- [x] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables).
17-
- [x] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate).
18-
- [x] Click the <kbd>Watch</kbd> button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes.
19-
208
<!-- Plugin description -->
21-
This a plugin for better Groovy development experience in IntelliJ IDEA.
9+
A plugin for better Groovy development experience in IntelliJ IDEA.
2210
<!-- Plugin description end -->
2311

12+
## Features
13+
14+
- Folding for lists and maps in Groovy code
15+
- Folding for (Spock) specification labels (e.g. given, when, then, etc.)
16+
- Highlighting for (Spock) specification labels
17+
- Inlay hints for implicit assertions in Spock specifications expectation blocks
18+
2419
## Installation
2520

2621
- Using the IDE built-in plugin system:
27-
22+
2823
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "groom"</kbd> >
2924
<kbd>Install</kbd>
30-
25+
3126
- Using JetBrains Marketplace:
3227

33-
Go to [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/26269-groom) and install it by clicking the <kbd>Install to ...</kbd> button in case your IDE is running.
28+
Go to [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/26269-groom) and install it by clicking the <kbd>
29+
Install to ...</kbd> button in case your IDE is running.
3430

35-
You can also download the [latest release](https://plugins.jetbrains.com/plugin/26269-groom/versions) from JetBrains Marketplace and install it manually using
31+
You can also download the [latest release](https://plugins.jetbrains.com/plugin/26269-groom/versions) from JetBrains
32+
Marketplace and install it manually using
3633
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd>
3734

3835
- Manually:
3936

4037
Download the [latest release](https://github.com/akefirad/groom/releases/latest) and install it manually using
4138
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd>
4239

43-
4440
---
4541
Plugin based on the [IntelliJ Platform Plugin Template][template].
4642

4743
[template]: https://github.com/JetBrains/intellij-platform-plugin-template
44+
4845
[docs:plugin-description]: https://plugins.jetbrains.com/docs/intellij/plugin-user-experience.html#plugin-description-and-presentation

src/main/kotlin/com/akefirad/groom/spock/AssertInlayHintsProvider.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.akefirad.groom.spock
22

3-
import com.akefirad.groom.spock.SpockSpecUtils.hasAnySpecification
43
import com.akefirad.groom.spock.SpockSpecUtils.isSpeckLabel
54
import com.intellij.codeInsight.hints.declarative.InlayHintsProvider
65
import com.intellij.codeInsight.hints.declarative.InlayTreeSink
@@ -11,6 +10,7 @@ import com.intellij.openapi.editor.Editor
1110
import com.intellij.openapi.project.PossiblyDumbAware
1211
import com.intellij.psi.PsiElement
1312
import com.intellij.psi.PsiFile
13+
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
1414
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock
1515
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock
1616
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression
@@ -20,14 +20,16 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe
2020
import org.jetbrains.plugins.groovy.lang.psi.util.isWhiteSpaceOrNewLine
2121

2222
class AssertInlayHintsProvider : InlayHintsProvider, PossiblyDumbAware {
23-
override fun createCollector(file: PsiFile, editor: Editor) =
24-
if (file.hasAnySpecification()) AssertInlayHintsCollector() else null
23+
override fun createCollector(file: PsiFile, editor: Editor): AssertInlayHintsCollector? {
24+
// TODO: check if it's an actual test file!
25+
return if (file is GroovyFile) AssertInlayHintsCollector() else null
26+
}
2527
}
2628

2729
class AssertInlayHintsCollector : SharedBypassCollector {
2830

2931
override fun collectFromElement(element: PsiElement, sink: InlayTreeSink) {
30-
if (element is GrMethod)
32+
if (element is GrMethod) // TODO: check if it's a test method!
3133
collectFromMethod(element, sink)
3234
}
3335

src/main/kotlin/com/akefirad/groom/spock/SpockSpecUtils.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.akefirad.groom.spock
22

3-
import com.intellij.psi.PsiClass
43
import com.intellij.psi.PsiElement
5-
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
64
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement
75
import kotlin.contracts.contract
86

97
object SpockSpecUtils {
8+
/*
109
private const val SPOCK_SPEC_CLASS: String = "spock.lang.Specification"
1110
1211
@JvmStatic
@@ -16,16 +15,15 @@ object SpockSpecUtils {
1615
.any(SpockSpecUtils::hasSpecificationSuperClass)
1716
}
1817
19-
/*
2018
fun PsiElement.isSpecification(): Boolean {
2119
val clazz = PsiTreeUtil.findFirstParent(this, true) { it is PsiClass }
2220
return clazz != null && hasSpecificationSuperClass(clazz as PsiClass)
2321
}
24-
*/
2522
2623
private fun hasSpecificationSuperClass(clazz: PsiClass) =
2724
generateSequence(clazz) { it.superClass }
2825
.any { it.qualifiedName == SPOCK_SPEC_CLASS }
26+
*/
2927

3028
fun PsiElement.isSpeckLabel(): Boolean {
3129
contract {

src/test/groovy/com/akefirad/groom/spock/AssertInlayHintsProviderTest.groovy

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
2626

2727
@Test
2828
void 'provider should provide implicit assert to simple spec'() {
29-
def text = """
29+
def code = """
3030
$SpecificationClass
3131
3232
class MySpec extends Specification {
@@ -63,12 +63,12 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
6363
}
6464
}
6565
""".stripIndent()
66-
testAnnotations(text)
66+
testAnnotations(code)
6767
}
6868

6969
@Test
7070
void 'provider should provide implicit assert to simple spec with repeated labels'() {
71-
def text = """
71+
def code = """
7272
$SpecificationClass
7373
7474
class MySpec extends Specification {
@@ -125,12 +125,12 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
125125
}
126126
}
127127
""".stripIndent()
128-
testAnnotations(text)
128+
testAnnotations(code)
129129
}
130130

131131
@Test
132132
void 'provider should provide implicit assert'() {
133-
def text = """
133+
def code = """
134134
$SpecificationClass
135135
136136
abstract class MyBase {
@@ -212,12 +212,12 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
212212
}
213213
}
214214
""".stripIndent()
215-
testAnnotations(text)
215+
testAnnotations(code)
216216
}
217217

218218
@Test
219219
void 'provider should provide implicit assert when using verifyAll'() {
220-
def text = """
220+
def code = """
221221
$SpecificationClass
222222
223223
class MySpec extends Specification {
@@ -250,12 +250,12 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
250250
}
251251
}
252252
""".stripIndent()
253-
testAnnotations(text)
253+
testAnnotations(code)
254254
}
255255

256256
@Test
257257
void 'provider should provide implicit assert when using with'() {
258-
def text = """
258+
def code = """
259259
$SpecificationClass
260260
261261
class MySpec extends Specification {
@@ -293,12 +293,12 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
293293
}
294294
}
295295
""".stripIndent()
296-
testAnnotations(text)
296+
testAnnotations(code)
297297
}
298298

299299
@Test
300300
void 'provider should not provide implicit assert when assert is present'() {
301-
def text = """
301+
def code = """
302302
$SpecificationClass
303303
304304
class MySpec extends Specification {
@@ -332,11 +332,37 @@ class AssertInlayHintsProviderTest extends LightPlatformCodeInsightFixture4TestC
332332
}
333333
}
334334
""".stripIndent()
335-
testAnnotations(text)
335+
testAnnotations(code)
336336
}
337337

338-
private void testAnnotations(@Language("Groovy") String text) {
339-
doTestProvider("MySpec.groovy", text, new AssertInlayHintsProvider())
338+
@Test
339+
void 'provider should do nothing when file is not GroovyFile'() {
340+
given:
341+
def code = '''
342+
class SampleSpec extends Specification {
343+
void test_method() <fold text='{...}'>{
344+
given: "some given block"
345+
var foo = 'foo';
346+
347+
when: "some when block"
348+
var baz = foo + bar;
349+
350+
then: "some then block"
351+
baz == 'foobar';
352+
}</fold>
353+
}
354+
355+
'''.stripIndent()
356+
357+
when:
358+
doTestProvider("MySpec.java", code, new AssertInlayHintsProvider())
359+
360+
then:
361+
true // TODO: How to check it's not folded?
362+
}
363+
364+
private void testAnnotations(@Language("Groovy") String code) {
365+
doTestProvider("MySpec.groovy", code, new AssertInlayHintsProvider())
340366
}
341367

342368
@SuppressWarnings("UnstableApiUsage")

src/test/groovy/com/akefirad/groom/spock/SpockSpecUtilsTest.groovy

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

0 commit comments

Comments
 (0)