-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from earthly/nacho/textmate
Nacho/textmate
- Loading branch information
Showing
22 changed files
with
416 additions
and
1,006 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
VERSION 0.6 | ||
FROM gradle:7.1.0-jdk11 | ||
RUN apt-get update && apt-get install -y \ | ||
zip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
ARG version=0.0.0 | ||
ARG bundle="github.com/earthly/earthly/contrib/earthfile-syntax-highlighting+export/" | ||
COPY settings.gradle.kts build.gradle.kts ./ | ||
COPY scripts scripts | ||
COPY src src | ||
|
||
test: | ||
RUN --mount=type=cache,target=/root/.gradle/caches gradle test --tests LexerTests | ||
GET_BUNDLE: | ||
COMMAND | ||
COPY $bundle build/ | ||
RUN scripts/bundle.sh build/earthfile-syntax-highlighting | ||
|
||
dist: | ||
DO +GET_BUNDLE | ||
RUN sed -i 's^0.0.0^'"$version"'^g' ./build.gradle.kts | ||
RUN --mount=type=cache,target=/root/.gradle/caches gradle --no-daemon buildPlugin | ||
SAVE ARTIFACT build/distributions/earthly-intellij-plugin-$version.zip AS LOCAL earthly-intellij-plugin-$version.zip | ||
|
||
sign: | ||
FROM +dist | ||
RUN --mount=type=cache,target=/root/.gradle/caches \ | ||
--secret CERTIFICATE_CHAIN=+secrets/earthly-technologies/intellij-plugin/chain.crt \ | ||
--secret PRIVATE_KEY=+secrets/earthly-technologies/intellij-plugin/private.pem \ | ||
--secret PRIVATE_KEY_PASSWORD=+secrets/earthly-technologies/intellij-plugin/private-key-password \ | ||
gradle --no-daemon signPlugin | ||
SAVE ARTIFACT build/distributions/earthly-intellij-plugin-$version.zip AS LOCAL earthly-intellij-plugin-signed-$version.zip | ||
|
||
publish: | ||
FROM +sign | ||
RUN --push \ | ||
--mount=type=cache,target=/root/.gradle/caches \ | ||
--secret CERTIFICATE_CHAIN=+secrets/earthly-technologies/intellij-plugin/chain.crt \ | ||
--secret PRIVATE_KEY=+secrets/earthly-technologies/intellij-plugin/private.pem \ | ||
--secret PRIVATE_KEY_PASSWORD=+secrets/earthly-technologies/intellij-plugin/private-key-password \ | ||
--secret PUBLISH_TOKEN=+secrets/earthly-technologies/intellij-plugin/marketplace-token \ | ||
gradle --no-daemon publishPlugin | ||
|
||
ide: | ||
LOCALLY | ||
DO +GET_BUNDLE | ||
RUN gradle runIde |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -e | ||
bundle_path=$1 | ||
if [ "${bundle_path: -4}" != ".zip" ]; then | ||
folder=$(pwd) | ||
cd $bundle_path; | ||
zip -rqq vsc-bundle.zip * | ||
cd $folder; | ||
bundle_path=$bundle_path/vsc-bundle.zip; | ||
fi | ||
mv $bundle_path src/main/resources/ |
24 changes: 0 additions & 24 deletions
24
src/main/java/dev/earthly/plugin/language/EarthTokenTypes.java
This file was deleted.
Oops, something went wrong.
56 changes: 0 additions & 56 deletions
56
src/main/java/dev/earthly/plugin/language/EarthlySyntaxHighlighter.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...ava/dev/earthly/plugin/language/syntax/highlighting/EarthlyEditorHighlighterProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package dev.earthly.plugin.language.syntax.highlighting; | ||
|
||
import com.intellij.openapi.editor.colors.EditorColorsScheme; | ||
import com.intellij.openapi.editor.ex.util.DataStorage; | ||
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter; | ||
import com.intellij.openapi.editor.highlighter.EditorHighlighter; | ||
import com.intellij.openapi.fileTypes.EditorHighlighterProvider; | ||
import com.intellij.openapi.fileTypes.FileType; | ||
import com.intellij.openapi.fileTypes.SyntaxHighlighter; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import dev.earthly.plugin.language.syntax.lexer.EarthlyLexerDataStorage; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class EarthlyEditorHighlighterProvider implements EditorHighlighterProvider { | ||
|
||
@Override | ||
public EditorHighlighter getEditorHighlighter(@Nullable Project project, | ||
@NotNull FileType fileType, | ||
@Nullable VirtualFile virtualFile, | ||
@NotNull EditorColorsScheme colors) { | ||
return new EarthlyEditorHighlighter(new EarthlySyntaxHighlighterFactory().getSyntaxHighlighter(project,virtualFile), colors); | ||
} | ||
|
||
private static final class EarthlyEditorHighlighter extends LexerEditorHighlighter { | ||
private EarthlyEditorHighlighter(@Nullable SyntaxHighlighter highlighter, @NotNull EditorColorsScheme colors) { | ||
|
||
super(highlighter != null ? highlighter : new EarthlyHighlighter(null), colors); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
protected DataStorage createStorage() { | ||
return new EarthlyLexerDataStorage(); | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/dev/earthly/plugin/language/syntax/highlighting/EarthlyHighlighter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package dev.earthly.plugin.language.syntax.highlighting; | ||
|
||
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; | ||
|
||
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 dev.earthly.plugin.language.syntax.lexer.EarthlyElementType; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class EarthlyHighlighter extends SyntaxHighlighterBase { | ||
|
||
private static final TextAttributesKey[] DEFAULT = new TextAttributesKey[0]; | ||
private static final TextAttributesKey[] TARGET_REF = new TextAttributesKey[]{createTextAttributesKey("TARGET_REF", DefaultLanguageHighlighterColors.METADATA)}; | ||
private static final TextAttributesKey[] TARGET = new TextAttributesKey[]{createTextAttributesKey("EARTHLY_TARGET", DefaultLanguageHighlighterColors.INSTANCE_FIELD)}; | ||
private static final TextAttributesKey[] EXPOSE_PORT = new TextAttributesKey[]{createTextAttributesKey("EXPOSE_PORT", DefaultLanguageHighlighterColors.NUMBER)}; | ||
private static final TextAttributesKey[] COMMENT = new TextAttributesKey[]{createTextAttributesKey("EARTHLY_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT)}; | ||
private static final TextAttributesKey[] STRING = new TextAttributesKey[]{createTextAttributesKey("EARTHLY_STRING", DefaultLanguageHighlighterColors.STRING)}; | ||
private static final TextAttributesKey[] OPERATION_SIGN = new TextAttributesKey[]{createTextAttributesKey("OPERATION_SIGN", DefaultLanguageHighlighterColors.OPERATION_SIGN)}; | ||
private static final TextAttributesKey[] PARENTHESES = new TextAttributesKey[]{createTextAttributesKey("PARENTHESES", DefaultLanguageHighlighterColors.PARENTHESES)}; | ||
|
||
private static final TextAttributesKey[] KEYWORD = new TextAttributesKey[]{createTextAttributesKey("KEYWORD", DefaultLanguageHighlighterColors.KEYWORD)}; | ||
|
||
private static final TextAttributesKey[] VARIABLE = new TextAttributesKey[]{createTextAttributesKey("VARIABLE", DefaultLanguageHighlighterColors.INSTANCE_METHOD)}; | ||
|
||
private static final Map<String, TextAttributesKey[]> COLOR_MAP = new HashMap<>(); | ||
|
||
static { | ||
COLOR_MAP.put("comment.line.earthfile", COMMENT); | ||
COLOR_MAP.put("comment.line.number-sign.earthfile", COMMENT); | ||
COLOR_MAP.put("constant.numeric-port.earthfile", EXPOSE_PORT); | ||
COLOR_MAP.put("entity.name.class.target.earthfile", TARGET); | ||
COLOR_MAP.put("entity.name.function.user-command.earthfile", TARGET_REF); | ||
COLOR_MAP.put("entity.name.type.base-image.earthfile", TARGET_REF); | ||
COLOR_MAP.put("entity.name.type.target.earthfile", TARGET_REF); | ||
COLOR_MAP.put("entity.name.variable.artifact.earthfile", TARGET_REF); | ||
COLOR_MAP.put("entity.name.variable.target.earthfile", TARGET_REF); | ||
COLOR_MAP.put("keyword.operator.assignment.earthfile", OPERATION_SIGN); | ||
COLOR_MAP.put("keyword.operator.flag.earthfile", OPERATION_SIGN); | ||
COLOR_MAP.put("keyword.operator.shell.earthfile", OPERATION_SIGN); | ||
COLOR_MAP.put("punctuation.definition.comment.earthfile", COMMENT); | ||
COLOR_MAP.put("punctuation.definition.variable.begin.earthfile", PARENTHESES); | ||
COLOR_MAP.put("punctuation.definition.variable.end.earthfile", PARENTHESES); | ||
COLOR_MAP.put("punctuation.definition.string.begin.earthfile", STRING); | ||
COLOR_MAP.put("punctuation.definition.string.end.earthfile", STRING); | ||
COLOR_MAP.put("string.quoted.double.earthfile", STRING); | ||
COLOR_MAP.put("string.quoted.single.earthfile", STRING); | ||
COLOR_MAP.put("keyword.other.special-method.earthfile", KEYWORD); | ||
COLOR_MAP.put("variable.other.earthfile", VARIABLE); | ||
} | ||
|
||
private final EarthlyHighlightingLexer myLexer; | ||
|
||
public EarthlyHighlighter(EarthlyHighlightingLexer lexer) { | ||
myLexer = lexer; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Lexer getHighlightingLexer() { | ||
return myLexer; | ||
} | ||
|
||
@Override | ||
public TextAttributesKey @NotNull [] getTokenHighlights(IElementType tokenType) { | ||
if (tokenType instanceof EarthlyElementType) { | ||
EarthlyElementType type = (EarthlyElementType) tokenType; | ||
TextAttributesKey[] ret = COLOR_MAP.get(type.getScope().getScopeName()); | ||
if (ret != null) { | ||
return ret; | ||
} | ||
} | ||
return DEFAULT; | ||
} | ||
} |
Oops, something went wrong.