Skip to content

Commit 30afc9a

Browse files
committed
Updated linter
- Implemented Find and RFind functions for arrays in the linter. - Implemented documentation strings for functions and events with the Native keyword.
1 parent 1750fd5 commit 30afc9a

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ Single file build system and a batch build variant.
168168
- SKSE mod event names
169169

170170
## **Changelog**
171+
Version 1.0.1 - 2016/03/05:
172+
- Implemented support in the linter for Find and RFind functions for arrays.
173+
- Implemented support in the linter for documentation strings for functions and events with the Native keyword.
174+
171175
Version 1.0.0 - 2016/03/04:
172176
- Major rewrite
173177
- Introduction of version numbers

Source/Modules/Skyrim/Linter.py

+36-12
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,11 @@ def Process(self, statements, paths, cancel = None): # Return True if successful
15641564
else:
15651565
self.Abort("Unterminated function definition.", func[0].line)
15661566
return False
1567+
else:
1568+
docString = None
1569+
if len(statements) > 0:
1570+
if statements[0].type == self.STAT_DOCUMENTATION:
1571+
docString = statements.pop(0)
15671572
elif stat.type == self.STAT_EVENTDEF:
15681573
if not self.AddFunction(stat):
15691574
return False
@@ -1577,6 +1582,11 @@ def Process(self, statements, paths, cancel = None): # Return True if successful
15771582
else:
15781583
self.Abort("Unterminated event definition.", event[0].line)
15791584
return False
1585+
else:
1586+
docString = None
1587+
if len(statements) > 0:
1588+
if statements[0].type == self.STAT_DOCUMENTATION:
1589+
docString = statements.pop(0)
15801590
elif stat.type == self.STAT_IMPORT:
15811591
if not stat.data.name in self.imports:
15821592
self.imports.append(stat.data.name)
@@ -2016,21 +2026,35 @@ def NodeVisitor(self, node, expected = None):
20162026
else:
20172027
self.Abort("This script does not have a function/event called %s." % node.data.name.value)
20182028
elif expected:
2019-
script = self.GetCachedScript(expected)
2020-
if script:
2021-
func = script.functions.get(node.data.name.value.upper(), None)
2022-
if func:
2023-
if func.data.type:
2024-
if func.data.array:
2025-
result = "%s[]" % func.data.type
2029+
if "[]" in expected:
2030+
typ = expected[:-2]
2031+
script = self.GetCachedScript(typ)
2032+
if script:
2033+
funcName = node.data.name.value.upper()
2034+
if funcName == "FIND":
2035+
func = Statement(self.STAT_FUNCTIONDEF, 0, FunctionDef("INT", "Int", False, "FIND", "Find", [ParameterDef(typ, typ.capitalize(), False, "AKELEMENT", "akElement", None), ParameterDef("INT", "Int", False, "AISTARTINDEX", "aiStartIndex", Node(self.NODE_EXPRESSION, ExpressionNode(Node(self.NODE_CONSTANT, ConstantNode(Token(self.INT, "0", 0, 0))))))], [self.KW_NATIVE]))
2036+
result = self.KW_INT
2037+
elif funcName == "RFIND":
2038+
func = Statement(self.STAT_FUNCTIONDEF, 0, FunctionDef("INT", "Int", False, "RFIND", "RFind", [ParameterDef(typ, typ.capitalize(), False, "AKELEMENT", "akElement", None), ParameterDef("INT", "Int", False, "AISTARTINDEX", "aiStartIndex", Node(self.NODE_EXPRESSION, ExpressionNode(Node(self.NODE_UNARYOPERATOR, UnaryOperatorNode(self.OP_SUBTRACTION, Node(self.NODE_CONSTANT, ConstantNode(Token(self.INT, "1", 0, 0))))))))], [self.KW_NATIVE]))
2039+
result = self.KW_INT
2040+
else:
2041+
self.Abort("Arrays objects only have FIND and RFIND functions.")
2042+
else:
2043+
script = self.GetCachedScript(expected)
2044+
if script:
2045+
func = script.functions.get(node.data.name.value.upper(), None)
2046+
if func:
2047+
if func.data.type:
2048+
if func.data.array:
2049+
result = "%s[]" % func.data.type
2050+
else:
2051+
result = func.data.type
20262052
else:
2027-
result = func.data.type
2053+
result = self.KW_NONE
20282054
else:
2029-
result = self.KW_NONE
2055+
self.Abort("%s does not have a function/event called %s." % (expected, node.data.name.value))
20302056
else:
2031-
self.Abort("%s does not have a function/event called %s." % (expected, node.data.name.value))
2032-
else:
2033-
pass
2057+
pass
20342058
else:
20352059
func = self.GetFunction(node.data.name.value)
20362060
if func:

0 commit comments

Comments
 (0)