`CodeRange` provided by `PositionProvider` doesn't include decorators
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 229
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
since decorators are sub nodes of `FunctionDef` and `ClassDef` I expected the code range to cover them. Is this intended?
```python
import libcst
import libcst.metadata as l_metadata
metadata_wrapper = libcst.MetadataWrapper(libcst.parse_module("""
@decorator
def function():
pass
@decorator
class Class:
pass
"""))
positions = metadata_wrapper.resolve(l_metadata.PositionProvider)
function_node, class_node = metadata_wrapper.module.body
print("function :", positions[function_node])
print("decorator:", positions[function_node.decorators[0]])
print()
print("class :", positions[class_node])
print("decorator:", positions[class_node.decorators[0]])
# function : CodeRange(start=CodePosition(line=3, column=0), end=CodePosition(line=4, column=8))
# decorator: CodeRange(start=CodePosition(line=2, column=0), end=CodePosition(line=2, column=10))
#
# class : CodeRange(start=CodePosition(line=7, column=0), end=CodePosition(line=8, column=8))
# decorator: CodeRange(start=CodePosition(line=6, column=0), end=CodePosition(line=6, column=10))
```
Contributor guide
Assessment
This issue has not been assessed yet.