Commit Graph

1224 Commits

Author SHA1 Message Date
Slava Pestov
12231d2df3 Merge pull request #27571 from slavapestov/circular-validation-cleanups-5
Circular validation cleanups, part 5
2019-10-10 19:52:56 -04:00
Rintaro Ishizaki
6a9b2522a7 [SyntaxParse] Parse unresolved member expression syntax 2019-10-10 13:29:42 -07:00
Rintaro Ishizaki
f50966fcc1 [SyntaxParse] Parse ObjectLiteralExpr syntax 2019-10-10 13:22:57 -07:00
Slava Pestov
d8b61ff24b Sema: Peel off typeCheckParameterList()'s specifier computation into a request
Since getSpecifier() now kicks off a request instead of always
returning what was previously set, we can't pass a ParamSpecifier
to the ParamDecl constructor anymore. Instead, callers either
call setSpecifier() if the ParamDecl is synthesized, or they
rely on the request, which can compute the specifier in three
specific cases:

- Ordinary parsed parameters get their specifier from the TypeRepr.

- The 'self' parameter's specifier is based on the self access kind.

- Accessor parameters are either the 'newValue' parameter of a
  setter, or a cloned subscript parameter.

For closure parameters with inferred types, we still end up
calling setSpecifier() twice, once to set the initial defalut
value and a second time when applying the solution in the
case that we inferred an 'inout' specifier. In practice this
should not be a big problem because expression type checking
walks the AST in a pre-determined order anyway.
2019-10-10 15:00:07 -04:00
Rintaro Ishizaki
bb08667bf5 [SyntaxParse] Parse tuple/paren expression syntax 2019-10-09 14:48:47 -07:00
Rintaro Ishizaki
1de6819e34 [SyntaxParse] Parse Array/Dictionary literal syntax 2019-10-08 23:11:08 -07:00
Rintaro Ishizaki
242f9a7273 [SyntaxParse] parseExpressionSyntax()
(Implemented by Nathan Hawes @nathawes)
2019-10-08 23:11:08 -07:00
Rintaro Ishizaki
43df5a240e [SyntaxParse] Parse SuperRefExpr syntax 2019-10-08 22:15:02 -07:00
Rintaro Ishizaki
dfe962f19a Merge pull request #27508 from rintaro/syntaxparse-expridentifier
[SyntaxParse] Parse IdentifierExpr syntax
2019-10-08 19:17:46 +02:00
Rintaro Ishizaki
f42f60f233 [Syntax] Consolidate 'TupleElement' and 'FunctionCallArgument' kinds
into 'TupleExprElement'. They had exact the same layout.
2019-10-07 20:52:11 -07:00
Rintaro Ishizaki
597538ca18 [SyntaxParse] Parse IdentifierExpr syntax
Along with UnqualifiedDeclName (e.g. 'foo(x:y:)').
2019-10-02 17:06:51 -07:00
Rintaro Ishizaki
0264687b39 [SyntaxParse] Code styling 2019-10-01 15:41:40 -07:00
Nathan Hawes
f1a21348d2 [Parse] Assert that the children of syntax tree nodes have contiguous source ranges
This should help us catch syntax tree round-tripping issues.
2019-09-27 16:02:27 -07:00
Jordan Rose
8ff1dac381 [AST] Break some header dependencies for faster rebuilds (#27374)
DiagnosticEngine.h no longer depends on Attr.h.
Expr.h no longer depends on TypeRepr.h.

No functionality change.
2019-09-26 09:17:10 -07:00
Rintaro Ishizaki
b09f87594a Merge pull request #27230 from rintaro/syntaxparsse-rdar55421369
[SyntaxParse] Re-apply move-only ParsedRawSyntaxNode
2019-09-19 07:36:14 +02:00
Nathan Hawes
4dac0d1e8b Merge pull request #27218 from nathawes/r53958454-getFixedTypeRecursive-code-completion-crash
[code-completion] Remove special handling for completion on the RHS of an assignment
2019-09-18 10:49:38 -07:00
Nathan Hawes
54defbc7f7 [code-completion] Remove special handling for completion on the RHS of an assignment
This simplifies the code and prevents an assertion failure this code was
hitting computing the type relations between the result types and what it
determined as the expected type.

Resolves rdar://problem/53958454
2019-09-17 18:59:33 -07:00
Rintaro Ishizaki
9f642f0bc1 Revert "Merge pull request #27203 from CodaFi/movin-on-up"
This reverts commit 387d2a9aee, reversing
changes made to bf1ab6c29d.
2019-09-17 16:42:44 -07:00
Robert Widmann
d8aaf29617 Revert "Merge pull request #27132 from rintaro/syntaxparse-parsedrawsyntax-moveonly"
This reverts commit e675c4947d, reversing
changes made to 73315ba01e.
2019-09-16 15:10:33 -07:00
Rintaro Ishizaki
e675c4947d Merge pull request #27132 from rintaro/syntaxparse-parsedrawsyntax-moveonly
[SyntaxParse] Prevent memory leak in Syntax parsing
2019-09-14 01:06:15 +02:00
Rintaro Ishizaki
80085e0d27 [SyntaxParse] Make ParsedRawSyntaxNode move-only
So that we can easily detect 'ParsedSyntaxNode' leaking. When it's
moved, the original node become "null" node. In the destructor of
'ParsedSyntaxNode', assert the node is not "recorded" node.
2019-09-11 16:33:49 -07:00
Nathan Hawes
aa0305ee80 [Parse][IDE] Fix document structure request output for interpolated string literals
InterpolatedStringLiteralExpr has a TapExpr, which contains a BraceStmt
containing the builder CallExprs to the builder appendInterpolation /
appendStringLiteral methods used to construct the final string. This is all
implementation detail, but the BraceStmt wasn't marked implicit and had a valid
(but incorrect) SourceRange, so the document structure request treated it as
any other BraceStmt and made a structure node for it. The invalid range ended
up tripping an assertion in the document structure walker in swift-ide-test.

This patch corrects the BraceStmts produced by interpolated strings to be
marked implicit and have the correct range, and also updates ModelASTWalker to
skip over the internal details of interpolated strings when walking them (the
CallExprs were also being emitted).
2019-09-09 09:54:17 -07:00
Nathan Hawes
feb48a61b9 [code-completion] Fix correctness regressions from disabling diagnostics in code completion
There were some changes to completion results because AST mutations that were
made while diagnosing are no longer happening.

This patch 1) changes expression type checking to allow unresolved types when
solving constraint systems, so we get a solution and apply its types in more
cases, and 2) fixes a parsing issue where we would drop a ternary expression
completely if the code completion point was in its true branch.
2019-08-30 15:26:27 -07:00
Rintaro Ishizaki
cb308b7e53 Revert "Revert "[Parser] Decouple the parser from AST creation (part 2)""
This reverts commit 8ad3cc8a82.
2019-08-27 14:36:41 -07:00
Rintaro Ishizaki
8ad3cc8a82 Revert "[Parser] Decouple the parser from AST creation (part 2)" 2019-08-27 12:28:48 -07:00
Rintaro Ishizaki
1551db619e [SyntaxParse] Support kindof() in isTopNode() 2019-08-26 19:10:51 +02:00
Jan Svoboda
77924c4b84 [Parser] Decouple the parser from AST creation (part 2)
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-08-26 19:10:51 +02:00
David Ungar
35e82185e6 Back off and strategically retreat from more sensible ranges for TapExpressions and their subexpressions 2019-08-22 17:44:47 -07:00
David Ungar
a40b694801 Use token start locations 2019-08-21 22:36:15 -07:00
David Ungar
d84d541e99 De-lazify 2019-08-21 12:02:25 -07:00
David Ungar
0dbf7e6ab6 Parser changes for lazy ASTScopes 2019-08-21 09:45:45 -07:00
Owen Voorhees
686e4a600c Assign a SourceLoc to implicit appendInterpolation calls for diagnostics
This helps ensure that if, for example, a deprecated appendInterpolation is used, the resulting diag points to the opening paren of the corresponding string interpolation segment
2019-08-04 18:00:09 -07:00
Jan Svoboda
f0395a469a Revert "Revert "[Parser] Decouple the parser from AST creation (part 1)"" 2019-07-30 04:34:09 +00:00
Slava Pestov
a532a325e1 AST: Move a few methods from VarDecl down to ParamDecl 2019-07-22 20:19:09 -04:00
Suyash Srijan
1e00633ac7 [Parser] Use getLocForEndOfToken for diagnostic fix-it 2019-07-16 20:04:53 +01:00
Suyash Srijan
4feb7f6f86 [Parser] Emit fix-it in separate notes 2019-07-16 19:21:14 +01:00
Suyash Srijan
be2ac04725 [Parser] Don't call setIsParseError() 2019-07-16 19:05:03 +01:00
Suyash Srijan
59660d82fc [Diagnostics] Tweak diagnostic message slightly (replace ',' with ';' in message) 2019-07-16 19:04:14 +01:00
Suyash Srijan
f16a012492 [Parser] Dianogse use of subscript inside array literal and emit appropriate fix-its depending on whether it was expected or unexpected 2019-07-16 18:58:20 +01:00
Suyash Srijan
b839e07c12 [Parser] Adds a fix-it to convert the subscript into two arrays 2019-07-15 21:26:59 +01:00
Suyash Srijan
8092dd9ad7 [Parser] Validate a collection element if its a subscript 2019-07-15 20:59:22 +01:00
Brent Royal-Gordon
c66a8be4eb Revert "[Parser] Decouple the parser from AST creation (part 1)" 2019-07-09 14:07:43 -07:00
Jan Svoboda
5aee188716 Rename SyntaxTransformer to ASTGen 2019-07-08 17:16:35 +02: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
Rintaro Ishizaki
302052cd22 [Parse] 'super' requires following l-square 2019-06-27 16:50:29 -07:00
Rintaro Ishizaki
257b61744e [CodeCompletion] Eliminate super related completion
In parser, 'parseExprPostfixSuffix()' can parse postfix expression for
'super'. 'parseExprSuper()' doesn't need to parse them.

In code-completion, 'completeExprSuper()' and 'completeExprSuperDot()'
can be consolidated to 'completePostfixExpr()' and 'completeDotExpr()'.
2019-06-26 09:59:47 -07:00
Xi Ge
2509f50e45 Syntax: introduce a token kind for single quote to preserve round-trip printing of syntax tree
For invalid code, lexer is forgiving enough to allow single quote '\'' as the starting point
of string literals. Later, parser assumes the string literals are always using double quote "\"", and passes
such knowledge to SwiftSyntax side, leading to the round-trip failure we observed in the radar.
This commit fixes the issue by introducing another token kind for single quote.

rdar://51071021
2019-06-12 17:16:16 -07:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
David Ungar
92fd649b92 Use CloseQuoteBegin 2019-05-20 10:41:47 -07:00
David Ungar
7a8b3c8383 Add trailing quote location to interpolated string literal. 2019-05-19 15:26:34 -07:00