Commit Graph

2134 Commits

Author SHA1 Message Date
Rintaro Ishizaki
55144fb302 [Macros] Add test for macro expansion printing
* Macro expanded member decls in .swiftinterface (rdar://117374821)
* cursor-info on a decl with peer macro attribute (rdar://117374966)
2023-10-23 15:21:33 -07:00
Alex Hoppen
2507e0e9ee [SourceKit] Support getting semantic tokens for macro expansion buffers 2023-10-23 11:06:49 -07:00
Alex Hoppen
4bc03f8392 [SourceKit] Add a request to get the semantic tokens of a file
We need this request for semantic highlighting in LSP. Previously, we were getting the semantic tokens using a 0,0 edit after a document update notification but that will no longer be possible if we open the documents in syntactic only mode.
2023-10-20 10:38:08 -07:00
Simon Barinka
23cde9b2e0 [SourceKit] Move the option to IndexToStore request 2023-10-20 12:55:41 +02:00
Alexis Laferrière
8b098ab487 [Tests] Remove the flag AccessLevelOnImport from all tests but one 2023-10-10 09:09:22 -07:00
Simon Barinka
b918345910 [SourceKit] Add tests 2023-10-09 21:09:25 +02:00
Egor Zhdan
041005af7c [cxx-interop] Use more correct type names in C++ template parameters
When importing a C++ class template instantiation, Swift translates the template parameter type names from C++ into their Swift equivalent.

For instance, `basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>` gets imported as `basic_string<Scalar, char_traits<Scalar>, allocator<Scalar>>`: `wchar_t` is imported as `CWideChar`, which is a typealias for `Scalar` on most platforms including Darwin. Notice that Swift goes through the `CWideChar` typealias on the specific platform. Another instantiation `basic_string<uint32_t, char_traits<uint32_t>, allocator<uint32_t>>` also gets imported as `basic_string<Scalar, char_traits<Scalar>, allocator<Scalar>>`: `uint32_t` is also imported as `Scalar`. This is problematic because we have two distinct C++ types that have the same name in Swift.

This change makes sure Swift doesn't go through typealiases when emitting names of template parameters, so `wchar_t` would now get printed as `CWideChar`, `int` would get printed as `CInt`, etc.

This also encourages clients to use the correct type (`CInt`, `CWideChar`, etc) instead of relying on platform-specific typealiases.

rdar://115673622
2023-10-09 14:57:10 +01:00
Alex Hoppen
8dec9addfc [ASTGen] Relax assertion on BridgedSourceLoc initializer
We do allow `SourceLoc` to point to the address right after the buffer ends to point to the end of a file.
2023-09-26 15:46:54 -07:00
Mishal Shah
5b73dd6929 Bump the Swift version to 5.11 2023-09-18 09:37:38 -07:00
Slava Pestov
fd06bd87aa AST: Allow the extended type of an extension to refer to be a tuple type
Either directly, or via a type alias.
2023-09-05 23:21:26 -04:00
Michael Spencer
b2640e15e4 [test] Rename all module.map files to module.modulemap
`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.

rdar://106123303
2023-08-21 15:58:59 -07:00
Nishith Shah
8e2e625543 [Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
This commit changes fixit messages from a question/suggestion to an
imperative message for protocol conformances and switch-case. Addresses
https://github.com/apple/swift/issues/67510.
2023-08-13 22:34:26 -07:00
Alex Hoppen
bba2f476ab Merge pull request #67613 from barinsim/my-main
[SourceKit] Report cursor info information for literals
2023-08-08 20:54:00 -07:00
Simon Barinka
9342e78e3e [SourceKit] Fix support for interpolated strings 2023-08-08 23:36:16 +02:00
Hamish Knight
c0e2d5ecbb Merge pull request #67015 from skrtks/sk-fix-incorrect-optional-types 2023-08-03 19:44:29 +01:00
Simon Barinka
06af7494e9 [SourceKit] Report type decl info instead of hidden inits 2023-08-02 23:40:08 +02:00
Simon Barinka
b7ee6e4c1d [SourceKit] Remove unnecessary open request 2023-08-01 19:16:41 +02:00
Simon Barinka
944a81836c [SourceKit] Remove sourcekit-test_plain 2023-08-01 19:13:20 +02:00
Alex Hoppen
b92530f50b Merge pull request #67500 from ahoppen/ahoppen/accessor-refactoring
Adjustments for refactoring of representation of Accessors in SwiftSyntax
2023-08-01 06:34:24 -07:00
Simon Barinka
d0cf2e4bf3 [SourceKit] Fix formatting issues 2023-08-01 13:26:14 +02:00
Simon Barinka
e32a20a55c [SourceKit] Report init info instead of the type decl info
Addresses PR review comments.
2023-08-01 12:51:39 +02:00
Alex Hoppen
cf81bab67d [Macros] Adjust test case because accessors are only separated by a single line 2023-07-31 21:53:24 -07:00
Simon Barinka
fcd084f9dd [SourceKit] Report cursor info information for literals
Adds literals support for the CursorInfo request.
Previously CursorInfo just returned error for literals.
Implements issue #57725
2023-07-30 14:22:08 +02:00
Alex Hoppen
992398b211 Merge pull request #67584 from ahoppen/ahoppen/de-duplicate-cursor-info-results
[CursorInfo] De-duplicate reported cursor info results
2023-07-28 07:33:52 -07:00
Alex Hoppen
862e14e084 [CursorInfo] De-duplicate reported cursor info results
The constraint system might produce multiple solutions that all reference the same declaration. We should only report the declaration once in those cases instead of multiple times.

rdar://111814276
2023-07-27 16:48:28 -07:00
Ben Barham
7e8a33097e Merge pull request #67488 from bnbarham/better-note-locations
[Diagnostics] Improve diagnostics involving macros
2023-07-26 17:48:02 -07:00
Ben Barham
18cb5f4f3d [Diagnostics] Update in_macro_expansion note for attached macros
Use the attached atttribute's location as the location of the macro,
rather than the location of the declaration it's attached to. Also add
the kind and name of that declaration to the note itself.
2023-07-25 16:03:52 -07:00
Kavon Farvardin
b5e0f95a18 eliminate pipes in favor of shlex
This solves deprecation warnings in build-script:

```
DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
```

This change assumes that the minimum version
of Python3 is 3.3, which has `shlex.quote`.

Since our build bots currently use 3.6 as their
Python version, we can't yet use `shlex.join`
to further simplify some of the code using
quote.
2023-07-25 15:24:54 -07:00
Sam Kortekaas
c210a08afb [SourceKit] Don't report types for implicit expressions
Fixes incorrectly reporting an optional type for an expression when the contextual type is optional.

fixes #66882
rdar://111462279
2023-07-25 10:12:14 +02:00
Holly Borla
61e5811d73 [NFC] Update IDE, Index, ModuleInterface, and SourceKit tests to remove
conformance macros.
2023-07-19 12:38:52 -07:00
QuietMisdreavus
2565925f88 [SymbolGraphGen] allow cursor symbol graphs from function params (#67267)
rdar://105516823
2023-07-13 13:48:12 -06:00
Ben Barham
6e93ac1627 Merge pull request #66958 from DavidGoldman/main
Add source.request.index_to_store to sourcekitd
2023-07-12 13:53:33 -07:00
David Goldman
bce6490e44 Fix indexstore test paths on Windows 2023-07-11 17:14:52 -04:00
Alex Hoppen
c7e0bfae02 [IDE] Adjust test cases for migrating all completion kinds to solver-based 2023-07-07 19:51:01 +02:00
Holly Borla
67b30a406a [NFC] Fix formatting of expanded extensions in SourceKit tests. 2023-06-30 22:54:22 -07:00
David Goldman
af81adb63c sourcekitd source.request.index_to_store fixes - new test and minor changes 2023-06-30 15:55:43 -04:00
David Goldman
d618233166 Add source.request.index_to_store to sourcekitd
This requests performs an index store index of the given file using the
given index store path and index unit output path. All other options are
derived from the index store related compiler flags.

This will allow IDEs like Xcode to index the file directly inside of
sourcekitd and potentially reuse an already built AST.
2023-06-28 14:24:20 -04:00
Ben Barham
ab95dba720 [CursorInfo] Pass primary path to allow comparing previous ASTs
Update the cursor requests to also pass in their primary file. Snapshots
should be compared using this file, not the input buffer name. This
fixes AST re-use when the AST is usable with snapshots.

Resolves rdar://110344363.
2023-06-23 20:00:19 -07:00
Ben Barham
037ddc92ee [CursorInfo] Re-use already built ASTs ahead of currently building ones
Resolves rdar://110344363.
2023-06-22 14:12:48 -07:00
Kim de Vos
28df294e00 Remove spacing 2023-06-21 10:56:57 +02:00
Hamish Knight
a9f9bd1394 [SourceKit] Record module loading errors when generating interfaces
Record up to two errors emitted when we fail to
load a module for interface generation, and include
these errors in the message we pass back to the
editor. This should help us better pin down the
reason why interface generation failed.

rdar://109511099
2023-06-15 23:55:07 +01:00
QuietMisdreavus
e45c9df2a3 always use the argNames constructor for macro DeclNames (#66497)
rdar://110179186
2023-06-12 09:10:02 -06:00
Alex Hoppen
78d6822840 Merge pull request #66458 from ahoppen/ahoppen/consume-borrow-highlighting
[SourceKit] Highlight `consuming` and `borrowing` as keywords
2023-06-08 16:58:40 -07:00
Alex Hoppen
2ff585d6ff [SourceKit] Highlight consuming and borrowing as keywords 2023-06-08 10:59:42 -07:00
Rintaro Ishizaki
c3d1304345 [SourceKit] Add request to expand macros syntactically
Expand macros in the specified source file syntactically (without any
module imports, nor typechecking).

Request would look like:
```
{
  key.compilerargs: [...]
  key.sourcefile: <file name>
  key.sourcetext: <source text> (optional)
  key.expansions: [<expansion specifier>...]
}
```
`key.compilerargs` are used for getting plugins search paths. If
`key.sourcetext` is not specified, it's loaded from the file system.
Each `<expansion sepecifier>` is
```
{
  key.offset: <offset>
  key.modulename: <plugin module name>
  key.typename: <macro typename>
  key.macro_roles: [<macro role UID>...]
}
```
Clients have to provide the module and type names because that's
semantic.

Response is a `CategorizedEdits` just like (semantic) "ExpandMacro"
refactoring. But without `key.buffer_name`. Nested expnasions are not
supported at this point.
2023-06-07 14:26:40 -07:00
Doug Gregor
1ddecc00cc Merge pull request #66403 from DougGregor/remove-option-set 2023-06-07 06:49:39 -07:00
Doug Gregor
feb5c09d93 Remove OptionSet macro from the standard library. 2023-06-06 23:37:38 -07:00
Doug Gregor
70820749df Update mangled names in test case 2023-06-06 23:22:01 -07:00
Kim de Vos
d0b412e3eb Merge pull request #66106 from kimdv/kimdv/remove-newline-from-swift-syntax-code-gen
[SwiftSyntax] Remove `requiresLeadingNewline` from basic format
2023-05-30 21:32:50 +02:00
QuietMisdreavus
60ef958116 don't break a doc comment with a regular comment (#66136)
rdar://95307936
2023-05-30 08:44:02 -06:00