Repository navigation
Conversation
The Dart grammar makes `function_body` a sibling of `function_signature` (or of the `method_signature` wrapping it), so a definition's range ended with the signature. get_code_snippet then returned the declaration alone for any member whose body starts or continues on a later line. End the range on the following `function_body` when there is one. A bodiless signature keeps its own range. Fixes DeusData#3010 Signed-off-by: x-labb <154824493+x-labb@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #3010.
The Dart grammar makes
function_bodya sibling offunction_signature(or of themethod_signaturewrapping it), so a function's or method's line range ended with its signature, andget_code_snippetreturned the declaration without the body.The range now ends on the following
function_bodywhen there is one (comments in between are skipped). A bodiless signature keeps its own range, and other languages are unaffected: the new helper returns the definition node for anything but Dart.Only
end_lineandlineschange. Complexity metrics and fingerprints are still computed from the same node as before. I did not bumpCBM_INDEX_FORMAT_VERSION.How it was checked
Windows 11, MSYS2 CLANG64 (clang 23.1.6), ASan + UBSan.
dart_def_range_covers_bodyintests/test_extraction.c: block body, multi-line signature, arrow body, static method, unnamed extension member, comment between signature and body, bodilessexternalfunction.scripts/test.sh CC=clang CXX=clang++ --suites extractionwithout the fix: 590 passed, 1 failed (def->end_line == 6, expected 8).lib/repro.dartfrom the issue, indexed with a binary built from this branch:BlockBody.pingis 9-13,BlockBody.wide15-22, andget_code_snippetonpingreturns the whole body.make -f Makefile.cbm test CC=clang CXX=clang++(run before rebasing onto feat(pipeline): resolve Dart import URIs in the path rule #3176): 10653 passed, 3 failed, 114 skipped. The failures aretest_git_facts_gitfile_redirection_cannot_certify_false_ancestry,test_git_ancestor_changes_history_and_external_driver_guards_applyandmem_map_attributes_a_known_allocation; the same three fail withextract_defs.creverted. Theincrementalsuite did not run because its fixture clone failed. After the rebase I re-ran theextractionsuite (591 passed).make -k -f Makefile.cbm lint-ci(clang-format 20.1.8, cppcheck 2.22.0): clang-format, NOLINT, memory-core and vendored-scanner checks pass. cppcheck reports findings in other files and none inextract_defs.c.Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)Written with AI assistance.