Commit 1ab4a47
committed
[AST] Formalize getBodySourceRange() for fast completion
Fast completion replaces the body ('BraceStmt') of function decls with
other bodies parsed from different source buffers from the original
source buffer. That means the source range of the body and the location
of the function declaration itself might be in different buffers.
Previously, FuncDecl::getSourceRange() used to use the 'func' keyword decl
as the start loc and 'getBodySourceRange().End' as the end loc. This
breaks a SourceRange invariant where the start and end loc must be
in the same buffer.
This patch add a new function 'getOriginalBodySourceRange()' which
always return the source range of the original body of the function. And
use that from 'getSourceRange()' functions.
The orignal body source range is stored in a side table in ASTContext so
that normal compilation doesn't consume space for that extra info.1 parent 0d25abc commit 1ab4a47
File tree
4 files changed
+72
-5
lines changed- include/swift/AST
- lib
- AST
- IDE
4 files changed
+72
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5942 | 5942 | | |
5943 | 5943 | | |
5944 | 5944 | | |
| 5945 | + | |
| 5946 | + | |
5945 | 5947 | | |
5946 | 5948 | | |
5947 | 5949 | | |
| |||
6007 | 6009 | | |
6008 | 6010 | | |
6009 | 6011 | | |
| 6012 | + | |
| 6013 | + | |
| 6014 | + | |
| 6015 | + | |
| 6016 | + | |
| 6017 | + | |
| 6018 | + | |
| 6019 | + | |
| 6020 | + | |
| 6021 | + | |
| 6022 | + | |
| 6023 | + | |
| 6024 | + | |
6010 | 6025 | | |
6011 | 6026 | | |
6012 | 6027 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
| |||
4778 | 4782 | | |
4779 | 4783 | | |
4780 | 4784 | | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
| 4795 | + | |
| 4796 | + | |
| 4797 | + | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
| 4805 | + | |
| 4806 | + | |
| 4807 | + | |
| 4808 | + | |
| 4809 | + | |
| 4810 | + | |
| 4811 | + | |
| 4812 | + | |
| 4813 | + | |
| 4814 | + | |
4781 | 4815 | | |
4782 | 4816 | | |
4783 | 4817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6726 | 6726 | | |
6727 | 6727 | | |
6728 | 6728 | | |
| 6729 | + | |
| 6730 | + | |
| 6731 | + | |
| 6732 | + | |
| 6733 | + | |
| 6734 | + | |
| 6735 | + | |
| 6736 | + | |
| 6737 | + | |
| 6738 | + | |
| 6739 | + | |
| 6740 | + | |
| 6741 | + | |
| 6742 | + | |
| 6743 | + | |
6729 | 6744 | | |
6730 | 6745 | | |
6731 | 6746 | | |
| |||
7386 | 7401 | | |
7387 | 7402 | | |
7388 | 7403 | | |
7389 | | - | |
| 7404 | + | |
7390 | 7405 | | |
7391 | 7406 | | |
7392 | 7407 | | |
| |||
7507 | 7522 | | |
7508 | 7523 | | |
7509 | 7524 | | |
7510 | | - | |
| 7525 | + | |
7511 | 7526 | | |
7512 | 7527 | | |
7513 | 7528 | | |
| |||
7733 | 7748 | | |
7734 | 7749 | | |
7735 | 7750 | | |
7736 | | - | |
| 7751 | + | |
7737 | 7752 | | |
7738 | 7753 | | |
7739 | 7754 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
414 | 418 | | |
415 | | - | |
416 | | - | |
| 419 | + | |
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
| |||
0 commit comments