Skip to content

Commit 72d35a3

Browse files
committed
Add clientscript.sym to valid symbol file types
1 parent de5ced2 commit 72d35a3

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add error recovery for statements.
99
- Add support for parsing empty statements.
1010
- Add an inspection for missing script symbols.
11+
- Add clientscript.sym to valid symbol file types.
1112

1213
### Changed
1314
- The build window will now display internal compiler errors as well.

src/main/kotlin/io/runescript/plugin/lang/psi/type/RsPrimitiveType.kt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum class RsPrimitiveType(val literal: String, val referencable: Boolean = true
4343
DBCOLUMN("dbcolumn"),
4444
PLAYER_UID("player_uid"),
4545
STRINGVECTOR("stringvector"),
46+
4647
// Non-Referencable types
4748
PARAM("param", referencable = false),
4849
FLO("flo", referencable = false),
@@ -55,25 +56,39 @@ enum class RsPrimitiveType(val literal: String, val referencable: Boolean = true
5556
VARPHOOK("varphook", referencable = false),
5657
STATHOOK("stathook", referencable = false),
5758
INVHOOK("invhook", referencable = false),
58-
CONSTANT("constant", referencable = false);
59+
CONSTANT("constant", referencable = false),
60+
CLIENTSCRIPT("clientscript", referencable = false);
5961

6062
override val representation: String
6163
get() = literal
6264

6365
val baseType: RsBaseType
64-
get() = when(this) {
66+
get() = when (this) {
6567
STRING -> RsBaseType.STRING
6668
LONG -> RsBaseType.LONG
6769
else -> RsBaseType.INT
6870
}
6971

72+
val isDeclarable: Boolean
73+
get() = referencable
74+
7075
companion object {
71-
private val LOOKUP_REFERENCABLE_BY_LITERAL = RsPrimitiveType.values().associateBy { it.literal }.filterValues { it.referencable }
72-
private val LOOKUP_BY_LITERAL = RsPrimitiveType.values().associateBy { it.literal }
76+
77+
private val LOOKUP_REFERENCABLE_BY_LITERAL = RsPrimitiveType.values()
78+
.associateBy { it.literal }
79+
.filterValues { it.referencable }
80+
81+
private val LOOKUP_BY_LITERAL = RsPrimitiveType.values()
82+
.associateBy { it.literal }
7383

7484
fun lookupReferencableOrNull(literal: String) = LOOKUP_REFERENCABLE_BY_LITERAL[literal]
75-
fun lookupReferencable(literal: String) = lookupReferencableOrNull(literal) ?: error("No primitive type could be found for literal: `$literal`")
85+
86+
fun lookupReferencable(literal: String) = lookupReferencableOrNull(literal)
87+
?: error("No primitive type could be found for literal: `$literal`")
88+
7689
fun lookupOrNull(literal: String) = LOOKUP_BY_LITERAL[literal]
77-
fun lookup(literal: String) = lookupOrNull(literal) ?: error("No primitive type could be found for literal: `$literal`")
90+
91+
fun lookup(literal: String) = lookupOrNull(literal)
92+
?: error("No primitive type could be found for literal: `$literal`")
7893
}
7994
}

0 commit comments

Comments
 (0)