Commit Graph

2431 Commits

Author SHA1 Message Date
David Ungar
1011998a97 Fix PatternBindingEntry::getSourceRange 2019-08-01 16:59:40 -07:00
Rintaro Ishizaki
1a211e6e5f Merge pull request #26403 from rintaro/gsoc-2019-part1
Reapply: [Parser] Decouple the parser from AST creation (part 1)
2019-08-01 18:41:11 +02:00
Slava Pestov
1ee2db4520 AST: Accessors no longer appear as members of their parent DeclContext
Accessors logically belong to their storage and can be synthesized
on the fly, so removing them from the members list eliminates one
source of mutability (but doesn't eliminate it; there are also
witnesses for derived conformances, and implicit constructors).

Since a few ASTWalker implementations break in non-trivial ways when
the traversal is changed to visit accessors as children of the storage
rather than peers, I hacked up the ASTWalker to optionally preserve
the old traversal order for now. This is ugly and needs to be cleaned up,
but I want to avoid breaking _too_ much with this commit.
2019-07-30 15:56:00 -04:00
Jan Svoboda
f0395a469a Revert "Revert "[Parser] Decouple the parser from AST creation (part 1)"" 2019-07-30 04:34:09 +00:00
David Ungar
d236a178ca Merge pull request #26095 from davidungar/parser-changes
[Parser] Fixes for ASTScope lookup
2019-07-29 19:59:00 -07:00
David Ungar
634a6eb718 Remove code for updating closure body. 2019-07-29 15:21:36 -07:00
David Ungar
30769127c8 Insert in order and other fix 2019-07-28 21:00:51 -07:00
Holly Borla
709efbc52c Sema: implement getInitKind using a request evaluator.
Add the request `InitKind` to lazily compute the kind of an initializer
declaration.
2019-07-26 15:55:09 -07:00
Holly Borla
58394eda5e Parse: check if constructor decls are marked as convenience rather than (indirectly) calling getInitKind
When we requestify `getInitKind`, we don't want to invoke the request during parsing. What the parsing code
really cares about is whether or not the decl has `ConvenienceAttr`.
2019-07-26 14:16:28 -07:00
David Ungar
9f60bb4c2f Adapt to streamlined record. 2019-07-25 08:44:02 -07:00
David Ungar
008791fc0a Ensure that an accessor can be found from its VarDecl. 2019-07-25 07:50:39 -07:00
David Ungar
691b3c6f30 When delayed parsing a Decl in a closure body, add it to the body. 2019-07-25 07:50:39 -07:00
David Ungar
6577e68b6b Fixes for review 2019-07-25 07:50:39 -07:00
David Ungar
3c7de8d707 Oops! Missed porting over the line to set the alias decl end. 2019-07-25 07:50:39 -07:00
David Ungar
79b9f6c68a Fix SubscriptDecl end position 2019-07-25 07:50:38 -07:00
David Ungar
8caf6f39e1 Fixes for ASTScope lookup
1. Track real EndLoc of TypeAliasDecl and SubscriptDecl.
2. Ensure TypeAliasDecl gets added to AST when doing completion.
2019-07-25 07:50:38 -07:00
Slava Pestov
3e45b327de Parse: Remove some bogus error recovery code for 'lazy' 2019-07-23 22:00:31 -04:00
Slava Pestov
8047ddae82 Sema: Move finishStorageImplInfo() to StorageImplInfoRequest evaluation
This merges Sema's special logic for updating the ImplInfo of lazy properties
and property wrappers with the StorageImplInfoRequest.

I had to move some code from the parser into the StorageImplInfoRequest, to
avoid request cycles caused by hasStorage() calls; this is the right thing to
do anyway.

Since hasStorage() now answers false for lazy properties and property wrappers,
we have to move some diagnostic checks from checkDeclAttributesEarly() to
the StorageImplInfoRequest implementation itself.

Over time, I expect all of the checks currently in checkDeclAttributesEarly()
and checkDeclAttributes() to either migrate to requests, or typeCheckDecl().
2019-07-23 22:00:31 -04:00
Slava Pestov
60e1dfe8b9 Sema: Use a request to compute AbstractStorageDecl::getImplInfo()
This just moves the code from the parser into a request. Sema will
still overwrite the ImplInfo field for lazy properties and
property wrappers; refactoring that is next.
2019-07-23 16:13:28 -04:00
Slava Pestov
bfe0ebb493 Parse: Split off StorageImplInfo computation from accessor parsing
Soon this will be performed lazily as part of a request.
2019-07-23 16:13:28 -04:00
Slava Pestov
56f8f05f95 AST: Move 'private set' attribute computation to SetterAccessLevelRequest 2019-07-23 16:13:28 -04:00
Slava Pestov
454281b226 AST: Split off StorageImplInfo from AbstractStorageDecl::AccessorRecord
We want to compute the former independently of the latter.
It's only 16 bits so storing it inside the Decl is fine;
it also allows us to eliminate the 'compact' representation
where an AbstractStorageDecl without an accessor record is
assumed to be stored.
2019-07-22 20:19:09 -04:00
Slava Pestov
a532a325e1 AST: Move a few methods from VarDecl down to ParamDecl 2019-07-22 20:19:09 -04:00
Doug Gregor
4820d16d7f [AST] Separate out the operations that set *parsed* bodies of functions.
When the parser wires up the body of a function, it's a legitimate use of
setting a parsed body. Separate these out from the other uses of
setBody() that we want to eliminate over time.
2019-07-12 14:08:38 -07:00
Brent Royal-Gordon
c66a8be4eb Revert "[Parser] Decouple the parser from AST creation (part 1)" 2019-07-09 14:07:43 -07:00
Argyrios Kyrtzidis
d0ddece7e2 Merge pull request #25193 from jansvoboda11/gsoc-2019-parser
[Parser] Decouple the parser from AST creation (part 1)
2019-07-08 13:49:40 -07:00
Sergej Jaskiewicz
0446ad3c3d Fix failing test cases for expected_keyword_in_decl diagnostic 2019-07-07 00:12:37 +03:00
Sergej Jaskiewicz
2b3ebf715a Use DescriptiveDeclKind for better expected_keyword_in_decl diagnostic 2019-07-06 00:57:26 +03:00
Sergej Jaskiewicz
924f15ef39 [Parse] Simplify missing_func_keyword diagnostic 2019-07-04 22:03:35 +03:00
Sergej Jaskiewicz
95eea2f3e9 [Parse] Implement "missing 'func' keyword" diagnostic with a fix-it
- When parsing a type or extension declaration, attempt to parse a function or property declaration when meeting an identifier, an operator or a paren (for tuple declarations).
- Produce the diagnostic with a fix-it suggesting to insert the needed keyword
- Recover parsing as if the declaration with the missing keyword is a function/property declaration

