|
1 | 1 | package com.intellij.devkt.json;
|
2 | 2 |
|
| 3 | +import kotlin.Pair; |
| 4 | +import org.ice1000.devkt.ASTToken; |
3 | 5 | import org.ice1000.devkt.openapi.ColorScheme;
|
4 | 6 | import org.ice1000.devkt.openapi.ExtendedDevKtLanguage;
|
| 7 | +import org.ice1000.devkt.openapi.util.CompletionElement; |
5 | 8 | import org.jetbrains.annotations.NotNull;
|
6 | 9 | import org.jetbrains.annotations.Nullable;
|
7 | 10 | import org.jetbrains.kotlin.com.intellij.lexer.LayeredLexer;
|
|
12 | 15 | import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType;
|
13 | 16 |
|
14 | 17 | import javax.swing.*;
|
| 18 | +import java.util.Arrays; |
| 19 | +import java.util.HashSet; |
| 20 | +import java.util.Set; |
15 | 21 |
|
16 | 22 | public class Json<T> extends ExtendedDevKtLanguage<T> {
|
| 23 | + |
| 24 | + private final Pair<String, String> stringPair = new Pair<>("/*", "*/"); |
| 25 | + private final HashSet<CompletionElement> completionElements = new HashSet<>(Arrays.asList(new CompletionElement("null"), |
| 26 | + new CompletionElement("true"), |
| 27 | + new CompletionElement("false"))); |
| 28 | + |
17 | 29 | @NotNull
|
18 | 30 | @Override
|
19 | 31 | public String getLineCommentStart() {
|
20 | 32 | return "//";
|
21 | 33 | }
|
22 | 34 |
|
| 35 | + @Override |
| 36 | + public @NotNull Pair<String, String> getBlockComment() { |
| 37 | + return stringPair; |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public boolean invokeAutoPopup(@NotNull ASTToken currentElement, @NotNull String inputString) { |
| 42 | + return inputString.length() == 1 && invokeAutoPopup(inputString.charAt(0)); |
| 43 | + } |
| 44 | + |
| 45 | + private boolean invokeAutoPopup(char c) { |
| 46 | + return Character.isAlphabetic(c) || c == '"' || c == ' ' || c == ':'; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public @NotNull Set<CompletionElement> getInitialCompletionElementList() { |
| 51 | + return completionElements; |
| 52 | + } |
| 53 | + |
23 | 54 | @Override
|
24 | 55 | public @NotNull Icon getIcon() {
|
25 | 56 | return JsonFileType.INSTANCE.getIcon();
|
|
0 commit comments