Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix-idea
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d37988e67d5e^
Choose a base ref
...
head repository: NixOS/nix-idea
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4e71bd8d065e
Choose a head ref
  • 12 commits
  • 109 files changed
  • 1 contributor

Commits on Jan 25, 2021

  1. Remove unused NixParserUtil

    The Gradle plugin for Grammar-Kit does not support the usage of Util
    classes. See the following issues from the Gradle plugin.
    
    JetBrains/gradle-grammar-kit-plugin#23
    JetBrains/gradle-grammar-kit-plugin#3
    JojOatXGME committed Jan 25, 2021
    Copy the full SHA
    d37988e View commit details

Commits on Feb 20, 2021

  1. Add test for the current behavior of the parser

    The test cases are mostly based on the following resources:
    
    https://nixos.org/guides/nix-pills/basics-of-language.html
    https://nixos.org/manual/nix/stable/#ch-expression-language
    
    Note that the outcome expected by the tests is not based on the behavior
    described in the mentioned resources but on the current behavior of the
    parser. The expected outcome will be corrected in upcoming commits when
    the related bugs of the parser are fixed. This approach shall make
    bugfixes on the parser easier to review by showing the old and new
    behavior in the diff.
    JojOatXGME committed Feb 20, 2021
    Copy the full SHA
    8006296 View commit details
  2. Add tests for undocumented expressions

    The tests are based on src/libexpr/parser.y of commit 75efa421340 in
    https://github.com/NixOS/nix.
    JojOatXGME committed Feb 20, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ecf40fa View commit details

Commits on Apr 5, 2021

  1. Rewrite parser and lexer for Nix 2.3

    Commit 75efa421340b of https://github.com/NixOS/nix is used as
    reference.
    JojOatXGME committed Apr 5, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    52be0e1 View commit details
  2. Fix Lexer.start/FlexLexer.reset

    IDEA might start lexing from the middle of a file for syntax
    highlighting. In such case, IDEA calls Lexer.start (which calls
    FlexLexer.reset) to restore the state of the lexer. However, the
    implementation previous to this commit did only restore parts of the
    state.
    JojOatXGME committed Apr 5, 2021
    Copy the full SHA
    90afa8c View commit details
  3. Copy the full SHA
    9d6a6b1 View commit details
  4. Copy the full SHA
    fed186d View commit details
  5. Copy the full SHA
    254be86 View commit details
  6. Copy the full SHA
    77fbae3 View commit details
  7. Simplify error messages

    Remove 'NixTokenType.' prefix from expected tokens to improve
    readability of error messages. For example the error message
    
        NixTokenType.., NixTokenType.; or NixTokenType.or expected, got '}'
    
    becomes
    
        '.', ';' or 'or' expected, got '}'
    JojOatXGME committed Apr 5, 2021
    Copy the full SHA
    effa1bc View commit details
  8. Copy the full SHA
    ec6c905 View commit details
  9. Copy the full SHA
    4e71bd8 View commit details
