Commit Graph

210 Commits

Author SHA1 Message Date
Nathan Hawes
a1de792ae3 [IDE][syntax-coloring] Treat unterminated raw strings as strings for syntax coloring purposes
The existing check assumed unterminated strings started with " which is no
longer true now we have raw strings.

Resolves rdar://problem/48269826
2019-02-22 18:53:32 -08:00
Rintaro Ishizaki
d4c3ee6b49 [IDE] Handle '@unknown' attribute in syntax map
`@unknown` is so far the only attribute for statement. Handle it
specially in syntax-map.

rdar://problem/47855035 / https://bugs.swift.org/browse/SR-9873
2019-02-06 11:23:53 -08:00
Rintaro Ishizaki
e7700dc67f [IDE] Fix SyntaxModel to corretly walk sequence expression correctly
* Handle sequence expression at call argument position
* Set the sequence expression as the parent when walking into its sub
  expressions.
* Correctly call walkToExprPost() to the sequence expression.

rdar://problem/47603866 / https://bugs.swift.org/browse/SR-9776
2019-01-28 11:25:07 -08:00
Marcelo Fabri
d948823d89 [SR-9576][SourceKit] Fix syntax type when rethrows is present 2019-01-22 20:26:23 -08:00
Slava Pestov
fc8f122336 AST: Remove FuncDecl::getReturnTypeLoc() 2018-12-02 18:41:39 -05:00
Rintaro Ishizaki
fedc36e4fb [IDE] Don't walk to ExplicitCast expr twice in ModelASTWalker
Explict cast expressions (i.e. 'as', 'as!`, 'as?', and 'is') appear twice in
'SequenceExpr'. For instance, 'a as B' is parsed as:
  (sequence_expr
    (unresolved_declref_expr name='a')
    (coerce_expr writtenType='B')
    (coerce_expr writtenType='B'))
This patch prevents ModelASTWalker from walking into them twice.

rdar://problem/43135727
2018-08-14 08:19:48 +09:00
Rintaro Ishizaki
49f6a28637 [IDE] Use collected token to retrieve range of type identifier
Previously, it used to use length from AST. Because AST doesn't necessarily
holds actual source information, it may emits inacculate syntax info
which cause mis-coloring or compiler crash in the worst case. Instead, use
collected token info which contains actual token length.

https://bugs.swift.org/browse/SR-8378
rdar://problem/42653982
2018-08-02 10:02:58 +09:00
John McCall
9bee3cac5a Generalize storage implementations to support generalized accessors.
The storage kind has been replaced with three separate "impl kinds",
one for each of the basic access kinds (read, write, and read/write).
This makes it far easier to mix-and-match implementations of different
accessors, as well as subtleties like implementing both a setter
and an independent read/write operation.

AccessStrategy has become a bit more explicit about how exactly the
access should be implemented.  For example, the accessor-based kinds
now carry the exact accessor intended to be used.  Also, I've shifted
responsibilities slightly between AccessStrategy and AccessSemantics
so that AccessSemantics::Ordinary can be used except in the sorts of
semantic-bypasses that accessor synthesis wants.  This requires
knowing the correct DC of the access when computing the access strategy;
the upshot is that SILGenFunction now needs a DC.

Accessor synthesis has been reworked so that only the declarations are
built immediately; body synthesis can be safely delayed out of the main
decl-checking path.  This caused a large number of ramifications,
especially for lazy properties, and greatly inflated the size of this
patch.  That is... really regrettable.  The impetus for changing this
was necessity: I needed to rework accessor synthesis to end its reliance
on distinctions like Stored vs. StoredWithTrivialAccessors, and those
fixes were exposing serious re-entrancy problems, and fixing that... well.
Breaking the fixes apart at this point would be a serious endeavor.
2018-06-30 05:19:03 -04:00
Alex Hoppen
9149cb61c5 Merge pull request #16474 from ahoppen/namelength
[SourceKit] Make the NameLength of EnumElements take argument labels into account
2018-05-10 12:14:11 -07:00
Alex Hoppen
4f43c8e93c [SourceKit] Make the NameLength of EnumElements take argument labels into account 2018-05-10 11:27:49 -07:00
Rintaro Ishizaki
1fa04208e0 [IDE] Fix visiting DeferStmt
* Call balanced walkToStmtPost() for DeferStmt.
* In walkToStmtPre(), return DeferStmt itself instead of the body.

rdar://problem/39948168
2018-05-08 16:32:52 +09:00
Sho Ikeda
976c7f9c27 [gardening][IDE] Replace typedef with using 2018-03-26 13:45:36 +09:00
Rintaro Ishizaki
bdcd87754d [Parse] Eliminate POUND_OLD_OBJECT_LITERAL tokens
We don't want to handle them in libSyntax
2018-03-14 21:50:53 +09:00
John Fairhurst
677491fc9b [SourceKit] Add syntaxtype for #error/#warning (#14742) 2018-02-21 14:48:18 -08:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Marcelo Fabri
94465a38c0 [SourceKit] Add GenericTypeParam to structure (SR-5474) (#13616) 2018-01-09 17:28:52 -08:00
Marcelo Fabri
b6ecf9c6d4 [SourceKit] Introduce "source.lang.swift.expr.closure" in structure (SR-6116) (#13617) 2018-01-04 10:45:29 -08:00
Marcelo Fabri
95383df793 [SourceKit] Introduce "source.lang.swift.expr.tuple" (SR-5977) (#12089) 2017-09-27 10:08:27 -07:00
Nathan Hawes
90cc29bb2c [syntax-coloring] Highlight unterminated regular and multi-line strings as strings
Also add tests for syntax map deltas when editing multi-line strings
2017-09-14 21:34:21 -07:00
Xi Ge
2ba1ca2d8f IDE: simplify some code. NFC (#11935)
* IDE: simplify some code. NFC

* add assert.
2017-09-14 18:19:48 -07:00
Xi Ge
6970b692e1 SyntaxModel: remove more unnecessary code. NFC 2017-09-08 13:23:48 -07:00
Xi Ge
0cfa094e75 SyntaxModel: remove unnecessary code. NFC (#11820) 2017-09-08 13:13:01 -07:00
Xi Ge
560b08c171 SyntaxModel: simplify the collecting of contextual keywords in PrecedenceGroup.NFC (#11819) 2017-09-08 12:38:44 -07:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -07:00
Marcelo Fabri
5c65887fd0 [SourceKit] Add function argument when optional chaining is used (SR-5717) (#11542) 2017-08-29 12:59:43 -07:00
Marcelo Fabri
8b9b49fdf3 [SourceKit] Add associatedtype to doc structure (SR-5700) 2017-08-16 23:40:36 +02:00
Marcelo Fabri
c639147f02 [SourceKit] Include function return type in function kinds structure (SR-5613) 2017-08-14 20:53:00 +02:00
swift-ci
98f9510e39 Merge pull request #11438 from nkcsgexi/color-keyword 2017-08-11 14:43:19 -07:00
Xi Ge
6123cb19e8 SyntaxColoring: Highlight keywords immediately after periods as identifiers. rdar://33805178 2017-08-11 14:14:15 -07:00
Marcelo Fabri
40b054b642 [SourceKit] Add local variables to structure (SR-5057) (#11431) 2017-08-11 13:43:05 -07:00
Rintaro Ishizaki
eb6914ccfc Merge pull request #11346 from rintaro/rip-cfor
Eliminate C-style ForStmt
2017-08-08 07:49:42 -07:00
Xi Ge
6573a5fe41 SourceKit: Report the signature length for subscript declarations. SR-5626 (#11376) 2017-08-07 14:11:52 -07:00
Rintaro Ishizaki
b754b9e9b6 [IDE] Remove support for C-style ForStmt 2017-08-04 23:27:22 +09:00
Rintaro Ishizaki
546aeb2336 [Parse] Remove Parser support for C-style for statement. 2017-08-04 23:27:15 +09:00
Nathan Hawes
df91a46729 Filter out 0-length tokens when generating syntax model nodes.
Resolves rdar://problem/33601932.
2017-08-03 13:09:18 -07:00
Marcelo Fabri
d16cce3a94 [SourceKit] Add documentation range in structure (SR-2487) (#11264) 2017-08-02 13:39:49 -07:00
Marcelo Fabri
c4dad0c321 [SourceKit] Add subscript to doc structure (SR-5035) 2017-08-01 00:00:20 +02:00
John Fairhurst
1f94eca80c [SourceKit] Add typealias to doc structure (#11143)
From https://bugs.swift.org/browse/SR-4828
2017-07-26 09:59:06 -07:00
Robert Widmann
b77f2c147c Parse Shared
Add parser support for __shared and __owned as type attributes.  Also, extend parser diagnostics and tests to account for the new type attributes.
2017-07-23 21:47:25 -07:00
Xi Ge
b8cf32f1e9 Revert "[syntax-coloring] Rework the syntax map to use offset + length and simplify the delta logic" (#10633)
Resolving rdar://32988175.
2017-06-27 12:28:41 -07:00
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
Nathan Hawes
9ec658ae7f Merge pull request #10289 from nathawes/rdar32148117-multiline-syntax-coloring-issues
[syntax-coloring] Rework the syntax map to use offset + length and simplify the delta logic
2017-06-19 13:26:26 -07:00
Slava Pestov
732b215b88 Merge pull request #9413 from rintaro/ast-eliminate-ifconfigstmt
[AST] Eliminate IfConfigStmt
2017-06-16 15:39:47 -07:00
Nathan Hawes
fa3873ec8e [syntax-coloring] Highlight unterminated regular and multi-line strings as strings
Also add tests for syntax map deltas when editing multi-line strings
2017-06-15 13:16:04 -07:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00
Nathan Hawes
e5426ecfa5 Revert "[SyntaxColor] Improve highligting of multiline strings"
This reverts commit 86d0fc37bc.
This was causing a performance regression.

Resolves rdar://problem/32434045
2017-05-26 16:46:03 -07:00
Nathan Hawes
56fb4a5d9f [SyntaxColor] Improve highligting of multiline strings
Multiline strings (and multiline tokens in general) were not well supported by the existing highlighting logic. Edits
on one line can make tokens appear/disappear on previous and later lines, which broke assumptions in the existing
logic, and left odd ranges of source unhighlighted or out of date. This patch accounts for these changes, and also
changes unterminated  multiline (and regular strings) to still be highlighted as strings, so the rest of the
file doesn't look like plain text.

Resolves rdar://problem/32148117.
2017-05-22 16:53:32 -07:00
Rintaro Ishizaki
6fa84150c5 [AST] Eliminate IfConfigStmt
Resolves: https://bugs.swift.org/browse/SR-4426

* Make IfConfigDecl be able to hold ASTNodes
* Parse #if as IfConfigDecl
* Stop enclosing toplevel #if into TopLevelCodeDecl.
* Eliminate IfConfigStmt
2017-05-16 12:19:54 +09:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00