From 96e25a1a3da858a789a43e7f8e1895c99ef0d270 Mon Sep 17 00:00:00 2001 From: Blank Spruce <32396809+BlankSpruce@users.noreply.github.com> Date: Fri, 22 Dec 2023 20:16:44 +0100 Subject: [PATCH] Meaningless target_link_libraries should be valid code, fixes #13 --- CHANGELOG.md | 9 +++++++++ README.md | 2 +- gersemi/__version__.py | 2 +- .../target_link_libraries_command_dumper.py | 3 +++ ...s_target_link_libraries_should_be_valid_code.in.cmake | 1 + ..._target_link_libraries_should_be_valid_code.out.cmake | 1 + 6 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.in.cmake create mode 100644 tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.out.cmake diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cf3896..1f77f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [0.10.0] 2023-12-22 +### Added +- configuration schema that can be used with yaml LSP server, see: [JSON Schema](https://json-schema.org/) and #12 +- yaml header linking to configuration schema in configuration produced by `--default-config` +- support for Python 3.12 + +### Fixed +- meaningless but syntactically valid `target_link_libraries` with just library name won't crash gersemi + ## [0.9.4] 2023-12-17 ### Added - support for new keywords in native commands available in CMake 3.28 diff --git a/README.md b/README.md index 6a8a144..f895e3f 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ You can use gersemi with a pre-commit hook by adding the following to `.pre-comm ```yaml repos: - repo: https://github.com/BlankSpruce/gersemi - rev: 0.9.4 + rev: 0.10.0 hooks: - id: gersemi ``` diff --git a/gersemi/__version__.py b/gersemi/__version__.py index 702866f..888513b 100644 --- a/gersemi/__version__.py +++ b/gersemi/__version__.py @@ -4,4 +4,4 @@ __license__ = "MPL 2.0" __title__ = "gersemi" __url__ = "https://github.com/BlankSpruce/gersemi" -__version__ = "0.9.4" +__version__ = "0.10.0" diff --git a/gersemi/command_invocation_dumpers/target_link_libraries_command_dumper.py b/gersemi/command_invocation_dumpers/target_link_libraries_command_dumper.py index cbbf744..00d4ab3 100644 --- a/gersemi/command_invocation_dumpers/target_link_libraries_command_dumper.py +++ b/gersemi/command_invocation_dumpers/target_link_libraries_command_dumper.py @@ -12,6 +12,9 @@ class IsolateConfigurationTypeAndItem(Transformer_InPlace): def arguments(self, children): new_children = [] + if len(children) < 2: + return Tree("arguments", new_children) + iterator = zip(children, children[1:]) is_one_of_defined_keywords = is_one_of_keywords(self.keywords) for one_behind, current in iterator: diff --git a/tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.in.cmake b/tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.in.cmake new file mode 100644 index 0000000..5fa7498 --- /dev/null +++ b/tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.in.cmake @@ -0,0 +1 @@ +target_link_libraries(foo) diff --git a/tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.out.cmake b/tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.out.cmake new file mode 100644 index 0000000..5fa7498 --- /dev/null +++ b/tests/formatter/issue_0013_meaningless_target_link_libraries_should_be_valid_code.out.cmake @@ -0,0 +1 @@ +target_link_libraries(foo)