Add tests, remove unused code, fix bugs

- Added tests for more error messages
- Test the "go to reference" feature at every character index of every
test case
- Delete unused code and imports
- Fix some bugs I found along the way
This commit is contained in:
James Westman 2024-12-22 18:00:39 -06:00
parent 5b0f662478
commit 9b9fab832b
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
47 changed files with 140 additions and 190 deletions

View file

@ -160,6 +160,11 @@ class AstNode:
yield e
if e.fatal:
return
except MultipleErrors as e:
for error in e.errors:
yield error
if error.fatal:
return
for child in self.children:
yield from child._get_errors()
@ -249,14 +254,7 @@ def validate(
if skip_incomplete and self.incomplete:
return
try:
func(self)
except CompileError as e:
# If the node is only partially complete, then an error must
# have already been reported at the parsing stage
if self.incomplete:
return
def fill_error(e: CompileError):
if e.range is None:
e.range = (
Range.join(
@ -266,8 +264,26 @@ def validate(
or self.range
)
try:
func(self)
except CompileError as e:
# If the node is only partially complete, then an error must
# have already been reported at the parsing stage
if self.incomplete:
return
fill_error(e)
# Re-raise the exception
raise e
except MultipleErrors as e:
if self.incomplete:
return
for error in e.errors:
fill_error(error)
raise e
inner._validator = True
return inner