Commit Graph

130 Commits

Author SHA1 Message Date
Alex Hoppen
fe2ae72ad2 [IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
The code completio infrastructure is also being used for cursor info now, so it should no longer be called code completion.

rdar://103251187
2022-12-13 11:41:05 +01:00
Robert Widmann
530d937879 Remove SyntaxContext and Parser Affordances 2022-11-16 13:24:21 -08:00
Hamish Knight
6aa44a1754 [AST] Remove @_typeSequence attribute
This is no longer needed now that we have the
ellipsis spelling.
2022-10-14 15:40:13 +01:00
Hamish Knight
48ea933804 Parse an ellipsis T... for type parameter packs
In a generic parameter list, parse an ellipsis
to produce a type parameter pack. This replaces
the previous `@_typeSequence` attribute.
2022-10-14 15:40:12 +01:00
Hamish Knight
b645e63ce5 [AST] NFC: Refactor GenericTypeParamDecl construction
Add distinct overloads for the parser,
deserialization and code synthesis.
2022-10-14 15:40:12 +01:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Robert Widmann
8fbe69f698 Add Layout Requirements To AST
Layout Requirements aren't a fully-exposed part of the language, but
we do need some representation for them.
2022-08-01 17:11:07 -07:00
Alex Hoppen
a35f1856c0 [CodeCompletion] Offer suggestions if a nested type is followed by an equal type requirement
If the first type has a code completion token, don't record a same type constraint because otherwise if we have
```swift
  K.#^COMPLETE^# == Foo
```
we parse this as
```
  K == Foo
```
and thus simplify `K` to `Foo`. But we didn't want to state that `K` is `Foo` but that `K` has a member of type `Foo`.

rdar://77458518
2022-05-03 09:36:51 +02:00
Slava Pestov
2b766c278a Parse: Remove unnecessary blank lines 2022-04-01 13:54:42 -04:00
Doug Gregor
0416ec708b Augment GenericTypeParamDecl with bits indicating they came from opaque types 2022-01-26 14:47:11 -08:00
Alex Hoppen
60c78afb13 Merge pull request #40065 from ahoppen/pr/lexing-cutoff
[Parser] Don't modify the current token kind when cutting off parsing
2021-11-09 18:33:19 +01:00
Alex Hoppen
b888dc0e40 [Parser] Don't modify the current token kind when cutting off parsing
Previously, when we reached the maximum nesting level, we changed the current token’s kind to an EOF token. A lot of places in the parser are not set up to expect this token change. The intended workaround was to check whether pushing a structure marker failed (which would change the token kind) and bail out parsing if this happened. This was fragile and caused assertion failures in assert builds.

Instead of changing the current token’s kind, and failing to push the structure marker, let the lexer know that it should cut off lexing, essentially making the input buffer stop at the current position. The parser will continue to consume its current token (`Parser.Tok`) and the next token that’s already lexed in the lexer (`Lexer.NextToken`) before reaching the emulated EOF token. Thus two more tokens are parsed than before, but that shouldn’t make much of a difference.
2021-11-09 12:28:10 +01:00
Robert Widmann
22405cefea Plumb the "Is Type Sequence" Bit Through the Surface AST 2021-11-08 13:48:30 -08:00
Doug Gregor
06bbc70b3e Module printing and serialization support for @unchecked Sendable 2021-07-11 12:29:54 -07:00
Anthony Latsis
47ce1529f0 Parse: Only diagnose dollar-prefixed identifiers that are Swift declarations 2020-11-19 20:30:53 +03:00
Slava Pestov
5808d9beb9 Parse: Remove parse-time name lookup 2020-11-16 22:39:44 -05:00
Slava Pestov
0a9a6405ab Parse: Create a trailing where clause even if it was incomplete
Also, store the end location of the where clause explicitly, so that
we can recover it even if there are no requirements.

This fixes one of the failing tests when parser lookup is disabled in
swift-ide-test by ensuring that the source range of the function
extends to the end of the 'where' clause, even though the 'where'
clause has a code completion token in it.
2020-11-16 16:52:50 -05:00
Slava Pestov
445d747622 AST: Move GenericParamList and friends to GenericParamList.{h,cpp} 2020-09-29 19:51:03 -04:00
Nathan Hawes
bb773232a8 [Parse][CodeCompletion] Stop code completion within a closure causing parser recovery after the closure.
For example, the completion below would trigger error recovery within the
closure, which we recover from by skipping to the first inner closure's right
brace. The fact that we recovered though, was not recorded. The closure is
treated as still being an error, triggering another recovery after it that
skips over the 'Thing' token, giving a lone closure expression, rather than a
call.

CreateThings {
    Thing { point in
      print("hello")
      point.#^HERE^#
    }
    Thing { _ in }
}

This isn't an issue for code completion when the outer closure is a regular
closure, but when it's a function builder, invalid elements result in no types
being applied (no valid solutions) and we end up with no completion results.

The fix here is removing the error status from the parser result after the
initial parser recovery.
2020-09-10 21:59:09 -07:00
Slava Pestov
c46eb22fcd AST: Don't attach trailing where clause requirements to the GenericParamList
Previously we had two representations for the 'where' clause of a
parsed declaration; if the declaration had generic parameters of
its own, we would store them in the GenericParamList, otherwise
we would store them separately in a TrailingWhereClause instance.

Since the latter is more general and also used for protocols and
extensions, let's just use it for everything and simplify
GenericParamList in the process.
2020-07-28 02:07:16 -04:00
Rintaro Ishizaki
62d8eed570 [Parse] Don't drop parsed error types in where clause from AST
Code completion requires the source range of the 'where' clause to
correctly lookup member of types in where clause.

rdar://problem/61911134
2020-04-23 08:54:38 -07:00
Anthony Latsis
d688710fb3 [Diag] Move invalid where clause on top-level decl diagnostic to Sema 2020-03-15 13:38:49 +03:00
fischertony
6f08216936 Sema: Support where clauses on contextually generic decls 2020-03-05 04:37:12 +03:00
fischertony
eb539e62f8 Parse: Diagnose where clauses early on non-generic top-level declarations 2020-03-04 15:04:28 +03:00
Rintaro Ishizaki
ea6886114a [CodeCompletion] Generalize generic requirement completion
Align completion logics for all 'where' clauses.
2020-02-26 09:57:18 -08:00
ninjiacoder
06424ee6e5 [Diagnostics] Resolve SR-11677: Offer a better diagnostic when && is used in trailing where clause declaration 2019-11-03 23:50:09 +08:00
Rintaro Ishizaki
60341baf62 [SyntaxParse] Refactor generic requirement syntax structure
Re-apply a part of 0569cbfb28 after
reverting ASTGen changes. This is still an improvement.
2019-10-21 15:16:56 -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
402e791422 Revert "Merge pull request #27377 from rintaro/syntaxparse-rdar55711699"
This reverts commit 6a0bc459fc, reversing
changes made to 6aadbc3d52.
2019-10-14 12:20:21 -07:00
Rintaro Ishizaki
fbc7c6c1c5 Revert "Merge pull request #27416 from rintaro/syntaxparse-declassociatedtype"
This reverts commit 5726179da9, reversing
changes made to d5adbe2c55.
2019-10-14 12:19:53 -07:00
Rintaro Ishizaki
c773c3b5cf Revert "Merge pull request #27485 from rintaro/syntaxparse-decltypealias"
This reverts commit 8c5dcc0fe5, reversing
changes made to af5eda5d24.
2019-10-14 12:18:47 -07:00
Rintaro Ishizaki
550865caf6 Revert "Merge pull request #27528 from rintaro/syntaxparse-rdar55952739"
This reverts commit 2ddba9cf21, reversing
changes made to 33770fa665.
2019-10-14 12:18:05 -07:00
Rintaro Ishizaki
6f4dc258f5 Revert "Merge pull request #27544 from rintaro/syntaxparse-attrincomplete"
This reverts commit 071a7134b3, reversing
changes made to dbddb0d89a.
2019-10-14 12:17:27 -07:00
Rintaro Ishizaki
d2971fa1a0 [SyntaxParse] Fix crasher for generic parameter with attributes
It used to crash for:
Attribute without its name (e.g. Foo<@>)
Missing name with attributes (e.g. Foo<@available(*, unavailable)>

- Synthesize identifier token so that the SyntaxParsingContext can
  successfully construct the Attribute syntax.
- Don't throw away the parsed attributes if the parameter name is
  missing. Instead, construct GenericParamater syntax anyway, and handle
  it in ASTGen.
2019-10-04 11:03:23 -07:00
Rintaro Ishizaki
edbf24c5b3 [SyntaxParse] Fix attribute generation in ASTGen
For the intermediate lookup table of the parsed decl attributes, use
location the first token of the attributes instead of the start location
of the *parsed* attribute list because some attributes can be ignored
during the parsing.

rdar://problem/55952739
2019-10-03 12:57:53 -07:00
Rintaro Ishizaki
5914325a02 [SyntaxParse] Parse typealias declaration 2019-10-02 14:24:33 -07:00
Rintaro Ishizaki
9eb4c216ee Revert "Revert "[SyntaxParse] Parse associatedtype decl""
This reverts commit 859f90afc1.
2019-09-27 23:52:39 -07:00
Rintaro Ishizaki
6a0bc459fc Merge pull request #27377 from rintaro/syntaxparse-rdar55711699
[SyntaxParse] Fix ASAN issue
2019-09-28 05:03:45 +02: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
d9eba19b74 [SyntaxParse] Fix ASAN issue
rdar://problem/55711699
rdar://problem/55711787
rdar://problem/55711952
2019-09-25 21:27:44 -07:00
Rintaro Ishizaki
859f90afc1 Revert "[SyntaxParse] Parse associatedtype decl" 2019-09-25 11:00:21 -07:00
Rintaro Ishizaki
fc8a2e6f86 [SyntaxParse] Parse associatedtype decl
Along with inheritance clause.
2019-09-24 12:03:06 -07:00
Rintaro Ishizaki
0569cbfb28 Revert "Revert "[SyntaxParse] Parse generic parameter clause and generic where clause""
This reverts commit 1584e87aa7.
2019-09-20 15:26:04 -07:00
Rintaro Ishizaki
1584e87aa7 Revert "[SyntaxParse] Parse generic parameter clause and generic where clause" 2019-09-20 14:02:53 -07:00
Rintaro Ishizaki
f919b2ddd8 [SyntaxParse] Parse generic parameter clause and generic where clause 2019-09-19 23:09:58 -07:00
Robert Widmann
23969e9555 Clean up the way Parse deals with GenericParamList
- The parser no longer mutates these in place
- Pass generic param lists off to constructors that will readily take them
2019-09-06 17:20:28 -07:00
Rintaro Ishizaki
9ba232d718 [CodeCompletion] Implement completion at custom attribute argument 2019-05-31 11:09:54 -07:00
Doug Gregor
32b0245187 [Parser] Consistently use consumeIdentifier() for normal identifiers.
consumeIdentifier() provides the general way in which we consume an
identifier token and fill in an Identifier. Use it consistently in the
parser.
2019-04-23 11:31:58 -07:00
Christopher Ian Stern
469a0f3eb0 fix stack overflow on deeply nested parens [SR-4866] (#19631)
Make sure StructureMarkerRAII checks structure nesting level on all paths.  Previously swift crashed with  no diagnostic on deeply nested '('. Now we print an error when more than 256 parens deep, just as we always have for '['.

fixes SR-4866
2018-10-10 13:42:18 +09:00
Slava Pestov
d488509cca Parse: Remove Swift 3 support 2018-10-08 17:21:32 -07:00