File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
src/main/kotlin/io/runescript/plugin/lang/psi/type/inference Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
- Add inspection and quick fix for unused local variables.
8
8
- Add varchook to valid types.
9
+ - Implement support for enum_getreverseindex command.
9
10
10
11
### Changed
12
+
11
13
- Update to IntelliJ 2024.1.
12
14
13
15
## [ 1.5.0] - 2023-11-27
Original file line number Diff line number Diff line change @@ -186,3 +186,38 @@ data object EnumCommandHandler : CommandHandler {
186
186
o.type = outputType ? : RsErrorType
187
187
}
188
188
}
189
+
190
+
191
+ data object EnumGetReverseIndexCommandHandler : CommandHandler {
192
+ override fun RsTypeInferenceVisitor.inferTypes (
193
+ reference : RsScript ,
194
+ o : RsCommandExpression
195
+ ) {
196
+ val arguments = o.argumentList.expressionList
197
+ var outputType: RsType ? = null
198
+ if (arguments.size >= 1 ) {
199
+ arguments[0 ].typeHint = RsTypeType
200
+ arguments[0 ].accept(this )
201
+ if (arguments[0 ] is RsDynamicExpression ) {
202
+ outputType = RsPrimitiveType .lookupReferencableOrNull(arguments[0 ].text) ? : RsErrorType
203
+ }
204
+ }
205
+ var inputType: RsType ? = null
206
+ if (arguments.size >= 2 ) {
207
+ arguments[1 ].typeHint = RsTypeType
208
+ arguments[1 ].accept(this )
209
+ if (arguments[1 ] is RsDynamicExpression ) {
210
+ inputType = RsPrimitiveType .lookupReferencableOrNull(arguments[1 ].text) ? : RsErrorType
211
+ }
212
+ }
213
+ val parameterTypes = arrayOf(
214
+ RsTypeType ,
215
+ RsTypeType ,
216
+ RsPrimitiveType .ENUM ,
217
+ outputType ? : RsErrorType ,
218
+ RsPrimitiveType .INT ,
219
+ )
220
+ checkArgumentList(o.argumentList, parameterTypes)
221
+ o.type = inputType ? : RsErrorType
222
+ }
223
+ }
Original file line number Diff line number Diff line change @@ -685,6 +685,7 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
685
685
private fun RsScript.findCommandHandler (): CommandHandler {
686
686
return when (nameLiteralList[1 ].text) {
687
687
" enum" -> EnumCommandHandler
688
+ " enum_getreverseindex" -> EnumGetReverseIndexCommandHandler
688
689
" struct_param" -> ParamCommandHandler .STRUCT_PARAM
689
690
" lc_param" -> ParamCommandHandler .LC_PARAM
690
691
" nc_param" -> ParamCommandHandler .NC_PARAM
You can’t perform that action at this time.
0 commit comments