Skip to content
This repository was archived by the owner on Dec 8, 2023. It is now read-only.

Commit 437df1f

Browse files
authored
Merge pull request #25 from MarioAriasC/0.1.0
Version 0.1.0
2 parents a6ddab2 + 9297b1d commit 437df1f

File tree

14 files changed

+162
-43
lines changed

14 files changed

+162
-43
lines changed

.github/workflows/build.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,26 @@ jobs:
3232
version: ${{ steps.properties.outputs.version }}
3333
changelog: ${{ steps.properties.outputs.changelog }}
3434
steps:
35+
- name: Maximize Build Space
36+
run: |
37+
sudo rm -rf /usr/share/dotnet
38+
sudo rm -rf /usr/local/lib/android
39+
sudo rm -rf /opt/ghc
3540
3641
# Check out current repository
3742
- name: Fetch Sources
38-
uses: actions/checkout@v2.4.0
43+
uses: actions/checkout@v3
3944

4045
# Validate wrapper
4146
- name: Gradle Wrapper Validation
4247
uses: gradle/wrapper-validation-action@v1.0.4
4348

4449
# Setup Java 11 environment for the next steps
4550
- name: Setup Java
46-
uses: actions/setup-java@v2
51+
uses: actions/setup-java@v3
4752
with:
4853
distribution: zulu
4954
java-version: 11
50-
cache: gradle
5155

5256
# Set environment variables
5357
- name: Export Properties
@@ -76,14 +80,14 @@ jobs:
7680
# Collect Tests Result of failed tests
7781
- name: Collect Tests Result
7882
if: ${{ failure() }}
79-
uses: actions/upload-artifact@v2
83+
uses: actions/upload-artifact@v3
8084
with:
8185
name: tests-result
8286
path: ${{ github.workspace }}/build/reports/tests
8387

8488
# Cache Plugin Verifier IDEs
8589
- name: Setup Plugin Verifier IDEs Cache
86-
uses: actions/cache@v2.1.7
90+
uses: actions/cache@v3
8791
with:
8892
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
8993
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
@@ -95,14 +99,14 @@ jobs:
9599
# Collect Plugin Verifier Result
96100
- name: Collect Plugin Verifier Result
97101
if: ${{ always() }}
98-
uses: actions/upload-artifact@v2
102+
uses: actions/upload-artifact@v3
99103
with:
100104
name: pluginVerifier-result
101105
path: ${{ github.workspace }}/build/reports/pluginVerifier
102106

103107
# Run Qodana inspections
104108
- name: Qodana - Code Inspection
105-
uses: JetBrains/qodana-action@v4.2.5
109+
uses: JetBrains/qodana-action@v2022.2.1
106110