Resolves https://bugs.swift.org/browse/SR-10477
2019-07-04 20:06:35 +03:00
Jan Svoboda
44d7769238 [Parser] Decouple the parser from AST creation (part 1)
Instead of creating the AST directly in the parser (and libSyntax or
SwiftSyntax via SyntaxParsingContext), make Parser to explicitly create
a tree of ParsedSyntaxNodes. Their OpaqueSyntaxNodes can be either
libSyntax or SwiftSyntax. If AST is needed, it can be generated from the
libSyntax tree.
2019-06-28 14:28:19 +02:00
Doug Gregor
db5440bdef [SE-0258] Rename wrapperValue to projectedValue. 2019-06-26 07:39:01 -07:00
Doug Gregor
7bb01c743b [SE-0258] Promote projection variables ($foo) to the original property access
When the outermost property wrapper associated with a property has a
`wrapperValue`, create the projection property (with the `$` prefix)
at the same access level as the original property. This puts the
wrapped-value interface and the projection interface at the same level.

The newly-introduced @_projectionValueProperty attribute is implicitly
created to establish the link between the original property and the
projection value within module interfaces, where both properties will
be explicitly written out.
2019-06-26 07:39:01 -07:00
David Ungar
7c7c77c0ae Handle TopLevelCode case 2019-06-23 13:46:56 -07:00
Rintaro Ishizaki
bb3edd5dde [CodeCompletion] contextual attribute completion only on the same line
It's common to have decls on consecutive lines. Better to show too many
attributes than too few.
2019-06-21 14:03:09 -07:00
Rintaro Ishizaki
09ca68e485 [CodeCompletion] Don't attach attr to decl if blank line exists
```
@#^COMPLETE^#

public func something() {}
```
In this case, we can't say the user is adding attribute to the func or
starting a new declaration. So if there're one or more blank lines after the
completion, suggest context free attribute list.

rdar://problem/50441643
2019-06-20 17:06:32 -07:00
Slava Pestov
7913d30236 Sema: Use a request to compute FuncDecl::getSelfAccessKind() 2019-06-19 14:38:43 -04:00
Slava Pestov
25570d9f05 Merge pull request #25588 from slavapestov/remove-parser-implicit-accessors
Stop synthesizing accessors inside the parser
2019-06-19 14:12:13 -04:00
Rintaro Ishizaki
e52feac6d0 Merge pull request #25565 from owenv/unnamed_static_var_diag
[Diagnostics]: Fix broken diagnostic for unnamed static class property
2019-06-19 09:44:32 -07:00
Slava Pestov
ea84da3fad Parse: Stop synthesizing implicit getters and setters
Sema is now capable of synthesizing accessors for local properties,
and SILGen can emit them, so we can remove this codepath altogether.
2019-06-18 18:38:38 -04:00
Owen Voorhees
89d4e6378d [Diagnostics]: Fix broken diagnostic for unnamed static class property 2019-06-16 19:35:17 -07:00
Doug Gregor
2e8d9a4331 [SE-0258] Adopt @propertyWrapper everywhere. 2019-06-12 13:09:40 -07:00
Rintaro Ishizaki
04ca9752cf [CodeCompletion] Enable type name completion for param decl attribute
rdar://problem/50074177
2019-06-11 17:34:45 -07:00
Rintaro Ishizaki
b31c142efb [CodeCompletion] Implement completion at custom attribute argument 2019-06-11 17:34:44 -07:00
Rintaro Ishizaki
62193c961e [CodeCompletion] Enable type completion at beginning of attribute
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
2019-06-11 17:34:44 -07:00
Rintaro Ishizaki
9ba232d718 [CodeCompletion] Implement completion at custom attribute argument 2019-05-31 11:09:54 -07:00
Rintaro Ishizaki
878c9c600b [CodeCompletion] Enable type completion at beginning of attribute
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
2019-05-31 09:44:19 -07:00
Nate Chandler
1267f659c6 Address PR comments on return omission. 2019-05-07 14:20:21 -07:00
Xi Ge
24f5ba741a Syntax: add Syntax support for property delegate attributes
rdar://50056605
2019-05-02 09:50:40 -07:00
Ben Langmuir
81ce653bc3 Merge pull request #23587 from benlangmuir/cc-omit-return
[code-completion] Add type context for single-expression function bodies
2019-04-25 13:49:45 -07:00