Commit Graph

133 Commits

Author SHA1 Message Date
Gwen Mittertreiner
cac35ca06b Merge pull request #24171 from gmittert/SourceKitTests
Fix SourceKit/CursorInfo Tests on Windows
2019-04-23 10:30:10 -07:00
Gwen Mittertreiner
7da91d5aeb Fix SourceKit/CursorInfo Tests on Windows 2019-04-22 15:55:55 -07:00
Rintaro Ishizaki
b5351a154c [CursorInfo] UID for opaque result type.
rdar://problem/49819227
2019-04-19 17:34:08 -07:00
Gwen Mittertreiner
c45381d286 Windows: Close Handle after Resolving Symlinks
Calling resolvePathSymlinks twice on the same path failed with a sharing
exception due to the old handle still being help.
2019-03-15 12:24:20 -07:00
Nathan Hawes
7680cc6b16 [sourcekitd] Report entities that are implicitly objc as objc in the index request responses for compatibility
Members of an @objcMembers context previous had implicit @objc attributes, but
now don't (possibly because of the request evaluator changes?). This updates the
output of sourcekitd's 'index' request to act as if they still had implicit
@objc attributes on them for compatibility.

Resolves rdar://problem/48140265
2019-02-22 16:35:30 -08:00
Rintaro Ishizaki
1d845d6e3f [IDE/SourceKit] New SourceKit request for filtered method list
`source.request.conformingmethods` is a new SourceKit request which
receives a source position and a list of protocol namses, returns a list
of methods whose return type conforms to the requested protocols.