Showing with 2,822 additions and 682 deletions.
  1. +10 −1 build.gradle.kts
  2. +25 −8 src/main/java/org/nixos/idea/lang/NixBraceMatcher.java
  3. +52 −0 src/main/java/org/nixos/idea/lang/NixLexer.java
  4. +0 −10 src/main/java/org/nixos/idea/lang/NixLexerAdapter.java
  5. +19 −7 src/main/java/org/nixos/idea/lang/NixParserDefinition.java
  6. +12 −28 src/main/java/org/nixos/idea/lang/NixSyntaxHighlighter.java
  7. +0 −28 src/main/java/org/nixos/idea/psi/NixParserUtil.java
  8. +36 −3 src/main/java/org/nixos/idea/psi/NixTokenType.java
  9. +39 −0 src/main/java/org/nixos/idea/psi/impl/NixParserUtil.java
  10. +183 −158 src/main/lang/Nix.bnf
  11. +129 −191 src/main/lang/Nix.flex
  12. +0 −248 src/main/lang/idea-flex.skeleton
  13. +32 −0 src/test/java/org/nixos/idea/lang/LexerTest.java
  14. +109 −0 src/test/java/org/nixos/idea/lang/ParsingFailTest.java
  15. +155 −0 src/test/java/org/nixos/idea/lang/ParsingTest.java
  16. +1 −0 src/test/testData/ParsingFailTest/AntiquotationStateSynchronization1.nix
  17. +35 −0 src/test/testData/ParsingFailTest/AntiquotationStateSynchronization1.txt
  18. +1 −0 src/test/testData/ParsingFailTest/AntiquotationStateSynchronization2.nix
  19. +22 −0 src/test/testData/ParsingFailTest/AntiquotationStateSynchronization2.txt
  20. +2 −0 src/test/testData/ParsingFailTest/Comment.nix
  21. +6 −0 src/test/testData/ParsingFailTest/Comment.txt
  22. 0 src/test/testData/ParsingFailTest/Empty.nix
  23. +3 −0 src/test/testData/ParsingFailTest/Empty.txt
  24. +6 −0 src/test/testData/ParsingFailTest/IncompleteExpressionsInBraces.nix
  25. +62 −0 src/test/testData/ParsingFailTest/IncompleteExpressionsInBraces.txt
  26. +4 −0 src/test/testData/ParsingFailTest/MissingSemicolon.nix
  27. +29 −0 src/test/testData/ParsingFailTest/MissingSemicolon.txt
  28. +5 −0 src/test/testData/ParsingFailTest/MissingSemicolonTrap.nix
  29. +32 −0 src/test/testData/ParsingFailTest/MissingSemicolonTrap.txt
  30. +1 −0 src/test/testData/ParsingFailTest/RecWithoutSet.nix
  31. +6 −0 src/test/testData/ParsingFailTest/RecWithoutSet.txt
  32. +1 −0 src/test/testData/ParsingFailTest/RecoverFromAntiquotation.nix
  33. +15 −0 src/test/testData/ParsingFailTest/RecoverFromAntiquotation.txt
  34. +1 −0 src/test/testData/ParsingFailTest/RecoverFromAssertCondition.nix
  35. +13 −0 src/test/testData/ParsingFailTest/RecoverFromAssertCondition.txt
  36. +1 −0 src/test/testData/ParsingFailTest/RecoverFromIfCondition.nix
  37. +18 −0 src/test/testData/ParsingFailTest/RecoverFromIfCondition.txt
  38. +1 −0 src/test/testData/ParsingFailTest/RecoverFromIfThenExpression.nix
  39. +19 −0 src/test/testData/ParsingFailTest/RecoverFromIfThenExpression.txt
  40. +1 −0 src/test/testData/ParsingFailTest/RecoverFromLetBinding.nix
  41. +42 −0 src/test/testData/ParsingFailTest/RecoverFromLetBinding.txt
  42. +1 −0 src/test/testData/ParsingFailTest/RecoverFromListItem.nix
  43. +27 −0 src/test/testData/ParsingFailTest/RecoverFromListItem.txt
  44. +1 −0 src/test/testData/ParsingFailTest/RecoverFromParens.nix
  45. +15 −0 src/test/testData/ParsingFailTest/RecoverFromParens.txt
  46. +1 −0 src/test/testData/ParsingFailTest/RecoverFromParensWithValidSubexpressions.nix
  47. +18 −0 src/test/testData/ParsingFailTest/RecoverFromParensWithValidSubexpressions.txt
  48. +1 −0 src/test/testData/ParsingFailTest/RecoverFromSetBinding.nix
  49. +43 −0 src/test/testData/ParsingFailTest/RecoverFromSetBinding.txt
  50. +1 −0 src/test/testData/ParsingFailTest/RecoverFromString.nix
  51. +26 −0 src/test/testData/ParsingFailTest/RecoverFromString.txt
  52. +1 −0 src/test/testData/ParsingFailTest/RecoverFromWith.nix
  53. +13 −0 src/test/testData/ParsingFailTest/RecoverFromWith.txt
  54. +1 −0 src/test/testData/ParsingTest/Assertion.nix
  55. +10 −0 src/test/testData/ParsingTest/Assertion.txt
  56. +4 −0 src/test/testData/ParsingTest/Boolean.nix
  57. +11 −0 src/test/testData/ParsingTest/Boolean.txt
  58. +9 −0 src/test/testData/ParsingTest/Function.nix
  59. +151 −0 src/test/testData/ParsingTest/Function.txt
  60. +5 −0 src/test/testData/ParsingTest/Identifier.nix
  61. +14 −0 src/test/testData/ParsingTest/Identifier.txt
  62. +1 −0 src/test/testData/ParsingTest/If.nix
  63. +16 −0 src/test/testData/ParsingTest/If.txt
  64. +1 −0 src/test/testData/ParsingTest/LegacyLet.nix
  65. +29 −0 src/test/testData/ParsingTest/LegacyLet.txt
  66. +1 −0 src/test/testData/ParsingTest/LegacyLetInList.nix
  67. +34 −0 src/test/testData/ParsingTest/LegacyLetInList.txt
  68. +1 −0 src/test/testData/ParsingTest/LegacyOrAsArgument.nix
  69. +6 −0 src/test/testData/ParsingTest/LegacyOrAsArgument.txt
  70. +1 −0 src/test/testData/ParsingTest/LegacyOrAsAttribute.nix
  71. +33 −0 src/test/testData/ParsingTest/LegacyOrAsAttribute.txt
  72. +1 −0 src/test/testData/ParsingTest/LegacyOrInList.nix
  73. +17 −0 src/test/testData/ParsingTest/LegacyOrInList.txt
  74. +4 −0 src/test/testData/ParsingTest/Let.nix
  75. +39 −0 src/test/testData/ParsingTest/Let.txt
  76. +1 −0 src/test/testData/ParsingTest/LetEmpty.nix
  77. +8 −0 src/test/testData/ParsingTest/LetEmpty.txt
  78. +1 −0 src/test/testData/ParsingTest/List.nix
  79. +36 −0 src/test/testData/ParsingTest/List.txt
  80. +1 −0 src/test/testData/ParsingTest/ListWithFunction.nix
  81. +40 −0 src/test/testData/ParsingTest/ListWithFunction.txt
  82. +1 −0 src/test/testData/ParsingTest/Null.nix
  83. +3 −0 src/test/testData/ParsingTest/Null.txt
  84. +5 −0 src/test/testData/ParsingTest/Number.nix
  85. +14 −0 src/test/testData/ParsingTest/Number.txt
  86. +23 −0 src/test/testData/ParsingTest/Operators.nix
  87. +447 −0 src/test/testData/ParsingTest/Operators.txt
  88. +9 −0 src/test/testData/ParsingTest/OperatorsAssociativity.nix
  89. +138 −0 src/test/testData/ParsingTest/OperatorsAssociativity.txt
  90. +6 −0 src/test/testData/ParsingTest/Path.nix
  91. +17 −0 src/test/testData/ParsingTest/Path.txt
  92. +4 −0 src/test/testData/ParsingTest/RecursiveSet.nix
  93. +29 −0 src/test/testData/ParsingTest/RecursiveSet.txt
  94. +9 −0 src/test/testData/ParsingTest/Set.nix
  95. +99 −0 src/test/testData/ParsingTest/Set.txt
  96. +6 −0 src/test/testData/ParsingTest/SetAccess.nix
  97. +66 −0 src/test/testData/ParsingTest/SetAccess.txt
  98. +4 −0 src/test/testData/ParsingTest/String.nix
  99. +17 −0 src/test/testData/ParsingTest/String.txt
  100. +4 −0 src/test/testData/ParsingTest/StringWithAntiquotation.nix
  101. +39 −0 src/test/testData/ParsingTest/StringWithAntiquotation.txt
  102. +11 −0 src/test/testData/ParsingTest/StringWithEscapeSequences.nix
  103. +75 −0 src/test/testData/ParsingTest/StringWithEscapeSequences.txt
  104. +12 −0 src/test/testData/ParsingTest/StringWithMultipleLines.nix
  105. +17 −0 src/test/testData/ParsingTest/StringWithMultipleLines.txt
  106. +1 −0 src/test/testData/ParsingTest/Uri.nix
  107. +3 −0 src/test/testData/ParsingTest/Uri.txt
  108. +1 −0 src/test/testData/ParsingTest/With.nix
  109. +10 −0 src/test/testData/ParsingTest/With.txt