107111
# Prepare plugin archive content for creating artifact
108112
- name: Prepare Plugin Artifact
@@ -117,7 +121,7 @@ jobs:
117121
118122
# Store already-built plugin as an artifact for downloading
119123
- name: Upload artifact
120-
uses: actions/upload-artifact@v2.2.4
124+
uses: actions/upload-artifact@v3
121125
with:
122126
name: ${{ steps.artifact.outputs.filename }}
123127
path: ./build/distributions/content/*/*
@@ -129,11 +133,13 @@ jobs:
129133
if: github.event_name != 'pull_request'
130134
needs: build
131135
runs-on: ubuntu-latest
136+
permissions:
137+
contents: write
132138
steps:
133139

134140
# Check out current repository
135141
- name: Fetch Sources
136-
uses: actions/checkout@v2.4.0
142+
uses: actions/checkout@v3
137143

138144
# Remove old release drafts by using the curl request for the available releases with draft flag
139145
- name: Remove Old Release Drafts

.github/workflows/release.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ jobs:
1212
release:
1313
name: Publish Plugin
1414
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
1518
steps:
1619

1720
# Check out current repository
1821
- name: Fetch Sources
19-
uses: actions/checkout@v2.4.0
22+
uses: actions/checkout@v3
2023
with:
2124
ref: ${{ github.event.release.tag_name }}
2225

.github/workflows/run-ui-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ jobs:
3333

3434
# Check out current repository
3535
- name: Fetch Sources
36-
uses: actions/checkout@v2.4.0
36+
uses: actions/checkout@v3
3737

3838
# Setup Java 11 environment for the next steps
3939
- name: Setup Java
40-
uses: actions/setup-java@v2
40+
uses: actions/setup-java@v3
4141
with:
4242
distribution: zulu
4343
java-version: 11

CHANGELOG.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
# zig-support Changelog
44

55
## [Unreleased]
6+
### Added
67

8+
- [#24](https://github.com/MarioAriasC/zig-support/issues/24) Use `zig fmt` to format `*.zig` files. You can use
9+
the `Reformat code` action (By default `Cmd/Ctrl + Alt + L`)
10+
- Updated to the latest JetBrain's IntelliJ platform plugin version.
711
## [0.0.7]
8-
### Added
9-
- More Live Templates for Zig:
10-
- `St` -> `[]const u8`
11-
- `tst` -> Creates a test: `test "" {}`
12-
- `csd` -> Constant `Self` declaration: `const Self = @This();`
13-
- `ced` -> Enum
14-
- `cstd` -> Struct
15-
- `fn0` -> Function without parameters
16-
- `fn1` -> Function with one parameter
17-
- `fn2` -> Function with two parameters
12+
### Added
13+
- More Live Templates for Zig:
14+
- `St` -> `[]const u8`
15+
- `tst` -> Creates a test: `test "" {}`
16+
- `csd` -> Constant `Self` declaration: `const Self = @This();`
17+
- `ced` -> Enum
18+
- `cstd` -> Struct
19+
- `fn0` -> Function without parameters
20+
- `fn1` -> Function with one parameter
21+
- `fn2` -> Function with two parameters
1822
- Support for the new IDEA platform version 2022.2
1923

2024
## [0.0.6]

build.gradle.kts

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ plugins {
99
// Java support
1010
id("java")
1111
// Kotlin support
12-
id("org.jetbrains.kotlin.jvm") version "1.6.10"
12+
id("org.jetbrains.kotlin.jvm") version "1.7.10"
1313
// Gradle IntelliJ Plugin
14-
id("org.jetbrains.intellij") version "1.4.0"
14+
id("org.jetbrains.intellij") version "1.8.0"
1515
// Gradle Changelog Plugin
1616
id("org.jetbrains.changelog") version "1.3.1"
1717
// Gradle Qodana Plugin
@@ -34,6 +34,12 @@ sourceSets {
3434
}
3535
}
3636

37+
kotlin {
38+
jvmToolchain {
39+
languageVersion.set(JavaLanguageVersion.of(11))
40+
}
41+
}
42+
3743
// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
3844
intellij {
3945
pluginName.set(properties("pluginName"))
@@ -77,16 +83,6 @@ val generateZigLexer = task<GenerateLexer>("generateZigLexer") {
7783
}
7884

7985
tasks {
80-
// Set the JVM compatibility versions
81-
properties("javaVersion").let {
82-
withType<JavaCompile> {
83-
sourceCompatibility = it
84-
targetCompatibility = it
85-
}
86-
withType<KotlinCompile> {
87-
kotlinOptions.jvmTarget = it
88-
}
89-
}
9086

9187
wrapper {
9288
gradleVersion = properties("gradleVersion")

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
pluginGroup = com.github.marioariasc.zigsupport
55
pluginName = zig-support
6-
pluginVersion = 0.0.7
6+
pluginVersion = 0.1.0
77

88
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
99
# for insight into build numbers and IntelliJ Platform versions.
@@ -21,7 +21,7 @@ platformPlugins =
2121
# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
2222
javaVersion = 11
2323

24-
gradleVersion = 7.4
24+
gradleVersion = 7.5.1
2525

2626
# Opt-out flag for bundling Kotlin standard library.
2727
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ set -- \
205205
org.gradle.wrapper.GradleWrapperMain \
206206
"$@"
207207

208+
if ! command -v xargs >/dev/null 2>&1
209+
then
210+
die "xargs is not available"
211+
fi
208212
# Use "xargs" to parse quoted args.
209213
#
210214
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4040

4141
set JAVA_EXE=java.exe
4242
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
43+
if %ERRORLEVEL% equ 0 goto execute
4444

4545
echo.
4646
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7575

7676
:end
7777
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
78+
if %ERRORLEVEL% equ 0 goto mainEnd
7979

8080
:fail
8181
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8282
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
83+
set EXIT_CODE=%ERRORLEVEL%
84+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
85+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86+
exit /b %EXIT_CODE%
8587

8688
:mainEnd
8789
if "%OS%"=="Windows_NT" endlocal

qodana.yml

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
version: 1.0
55
profile:
66
name: qodana.recommended
7+
exclude:
8+
- name: All
9+
paths:
10+
- .qodana

src/main/kotlin/org/ziglang/jb/ZigLang.kt

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package org.ziglang.jb
22

3+
import com.intellij.execution.configurations.PathEnvironmentVariableUtil
34
import com.intellij.lang.Language
45
import org.ziglang.jb.reference.createLookup
56

67
object ZigLang : Language("Zig") {
8+
const val NOTIFICATION_GROUP_ID = "Zig"
9+
10+
val zigPath: String? by lazy {
11+
PathEnvironmentVariableUtil.findInPath("zig")?.absolutePath
12+
}
13+
714
val primitiveTypes = listOf(
815
"i8",
916
"u8",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.ziglang.jb.formatter
2+
3+
import com.intellij.execution.configurations.GeneralCommandLine
4+
import com.intellij.execution.process.CapturingProcessAdapter
5+
import com.intellij.execution.process.OSProcessHandler
6+
import com.intellij.execution.process.ProcessEvent
7+
import com.intellij.formatting.service.AsyncDocumentFormattingService
8+
import com.intellij.formatting.service.AsyncFormattingRequest
9+
import com.intellij.formatting.service.FormattingService
10+
import com.intellij.psi.PsiFile
11+
import org.ziglang.jb.ZigLang
12+
import org.ziglang.jb.psi.ZigFile
13+
import java.nio.charset.StandardCharsets
14+
15+
private const val FMT = "fmt"
16+
17+
private const val STDIN = "--stdin"
18+
19+
class ZigExternalFormatter : AsyncDocumentFormattingService() {
20+
override fun getFeatures(): MutableSet<FormattingService.Feature> = mutableSetOf(
21+
FormattingService.Feature.FORMAT_FRAGMENTS,
22+
FormattingService.Feature.AD_HOC_FORMATTING,
23+
FormattingService.Feature.OPTIMIZE_IMPORTS
24+
)
25+
26+
override fun canFormat(psiFile: PsiFile): Boolean = psiFile is ZigFile
27+
28+
override fun createFormattingTask(request: AsyncFormattingRequest): FormattingTask? {
29+
val zigPath = ZigLang.zigPath ?: return null
30+
val params = listOf(FMT, STDIN)
31+
val commandLine =
32+
GeneralCommandLine().withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
33+
.withExePath(zigPath).withParameters(params)
34+
val handler = OSProcessHandler(commandLine.withCharset(StandardCharsets.UTF_8))
35+
return object : FormattingTask {
36+
override fun run() {
37+
handler.processInput.use { out -> out.write(request.documentText.toByteArray()) }
38+
handler.addProcessListener(object : CapturingProcessAdapter() {
39+
override fun processTerminated(event: ProcessEvent) {
40+
val exitCode = event.exitCode
41+
if(exitCode == 0) {
42+
request.onTextReady(output.stdout)
43+
} else {
44+
request.onError(ZigLang.NOTIFICATION_GROUP_ID, output.stderr)
45+
}
46+
}
47+
})
48+
handler.startNotify()
49+
}
50+
51+
override fun cancel(): Boolean {
52+
handler.destroyProcess()
53+
return true
54+
}
55+
56+
}
57+
58+
}
59+
60+
override fun getNotificationGroupId(): String = ZigLang.NOTIFICATION_GROUP_ID
61+
62+
override fun getName(): String = ZigLang.NOTIFICATION_GROUP_ID
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.ziglang.jb.project
2+
3+
import com.intellij.openapi.projectRoots.*
4+
import org.jdom.Element
5+
6+
class ZigSdkType : SdkType("Zig") {
7+
override fun saveAdditionalData(p0: SdkAdditionalData, p1: Element) {
8+
TODO("Not yet implemented")
9+
}
10+
11+
override fun suggestHomePath(): String? {
12+
TODO("Not yet implemented")
13+
}
14+
15+
override fun isValidSdkHome(p0: String): Boolean {
16+
TODO("Not yet implemented")
17+
}
18+
19+
override fun suggestSdkName(p0: String?, p1: String): String {
20+
TODO("Not yet implemented")
21+
}
22+
23+
override fun createAdditionalDataConfigurable(p0: SdkModel, p1: SdkModificator): AdditionalDataConfigurable? {
24+
TODO("Not yet implemented")
25+
}
26+
27+
override fun getPresentableName(): String = "Zig SDK"
28+
}

0 commit comments

Comments
 (0)