rdar://problem/44699573
2019-02-08 12:56:58 -08:00
swift-ci
cf1be5e644 Merge pull request #20427 from rockbruno/sourcekit-operators 2018-11-30 09:02:57 -08:00
Harlan Haskins
a64a4e1940 [Sema] Add implicit @_hasStorage attribute for printing 2018-11-26 18:42:02 -08:00
Bruno Rocha
6f1f1bda92 [SourceKit] Recognize static method operators 2018-11-08 12:33:06 -02:00
Bruno Rocha
bf84b297f8 [SourceKit] Allow module references to be indexed (#19243)
Module references get indexed as a 'module' symbol; they get USRs similar to how clang would assign a USR for a module reference.

JIRA: https://bugs.swift.org/browse/SR-8677
2018-09-28 12:21:38 -07:00
Ben Langmuir
b3422c1e9d [sourcekit] Stop storing a bare reference to LangSupport in ASTManager
This fixes a use-after-free when an AST build finishes after shutdown().
2018-09-25 14:57:33 -07:00
Ben Langmuir
1015da026e [sourcekit] Remove reference to global context from SwiftLangSupport NFC
While the SwiftLangSupport doesn't currently outlive the global context
it clarifies the ownership to just store the weak reference we care
about instead of referencing the owning context. In the future we may
want to ref-count the lang support, in which case we'd need to do this
to avoid a cycle anyway.
2018-09-25 14:57:32 -07:00
Ben Langmuir
cc22c61d92 [sourcekit] Use a shared_ptr for the SwiftASTManager
When the server shuts down we may still have outstanding async work to
build an AST, so use a shared_ptr + weak_ptr instead of unique_ptr +
unowned references.
2018-09-25 14:57:32 -07:00
John McCall
b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
Robert Widmann
2fb5afb755 Remove the @_downgrade_exhaustivity_check hack
This hack was only needed for Swift 3 mode in a narrow case.  Flush it out of the compiler so we can simplify the space engine.
2018-08-24 10:54:43 -07:00
Huon Wilson
7753383223 [AST] Add @_hasInitialValue to var/lets that have initializers.
The information about whether a variable/property is initialized is lost in the
public interface, but is, unfortunately, required because it results in a symbol
for the initializer (if a class/struct `init` is inlined, it will call
initializers for properties that it doesn't initialize itself). This is
important to preserve for TBD file generation.

Using an attribute rather than just a bit on the VarDecl means this fits into
the scheme for module interfaces: textual/valid Swift.
2018-08-07 09:54:35 +10:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Vedant Kumar
d910e5a5c2 [SourceKit] Disable expensive SIL options (#17306)
Disable the sanitizers and code coverage when building a swift
invocation for the purpose of collecting diagnostics.

This should speed up diagnostic generation and reduce exposure to
compiler bugs.

rdar://40955900
2018-06-18 14:43:27 -07:00
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04: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
Nathan Hawes
c326ec46c7 [Refactoring] Fix subscript rename
Adds support for renaming subscripts with external names, e.g.
subscript(x y: Int), and introduces a noncollapsible parameter name range for
subscript parameters, since these shouldn't be collapsed with an argument label
of the same name as function parameter names are.
2017-11-28 19:45:29 -08:00
Alex Hoppen
746bfc6d59 [Refactoring] Add refactoring action to move type members to extension (#12795)
This implements SR-6297.
2017-11-09 11:08:34 -08:00
Marcelo Fabri
ba39c7b235 [SourceKit] Include AccessLevel attributes in structure (SR-5978) (#12086) 2017-10-11 20:57:09 -07:00
Ben Langmuir
9c7d9235de [sourcekitd] Add a request to get statistics from the service
... and add a few basic statistics about the number of requests, ASTs
built, etc.  The Statistic type is loosely based on the one from LLVM,
but suitable for using without DEBUG macros and using SourceKit UIdents
to identify the statistic.  The easiest way to add a new statistic is to
add it to SwiftStatistics.def in the SwiftLangSupport.
2017-10-05 12:34:49 -07:00
Marcelo Fabri
95383df793 [SourceKit] Introduce "source.lang.swift.expr.tuple" (SR-5977) (#12089) 2017-09-27 10:08:27 -07:00
Marcelo Fabri
2bf49b0151 [SourceKit] Add range for attributes in a structure (SR-5587) (#11750) 2017-09-20 15:54:42 -07:00
Jordan Rose
449cd98997 Excise "Accessibility" from the compiler (3/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

Rename AccessibilityAttr to AccessControlAttr and
SetterAccessibilityAttr to SetterAccessAttr, then track down the last
few uses of "accessibility" that don't have to do with
NSAccessibility. (I left the SourceKit XPC API alone because that's
supposed to be more stable.)
2017-08-28 13:27:59 -07:00
swift-ci
c64e7f7dd9 Merge pull request #11489 from marcelofabri/associatedtype-structure 2017-08-25 11:40:10 -07:00
Argyrios Kyrtzidis
60a91bb736 [refactoring] Upstreaming the implementation for Swift local refactoring (#11568)
[refactoring] Upstreaming the implementation for Swift local refactoring
2017-08-22 16:50:16 -07:00
Marcelo Fabri
8b9b49fdf3 [SourceKit] Add associatedtype to doc structure (SR-5700) 2017-08-16 23:40:36 +02:00
Marcelo Fabri
40b054b642 [SourceKit] Add local variables to structure (SR-5057) (#11431) 2017-08-11 13:43:05 -07:00
Rintaro Ishizaki
b754b9e9b6 [IDE] Remove support for C-style ForStmt 2017-08-04 23:27:22 +09: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
Xi Ge
63aeb0123e SourceKit: Refactor Kinds UIDs to ProtocolUIDs.def. (#10604)
"Kind" is a frequently appearing concept in SourceKitD. This patch
refactors the definitions of these "Kinds" and their associated values
 into the single protocol file. Ideally, we should structurally define Kinds instead of this
flat list.
2017-06-27 10:51:48 -07:00
Robert Widmann
4f35068772 Implement @_downgrade_exhaustivity_check
Dispatch requests the ability to add a new case, but to treat missing
instances of that case in patterns as warnings instead of errors.  It is
still an error to make reference to the annotated case in at least one
pattern then not cover the rest of the space, but it is not an error
to omit the space of patterns referencing the case entirely.

This attribute is private and uglified to intentionally discourage
its use outside just this one use case.
2017-05-25 12:51:17 -07:00
Xi Ge
83183abc38 RangeInfo: Add a new range info kind that describes part of a parent expression. rdar://32039874 (#9707) 2017-05-17 14:21:47 -07:00
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
swift-ci
64882e0bbf Merge pull request #7611 from hughbe/resolve-symlinks 2017-02-19 20:37:18 -08:00
Hugh Bellamy
3464a9399d Port SwiftLangSupport::resolvePathSymlinks to Windows 2017-02-20 10:04:46 +07:00
Hugh Bellamy
2bc2341300 Fix SourceKit unreachable warnings 2017-02-19 14:20:52 +07:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Xi Ge
b32424953e [SourceKit] Add a new request to translate from Objc names to Swift names and vice versa.
Extensive cross-language tooling support needs to bridge decl names between two different languages more freely. This SourceKit request is designed to translate Objc names to Swift names and vice versa. Working similarly to cursor-info requisition, the name translation request requires a Swift reference to a Swift/Clang decl, and the preferred name to translate from, and language kind that the given name belongs to. If the translation succeeds, SourceKit service responds with the corresponding name than belongs to the other kind of language.

Newly introduced keys:

“key.namekind": “source.lang.name.kind.objc” | "source.lang.name.kind.swift"
“key.basename”: “name"
“key.argnames”: [“name"]
“key.selectorpieces”: [“name[:]"]

This commit only implements translation from Objc to Swift.
2017-02-10 17:50:12 -08:00
Argyrios Kyrtzidis
7076ebbf72 [index] Switch to using the general accessor getter/setter symbol kinds. 2017-01-11 17:09:17 -08:00
Argyrios Kyrtzidis
db8ec19f55 [index] Use the index symbol types and APIs from the clang header.
This avoids duplication and centralizes handling of symbols.
2017-01-10 14:49:07 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00