Skip to content
Snippets Groups Projects
Commit 89cba244 authored by Johannes Mey's avatar Johannes Mey
Browse files

Merge branch 'master' into aspects

parents 63678718 68517123
Branches
Tags
No related merge requests found
Pipeline #9966 passed
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
# Ignore Gradle GUI config # Ignore Gradle GUI config
gradle-app.setting gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project # Cache of project
.gradletasknamecache .gradletasknamecache
...@@ -44,6 +42,9 @@ gen ...@@ -44,6 +42,9 @@ gen
*.tar.gz *.tar.gz
*.rar *.rar
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
stages:
- build
- test
- jar
- deploy
jar:
image: openjdk:11
stage: jar
script:
- ./gradlew --continue --console=plain --info buildPlugin
artifacts:
paths:
- "/builds/jastadd/*/build/libs/JastAddGrammar-*.jar"
import org.jetbrains.changelog.closure import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.markdownToHTML import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.grammarkit.tasks.GenerateLexer import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.grammarkit.tasks.GenerateParser import org.jetbrains.grammarkit.tasks.GenerateParser
fun properties(key: String) = project.findProperty(key).toString()
plugins { plugins {
// IDE support
idea id("idea")
// Java support // Java support
id("java") id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.5.10"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin // gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "0.6.5" id("org.jetbrains.intellij") version "1.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin // gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "0.6.2" id("org.jetbrains.changelog") version "1.1.2"
// Grammar-Kit - read more: https://github.com/JetBrains/Grammar-Kit // detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("org.jetbrains.grammarkit") version "2020.3.2" id("io.gitlab.arturbosch.detekt") version "1.17.1"
} // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
// Import variables from gradle.properties file
val pluginGroup: String by project
// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure.
// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29
val pluginName_: String by project
val pluginVersion: String by project
val pluginSinceBuild: String by project
val pluginUntilBuild: String by project
val pluginVerifierIdeVersions: String by project
val platformType: String by project
val platformVersion: String by project
val platformPlugins: String by project
val platformDownloadSources: String by project
id("org.jetbrains.grammarkit") version "2021.1.3"
apply {
plugin("idea")
plugin("org.jetbrains.grammarkit")
plugin("org.jetbrains.intellij")
} }
group = pluginGroup group = properties("pluginGroup")
version = pluginVersion version = properties("pluginVersion")
// Configure project's dependencies // Configure project's dependencies
repositories { repositories {
mavenCentral() mavenCentral()
jcenter() }
maven(url="https://www.jetbrains.com/intellij-repository/releases") dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.17.1")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
idea {
module {
generatedSourceDirs.add(file("./src/gen"))
}
} }
// Configure gradle-intellij-plugin plugin. // Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin // Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij { intellij {
pluginName = pluginName_ pluginName.set(properties("pluginName"))
version = platformVersion version.set(properties("platformVersion"))
type = platformType type.set(properties("platformType"))
downloadSources = platformDownloadSources.toBoolean() downloadSources.set(properties("platformDownloadSources").toBoolean())
updateSinceUntilBuild = true updateSinceUntilBuild.set(true)
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
setPlugins("java") plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
} }
sourceSets { sourceSets {
...@@ -68,20 +65,24 @@ sourceSets { ...@@ -68,20 +65,24 @@ sourceSets {
} }
} }
idea { // Configure gradle-changelog-plugin plugin.
module { // Read more: https://github.com/JetBrains/gradle-changelog-plugin
generatedSourceDirs.add(file("src/gen/java")) changelog {
} version = properties("pluginVersion")
groups = emptyList()
} }
//import org.jetbrains.grammarkit.tasks.* // Configure detekt plugin.
// // Read more: https://detekt.github.io/detekt/kotlindsl.html
grammarKit { detekt {
// version of IntelliJ patched JFlex (see bintray link below), Default is 1.7.0-1 config = files("./detekt-config.yml")
jflexRelease = "1.7.0-1" buildUponDefaultConfig = true
// tag or short commit hash of Grammar-Kit to use (see link below). Default is 2020.3.1 reports {
grammarKitRelease = "2020.3.1" html.enabled = false
xml.enabled = false
txt.enabled = false
}
} }
tasks { tasks {
...@@ -126,30 +127,27 @@ tasks { ...@@ -126,30 +127,27 @@ tasks {
dependsOn(generateAspectParser) dependsOn(generateAspectParser)
} }
// Set the compatibility versions to 1.8
withType<JavaCompile> { withType<JavaCompile> {
sourceCompatibility = "11" // "1.8" sourceCompatibility = "1.8"
targetCompatibility = "11" // "1.8" targetCompatibility = "1.8"
} }
withType<KotlinCompile> {
runIde { kotlinOptions.jvmTarget = "1.8"
jvmArgs("--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED")
} }
buildSearchableOptions { withType<Detekt> {
jvmArgs("--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED") jvmTarget = "1.8"
enabled = false // see https://youtrack.jetbrains.com/issue/KTIJ-782
} }
patchPluginXml { patchPluginXml {
version.set(properties("pluginVersion"))
version(pluginVersion) sinceBuild.set(properties("pluginSinceBuild"))
setSinceBuild(pluginSinceBuild) untilBuild.set(properties("pluginUntilBuild"))
untilBuild(pluginUntilBuild)
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription( pluginDescription.set(
closure { File(projectDir, "README.md").readText().lines().run {
File("./README.md").readText().lines().run {
val start = "<!-- Plugin description -->" val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->" val end = "<!-- Plugin description end -->"
...@@ -158,27 +156,22 @@ tasks { ...@@ -158,27 +156,22 @@ tasks {
} }
subList(indexOf(start) + 1, indexOf(end)) subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) } }.joinToString("\n").run { markdownToHTML(this) }
}
) )
// Get the latest available change notes from the changelog file // Get the latest available change notes from the changelog file
changeNotes( changeNotes.set(provider { changelog.getLatest().toHTML() })
closure {
changelog.getLatest().toHTML()
}
)
} }
runPluginVerifier { runPluginVerifier {
ideVersions(pluginVerifierIdeVersions) ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
} }
publishPlugin { publishPlugin {
dependsOn("patchChangelog") dependsOn("patchChangelog")
token(System.getenv("PUBLISH_TOKEN")) token.set(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first()) channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
} }
} }
# Default detekt configuration:
# https://github.com/detekt/detekt/blob/master/detekt-core/src/main/resources/default-detekt-config.yml
formatting:
Indentation:
continuationIndentSize: 8
ParameterListWrapping:
indentSize: 8
# IntelliJ Platform Artifacts Repositories # IntelliJ Platform Artifacts Repositories
# -> https://www.jetbrains.org/intellij/sdk/docs/reference_guide/intellij_artifacts.html # -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
pluginGroup = org.jetbrains.plugins.template
pluginName = IntelliJ Platform Plugin Template
pluginVersion = 0.10.1
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 202
pluginUntilBuild = 211.*
pluginGroup = org.jastadd
pluginName_ = JastAddGrammar
pluginVersion = 0.1.0
pluginSinceBuild = 201
pluginUntilBuild = 203.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions # See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2020.3.2 pluginVerifierIdeVersions = 2020.2.4, 2020.3.4, 2021.1.1
platformType = IC platformType = IC
platformVersion = 2020.3.2 platformVersion = 2020.2.4
platformDownloadSources = true platformDownloadSources = true
# Plugin Dependencies -> https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.modules.java platformPlugins = com.intellij.java
# Opt-out flag for bundling Kotlin standard library. # Opt-out flag for bundling Kotlin standard library.
# See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. # See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
kotlin.stdlib.default.dependency = false kotlin.stdlib.default.dependency = false
File added
...@@ -19,7 +19,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -19,7 +19,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
// add completion in definition of relations // add completion in definition of relations
extend(CompletionType.BASIC, PlatformPatterns.psiElement(GrammarTypes.ID).afterLeaf("rel", "<->", "->", "<-"), extend(CompletionType.BASIC, PlatformPatterns.psiElement(GrammarTypes.ID).afterLeaf("rel", "<->", "->", "<-"),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
...@@ -37,7 +37,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -37,7 +37,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
.afterLeaf(".") .afterLeaf(".")
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID))) .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID)))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel"))), .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel"))),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
...@@ -54,7 +54,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -54,7 +54,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
.afterLeaf(".") .afterLeaf(".")
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID))) .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID)))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("<-", "<->"))), .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("<-", "<->"))),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
...@@ -70,7 +70,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -70,7 +70,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(".")) .afterLeaf(PlatformPatterns.psiElement().afterLeaf("."))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID)))) .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID))))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel")))), .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel")))),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
...@@ -87,7 +87,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -87,7 +87,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("."))) .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(".")))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID))))) .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID)))))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel"))))), .afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel"))))),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
...@@ -102,7 +102,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -102,7 +102,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(GrammarTypes.ID) extend(CompletionType.BASIC, PlatformPatterns.psiElement(GrammarTypes.ID)
.withTextLengthLongerThan(COMPLETION_ELEMENT_SUFFIX.length()) // see https://intellij-support.jetbrains.com/hc/en-us/community/posts/206752355-The-dreaded-IntellijIdeaRulezzz-string .withTextLengthLongerThan(COMPLETION_ELEMENT_SUFFIX.length()) // see https://intellij-support.jetbrains.com/hc/en-us/community/posts/206752355-The-dreaded-IntellijIdeaRulezzz-string
.afterLeaf("rel", "<->", "<-"), .afterLeaf("rel", "<->", "<-"),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
...@@ -115,7 +115,7 @@ public class GrammarCompletionContributor extends CompletionContributor { ...@@ -115,7 +115,7 @@ public class GrammarCompletionContributor extends CompletionContributor {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(GrammarTypes.ID) extend(CompletionType.BASIC, PlatformPatterns.psiElement(GrammarTypes.ID)
.afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID)) .afterLeaf(PlatformPatterns.psiElement(GrammarTypes.ID))
.afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel")), .afterLeaf(PlatformPatterns.psiElement().afterLeaf("rel")),
new CompletionProvider<>() { new CompletionProvider<CompletionParameters>() {
public void addCompletions(@NotNull CompletionParameters parameters, public void addCompletions(@NotNull CompletionParameters parameters,
@NotNull ProcessingContext context, @NotNull ProcessingContext context,
@NotNull CompletionResultSet resultSet) { @NotNull CompletionResultSet resultSet) {
......
...@@ -3,6 +3,7 @@ package org.jastadd.tooling.grammar; ...@@ -3,6 +3,7 @@ package org.jastadd.tooling.grammar;
import com.intellij.formatting.*; import com.intellij.formatting.*;
import com.intellij.lang.ASTNode; import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
...@@ -37,16 +38,15 @@ public class GrammarFormattingModelBuilder implements FormattingModelBuilder { ...@@ -37,16 +38,15 @@ public class GrammarFormattingModelBuilder implements FormattingModelBuilder {
.beforeInside(GrammarTypes.SLASH, GrammarTypes.NTA_COMPONENT).none(); .beforeInside(GrammarTypes.SLASH, GrammarTypes.NTA_COMPONENT).none();
} }
@NotNull
@Override @Override
public FormattingModel createModel(FormattingContext context) { public @NotNull FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
return FormattingModelProvider return FormattingModelProvider
.createFormattingModelForPsiFile(context.getPsiElement().getContainingFile(), .createFormattingModelForPsiFile(element.getContainingFile(),
new GrammarBlock(context.getPsiElement().getNode(), new GrammarBlock(element.getNode(),
Wrap.createWrap(WrapType.NONE, false), Wrap.createWrap(WrapType.NONE, false),
Alignment.createAlignment(), Alignment.createAlignment(),
createSpaceBuilder(context.getCodeStyleSettings())), createSpaceBuilder(settings)),
context.getCodeStyleSettings()); settings);
} }
@Nullable @Nullable
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment