Skip to content

Commit de8be76

Browse files
committed
Add predefined
1 parent 069b041 commit de8be76

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import java.io.*
33
val kotlinVersion = "1.2.40"
44

55
group = "org.jetbrains.plugin.devkt.clojure"
6-
version = "v1.1-SNAPSHOT"
6+
version = "v1.1"
77

88
plugins { java }
99

@@ -32,6 +32,8 @@ repositories {
3232

3333
dependencies {
3434
compileOnly(kotlin("compiler-embeddable", kotlinVersion))
35-
compileOnly(files(*File("lib").listFiles()))
35+
val version = "efb0f52d89"
36+
compileOnly(group = "com.github.ice1000.dev-kt", name = "common", version = version)
37+
runtime(group = "com.github.ice1000.dev-kt", name = "swing", version = version)
3638
}
3739

la-clojure-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="la-clojure-devkt" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="org.jetbrains.plugin.devkt.clojure" external.system.module.version="v1.0" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="la-clojure-devkt" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="org.jetbrains.plugin.devkt.clojure" external.system.module.version="v1.1" type="JAVA_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
55
<content url="file://$MODULE_DIR$">

src/org/jetbrains/plugin/devkt/clojure/Clojure.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.jetbrains.plugin.devkt.clojure;
22

3+
import kotlin.collections.CollectionsKt;
34
import org.ice1000.devkt.openapi.AnnotationHolder;
45
import org.ice1000.devkt.openapi.ColorScheme;
56
import org.ice1000.devkt.openapi.ExtendedDevKtLanguage;
7+
import org.ice1000.devkt.openapi.util.CompletionElement;
68
import org.jetbrains.annotations.NotNull;
79
import org.jetbrains.annotations.Nullable;
810
import org.jetbrains.kotlin.com.intellij.psi.PsiElement;
@@ -17,7 +19,9 @@
1719

1820
import javax.swing.*;
1921
import java.util.Arrays;
22+
import java.util.HashSet;
2023
import java.util.List;
24+
import java.util.Set;
2125

2226
import static org.jetbrains.plugin.devkt.clojure.lexer.ClojureTokenTypes.*;
2327

@@ -108,24 +112,34 @@ public Icon getIcon() {
108112
"dotimes",
109113
"with-local-vars");
110114

115+
private Set<CompletionElement> predefinedCompletions = new HashSet<>();
116+
111117
public Clojure() {
112118
super(ClojureLanguage.getInstance(), new ClojureParserDefinition());
119+
predefinedCompletions.addAll(CollectionsKt.map(reserved, CompletionElement::new));
120+
predefinedCompletions.addAll(CollectionsKt.map(typeMetaAliases, CompletionElement::new));
121+
predefinedCompletions.addAll(CollectionsKt.map(cljsPredefined, CompletionElement::new));
122+
predefinedCompletions.addAll(CollectionsKt.map(cljsTypes, CompletionElement::new));
123+
}
124+
125+
@Override
126+
public @NotNull Set<CompletionElement> getInitialCompletionElementList() {
127+
return predefinedCompletions;
113128
}
114129

115130
@Override
116-
public @NotNull
117-
String getLineCommentStart() {
131+
public @NotNull String getLineCommentStart() {
118132
return ";";
119133
}
120134

121135
@Override
122-
public boolean satisfies(String fileName) {
136+
public boolean satisfies(@NotNull String fileName) {
123137
return fileName.endsWith(".clj") || fileName.endsWith(".cljs") || fileName.endsWith(".cljc") || fileName.equals(
124138
"built.boot");
125139
}
126140

127141
@Override
128-
public void annotate(PsiElement psiElement, AnnotationHolder<? super TextAttributes> annotationHolder, ColorScheme<? extends TextAttributes> colorScheme) {
142+
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder<? super TextAttributes> annotationHolder, @NotNull ColorScheme<? extends TextAttributes> colorScheme) {
129143
if (psiElement instanceof ClSymbol) symbol((ClSymbol) psiElement, annotationHolder, colorScheme);
130144
else if (psiElement instanceof ClKeyword) keyword(((ClKeyword) psiElement), annotationHolder, colorScheme);
131145
}
@@ -155,8 +169,7 @@ private void symbol(ClSymbol symbol, AnnotationHolder<? super TextAttributes> an
155169
}
156170

157171
@Override
158-
public @Nullable
159-
TextAttributes attributesOf(IElementType iElementType, ColorScheme<? extends TextAttributes> colorScheme) {
172+
public @Nullable TextAttributes attributesOf(@NotNull IElementType iElementType, @NotNull ColorScheme<? extends TextAttributes> colorScheme) {
160173
if (iElementType == COMMA) return colorScheme.getComma();
161174
else if (iElementType == CHAR_LITERAL) return colorScheme.getCharLiteral();
162175
else if (iElementType == LINE_COMMENT) return colorScheme.getLineComments();

0 commit comments

Comments
 (0)