backport: 16.1.0
This commit is contained in:
parent
c209831fa5
commit
b707d6299c
18 changed files with 238 additions and 92 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -15,6 +15,21 @@ Changelog structure reference:
|
||||||
|
|
||||||
# ZigBrains
|
# ZigBrains
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [16.1.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Zon
|
||||||
|
- Support for .lazy dependency property
|
||||||
|
- Comment/uncomment hotkey support
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Zon
|
||||||
|
- More reliable autocomplete
|
||||||
|
|
||||||
## [16.0.0]
|
## [16.0.0]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -14,7 +14,7 @@ plugins {
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
`java-library`
|
`java-library`
|
||||||
id("org.jetbrains.intellij.platform") version("2.0.0-beta8")
|
id("org.jetbrains.intellij.platform") version("2.0.0-rc1")
|
||||||
id("org.jetbrains.changelog") version("2.2.1")
|
id("org.jetbrains.changelog") version("2.2.1")
|
||||||
id("org.jetbrains.grammarkit") version("2022.3.2.2")
|
id("org.jetbrains.grammarkit") version("2022.3.2.2")
|
||||||
id("de.undercouch.download") version("5.6.0")
|
id("de.undercouch.download") version("5.6.0")
|
||||||
|
@ -100,7 +100,7 @@ allprojects {
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||||
if (path !in listOf(":", ":plugin", ":debugger")) {
|
if (path !in listOf(":", ":plugin", ":debugger")) {
|
||||||
intellijPlatform {
|
intellijPlatform {
|
||||||
intellijIdeaCommunity(ideaVersion)
|
intellijIdeaCommunity(ideaVersion, useInstaller = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ project(":debugger") {
|
||||||
exclude("com.google.code.gson", "gson")
|
exclude("com.google.code.gson", "gson")
|
||||||
}
|
}
|
||||||
intellijPlatform {
|
intellijPlatform {
|
||||||
clion(clionVersion)
|
clion(clionVersion, useInstaller = false)
|
||||||
for (p in clionPlugins) {
|
for (p in clionPlugins) {
|
||||||
bundledPlugin(p)
|
bundledPlugin(p)
|
||||||
}
|
}
|
||||||
|
@ -278,8 +278,8 @@ project(":plugin") {
|
||||||
zipSigner()
|
zipSigner()
|
||||||
pluginVerifier()
|
pluginVerifier()
|
||||||
when (baseIDE) {
|
when (baseIDE) {
|
||||||
"idea" -> intellijIdeaCommunity(ideaVersion)
|
"idea" -> intellijIdeaCommunity(ideaVersion, useInstaller = false)
|
||||||
"clion" -> clion(clionVersion)
|
"clion" -> clion(clionVersion, useInstaller = false)
|
||||||
}
|
}
|
||||||
plugin(lsp4ijPluginString)
|
plugin(lsp4ijPluginString)
|
||||||
}
|
}
|
||||||
|
@ -326,56 +326,16 @@ project(":plugin") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include the generated files in the source set
|
|
||||||
|
|
||||||
// Collects all jars produced by compilation of project modules and merges them into singe one.
|
|
||||||
// We need to put all plugin manifest files into single jar to make new plugin model work
|
|
||||||
val mergePluginJarTask = task<Jar>("mergePluginJars") {
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
|
||||||
archiveBaseName.set("ZigBrains")
|
|
||||||
|
|
||||||
exclude("META-INF/MANIFEST.MF")
|
|
||||||
exclude("**/classpath.index")
|
|
||||||
|
|
||||||
val pluginLibDir by lazy {
|
|
||||||
val sandboxTask = tasks.prepareSandbox.get()
|
|
||||||
sandboxTask.destinationDir.resolve("${project.extensionProvider.map { it.projectName }.get()}/lib")
|
|
||||||
}
|
|
||||||
|
|
||||||
val pluginJars by lazy {
|
|
||||||
pluginLibDir.listFiles().orEmpty().filter { it.isPluginJar() }
|
|
||||||
}
|
|
||||||
|
|
||||||
destinationDirectory.set(project.layout.dir(provider { pluginLibDir }))
|
|
||||||
|
|
||||||
doFirst {
|
|
||||||
for (file in pluginJars) {
|
|
||||||
from(zipTree(file))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doLast {
|
|
||||||
delete(pluginJars)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
runIde {
|
runIde {
|
||||||
dependsOn(mergePluginJarTask)
|
|
||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareSandbox {
|
prepareSandbox {
|
||||||
finalizedBy(mergePluginJarTask)
|
|
||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSearchableOptions {
|
|
||||||
dependsOn(mergePluginJarTask)
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyPlugin {
|
verifyPlugin {
|
||||||
dependsOn(mergePluginJarTask)
|
|
||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,8 +360,8 @@ project(":plugin") {
|
||||||
dependencies {
|
dependencies {
|
||||||
intellijPlatform {
|
intellijPlatform {
|
||||||
when (baseIDE) {
|
when (baseIDE) {
|
||||||
"idea" -> intellijIdeaCommunity(ideaVersion)
|
"idea" -> intellijIdeaCommunity(ideaVersion, useInstaller = false)
|
||||||
"clion" -> clion(clionVersion)
|
"clion" -> clion(clionVersion, useInstaller = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,16 @@ baseIDE=clion
|
||||||
ideaVersion=2023.2.7
|
ideaVersion=2023.2.7
|
||||||
clionVersion=2023.2.4
|
clionVersion=2023.2.4
|
||||||
|
|
||||||
pluginVersion=16.0.0
|
pluginVersion=16.1.0
|
||||||
|
|
||||||
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
||||||
gradleVersion=8.8
|
gradleVersion=8.9
|
||||||
|
|
||||||
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
|
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
|
||||||
org.gradle.caching=true
|
# TODO grammarkit breaks with this
|
||||||
|
org.gradle.caching=false
|
||||||
|
|
||||||
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
|
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
|
||||||
systemProp.org.gradle.unsafe.kotlin.assignment=true
|
systemProp.org.gradle.unsafe.kotlin.assignment=true
|
||||||
|
|
||||||
org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false
|
org.jetbrains.intellij.platform.useCacheRedirector=false
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
5
gradlew
vendored
5
gradlew
vendored
|
@ -15,6 +15,8 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
|
@ -84,7 +86,8 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
|
@ -13,6 +13,8 @@
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
|
@ -232,7 +232,7 @@ public final class ZigDebuggerToolchainService {
|
||||||
if (!accepted.get())
|
if (!accepted.get())
|
||||||
yield null;
|
yield null;
|
||||||
|
|
||||||
yield List.of(new DownloadableDebuggerBinary(msvcUrl.url.toString(), MSVC_PROPERTY_NAME, msvcUrl.version, "extension/debugAdapters/vsdbg/bin"));
|
yield List.of(new DownloadableDebuggerBinary(msvcUrl.url, MSVC_PROPERTY_NAME, msvcUrl.version, "extension/debugAdapters/vsdbg/bin"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -420,16 +420,10 @@ public final class ZigDebuggerToolchainService {
|
||||||
if (url == null || version == null)
|
if (url == null || version == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
try {
|
return new MSVCUrl(url, version, props.getProperty("dialogTitle"), props.getProperty("dialogBody"), props.getProperty("dialogLink"));
|
||||||
return new MSVCUrl(new URL(url), version, props.getProperty("dialogTitle"), props.getProperty("dialogBody"), props.getProperty("dialogLink"));
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
//TODO logging
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private record MSVCUrl(URL url, String version, String dialogTitle, String dialogBody, String dialogLink) {}
|
private record MSVCUrl(String url, String version, String dialogTitle, String dialogBody, String dialogLink) {}
|
||||||
|
|
||||||
private static String fileName(String url) {
|
private static String fileName(String url) {
|
||||||
return url.substring(url.lastIndexOf('/') + 1);
|
return url.substring(url.lastIndexOf('/') + 1);
|
||||||
|
|
|
@ -97,6 +97,8 @@ The <a href="https://github.com/Zigtools/ZLS">Zig Language Server</a>, for ZigBr
|
||||||
<completion.contributor language="Zon"
|
<completion.contributor language="Zon"
|
||||||
implementationClass="com.falsepattern.zigbrains.zon.completion.ZonCompletionContributor"/>
|
implementationClass="com.falsepattern.zigbrains.zon.completion.ZonCompletionContributor"/>
|
||||||
|
|
||||||
|
<lang.commenter language="Zon" implementationClass="com.falsepattern.zigbrains.zon.comments.ZonCommenter"/>
|
||||||
|
|
||||||
<lang.formatter language="Zon"
|
<lang.formatter language="Zon"
|
||||||
implementationClass="com.falsepattern.zigbrains.zon.formatter.ZonFormattingModelBuilder"/>
|
implementationClass="com.falsepattern.zigbrains.zon.formatter.ZonFormattingModelBuilder"/>
|
||||||
|
|
||||||
|
|
|
@ -38,23 +38,25 @@
|
||||||
STRING_LITERAL_SINGLE='string'
|
STRING_LITERAL_SINGLE='string'
|
||||||
LINE_STRING='multiline string'
|
LINE_STRING='multiline string'
|
||||||
BAD_STRING='unterminated string'
|
BAD_STRING='unterminated string'
|
||||||
|
BOOL_TRUE='true'
|
||||||
|
BOOL_FALSE='false'
|
||||||
]
|
]
|
||||||
|
|
||||||
//Mixins
|
//Mixins
|
||||||
mixin("struct")="com.falsepattern.zigbrains.zon.psi.impl.mixins.ZonStructMixinImpl"
|
mixin("entry")="com.falsepattern.zigbrains.zon.psi.impl.mixins.ZonEntryMixinImpl"
|
||||||
implements("struct")="com.falsepattern.zigbrains.zon.psi.mixins.ZonStructMixin"
|
implements("entry")="com.falsepattern.zigbrains.zon.psi.mixins.ZonEntryMixin"
|
||||||
|
|
||||||
mixin("identifier")="com.falsepattern.zigbrains.zon.psi.impl.mixins.ZonIdentifierMixinImpl"
|
mixin("identifier")="com.falsepattern.zigbrains.zon.psi.impl.mixins.ZonIdentifierMixinImpl"
|
||||||
implements("identifier")="com.falsepattern.zigbrains.zon.psi.mixins.ZonIdentifierMixin"
|
implements("identifier")="com.falsepattern.zigbrains.zon.psi.mixins.ZonIdentifierMixin"
|
||||||
}
|
}
|
||||||
|
|
||||||
zonFile ::= struct
|
zonFile ::= entry
|
||||||
|
|
||||||
struct ::= DOT LBRACE (struct_string_list | struct_map | ()) RBRACE
|
entry ::= DOT LBRACE (list | struct | ()) RBRACE
|
||||||
|
|
||||||
struct_map ::= (property | property_placeholder) (COMMA (property_placeholder? property property_placeholder? | property_placeholder))* COMMA?
|
struct ::= (property | property_placeholder) (COMMA (property_placeholder? property property_placeholder? | property_placeholder))* COMMA?
|
||||||
|
|
||||||
struct_string_list ::= STRING_LITERAL (COMMA STRING_LITERAL)* COMMA?
|
list ::= value (COMMA value)* COMMA?
|
||||||
|
|
||||||
property ::= DOT identifier EQ value
|
property ::= DOT identifier EQ value
|
||||||
|
|
||||||
|
@ -62,6 +64,10 @@ identifier ::= ID
|
||||||
|
|
||||||
property_placeholder ::= DOT? INTELLIJ_COMPLETION_DUMMY
|
property_placeholder ::= DOT? INTELLIJ_COMPLETION_DUMMY
|
||||||
|
|
||||||
private value ::= struct | STRING_LITERAL
|
private value ::= entry | boolean | STRING_LITERAL | value_placeholder
|
||||||
|
|
||||||
|
value_placeholder ::= INTELLIJ_COMPLETION_DUMMY
|
||||||
|
|
||||||
|
boolean ::= BOOL_TRUE | BOOL_FALSE
|
||||||
|
|
||||||
STRING_LITERAL ::= STRING_LITERAL_SINGLE | LINE_STRING+
|
STRING_LITERAL ::= STRING_LITERAL_SINGLE | LINE_STRING+
|
||||||
|
|
|
@ -62,6 +62,8 @@ LINE_STRING=("\\\\" [^\n]* [ \n]*)+
|
||||||
<YYINITIAL> "}" { return RBRACE; }
|
<YYINITIAL> "}" { return RBRACE; }
|
||||||
<YYINITIAL> "=" { return EQ; }
|
<YYINITIAL> "=" { return EQ; }
|
||||||
<YYINITIAL> "," { return COMMA; }
|
<YYINITIAL> "," { return COMMA; }
|
||||||
|
<YYINITIAL> "true" { return BOOL_TRUE; }
|
||||||
|
<YYINITIAL> "false" { return BOOL_FALSE; }
|
||||||
<YYINITIAL> {COMMENT} { return COMMENT; }
|
<YYINITIAL> {COMMENT} { return COMMENT; }
|
||||||
<YYINITIAL> {LINE_COMMENT} { return COMMENT; }
|
<YYINITIAL> {LINE_COMMENT} { return COMMENT; }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2023-2024 FalsePattern
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.falsepattern.zigbrains.zon.comments;
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.zon.psi.ZonTypes;
|
||||||
|
import com.intellij.codeInsight.generation.IndentedCommenter;
|
||||||
|
import com.intellij.lang.CodeDocumentationAwareCommenter;
|
||||||
|
import com.intellij.psi.PsiComment;
|
||||||
|
import com.intellij.psi.tree.IElementType;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class ZonCommenter implements CodeDocumentationAwareCommenter, IndentedCommenter {
|
||||||
|
|
||||||
|
public static final String COMMENT = "// ";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Boolean forceIndentedLineComment() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable IElementType getLineCommentTokenType() {
|
||||||
|
return ZonTypes.COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable IElementType getBlockCommentTokenType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable IElementType getDocumentationCommentTokenType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getDocumentationCommentPrefix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getDocumentationCommentLinePrefix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getDocumentationCommentSuffix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDocumentationComment(PsiComment element) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getLineCommentPrefix() {
|
||||||
|
return COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getBlockCommentPrefix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getBlockCommentSuffix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getCommentedBlockCommentPrefix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String getCommentedBlockCommentSuffix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,10 +17,12 @@
|
||||||
package com.falsepattern.zigbrains.zon.completion;
|
package com.falsepattern.zigbrains.zon.completion;
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.zon.parser.ZonFile;
|
import com.falsepattern.zigbrains.zon.parser.ZonFile;
|
||||||
|
import com.falsepattern.zigbrains.zon.psi.ZonEntry;
|
||||||
import com.falsepattern.zigbrains.zon.psi.ZonProperty;
|
import com.falsepattern.zigbrains.zon.psi.ZonProperty;
|
||||||
import com.falsepattern.zigbrains.zon.psi.ZonPropertyPlaceholder;
|
import com.falsepattern.zigbrains.zon.psi.ZonPropertyPlaceholder;
|
||||||
import com.falsepattern.zigbrains.zon.psi.ZonStruct;
|
import com.falsepattern.zigbrains.zon.psi.ZonStruct;
|
||||||
import com.falsepattern.zigbrains.zon.psi.ZonTypes;
|
import com.falsepattern.zigbrains.zon.psi.ZonTypes;
|
||||||
|
import com.falsepattern.zigbrains.zon.psi.ZonValuePlaceholder;
|
||||||
import com.intellij.codeInsight.completion.CompletionContributor;
|
import com.intellij.codeInsight.completion.CompletionContributor;
|
||||||
import com.intellij.codeInsight.completion.CompletionParameters;
|
import com.intellij.codeInsight.completion.CompletionParameters;
|
||||||
import com.intellij.codeInsight.completion.CompletionProvider;
|
import com.intellij.codeInsight.completion.CompletionProvider;
|
||||||
|
@ -38,7 +40,7 @@ import static com.falsepattern.zigbrains.common.util.PsiElementUtil.parent;
|
||||||
|
|
||||||
public class ZonCompletionContributor extends CompletionContributor {
|
public class ZonCompletionContributor extends CompletionContributor {
|
||||||
private static final List<String> ZON_ROOT_KEYS = List.of("name", "version", "minimum_zig_version", "dependencies", "paths");
|
private static final List<String> ZON_ROOT_KEYS = List.of("name", "version", "minimum_zig_version", "dependencies", "paths");
|
||||||
private static final List<String> ZON_DEP_KEYS = List.of("url", "hash", "path");
|
private static final List<String> ZON_DEP_KEYS = List.of("url", "hash", "path", "lazy");
|
||||||
|
|
||||||
public ZonCompletionContributor() {
|
public ZonCompletionContributor() {
|
||||||
extend(CompletionType.BASIC,
|
extend(CompletionType.BASIC,
|
||||||
|
@ -48,12 +50,26 @@ public class ZonCompletionContributor extends CompletionContributor {
|
||||||
new CompletionProvider<>() {
|
new CompletionProvider<>() {
|
||||||
@Override
|
@Override
|
||||||
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
||||||
var placeholder = parent(parameters.getPosition(), ZonPropertyPlaceholder.class).orElseThrow();
|
var placeholder = parent(parameters.getPosition(), ZonPropertyPlaceholder.class).orElseThrow();
|
||||||
var zonStruct = parent(placeholder, ZonStruct.class).orElseThrow();
|
var zonEntry = parent(placeholder, ZonEntry.class).orElseThrow();
|
||||||
var keys = zonStruct.getKeys();
|
var keys = zonEntry.getKeys();
|
||||||
doAddCompletions(placeholder.getText().startsWith("."), keys, ZON_ROOT_KEYS, result);
|
doAddCompletions(placeholder.getText().startsWith("."), keys, ZON_ROOT_KEYS, result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
extend(CompletionType.BASIC,
|
||||||
|
PlatformPatterns.psiElement()
|
||||||
|
.withParent(PlatformPatterns.psiElement(ZonTypes.VALUE_PLACEHOLDER))
|
||||||
|
.withSuperParent(2, PlatformPatterns.psiElement(ZonTypes.LIST))
|
||||||
|
.withSuperParent(4, PlatformPatterns.psiElement(ZonFile.class)),
|
||||||
|
new CompletionProvider<>() {
|
||||||
|
@Override
|
||||||
|
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
||||||
|
var placeholder = parent(parameters.getPosition(), ZonValuePlaceholder.class).orElseThrow();
|
||||||
|
var zonEntry = parent(placeholder, ZonEntry.class).orElseThrow();
|
||||||
|
var keys = zonEntry.getKeys();
|
||||||
|
doAddCompletions(false, Set.of(), ZON_ROOT_KEYS, result);
|
||||||
|
}
|
||||||
|
});
|
||||||
extend(CompletionType.BASIC,
|
extend(CompletionType.BASIC,
|
||||||
PlatformPatterns.psiElement()
|
PlatformPatterns.psiElement()
|
||||||
.withParent(PlatformPatterns.psiElement(ZonTypes.PROPERTY_PLACEHOLDER))
|
.withParent(PlatformPatterns.psiElement(ZonTypes.PROPERTY_PLACEHOLDER))
|
||||||
|
@ -64,14 +80,59 @@ public class ZonCompletionContributor extends CompletionContributor {
|
||||||
@Override
|
@Override
|
||||||
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
||||||
var placeholder = parent(parameters.getPosition(), ZonPropertyPlaceholder.class).orElseThrow();
|
var placeholder = parent(parameters.getPosition(), ZonPropertyPlaceholder.class).orElseThrow();
|
||||||
var depStruct = parent(placeholder, ZonStruct.class).orElseThrow();
|
var depEntry = parent(placeholder, ZonEntry.class).orElseThrow();
|
||||||
var parentProperty = parent(depStruct, ZonProperty.class).flatMap(e -> parent(e, ZonProperty.class)).orElseThrow();
|
if (!isADependency(depEntry))
|
||||||
if (!"dependencies".equals(parentProperty.getIdentifier().getName())) {
|
|
||||||
return;
|
return;
|
||||||
}
|
doAddCompletions(placeholder.getText().startsWith("."), depEntry.getKeys(), ZON_DEP_KEYS, result);
|
||||||
doAddCompletions(placeholder.getText().startsWith("."), depStruct.getKeys(), ZON_DEP_KEYS, result);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
extend(CompletionType.BASIC,
|
||||||
|
PlatformPatterns.psiElement()
|
||||||
|
.withParent(PlatformPatterns.psiElement(ZonTypes.VALUE_PLACEHOLDER))
|
||||||
|
.withSuperParent(2, PlatformPatterns.psiElement(ZonTypes.LIST))
|
||||||
|
.withSuperParent(4, PlatformPatterns.psiElement(ZonTypes.PROPERTY))
|
||||||
|
.withSuperParent(7, PlatformPatterns.psiElement(ZonTypes.PROPERTY))
|
||||||
|
.withSuperParent(10, PlatformPatterns.psiElement(ZonFile.class)),
|
||||||
|
new CompletionProvider<>() {
|
||||||
|
@Override
|
||||||
|
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
||||||
|
var placeholder = parent(parameters.getPosition(), ZonValuePlaceholder.class).orElseThrow();
|
||||||
|
var depEntry = parent(placeholder, ZonEntry.class).orElseThrow();
|
||||||
|
if (!isADependency(depEntry))
|
||||||
|
return;
|
||||||
|
doAddCompletions(false, Set.of(), ZON_DEP_KEYS, result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
extend(CompletionType.BASIC, PlatformPatterns.psiElement()
|
||||||
|
.withParent(PlatformPatterns.psiElement(ZonTypes.VALUE_PLACEHOLDER))
|
||||||
|
.withSuperParent(5, PlatformPatterns.psiElement(ZonTypes.PROPERTY))
|
||||||
|
.withSuperParent(8, PlatformPatterns.psiElement(ZonTypes.PROPERTY))
|
||||||
|
.withSuperParent(11, PlatformPatterns.psiElement(ZonFile.class)),
|
||||||
|
new CompletionProvider<>() {
|
||||||
|
@Override
|
||||||
|
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
||||||
|
var placeholder = parent(parameters.getPosition(), ZonValuePlaceholder.class).orElseThrow();
|
||||||
|
var valueProperty = parent(placeholder, ZonProperty.class).orElseThrow();
|
||||||
|
if (!"lazy".equals(valueProperty.getIdentifier().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isADependency(valueProperty))
|
||||||
|
return;
|
||||||
|
|
||||||
|
result.addElement(LookupElementBuilder.create("true"));
|
||||||
|
result.addElement(LookupElementBuilder.create("false"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isADependency(ZonProperty property) {
|
||||||
|
var depEntry = parent(property, ZonEntry.class).orElseThrow();
|
||||||
|
return isADependency(depEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isADependency(ZonEntry entry) {
|
||||||
|
var parentProperty = parent(entry, ZonProperty.class).flatMap(e -> parent(e, ZonProperty.class)).orElseThrow();
|
||||||
|
return "dependencies".equals(parentProperty.getIdentifier().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void doAddCompletions(boolean hasDot, Set<String> current, List<String> expected, CompletionResultSet result) {
|
private static void doAddCompletions(boolean hasDot, Set<String> current, List<String> expected, CompletionResultSet result) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ZonBlock extends AbstractBlock {
|
||||||
return Indent.getNoneIndent();
|
return Indent.getNoneIndent();
|
||||||
|
|
||||||
val myElementType = myNode.getElementType();
|
val myElementType = myNode.getElementType();
|
||||||
if (parent.getElementType() == ZonTypes.STRUCT &&
|
if (parent.getElementType() == ZonTypes.ENTRY &&
|
||||||
!(myElementType == ZonTypes.DOT ||
|
!(myElementType == ZonTypes.DOT ||
|
||||||
myElementType == ZonTypes.LBRACE ||
|
myElementType == ZonTypes.LBRACE ||
|
||||||
myElementType == ZonTypes.RBRACE)) {
|
myElementType == ZonTypes.RBRACE)) {
|
||||||
|
@ -86,7 +86,7 @@ public class ZonBlock extends AbstractBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable Indent getChildIndent() {
|
protected @Nullable Indent getChildIndent() {
|
||||||
if (myNode.getElementType() == ZonTypes.STRUCT) {
|
if (myNode.getElementType() == ZonTypes.ENTRY) {
|
||||||
return Indent.getNormalIndent();
|
return Indent.getNormalIndent();
|
||||||
} else {
|
} else {
|
||||||
return Indent.getNoneIndent();
|
return Indent.getNoneIndent();
|
||||||
|
|
|
@ -36,7 +36,9 @@ public class ZonColorSettingsPage implements ColorSettingsPage {
|
||||||
desc("Comment", ZonSyntaxHighlighter.COMMENT),
|
desc("Comment", ZonSyntaxHighlighter.COMMENT),
|
||||||
desc("Bad Value", ZonSyntaxHighlighter.BAD_CHAR),
|
desc("Bad Value", ZonSyntaxHighlighter.BAD_CHAR),
|
||||||
desc("String", ZonSyntaxHighlighter.STRING),
|
desc("String", ZonSyntaxHighlighter.STRING),
|
||||||
desc("Comma", ZonSyntaxHighlighter.COMMA), desc("Dot", ZonSyntaxHighlighter.DOT),
|
desc("Comma", ZonSyntaxHighlighter.COMMA),
|
||||||
|
desc("Dot", ZonSyntaxHighlighter.DOT),
|
||||||
|
desc("Boolean", ZonSyntaxHighlighter.BOOLEAN),
|
||||||
desc("Braces", ZonSyntaxHighlighter.BRACE)};
|
desc("Braces", ZonSyntaxHighlighter.BRACE)};
|
||||||
|
|
||||||
private static AttributesDescriptor desc(String name, TextAttributesKey key) {
|
private static AttributesDescriptor desc(String name, TextAttributesKey key) {
|
||||||
|
@ -60,11 +62,12 @@ public class ZonColorSettingsPage implements ColorSettingsPage {
|
||||||
//This is an example file with some random data
|
//This is an example file with some random data
|
||||||
.name = "zls",
|
.name = "zls",
|
||||||
.version = "0.11.0",
|
.version = "0.11.0",
|
||||||
|
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.known_folders = .{
|
.known_folders = .{
|
||||||
.url = "https://github.com/ziglibs/known-folders/archive/fa75e1bc672952efa0cf06160bbd942b47f6d59b.tar.gz",
|
.url = "https://github.com/ziglibs/known-folders/archive/fa75e1bc672952efa0cf06160bbd942b47f6d59b.tar.gz",
|
||||||
.hash = "122048992ca58a78318b6eba4f65c692564be5af3b30fbef50cd4abeda981b2e7fa5",
|
.hash = "122048992ca58a78318b6eba4f65c692564be5af3b30fbef50cd4abeda981b2e7fa5",
|
||||||
|
.lazy = true,
|
||||||
},
|
},
|
||||||
.diffz = .{
|
.diffz = .{
|
||||||
.url = "https://github.com/ziglibs/diffz/archive/90353d401c59e2ca5ed0abe5444c29ad3d7489aa.tar.gz",
|
.url = "https://github.com/ziglibs/diffz/archive/90353d401c59e2ca5ed0abe5444c29ad3d7489aa.tar.gz",
|
||||||
|
@ -75,6 +78,7 @@ public class ZonColorSettingsPage implements ColorSettingsPage {
|
||||||
.hash = "1220363c7e27b2d3f39de6ff6e90f9537a0634199860fea237a55ddb1e1717f5d6a5",
|
.hash = "1220363c7e27b2d3f39de6ff6e90f9537a0634199860fea237a55ddb1e1717f5d6a5",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
.paths = .{""},
|
||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class ZonSyntaxHighlighter extends SyntaxHighlighterBase {
|
||||||
BAD_CHAR = createKey("BAD_CHARACTER", HighlighterColors.BAD_CHARACTER ),
|
BAD_CHAR = createKey("BAD_CHARACTER", HighlighterColors.BAD_CHARACTER ),
|
||||||
STRING = createKey("STRING" , DefaultLanguageHighlighterColors.STRING ),
|
STRING = createKey("STRING" , DefaultLanguageHighlighterColors.STRING ),
|
||||||
COMMA = createKey("COMMA" , DefaultLanguageHighlighterColors.COMMA ),
|
COMMA = createKey("COMMA" , DefaultLanguageHighlighterColors.COMMA ),
|
||||||
|
BOOLEAN = createKey("BOOLEAN" , DefaultLanguageHighlighterColors.KEYWORD ),
|
||||||
DOT = createKey("DOT" , DefaultLanguageHighlighterColors.DOT ),
|
DOT = createKey("DOT" , DefaultLanguageHighlighterColors.DOT ),
|
||||||
BRACE = createKey("BRACE" , DefaultLanguageHighlighterColors.BRACES );
|
BRACE = createKey("BRACE" , DefaultLanguageHighlighterColors.BRACES );
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
@ -57,6 +58,7 @@ public class ZonSyntaxHighlighter extends SyntaxHighlighterBase {
|
||||||
addMapping(COMMENT , ZonTypes.COMMENT);
|
addMapping(COMMENT , ZonTypes.COMMENT);
|
||||||
addMapping(ID , ZonTypes.ID);
|
addMapping(ID , ZonTypes.ID);
|
||||||
addMapping(EQ , ZonTypes.EQ);
|
addMapping(EQ , ZonTypes.EQ);
|
||||||
|
addMapping(BOOLEAN , ZonTypes.BOOL_FALSE, ZonTypes.BOOL_TRUE);
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.zon.psi.impl.mixins;
|
package com.falsepattern.zigbrains.zon.psi.impl.mixins;
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.zon.psi.ZonStruct;
|
import com.falsepattern.zigbrains.zon.psi.ZonEntry;
|
||||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
@ -26,18 +26,18 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class ZonStructMixinImpl extends ASTWrapperPsiElement implements ZonStruct {
|
public abstract class ZonEntryMixinImpl extends ASTWrapperPsiElement implements ZonEntry {
|
||||||
public ZonStructMixinImpl(@NotNull ASTNode node) {
|
public ZonEntryMixinImpl(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getKeys() {
|
public Set<String> getKeys() {
|
||||||
val structMap = getStructMap();
|
val struct = getStruct();
|
||||||
if (structMap == null)
|
if (struct == null)
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
var result = new HashSet<String>();
|
var result = new HashSet<String>();
|
||||||
for (var property : structMap.getPropertyList()) {
|
for (var property : struct.getPropertyList()) {
|
||||||
result.add(property.getIdentifier().getName());
|
result.add(property.getIdentifier().getName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
|
@ -20,6 +20,6 @@ import com.intellij.psi.PsiElement;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface ZonStructMixin extends PsiElement {
|
public interface ZonEntryMixin extends PsiElement {
|
||||||
Set<String> getKeys();
|
Set<String> getKeys();
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue