Skip to content

Commit

Permalink
Merge pull request NixOS#22 from JojOatXGME/idea203
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Jan 5, 2021
2 parents ca3dd6c + 3f32ecb commit d332de0
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,11 @@
# Changelog

## [Unreleased]
### Added
- Support for IDEA 2020.3
### Removed
- Support for IDEA 2019.3
## [0.3.0.3]
### Fixed
- Change ID of plugin back from `org.nixos.idea` in version 0.3.0.0 to
`nix-idea` from earlier versions. The different ID of version 0.3.0.0
Expand Down
15 changes: 12 additions & 3 deletions build.gradle.kts
Expand Up @@ -7,11 +7,11 @@ plugins {
// Java support
id("java")
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "0.4.21"
id("org.jetbrains.intellij") version "0.6.5"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "0.4.0"
id("org.jetbrains.changelog") version "0.6.2"
// grammarkit - read more: https://github.com/JetBrains/gradle-grammar-kit-plugin
id("org.jetbrains.grammarkit") version "2020.1"
id("org.jetbrains.grammarkit") version "2020.3.2"
}

// Import variables from gradle.properties file
Expand All @@ -20,6 +20,7 @@ val pluginName: String by project
val pluginVersion: String by project
val pluginSinceBuild: String by project
val pluginUntilBuild: String by project
val pluginVerifierIdeVersions: String by project

val platformType: String by project
val platformVersion: String by project
Expand All @@ -43,6 +44,10 @@ intellij {
updateSinceUntilBuild = true
}

changelog {
headerParserRegex = "^[-._+0-9a-zA-Z]+\$"
}

grammarKit {
// version of IntelliJ patched JFlex (see bintray link below), Default is 1.7.0-1
jflexRelease = "1.7.0-1"
Expand Down Expand Up @@ -127,6 +132,10 @@ tasks {
)
}

runPluginVerifier {
ideVersions(pluginVerifierIdeVersions)
}

publishPlugin {
token(System.getenv("JETBRAINS_TOKEN"))
channels(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first())
Expand Down
9 changes: 6 additions & 3 deletions gradle.properties
Expand Up @@ -3,9 +3,12 @@

pluginGroup = org.nixos.idea
pluginName = NixIDEA
pluginVersion = 0.3.0.3
pluginSinceBuild = 193
pluginUntilBuild = 202.*
pluginVersion = 0.3.0.4
pluginSinceBuild = 201
pluginUntilBuild = 203.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions
pluginVerifierIdeVersions = 2020.1.4, 2020.2.3, 2020.3.1

platformType = IC
platformVersion = 2020.1
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/org/nixos/idea/file/NixFileType.java
Expand Up @@ -11,14 +11,6 @@
public class NixFileType extends LanguageFileType {

public static final NixFileType INSTANCE = new NixFileType();
public static final NixFileType SHELL = new NixFileType();
public static final NixFileType RELEASE = new NixFileType();
public static final NixFileType NIXOS_MODULE = new NixFileType();
public static final NixFileType SIMPLE_STDENV_PKG = new NixFileType();
public static final NixFileType NIXOPS_INFRA = new NixFileType();
public static final NixFileType DISNIX_SERVICE_MAPPING = new NixFileType();
public static final NixFileType DISNIX_INFRA = new NixFileType();
public static final NixFileType DISNIX_DEPLOY = new NixFileType();

private NixFileType() {
super(NixLanguage.INSTANCE);
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/org/nixos/idea/file/NixFileTypeFactory.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/org/nixos/idea/icon/NixIcons.java
Expand Up @@ -5,5 +5,5 @@
import javax.swing.*;

public class NixIcons {
public static final Icon FILE = IconLoader.getIcon("/org/nixos/idea/icon/nixos-icon.png");
public static final Icon FILE = IconLoader.getIcon("/org/nixos/idea/icon/nixos-icon.png", NixIcons.class);
}
14 changes: 10 additions & 4 deletions src/main/java/org/nixos/idea/lang/NixParserDefinition.java
@@ -1,6 +1,5 @@
package org.nixos.idea.lang;

import org.nixos.idea.file.NixFile;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lang.ParserDefinition;
Expand All @@ -14,9 +13,9 @@
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IFileElementType;
import com.intellij.psi.tree.TokenSet;
import org.nixos.idea.lang.NixParser;
import org.nixos.idea.psi.NixTypes;
import org.jetbrains.annotations.NotNull;
import org.nixos.idea.file.NixFile;
import org.nixos.idea.psi.NixTypes;

import java.io.Reader;

Expand All @@ -35,21 +34,25 @@ public Lexer createLexer(Project project) {
}

@NotNull
@Override
public TokenSet getWhitespaceTokens() {
return WHITE_SPACES;
}

@NotNull
@Override
public TokenSet getCommentTokens() {
return COMMENTS;
}

@NotNull
@Override
public TokenSet getStringLiteralElements() {
return STRING_LITERALS;
}

@NotNull
@Override
public PsiParser createParser(final Project project) {
return new NixParser();
}
Expand All @@ -59,15 +62,18 @@ public IFileElementType getFileNodeType() {
return FILE;
}

@Override
public PsiFile createFile(FileViewProvider viewProvider) {
return new NixFile(viewProvider);
}

public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
@Override
public SpaceRequirements spaceExistenceTypeBetweenTokens(ASTNode left, ASTNode right) {
return SpaceRequirements.MAY;
}

@NotNull
@Override
public PsiElement createElement(ASTNode node) {
return NixTypes.Factory.createElement(node);
}
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/nixos/idea/lang/NixSyntaxHighlighter.java
@@ -1,17 +1,14 @@
package org.nixos.idea.lang;

import org.nixos.idea.psi.NixTypes;
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;

import com.intellij.lexer.FlexAdapter;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.nixos.idea.psi.NixTypes;

import java.io.Reader;

import static com.intellij.openapi.editor.colors.TextAttributesKey.EMPTY_ARRAY;
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;

public class NixSyntaxHighlighter extends SyntaxHighlighterBase {
Expand Down Expand Up @@ -187,7 +184,7 @@ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
tokenType == NixTypes.REQUIRES) {
return KEYWORD_KEYS;
}
return EMPTY;
return EMPTY_ARRAY;
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/META-INF/plugin.xml
Expand Up @@ -4,14 +4,16 @@
<name>NixIDEA</name>
<vendor>NixOS</vendor>

<idea-version since-build="202" />

<depends>com.intellij.modules.lang</depends>

<extensions defaultExtensionNs="com.intellij">

<fileTypeFactory
implementation="org.nixos.idea.file.NixFileTypeFactory" />
<fileType
name="Nix file"
implementationClass="org.nixos.idea.file.NixFileType"
fieldName="INSTANCE"
language="Nix"
extensions="nix" />

<lang.parserDefinition
language="Nix"
Expand Down

0 comments on commit d332de0

Please sign in to comment.