1
1
package me .serce .devkt .solidity .lang ;
2
2
3
3
import kotlin .Pair ;
4
+ import kotlin .collections .CollectionsKt ;
4
5
import me .serce .devkt .solidity .lang .core .SolElementType ;
5
6
import me .serce .devkt .solidity .lang .core .SolidityParserDefinition ;
6
7
import me .serce .devkt .solidity .lang .core .SolidityTokenTypes ;
10
11
import org .ice1000 .devkt .openapi .ColorScheme ;
11
12
import org .ice1000 .devkt .openapi .ExtendedDevKtLanguage ;
12
13
import org .ice1000 .devkt .openapi .PsiUtils ;
14
+ import org .ice1000 .devkt .openapi .util .CompletionElement ;
13
15
import org .jetbrains .annotations .NotNull ;
14
16
import org .jetbrains .annotations .Nullable ;
15
17
import org .jetbrains .kotlin .com .intellij .psi .PsiElement ;
16
18
import org .jetbrains .kotlin .com .intellij .psi .TokenType ;
17
19
import org .jetbrains .kotlin .com .intellij .psi .tree .IElementType ;
18
20
21
+ import java .util .Arrays ;
22
+ import java .util .HashSet ;
23
+ import java .util .Set ;
24
+
19
25
public class Solidity <T > extends ExtendedDevKtLanguage <T > {
20
26
21
- private static final @ NotNull
22
- Pair <String , String > stringPair = new Pair <>("/*" , "*/" );
27
+ private static final @ NotNull Pair <String , String > stringPair = new Pair <>("/*" , "*/" );
28
+
29
+ private static final @ NotNull Set <CompletionElement > predefinedCompletions = CollectionsKt .mapTo (Arrays .asList (
30
+ "import" ,
31
+ "as" ,
32
+ "pragma" ,
33
+ "new" ,
34
+ "delete" ,
35
+ "emit" ,
36
+ "constructor" ,
37
+ "contract" ,
38
+ "library" ,
39
+ "interface" ,
40
+ "is" ,
41
+ "struct" ,
42
+ "function" ,
43
+ "enum" ,
44
+ "public" ,
45
+ "private" ,
46
+ "internal" ,
47
+ "external" ,
48
+ "constant" ,
49
+ "payable" ,
50
+ "pure" ,
51
+ "view" ,
52
+ "if" ,
53
+ "else" ,
54
+ "for" ,
55
+ "while" ,
56
+ "do" ,
57
+ "break" ,
58
+ "continue" ,
59
+ "throw" ,
60
+ "using" ,
61
+ "return" ,
62
+ "returns" ,
63
+ "mapping" ,
64
+ "event" ,
65
+ "anonymous" ,
66
+ "modifier" ,
67
+ "assembly" ,
68
+ "bytenumtype" ,
69
+ "bytesnumtype" ,
70
+ "fixednumtype" ,
71
+ "intnumtype" ,
72
+ "ufixednumtype" ,
73
+ "uintnumtype" ,
74
+ "string" ,
75
+ "bool" ,
76
+ "address" ,
77
+ "var" ,
78
+ "storage" ,
79
+ "memory" ,
80
+ "wei" ,
81
+ "ether" ,
82
+ "szabo" ,
83
+ "finney" ,
84
+ "seconds" ,
85
+ "minutes" ,
86
+ "hours" ,
87
+ "days" ,
88
+ "weeks" ,
89
+ "years" ), new HashSet <>(), CompletionElement ::new );
23
90
24
91
public Solidity () {
25
92
super (SolidityLanguage .INSTANCE , new SolidityParserDefinition ());
@@ -45,6 +112,11 @@ public T attributesOf(@NotNull IElementType type, @NotNull ColorScheme<? extends
45
112
else return super .attributesOf (type , colorScheme );
46
113
}
47
114
115
+ @ Override
116
+ public @ NotNull Set <CompletionElement > getInitialCompletionElementList () {
117
+ return predefinedCompletions ;
118
+ }
119
+
48
120
@ Override
49
121
public boolean shouldAddAsCompletion (@ NotNull PsiElement element ) {
50
122
return element instanceof SolParameterDef ;
@@ -78,14 +150,12 @@ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder<? su
78
150
}
79
151
80
152
@ Override
81
- public @ NotNull
82
- Pair <String , String > getBlockComment () {
153
+ public @ NotNull Pair <String , String > getBlockComment () {
83
154
return stringPair ;
84
155
}
85
156
86
157
@ Override
87
- public @ NotNull
88
- String getLineCommentStart () {
158
+ public @ NotNull String getLineCommentStart () {
89
159
return "//" ;
90
160
}
91
161
}
0 commit comments