Skip to content

Commit 1b8f85a

Browse files
committed
Update covscript plugin
1 parent 7c3ce15 commit 1b8f85a

File tree

10 files changed

+115
-31
lines changed

10 files changed

+115
-31
lines changed

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import java.nio.file.*
44
import java.util.concurrent.*
55
import java.util.stream.Collectors
66

7-
val kotlinVersion = "1.2.31"
7+
val kotlinVersion = "1.2.40"
88

99
group = "org.covscript.devkt.lang"
10-
version = "v1.0-SNAPSHOT"
10+
version = "v1.0"
1111

1212
plugins {
1313
java
14-
kotlin("jvm") version "1.2.31"
14+
kotlin("jvm") version "1.2.40"
1515
}
1616

1717
java {

covscript-devkt.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="covscript-devkt" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="org.covscript.devkt.lang" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="covscript-devkt" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="org.covscript.devkt.lang" external.system.module.version="v1.0" type="JAVA_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
55
<content url="file://$MODULE_DIR$">

res/icons/cov_big.png

293 Bytes
Loading

res/icons/cov_big.svg

Lines changed: 78 additions & 0 deletions
Loading

res/icons/cov_big@2x.png

538 Bytes
Loading

res/icons/cov_sdk.png

377 Bytes
Loading

res/icons/cov_sdk@2x.png

858 Bytes
Loading

res/icons/csc.png

173 Bytes
Loading

res/icons/svgo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
3+
4+
def do_svgo(path):
5+
list = os.walk(path)
6+
for root, dir, files in list:
7+
for file in files:
8+
if file[-3:] == "svg":
9+
os.system('svgo ./%s' % (file))
10+
11+
12+
do_svgo("/home/hoshino/Projects/IntelliJ/Kotlin/covscript-intellij/res/icons/svgs")

src/org/covscript/devkt/lang/cov-devkt.kt

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,40 @@ package org.covscript.devkt.lang
22

33
import org.covscript.devkt.lang.psi.CovSymbol
44
import org.covscript.devkt.lang.psi.CovTypes
5-
6-
import org.ice1000.devkt.openapi.AnnotationHolder
7-
import org.ice1000.devkt.openapi.Annotator
8-
import org.ice1000.devkt.openapi.ColorScheme
9-
import org.ice1000.devkt.openapi.ExtendedDevKtLanguage
10-
import org.ice1000.devkt.openapi.SyntaxHighlighter
11-
5+
import org.ice1000.devkt.openapi.*
6+
import org.ice1000.devkt.openapi.ui.IconLoader
127
import org.jetbrains.kotlin.com.intellij.psi.PsiElement
138
import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType
9+
import javax.swing.Icon
1410

15-
class CovScriptSyntaxHighlighter<TextAttributes> : SyntaxHighlighter<TextAttributes> {
16-
override fun attributesOf(type: IElementType, colorScheme: ColorScheme<TextAttributes>) = when (type) {
17-
in CovTokenType.KEYWORDS_LIST -> colorScheme.keywords
18-
in CovTokenType.COMMENTS -> colorScheme.lineComments
19-
CovTypes.NUM -> colorScheme.numbers
20-
CovTypes.STR, CovTypes.CHAR -> colorScheme.string
21-
CovTypes.COLLAPSER_BEGIN, CovTypes.COLLAPSER_END -> colorScheme.typeParam
22-
else -> null
23-
}
24-
}
11+
class CovScript<TextAttributes> : ExtendedDevKtLanguage<TextAttributes>(
12+
CovLanguage.INSTANCE,
13+
CovParserDefinition()) {
14+
override fun satisfies(fileName: String) = fileName.endsWith(".csc") or fileName.endsWith(".csp")
15+
override val lineCommentStart: String get() = "# "
16+
override val icon: Icon = IconLoader.getIcon("/icons/csc.png")
2517

26-
class CovScriptAnnotator<TextAttributes> : Annotator<TextAttributes> {
2718
override fun annotate(
2819
element: PsiElement,
2920
document: AnnotationHolder<TextAttributes>,
3021
colorScheme: ColorScheme<TextAttributes>) {
3122
when (element) {
3223
is CovSymbol -> symbol(element, document, colorScheme)
24+
else -> super.annotate(element, document, colorScheme)
3325
}
3426
}
3527

28+
override fun attributesOf(type: IElementType, colorScheme: ColorScheme<TextAttributes>) = when (type) {
29+
in CovTokenType.KEYWORDS_LIST -> colorScheme.keywords
30+
in CovTokenType.OPERATOR_LIST -> colorScheme.operators
31+
in CovTokenType.COMMENTS -> colorScheme.lineComments
32+
CovTypes.NUM -> colorScheme.numbers
33+
CovTypes.STR -> colorScheme.string
34+
CovTypes.CHAR -> colorScheme.charLiteral
35+
CovTypes.COLLAPSER_BEGIN, CovTypes.COLLAPSER_END -> colorScheme.typeParam
36+
else -> super.attributesOf(type, colorScheme)
37+
}
38+
3639
private fun symbol(
3740
element: CovSymbol,
3841
document: AnnotationHolder<TextAttributes>,
@@ -43,12 +46,3 @@ class CovScriptAnnotator<TextAttributes> : Annotator<TextAttributes> {
4346
}
4447
}
4548
}
46-
47-
class CovScript<TextAttributes> : ExtendedDevKtLanguage<TextAttributes>(
48-
CovLanguage.INSTANCE,
49-
CovParserDefinition()),
50-
Annotator<TextAttributes> by CovScriptAnnotator(),
51-
SyntaxHighlighter<TextAttributes> by CovScriptSyntaxHighlighter() {
52-
override fun satisfies(fileName: String) = fileName.endsWith(".csc") or fileName.endsWith(".csp")
53-
override val lineCommentStart: String get() = "# "
54-
}

0 commit comments

Comments
 (0)