Skip to content

Commit

Permalink
General update-to-date refactor
Browse files Browse the repository at this point in the history
+ comply with the newest IDEA API
+ minor highlight & linting improvement
+ integrate parser files into build assets
  • Loading branch information
Phosphorus15 committed Sep 20, 2022
1 parent 89204d6 commit 6bd2399
Show file tree
Hide file tree
Showing 55 changed files with 2,809 additions and 101 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ jobs:
java-version: 11
- name: Settle gradlew
run: chmod +x gradlew
- name: Parser generation
env:
CI: GitHub_Workflows
uses: eskatos/gradle-command-action@v1
with:
# Gradle command line arguments, see gradle --help
arguments: generatePrologParser generatePrologLexer
# since 0.1.3.0-beta2, the parsers are not auto-gened but was fine-tuned instead
# - name: Parser generation
# env:
# CI: GitHub_Workflows
# uses: eskatos/gradle-command-action@v1
# with:
# # Gradle command line arguments, see gradle --help
# arguments: generatePrologParser generatePrologLexer
- name: Gradle Command
env:
CI: GitHub_Workflows
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
run: chmod +x gradlew
- name: Publish token
run: pwd & echo intellijPublishToken=$INTELLIJPUBLISHTOKEN > intellij-prolog/gradle.properties
- name: Parser generation
env:
CI: GitHub_Workflows
uses: eskatos/gradle-command-action@v1
with:
# Gradle command line arguments, see gradle --help
arguments: generatePrologParser generatePrologLexer
# - name: Parser generation
# env:
# CI: GitHub_Workflows
# uses: eskatos/gradle-command-action@v1
# with:
# # Gradle command line arguments, see gradle --help
# arguments: generatePrologParser generatePrologLexer
- name: Gradle Command
env:
CI: GitHub_Workflows
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.gradle/
.idea/
src/main/gen/
#src/main/gen/ this must no longer be true because the current lexer is tailored
build/
idea-flex.skeleton
jflex-1.7.0-2.jar
Expand Down
121 changes: 71 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
buildscript {
repositories {
if (!System.getenv("CI")?.trim()) {
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
} else {
mavenCentral()
}
mavenCentral()
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
maven { url "https://cache-redirector.jetbrains.com/intellij-dependencies" }
}
dependencies {
classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.4.16"
classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-grammarkit-plugin:2020.1"
// classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.7.0"
// classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-grammarkit-plugin:2020.1"
}
}

plugins {
id 'scala'
id "org.jetbrains.intellij" version '1.9.0'
// id "org.jetbrains.grammarkit" version "2021.2.2"
}

apply plugin: "org.jetbrains.intellij"
apply plugin: "org.jetbrains.grammarkit"
//apply plugin: "org.jetbrains.intellij"
//apply plugin: "org.jetbrains.grammarkit"

group 'tech.phosphorus'
version '0.1.2.2-lts'
version '0.1.3.0-beta2'

sourceCompatibility = 1.8
sourceCompatibility = 11

repositories {
if (!System.getenv("CI")?.trim()) {
maven { url 'http://maven.aliyun.com/nexus/content/repositories/central/' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
} else {
mavenCentral()
}
mavenCentral()
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
maven { url "https://cache-redirector.jetbrains.com/intellij-dependencies" }
}

allprojects {
Expand All @@ -42,18 +39,34 @@ allprojects {
}

dependencies {
compile group: 'org.eclipse.mylyn.github', name: 'org.eclipse.egit.github.core', version: '2.1.5'
implementation group: 'org.eclipse.mylyn.github', name: 'org.eclipse.egit.github.core', version: '2.1.5'
implementation 'org.scala-lang:scala-library:2.11.12'
testImplementation 'org.scalatest:scalatest_2.11:3.0.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
}

publishPlugin {
Properties properties = new Properties()
try {
properties.load(new FileInputStream("gradle.properties"))
token properties.getProperty("intellijPublishToken")
} catch(IOException ignored) {
token = properties.getProperty("intellijPublishToken")
} catch (IOException ignored) {
}
}

runPluginVerifier {
ideVersions = ["IC-2022.2.2", "CL-2022.2.3", "WS-2022.2.2"]
}

signPlugin {
Properties properties = new Properties()
try {
properties.load(new FileInputStream("gradle.properties"))
certificateChain = Files.readString(Paths.get(properties.getProperty("keyChain"))).stripIndent()
privateKey = Files.readString(Paths.get(properties.getProperty("privateKey"))).stripIndent()
password = properties.getProperty("signPassword")
} catch (IOException ignored) {
// ignored.printStackTrace()
}
}

Expand Down Expand Up @@ -87,43 +100,48 @@ intellij {
if (!System.getenv("CI")?.trim() && localDist != null) {
localPath localDist.toString()
} else {
version "IU-2020.1"
type = "IU"
version = "2022.2.2"
}
}

sourceSets.main.scala.srcDirs = ['src/main/gen', 'src/main/scala']

import org.jetbrains.grammarkit.tasks.*
//apply plugin: 'org.jetbrains.grammarkit'
//
//import org.jetbrains.grammarkit.tasks.GenerateLexerTask
//import org.jetbrains.grammarkit.tasks.GenerateParserTask

import java.nio.file.Files
import java.nio.file.Paths

task generatePrologLexer(type: GenerateLexer) {
source = "src/main/lang/prologLexer.flex"

targetDir = "src/main/gen/tech/phosphorus/intellij/prolog"

targetClass = "PrologLexer"

purgeOldFiles = true
}

task generatePrologParser(type: GenerateParser) {
// source bnf file
source = "src/main/lang/prolog.bnf"

// optional, task-specific root for the generated files. Default: none
targetRoot = 'src/main/gen'

// path to a parser file, relative to the targetRoot
pathToParser = 'tech/phosphorus/intellij/prolog/psi/PrologParser.java'

// path to a directory with generated psi files, relative to the targetRoot
pathToPsiRoot = 'tech/phosphorus/intellij/prolog/psi/'

// if set, plugin will remove a parser output file and psi output directory before generating new ones. Default: false
purgeOldFiles = true
}
//task generatePrologLexer(type: GenerateLexer) {
// source = "src/main/lang/prologLexer.flex"
//
// targetDir = "src/main/gen/tech/phosphorus/intellij/prolog"
//
// targetClass = "PrologLexer"
//
// purgeOldFiles = true
//}
//
//task generatePrologParser(type: GenerateParser) {
// // source bnf file
// source = "src/main/lang/prolog.bnf"
//
// // optional, task-specific root for the generated files. Default: none
// targetRoot = 'src/main/gen'
//
// // path to a parser file, relative to the targetRoot
// pathToParser = 'tech/phosphorus/intellij/prolog/psi/PrologParser.java'
//
// // path to a directory with generated psi files, relative to the targetRoot
// pathToPsiRoot = 'tech/phosphorus/intellij/prolog/psi/'
//
// // if set, plugin will remove a parser output file and psi output directory before generating new ones. Default: false
// purgeOldFiles = true
//}

task "generateDirs" {
sourceSets*.scala.srcDirs*.each {
Expand All @@ -132,7 +150,10 @@ task "generateDirs" {
}

patchPluginXml {
changeNotes """<ul>
<li>patch for version compatibility</li>
changeNotes = """<ul>
<li>refactor for latest (2022.2.2) IDEA</li>
<li>improve API compatibility</li>
<li>improved singletion checking</li>
<li>fix minor highlight bug within identifiers</li>
</ul>"""
}
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Thu Mar 05 15:32:06 GMT+08:00 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 6bd2399

Please sign in to comment.