11 changes: 10 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -34,6 +34,12 @@ repositories {
mavenCentral()
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
}

// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
@@ -70,7 +76,7 @@ tasks {
task<GenerateLexer>("generateNixLexer") {
source = "src/main/lang/Nix.flex"
targetDir = "src/gen/java/org/nixos/idea/lang"
targetClass = "NixLexer"
targetClass = "_NixLexer"
purgeOldFiles = true
}

@@ -101,7 +107,10 @@ tasks {
}
}
}
}

test {
useJUnitPlatform()
}

patchPluginXml {
33 changes: 25 additions & 8 deletions src/main/java/org/nixos/idea/lang/NixBraceMatcher.java
Original file line number Diff line number Diff line change
@@ -2,35 +2,52 @@

import com.intellij.lang.BracePair;
import com.intellij.lang.PairedBraceMatcher;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.nixos.idea.psi.NixTypes;

public class NixBraceMatcher implements PairedBraceMatcher {
// Grammar-Kit uses the first pair of this array to guide the error recovery
// (even when structural is set to false). Since the lexer tracks curly
// braces for its state transitions, the curly braces must be on top to keep
// the state of parser and lexer consistent. See
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010379000
public static final BracePair[] PAIRS = new BracePair[] {
new BracePair(NixTypes.LCURLY,NixTypes.RCURLY,true),
new BracePair(NixTypes.LBRAC,NixTypes.RBRAC,false),
new BracePair(NixTypes.LPAREN,NixTypes.RPAREN,false),
new BracePair(NixTypes.LCURLY,NixTypes.RCURLY,false),
new BracePair(NixTypes.DOLLAR_CURLY,NixTypes.RCURLY,true),
new BracePair(NixTypes.IND_STRING_OPEN,NixTypes.IND_STRING_CLOSE,true),
new BracePair(NixTypes.FNUTT_OPEN,NixTypes.FNUTT_CLOSE,false)
new BracePair(NixTypes.IND_STRING_OPEN,NixTypes.IND_STRING_CLOSE,false),
new BracePair(NixTypes.STRING_OPEN,NixTypes.STRING_CLOSE,false)
};

@Override
public BracePair[] getPairs() {
public BracePair @NotNull [] getPairs() {
return PAIRS;
}

@Override
public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType iElementType, @Nullable IElementType iElementType1) {
public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType contextType) {
return false;
}

@Override
public int getCodeConstructStart(PsiFile psiFile, int i) {
return 0;
public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {
PsiElement openingBrace = file.findElementAt(openingBraceOffset);
if (openingBrace != null && openingBrace.getNode().getElementType() == NixTypes.LCURLY) {
PsiElement previousToken = openingBrace.getPrevSibling();
if (previousToken != null && previousToken.getNode().getElementType() == NixTypes.DOLLAR) {
return openingBraceOffset - 1;
}
else {
return openingBraceOffset;
}
}
else {
return openingBraceOffset;
}
}
}

52 changes: 52 additions & 0 deletions src/main/java/org/nixos/idea/lang/NixLexer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.nixos.idea.lang;

import com.intellij.lexer.FlexAdapter;
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;

import java.io.IOException;

public class NixLexer extends FlexAdapter {
// todo: Implement RestartableLexer when it becomes non-experimental. See
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010305800/comments/360002861979

public NixLexer() {
// We need this anonymous wrapper class to map between internal states
// of Flex and external states for IntelliJ. See
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010305800
super(new FlexLexer() {
private final _NixLexer lexer = new _NixLexer(null);

@Override
public void yybegin(int state) {
lexer.restoreState(state);
}

@Override
public int yystate() {
return lexer.getStateIndex();
}

@Override
public int getTokenStart() {
return lexer.getTokenStart();
}

@Override
public int getTokenEnd() {
return lexer.getTokenEnd();
}

@Override
public IElementType advance() throws IOException {
return lexer.advance();
}

@Override
public void reset(CharSequence buf, int start, int end, int initialState) {
lexer.reset(buf, start, end, _NixLexer.YYINITIAL);
lexer.restoreState(initialState);
}
});
}
}
10 changes: 0 additions & 10 deletions src/main/java/org/nixos/idea/lang/NixLexerAdapter.java

This file was deleted.

26 changes: 19 additions & 7 deletions src/main/java/org/nixos/idea/lang/NixParserDefinition.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
import com.intellij.lang.Language;
import com.intellij.lang.ParserDefinition;
import com.intellij.lang.PsiParser;
import com.intellij.lexer.FlexAdapter;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.FileViewProvider;
@@ -13,24 +12,23 @@
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IFileElementType;
import com.intellij.psi.tree.TokenSet;
import org.fest.util.Objects;
import org.jetbrains.annotations.NotNull;
import org.nixos.idea.file.NixFile;
import org.nixos.idea.psi.NixTokenType;
import org.nixos.idea.psi.NixTypes;

import java.io.Reader;

public class NixParserDefinition implements ParserDefinition {
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
public static final TokenSet COMMENTS = TokenSet.create(NixTypes.SCOMMENT,NixTypes.MCOMMENT);
public static final TokenSet STRING_LITERALS = TokenSet.create(NixTypes.LITERAL_SIMPLE_STRING, NixTypes.DOC_STRING);
public static final TokenSet STRING_LITERALS = TokenSet.create(NixTypes.STD_STRING, NixTypes.IND_STRING);

public static final IFileElementType FILE = new IFileElementType(Language.<NixLanguage>findInstance(NixLanguage.class));

@NotNull
@Override
public Lexer createLexer(Project project) {
NixLexer lxr = new NixLexer((Reader) null);
return new FlexAdapter(lxr);
return new NixLexer();
}

@NotNull
@@ -69,7 +67,21 @@ public PsiFile createFile(FileViewProvider viewProvider) {

@Override
public SpaceRequirements spaceExistenceTypeBetweenTokens(ASTNode left, ASTNode right) {
return SpaceRequirements.MAY;
NixTokenType leftType = Objects.castIfBelongsToType(left.getElementType(), NixTokenType.class);
NixTokenType rightType = Objects.castIfBelongsToType(right.getElementType(), NixTokenType.class);
if (leftType == NixTypes.SCOMMENT) {
return SpaceRequirements.MUST_LINE_BREAK;
}
if (leftType == NixTypes.DOLLAR && rightType == NixTypes.LCURLY) {
return SpaceRequirements.MUST_NOT;
}
else if (NixTokenType.MIGHT_COLLAPSE_WITH_ID.contains(leftType) &&
NixTokenType.MIGHT_COLLAPSE_WITH_ID.contains(rightType)) {
return SpaceRequirements.MUST;
}
else {
return SpaceRequirements.MAY;
}
}

@NotNull
40 changes: 12 additions & 28 deletions src/main/java/org/nixos/idea/lang/NixSyntaxHighlighter.java
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@ public class NixSyntaxHighlighter extends SyntaxHighlighterBase {

public static final TextAttributesKey ID = createTextAttributesKey("ID", DefaultLanguageHighlighterColors.IDENTIFIER);
public static final TextAttributesKey INT = createTextAttributesKey("INT", DefaultLanguageHighlighterColors.NUMBER);
public static final TextAttributesKey BOOL = createTextAttributesKey("BOOL", DefaultLanguageHighlighterColors.PREDEFINED_SYMBOL);

public static final TextAttributesKey ASSERT = createTextAttributesKey("ASSERT", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey IF = createTextAttributesKey("IF", DefaultLanguageHighlighterColors.KEYWORD);
@@ -40,10 +39,6 @@ public class NixSyntaxHighlighter extends SyntaxHighlighterBase {
public static final TextAttributesKey WITH = createTextAttributesKey("WITH", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey INHERIT = createTextAttributesKey("INHERIT", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey OR_KW = createTextAttributesKey("OR_KW", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey IMPORT = createTextAttributesKey("IMPORT", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey IMPORTS = createTextAttributesKey("IMPORTS", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey REQUIRE = createTextAttributesKey("REQUIRE", DefaultLanguageHighlighterColors.KEYWORD);
public static final TextAttributesKey REQUIRES = createTextAttributesKey("REQUIRES", DefaultLanguageHighlighterColors.KEYWORD);

public static final TextAttributesKey GT = createTextAttributesKey("GT", DefaultLanguageHighlighterColors.OPERATION_SIGN);
public static final TextAttributesKey LT = createTextAttributesKey("LT", DefaultLanguageHighlighterColors.OPERATION_SIGN);
@@ -91,7 +86,6 @@ public class NixSyntaxHighlighter extends SyntaxHighlighterBase {
public static final TextAttributesKey[] COLON_KEYS = new TextAttributesKey[]{COLON};
public static final TextAttributesKey[] ID_KEYS = new TextAttributesKey[]{ID};
public static final TextAttributesKey[] NUMBER_KEYS = new TextAttributesKey[]{INT};
public static final TextAttributesKey[] PREDEFINED_KEYS = new TextAttributesKey[]{BOOL};
public static final TextAttributesKey[] OPERATOR_KEYS = new TextAttributesKey[]{
GT,LT,LEQ,GEQ,NEQ,EQ,PLUS,MINUS,DIVIDE,TIMES,NOT,AND,OR,IMPL,UPDATE,IS,NAMED,CONCAT,DOT,DOLLAR_CURLY
};
@@ -100,18 +94,16 @@ public class NixSyntaxHighlighter extends SyntaxHighlighterBase {
public static final TextAttributesKey[] FUNCTION_KEYS = new TextAttributesKey[]{LAMBDA};
public static final TextAttributesKey[] PARAMETER_KEYS = new TextAttributesKey[]{FORMAL};

@NotNull
@Override
public Lexer getHighlightingLexer() {
return new NixLexerAdapter();
public @NotNull Lexer getHighlightingLexer() {
return new NixLexer();
}

@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
public TextAttributesKey @NotNull [] getTokenHighlights(IElementType tokenType) {
{
if (tokenType == NixTypes.PARAM) return PARAMETER_KEYS;
if (tokenType == NixTypes.LAMBDA) return FUNCTION_KEYS;
if (tokenType == NixTypes.EXPR_LAMBDA) return FUNCTION_KEYS;
if (tokenType == NixTypes.COMMA) return COMMA_KEYS;
if (tokenType == NixTypes.SEMI) return SEMI_KEYS;
if (tokenType == NixTypes.COLON) {
@@ -126,9 +118,6 @@ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
if (tokenType == NixTypes.ID) {
return ID_KEYS;
}
if (tokenType == NixTypes.BOOL) {
return PREDEFINED_KEYS;
}
if (tokenType == NixTypes.INT) {
return NUMBER_KEYS;
}
@@ -148,8 +137,8 @@ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
tokenType == NixTypes.OR ||
tokenType == NixTypes.IMPL ||
tokenType == NixTypes.UPDATE ||
tokenType == NixTypes.IS ||
tokenType == NixTypes.NAMED ||
tokenType == NixTypes.HAS ||
tokenType == NixTypes.AT ||
tokenType == NixTypes.CONCAT ||
tokenType == NixTypes.DOT )
return OPERATOR_KEYS;
@@ -159,29 +148,24 @@ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
tokenType == NixTypes.RPAREN ||
tokenType == NixTypes.LPAREN ||
tokenType == NixTypes.RCURLY ||
tokenType == NixTypes.DOLLAR_CURLY ||
tokenType == NixTypes.DOLLAR ||
tokenType == NixTypes.LCURLY) {
return PAREN_KEYS;
}
if (tokenType == NixTypes.STR || tokenType == NixTypes.IND_STR) {
return STRING_KEYS;
}
if (
tokenType == NixTypes.ASSERT ||
tokenType == NixTypes.IN ||
tokenType == NixTypes.OR_KW ||
tokenType == NixTypes.REC ||
tokenType == NixTypes.IF ||
tokenType == NixTypes.ELSE ||
tokenType == NixTypes.THEN ||
tokenType == NixTypes.LET ||
tokenType == NixTypes.ELSE ||
tokenType == NixTypes.ASSERT ||
tokenType == NixTypes.WITH ||
tokenType == NixTypes.LET ||
tokenType == NixTypes.IN ||
tokenType == NixTypes.REC ||
tokenType == NixTypes.INHERIT ||
tokenType == NixTypes.IMPORT ||
tokenType == NixTypes.IMPORTS ||
tokenType == NixTypes.REQUIRE ||
tokenType == NixTypes.REQUIRES) {
tokenType == NixTypes.OR_KW) {
return KEYWORD_KEYS;
}
return EMPTY_ARRAY;
28 changes: 0 additions & 28 deletions src/main/java/org/nixos/idea/psi/NixParserUtil.java

This file was deleted.

Loading