feat: update zon grammar to support the new paths entry
This commit is contained in:
parent
2645e2646a
commit
01e60f4f4e
3 changed files with 16 additions and 7 deletions
|
@ -50,7 +50,11 @@
|
|||
|
||||
zonFile ::= struct
|
||||
|
||||
struct ::= DOT LBRACE (property COMMA | property_placeholder COMMA?)* property? RBRACE
|
||||
struct ::= DOT LBRACE (struct_string_list | struct_map | ()) RBRACE
|
||||
|
||||
struct_map ::= (property | property_placeholder) (COMMA (property | property_placeholder))* COMMA?
|
||||
|
||||
struct_string_list ::= STRING_LITERAL (COMMA STRING_LITERAL)* COMMA?
|
||||
|
||||
property ::= DOT identifier EQ value
|
||||
|
||||
|
|
|
@ -37,14 +37,14 @@ import java.util.Set;
|
|||
import static com.falsepattern.zigbrains.common.util.PsiElementUtil.parent;
|
||||
|
||||
public class ZonCompletionContributor extends CompletionContributor {
|
||||
private static final List<String> ZON_ROOT_KEYS = List.of("name", "version", "dependencies");
|
||||
private static final List<String> ZON_ROOT_KEYS = List.of("name", "version", "dependencies", "path");
|
||||
private static final List<String> ZON_DEP_KEYS = List.of("url", "hash");
|
||||
|
||||
public ZonCompletionContributor() {
|
||||
extend(CompletionType.BASIC,
|
||||
PlatformPatterns.psiElement()
|
||||
.withParent(PlatformPatterns.psiElement(ZonTypes.PROPERTY_PLACEHOLDER))
|
||||
.withSuperParent(3, PlatformPatterns.psiElement(ZonFile.class)),
|
||||
.withSuperParent(4, PlatformPatterns.psiElement(ZonFile.class)),
|
||||
new CompletionProvider<>() {
|
||||
@Override
|
||||
protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) {
|
||||
|
@ -57,9 +57,9 @@ public class ZonCompletionContributor extends CompletionContributor {
|
|||
extend(CompletionType.BASIC,
|
||||
PlatformPatterns.psiElement()
|
||||
.withParent(PlatformPatterns.psiElement(ZonTypes.PROPERTY_PLACEHOLDER))
|
||||
.withSuperParent(3, PlatformPatterns.psiElement(ZonTypes.PROPERTY))
|
||||
.withSuperParent(5, PlatformPatterns.psiElement(ZonTypes.PROPERTY))
|
||||
.withSuperParent(7, PlatformPatterns.psiElement(ZonFile.class)),
|
||||
.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) {
|
||||
|
|
|
@ -19,8 +19,10 @@ package com.falsepattern.zigbrains.zon.psi.impl.mixins;
|
|||
import com.falsepattern.zigbrains.zon.psi.ZonStruct;
|
||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -31,8 +33,11 @@ public abstract class ZonStructMixinImpl extends ASTWrapperPsiElement implements
|
|||
|
||||
@Override
|
||||
public Set<String> getKeys() {
|
||||
val structMap = getStructMap();
|
||||
if (structMap == null)
|
||||
return Collections.emptySet();
|
||||
var result = new HashSet<String>();
|
||||
for (var property : getPropertyList()) {
|
||||
for (var property : structMap.getPropertyList()) {
|
||||
result.add(property.getIdentifier().getName());
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue