Commit Graph

25 Commits

Author SHA1 Message Date
Rintaro Ishizaki
a673043737 Terminology change: 'garbage' -> 'unexpected'
There are no "garbage" characters in Swift code. They are just
"unexpected."
2022-08-15 14:32:28 -07:00
Alex Hoppen
c2695f0ffc [libSyntax] Allow adding garbage nodes in between any two children of a syntax node
When the source code is invalid, this allows us to represent tokens that could not be used to form a valid syntax tree with more fidelity.

This commit does not start using GarbageNodes yet, it just sets everything up for them.
2022-08-04 09:20:31 +02:00
Alex Hoppen
e643fb14b5 Introduce a new syntax kind to represent missing base nodes
In the future, we only want to attach a source presence to tokens, not to nodes. All concreate nodes which are missing can be represented by creating the node and marking all tokens as missing, but if a syntax node carries a child, that has a base kind (like `Decl`), we can’t decide which concrete node to instantiate. Introduce `MissingDecl` etc. node for this purpose.

rdar://97908258
rdar://97775360
2022-08-01 16:22:47 +02:00
Alex Hoppen
4b45f05aa6 [SwiftSyntax] Move error function to standalone Utils.py 2022-07-23 09:28:03 +02:00
Kim de Vos
0bb409e63c [SwiftSyntax] Add kind and self.element_name 2022-06-29 21:48:21 +02:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Kim de Vos
a8fa3ba0eb Added helper variables and methods for SwiftSyntax gyb
https://github.com/apple/swift-syntax/pull/268
2021-04-21 13:03:23 +02:00
Rintaro Ishizaki
4ab3cb1532 Revert "Implements SR-11580"
This reverts commit c311e45195.
2020-10-13 12:57:41 -07:00
vermont42
c311e45195 Implements SR-11580 2020-09-14 15:50:11 -07:00
Gwynne Raskind
2001f07e52 Python 2/3 compat: gyb, gyb_sourcekit_support, gyb_syntax_support, line-directive 2020-05-31 14:20:20 -07:00
Alex Hoppen
932525d762 [gardening] Fix several python-lint warnings 2019-10-29 10:40:20 -07:00
Alex Hoppen
776e2c0030 Revert "Migrate building SwiftSyntax to swift_build_support" 2019-10-29 09:55:32 -07:00
Alex Hoppen
46501b881f [gardening] Fix several python-lint warnings 2019-10-25 15:58:07 -07:00
Rintaro Ishizaki
8768832f24 Revert "Merge pull request #27281 from rintaro/reapply-syntaxparse-genericparam"
This reverts commit 5d3e8d6c83, reversing
changes made to 27e881d97e.
2019-10-14 12:46:31 -07:00
Rintaro Ishizaki
1861536e3e [Syntax] Fix Python lint failure 2019-09-20 15:26:37 -07:00
Argyrios Kyrtzidis
3612cd3d72 [utils/gyb_syntax_support] Add collection_element_name for when specifying a Child
This is useful to provide `add<ELEMENT_NAME>` APIs for SwiftSyntax that are better named
and without having name conflicts.
2019-04-23 18:14:39 -07:00
Pavol Vaskovic
53cd115b0e [Gardening] Fix W291 trailing whitespace 2018-11-28 16:57:23 +01:00
Alex Hoppen
c50729badf [swiftSyntax] Remove validate methods
The methods were never executed because DEBUG was never defined in
normal builds and the only way to create nodes is through generated
factory methods which provide the same safety `validate` was supposed to
ensure at the interface level.
2018-08-23 09:12:14 -07:00
Alex Hoppen
e1a99efd57 [incrParse] Fix parsing of nodes covering no source text 2018-05-22 08:52:39 -07:00
Harlan
a66931e7fb [SwiftSyntax] Allow for visiting SyntaxCollections (#16687)
* Allow for visiting SyntaxCollections

* The 'base type' for a SyntaxCollection is 'Syntax'

* Actually add test file
2018-05-18 10:22:26 -07:00
Harlan
2a3d4cb598 Initial infrastructure for documenting SwiftSyntax API (#14701) 2018-02-26 13:43:11 -05:00
Xi Ge
2b61d4edbb SwiftSyntax: add a mechanism to define traits of syntax nodes to allow abstract access to popular child kinds. NFC (#14668)
Swift syntax APIs lack an abstract way of accessing children. The client has to
down-cast a syntax node to the leaf type to access any of its children. However,
some children are common among different syntax kinds, e.g.
DeclAttributeSyntax and DeclMembers. We should allow an abstract way to
access and modify them, so that clients can avoid logic duplication.

This patch adds a mechanism to define new traits and specify satisfied
traits in specific syntax nodes. A trait is a set of common children
and implemented in Swift as a protocol for syntax nodes to conform to.
As a proof-of-concept, we added two traits for now including DeclGroupSyntax
and BracedSyntax.

Resolves: SR-6931 and SR-6916
2018-02-15 16:41:20 -08:00
Xi Ge
cb4bc9eb69 libSyntax: allow SyntaxCollection to specify acceptable element kinds. NFC
Segments list in interpolated string literal accepts two syntax kinds as
elements: StringSegment and ExpressionSegment. This patch generates
factory methods to reject other kinds.
2018-01-04 13:35:39 -08: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
Harlan
a5098e6b69 Generate libSyntax API (#10926)
* Generate libSyntax API

This patch removes the hand-rolled libSyntax API and replaces it with an
API that's entirely automatically generated. This means the API is
guaranteed to be internally stylistically and functionally consistent.
2017-07-25 18:19:58 -07:00