Commit Graph

13 Commits

Author SHA1 Message Date
Alex Hoppen
285b337cf5 Merge pull request #18424 from ahoppen/incremental-classification
[swiftSyntax] Incremental syntax classification
2018-08-03 11:09:28 -07:00
Alex Hoppen
56bf9a3469 [SwiftSyntax] Refactor AbsolutePosition
AbsolutePosition being a mutable reference type easily leads to bugs
where an AbsolutePosition is modified. Making it immutable eliminates
this issue. Furthermore, the introduction of SourceLength should allow
easier manipulation of AbsolutePositions on the client side.

We still cannot make AbsolutePosition a value type since it is used
inside AtomicCache, but the immutability gives the same safety.
2018-08-01 11:55:35 -07:00
Alex Hoppen
49e9f824bf [SwiftSyntax] Record the nodes that have been reused during an incremental transfer
This way we will be able to avoid reclassifying these nodes for syntax
highlighting since we know they haven't changed.
2018-07-31 15:41:07 -07:00
Alex Hoppen
8c8f4eb1df [libSyntax] Make RawSyntax a struct
SourcePresence and ID are already shared between the two node kinds and
the node's length will soon be cached in RawSyntax as well. By making it
a struct, we will be able to compute the node's length when it is being
constructed in the initialiser.
2018-07-26 20:46:58 -07:00
Alex Hoppen
8bab276d64 [libSyntax] Add incremental syntax tree deserialization to SwiftSyntax 2018-07-24 16:32:23 -07:00
Xi Ge
cbf840fad4 SwiftSyntax: Allow absolute position access for dangling nodes.
Since absolute position is defined by accumulating proceeding nodes,
we should allow its access for nodes without SourceFileSyntax as root.
2018-05-03 12:13:36 -07:00
Harlan
9323d08b34 [SwiftSyntax] Add accessors for source locations and test diagnostic emission (#16141)
* [SwiftSyntax] Add accessors for source locations and test diagnostic emission

* Add tests for endLocation

* Pre-emptively copy AbsolutePosition to avoid mutating it twice
2018-04-26 16:17:07 +02:00
Xi Ge
1c9f1c48ed SwiftSyntax: allow any Syntax nodes to access their leading/trailing trivia. (#15278)
Although libSyntax is designed in a way that trivia is attached to
tokens, we shouldn't restrict clients to access trivia only from a token.
An example can be doc-comment, which conceptually attaches to a declaration rather
than the start token of a declaration, like at-attributes.
2018-03-15 15:31:08 -07:00
Xi Ge
ee36dbeda3 [WIP] SwiftSyntax: Implement APIs for Syntax nodes to calculate absolute positions. (#15097)
Syntax nodes are designed as reusable blocks to construct Swift source
code. For this reason, we don't track absolute position in each node;
instead, the absolute position should be calculated on the fly when
needed. We recently found absolute positions are useful to bridge with
sourcekitd, which typically speaks in the language of line, column and
offset. Therefore, this patch tries to add a computed
property on SyntaxNode to get its absolute position.

To compute the absolute position of a SyntaxNode from scratch requires tree traversal.
However, getting the absolute position from these added APIs doesn't necessarily
mean we'll traverse since SyntaxData will actively cache the computed position.
Also, since we recursively compute the absolute position, all the position caches
for a SyntaxNode's previous siblings and ancestors will be populated as well during
the calculation of this SyntaxNode.
2018-03-12 15:42:46 -07:00
Rintaro Ishizaki
fced748790 [Syntax] Represent missing optioanl nodes as nullptr (#14300)
Allocating RawSyntax/SyntaxData for missing optional node is a waste of
resource.
2018-01-31 19:24:00 +09:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
Harlan
cba8a865e2 Split RawSyntax.presence into multiple cases (#11526) 2017-08-19 07:43:42 -07:00
Harlan
ade67ca899 [Syntax] Swift libSyntax API (#11320)
* Create Swift libSyntax API

This patch is an initial implementation of the Swift libSyntax API. It
aims to provide all features of the C++ API but exposed to Swift.

It currently resides in SwiftExperimental and will likely exist in a
molten state for a while.

* Only build SwiftSyntax on macOS
2017-08-14 16:47:48 -07:00