Skip to content

Commit cc3b33b

Browse files
authored
Apply :end-line and :end-col metadata to forms from the reader (#904)
Fixes #903
1 parent 0d06028 commit cc3b33b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
* Added `:end-line` and `:end-col` metadata to forms during compilation (#903)
10+
811
### Fixed
912
* Fix a bug where `.` characters were not allowed in keyword names (#899)
1013
* Fix a bug where nested quotation marks were not escaped properly by various print functions and at the REPL (#894)

docs/cli.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ You can then establish a connection from your IDE to the server address.
5050

5151
- from `Emacs`, using `CIDER <https://github.com/clojure-emacs/cider>`_
5252

53-
`M-x cider-connect-clj`
53+
.. code-block::
54+
55+
M-x cider-connect-clj
5456
5557
- from `Visual Studio Code`, using `Calva <https://calva.io/>`_
5658

57-
`REPL` -> `Connect to a running REPL in your project` -> `Generic`
59+
.. code-block::
60+
61+
REPL -> Connect to a running REPL in your project -> Generic
5862
5963
.. _run_basilisp_code:
6064

src/basilisp/lang/compiler/analyzer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
COL_KW,
5151
DEFAULT_COMPILER_FILE_PATH,
5252
DOC_KW,
53+
END_COL_KW,
54+
END_LINE_KW,
5355
FILE_KW,
5456
LINE_KW,
5557
NAME_KW,
@@ -951,8 +953,8 @@ def _def_ast( # pylint: disable=too-many-locals,too-many-statements
951953
# is likely to have metadata. In rare cases, we may not be able to get
952954
# any metadata. This may happen if the form and name were both generated
953955
# programmatically.
954-
def_loc = _loc(form) or _loc(name) or (None, None)
955-
if def_loc == (None, None):
956+
def_loc = _loc(form) or _loc(name) or (None, None, None, None)
957+
if def_loc == (None, None, None, None):
956958
logger.warning(f"def line and column metadata not provided for Var {name}")
957959
if name.meta is None:
958960
logger.warning(f"def name symbol has no metadata for Var {name}")
@@ -963,8 +965,10 @@ def _def_ast( # pylint: disable=too-many-locals,too-many-statements
963965
lmap.map(
964966
{
965967
COL_KW: def_loc[1],
968+
END_COL_KW: def_loc[3],
966969
FILE_KW: def_node_env.file,
967970
LINE_KW: def_loc[0],
971+
END_LINE_KW: def_loc[2],
968972
NAME_KW: name,
969973
NS_KW: current_ns,
970974
}

src/basilisp/lang/compiler/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ class SpecialForm:
5555
INTERFACE_KW = kw.keyword("interface")
5656
REST_KW = kw.keyword("rest")
5757
COL_KW = kw.keyword("col")
58+
END_COL_KW = kw.keyword("end-col")
5859
DOC_KW = kw.keyword("doc")
5960
FILE_KW = kw.keyword("file")
6061
LINE_KW = kw.keyword("line")
62+
END_LINE_KW = kw.keyword("end-line")
6163
NAME_KW = kw.keyword("name")
6264
NS_KW = kw.keyword("ns")
6365

0 commit comments

Comments
 (0)