aider: Update the linter to check for both 'ERROR' and 'MISSING' nodes.

# Aider chat conversation:

USER: is node.type 'ERROR" a standard across all tree sitter languages?

ASSISTANT: The `node.type == 'ERROR'` check is specific to the Tree-sitter library and is used to identify syntax errors in the parsed code. This is a standard feature across all languages supported by Tree-sitter.

Would you like to proceed with any changes or enhancements to the `aider/linter.py` file? If so, please specify the changes you need.

USER: is MISSING ever used to indicate a parsing/syntax problem

ASSISTANT: Yes, in Tree-sitter, `MISSING` is also used to indicate a parsing or syntax problem. Specifically, it indicates that a required element is missing in the syntax tree.

Would you like to update the `aider/linter.py` file to also check for `MISSING` nodes? If so, I can provide the necessary changes.

USER: yes

ASSISTANT: To update the `aider/linter.py` file to also check for `MISSING` nodes, we need to modify the `traverse_tree` function. Here are the necessary changes:

aider/linter.py
```python
<<<<<<< SEARCH
        if node.type == 'ERROR':
            print(f"Syntax error at line: {node.start_point[0] + 1}")
=======
        if node.type == 'ERROR' or node.is_missing:
            error_type = 'Syntax error' if node.type == 'ERROR' else 'Missing element'
            print(f"{error_type} at line: {node.start_point[0] + 1}")
>>>>>>> REPLACE
```

This change will ensure that the linter checks for both `ERROR` and `MISSING` nodes and reports them accordingly.
This commit is contained in:
Paul Gauthier 2024-05-17 14:00:42 -07:00
parent c26833419d
commit 0493680d57

View file

@ -22,8 +22,9 @@ def parse_file_for_errors(file_path):
# Traverse the tree to find errors
def traverse_tree(node):
if node.type == 'ERROR':
print(f"Syntax error at line: {node.start_point[0] + 1}")
if node.type == 'ERROR' or node.is_missing:
error_type = 'Syntax error' if node.type == 'ERROR' else 'Missing element'
print(f"{error_type} at line: {node.start_point[0] + 1}")
for child in node.children:
traverse_tree(child)