|
1 | 1 | package org.jetbrains.plugin.devkt.clojure;
|
2 | 2 |
|
| 3 | +import kotlin.collections.CollectionsKt; |
3 | 4 | import org.ice1000.devkt.openapi.AnnotationHolder;
|
4 | 5 | import org.ice1000.devkt.openapi.ColorScheme;
|
5 | 6 | import org.ice1000.devkt.openapi.ExtendedDevKtLanguage;
|
| 7 | +import org.ice1000.devkt.openapi.util.CompletionElement; |
6 | 8 | import org.jetbrains.annotations.NotNull;
|
7 | 9 | import org.jetbrains.annotations.Nullable;
|
8 | 10 | import org.jetbrains.kotlin.com.intellij.psi.PsiElement;
|
|
17 | 19 |
|
18 | 20 | import javax.swing.*;
|
19 | 21 | import java.util.Arrays;
|
| 22 | +import java.util.HashSet; |
20 | 23 | import java.util.List;
|
| 24 | +import java.util.Set; |
21 | 25 |
|
22 | 26 | import static org.jetbrains.plugin.devkt.clojure.lexer.ClojureTokenTypes.*;
|
23 | 27 |
|
@@ -108,24 +112,34 @@ public Icon getIcon() {
|
108 | 112 | "dotimes",
|
109 | 113 | "with-local-vars");
|
110 | 114 |
|
| 115 | + private Set<CompletionElement> predefinedCompletions = new HashSet<>(); |
| 116 | + |
111 | 117 | public Clojure() {
|
112 | 118 | 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; |
113 | 128 | }
|
114 | 129 |
|
115 | 130 | @Override
|
116 |
| - public @NotNull |
117 |
| - String getLineCommentStart() { |
| 131 | + public @NotNull String getLineCommentStart() { |
118 | 132 | return ";";
|
119 | 133 | }
|
120 | 134 |
|
121 | 135 | @Override
|
122 |
| - public boolean satisfies(String fileName) { |
| 136 | + public boolean satisfies(@NotNull String fileName) { |
123 | 137 | return fileName.endsWith(".clj") || fileName.endsWith(".cljs") || fileName.endsWith(".cljc") || fileName.equals(
|
124 | 138 | "built.boot");
|
125 | 139 | }
|
126 | 140 |
|
127 | 141 | @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) { |
129 | 143 | if (psiElement instanceof ClSymbol) symbol((ClSymbol) psiElement, annotationHolder, colorScheme);
|
130 | 144 | else if (psiElement instanceof ClKeyword) keyword(((ClKeyword) psiElement), annotationHolder, colorScheme);
|
131 | 145 | }
|
@@ -155,8 +169,7 @@ private void symbol(ClSymbol symbol, AnnotationHolder<? super TextAttributes> an
|
155 | 169 | }
|
156 | 170 |
|
157 | 171 | @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) { |
160 | 173 | if (iElementType == COMMA) return colorScheme.getComma();
|
161 | 174 | else if (iElementType == CHAR_LITERAL) return colorScheme.getCharLiteral();
|
162 | 175 | else if (iElementType == LINE_COMMENT) return colorScheme.getLineComments();
|
|
0 commit comments