Skip to content

Commit

Permalink
Merge pull request #91 from linux-china/main
Browse files Browse the repository at this point in the history
feat: Add //PREVIEW support
  • Loading branch information
linux-china authored Jun 11, 2023
2 parents 0da1890 + 4c15910 commit 0b099c2
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 6 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,54 @@

## [Unreleased]

## [0.24.3]

### Added

- Feat: Add `//PREVIEW` support

## [0.24.2]

### Fixed

- Fixed: honor JBANG_HOME, PATH and ~/.jbang/bin in that order when searching for jbang command
- Fixed: Compatible with IntelliJ IDEA 2023.2
- Fixed: Add more properties for alias object in `jbang-catalog-schema.json`

## [0.24.1]

### Fixed

- Fixed: Compatible with IntelliJ IDEA 2023.1

## [0.24.0]

### Added

- Added: enable download sources
- Added: attach sources for jbang lib when syncing dependencies
- Added: NATIVE_OPTIONS support
- Fixed: support for quoted arguments in the build configuration

## [0.23.0]

### Fixed

- Fixed: Compatible with IntelliJ IDEA 2022.3

## [0.22.0]

### Added

- Added: new `//MANIFEST` keyword to allow writing entries to `META-INF/manifest.mf`
- Added: `JBANG_HOME` environment variable support
- Added: icon for `build.jbang`
- Added: Java Scratch file support - https://github.com/jbangdev/jbang-idea/issues/68

## [0.21.0]

### Added

- Added: JBang icon for build.java, build.kt and build.groovy files
- Added: JBang live templates
* jbang: generate JBang declaration
Expand All @@ -42,6 +60,8 @@

## [0.20.0]

### Added

- Added: Java 18 Snippet support with `java`, `groovy`, `kotlin` lang attribute

```
Expand All @@ -60,44 +80,60 @@ public class SnippetApp {

## [0.19.0]

### Added

- Added: Catalog alias support for JBang run configuration
- Added: environment variables support for JBang run configuration
- Fixed: Force to refresh script info when click refresh button in JBang tool window

## [0.18.0]

### Added

- Added: code completion/navigation for //SOURCES
- Added: Java version synced within module
- Fixed: external library name always as jbang, and now is `${moduelName}-jbang`

## [0.17.0]

### Added

- Added: JBang ToolWindow listener to make load JBang script info automatically
- Added: open new JBang script files after creation from template
- Fix: save all documents when to sync DEPS

## [0.17.0]

### Added

- Added: JBang ToolWindow listener to make load JBang script info automatically
- Added: open new JBang script files after creation from template
- Fix: save all documents when to sync DEPS

## [0.16.0]

### Added

- Added: introduce zt-exec to call JBang command
- Added: introduce ProgressManager and Task.Backgroundable to sync dependencies asynchronously
- Fix: added descriptions to directive completions

## [0.15.0]

### Added

- Added: Support 2022.1 EAP

## [0.13.0]

### Added

- GAV completion with last version support

## [0.12.0]

### Added

- Bug fix: remove file editor listener because of performance

## [0.11.0]
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pluginGroup = dev.jbang.intellij.plugins
pluginName = jbang-idea-plugin
# SemVer format -> https://semver.org
pluginVersion = 0.24.2
pluginVersion = 0.24.3

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dev/jbang/idea/JBang.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ val NOTIFICATION_GROUP_FAILURE = "JBang Failure"

const val JBANG_DECLARE = "///usr/bin/env jbang"
const val JBANG_DECLARE_FULL = "///usr/bin/env jbang \"\$0\" \"\$@\" ; exit \$?"
val ALL_DIRECTIVES = listOf("JAVA", "DEPS", "GAV", "FILES", "SOURCES", "DESCRIPTION", "REPOS", "JAVAC_OPTIONS", "JAVA_OPTIONS", "JAVAAGENT", "CDS", "KOTLIN", "GROOVY")
val ALL_DIRECTIVES = listOf("JAVA", "DEPS", "GAV", "FILES", "SOURCES", "DESCRIPTION", "REPOS", "JAVAC_OPTIONS", "JAVA_OPTIONS", "PREVIEW", "JAVAAGENT", "CDS", "KOTLIN", "GROOVY")
val ALL_EXT_NAMES = listOf(".java", ".kt", ".jsh", ".groovy")

fun findCommandInPath(command: String): Path? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JBangGroovyCompletionContributor : JBangBaseDirectiveCompletionContributor
result: CompletionResultSet
) {
super.addCompletions(parameters, context, result)
result.addElement(LookupElementBuilder.create("GROOVY").withTailText("Groovy version", true))
result.addElement(LookupElementBuilder.create("GROOVY").withTailText(" Groovy version", true))
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
package dev.jbang.idea.completion.directive

import com.intellij.codeInsight.completion.CompletionParameters
import com.intellij.codeInsight.completion.CompletionResultSet
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.lang.java.JavaLanguage
import com.intellij.util.ProcessingContext


class JBangJavaCompletionContributor : JBangBaseDirectiveCompletionContributor(JavaLanguage.INSTANCE) {

override fun addCompletions(
parameters: CompletionParameters,
context: ProcessingContext,
result: CompletionResultSet
) {
super.addCompletions(parameters, context, result)
result.addElement(LookupElementBuilder.create("PREVIEW").withTailText(" --enable-preview flag", true))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JBangKotlinCompletionContributor : JBangBaseDirectiveCompletionContributor
result: CompletionResultSet
) {
super.addCompletions(parameters, context, result)
result.addElement(LookupElementBuilder.create("KOTLIN").withTailText("Kotlin version", true))
result.addElement(LookupElementBuilder.create("KOTLIN").withTailText(" Kotlin version", true))
}

}
6 changes: 5 additions & 1 deletion src/main/resources/jbang-catalog-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@
"14",
"15",
"16",
"17"
"17",
"18",
"19",
"20",
"21"
],
"description": "Java version, such as 8, 11, 17"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testCompletionInJava() {
myFixture.complete(CompletionType.BASIC);
List<String> lookupElementStrings = myFixture.getLookupElementStrings();
assertNotNull(lookupElementStrings);
assertSameElements(lookupElementStrings, "CDS ", "DEPS ", "DESCRIPTION ","FILES ", "GAV ", "JAVA ", "JAVA_OPTIONS ", "JAVAAGENT ", "JAVAC_OPTIONS ", "MANIFEST ", "NATIVE_OPTIONS ", "REPOS ", "SOURCES ");
assertSameElements(lookupElementStrings, "CDS ", "DEPS ", "DESCRIPTION ","FILES ", "GAV ", "JAVA ", "JAVA_OPTIONS ", "JAVAAGENT ", "JAVAC_OPTIONS ", "MANIFEST ", "NATIVE_OPTIONS ", "PREVIEW", "REPOS ", "SOURCES ");
}

// @Test disabled unttil can figure out why kotlin and groovy are not activated intests
Expand Down

0 comments on commit 0b099c2

Please sign in to comment.