Commit Graph

54 Commits

Author SHA1 Message Date
Hamish Knight
98ffddb016 [Index] Record relations for pseudo accessors
I recently accidentally broke this, make sure
we carve out an exception for pseudo accessors in
`shouldIndex` such that we record e.g override
relations for them.

rdar://131749546
2024-07-15 15:42:48 +01:00
Hamish Knight
e22ac1419c [Index] Avoid reporting containers for non-indexed decls
Check to see whether we can index the given decl
before reporting it as a container, walking up to
a parent if we need to. This also lets us simplify
the AnyPattern handling a bit.

rdar://126137541
2024-04-09 21:28:22 +01:00
Keith Smiley
e80bbd5454 Include extended typealias in index data
Previously only the type underlying the typealias was included in the
index data. Now the extension of a typealias includes 2 entries, 1 for
the underlying type and one for the typealias definition.

Fixes https://github.com/apple/swift/issues/64594
2023-04-28 14:41:49 -07:00
Ben Barham
872001f28b [Index] Use original arguments for indexing memberwise init labels
This isn't actually an issue any more because we return early when the
location is invalid, but we shouldn't be attempting to add a reference
to a label that wasn't actually written in the first place.
2022-11-08 15:17:40 -08:00
Rintaro Ishizaki
8bda524cd2 [SourceKit] Update for primary associated types
* InterfaceGen reports a primary associated type as a reference to the
  'associatedtype' declaration
* CursorInfo on a primary associated type returns information of the
  'associatedtype' declaration

rdar://93275458
2022-05-18 17:16:49 -07:00
Ben Barham
8889daedce [SourceKit] Add whether a property is dynamic
Properties can also be specified in a protocol/overridden by subclasses,
so they should also be classed as "dynamic" in these cases.

Removed receiver USRs when *not* dynamic, since it's not used for
anything in that case and should be equivalent to the container anyway.

Resolves rdar://92882348.
2022-05-13 15:13:49 -07:00
Ian Leitch
1ef1e2f829 [Index] Apply RelationContainedBy role to references contained by VarDecl.
This reverts commit abf6a30ba0.
2021-11-30 10:54:14 +01:00
Ben Barham
abf6a30ba0 Revert "[Index] Apply RelationContainedBy role to references contained by VarDecl." 2021-11-16 08:56:01 +10:00
Ian Leitch
887e71009a [Index] Apply RelationContainedBy role to references contained by VarDecl.
References associated with a `VarDecl` had no `RelationContainedBy` role, resulting in "orphaned" references. From the perspective of identifying unused code (in tools using the index, like [Periphery](https://github.com/peripheryapp/periphery)), this made it impossible to identify that a variable's type, initializer and custom attributes are associated with the variable.

Resolves: [SR-13766](https://bugs.swift.org/browse/SR-13766)
2021-11-10 09:43:24 +00:00
Nathan Hawes
0f8619b943 [IDE][SourceKit] Support escaped identifiers for the syntactic rename and related idents requests.
Resolves rdar://problem/46409010
Resolves rdar://problem/48256383
2020-04-30 13:08:23 -07:00
Nathan Hawes
f78c93009d [AST] Fix assertion hit in AutoClosureExpr::getUnwrappedCurryThunkExpr()
For DoubleCurryThunk cases it’s expecting an ApplyExpr directly within the
OpenExistentialExpr, but in some cases it contains an ErasureExpr (implicit
conversion) that wraps the ApplyExpr. This updates the method to look
through implicit conversions.

Resolves rdar://problem/61885996
2020-04-27 15:30:04 -07:00
Nathan Hawes
bce68fa4e5 [IDE][Refactoring] Handle 'callAsFunction' specially in syntactic rename.
This change makes us treat it exactly as we do 'init'. We don't allow renaming the base name,
and don't fail if the basename doesn't match for calls.

Also:
  - explicit init calls/references like `MyType.init(42)` are now reported with
    'init' as a keywordBase range, rather than nothing.
  - cursor info no longer reports rename as available on init/callAsFunction
    calls without arguments, as there's nothing to rename in that case.
  - Improved detection of when a referenced function is a call (rather than
    reference) across syntactic rename, cursor-info, and indexing.

Resolves rdar://problem/60340429
2020-04-12 17:14:15 -07:00
Doug Gregor
99d4e8090c [Index] Handle memberwise initializers with defaulted arguments. 2019-04-23 11:32:29 -07:00
Doug Gregor
0972111c60 [Type checker] Start tracking overrides of protocol requirements.
When a protocol that inherits another protocol restates a requirement
from its inherited protocol, track that as an override in the AST.
2018-09-04 16:42:06 -07:00
Slava Pestov
eeb5c953aa Sema: Ban protocol where clauses that place constraints on 'Self'
These will never work properly because of phase ordering issues with
the current declaration checker design. Since we can always express
the same thing with the protocol inheritance clause instead, just
diagnose this as an error instead of trying to hack around it.

Fixes <rdar://problem/38077232>, <https://bugs.swift.org/browse/SR-5581>.
2018-07-10 00:34:02 -07:00
Slava Pestov
03f1e13a50 IDE: Index references from keypaths 2018-07-05 23:33:59 -07:00
Saleem Abdulrasool
b67d5f0cf7 test: convert rm -rf && mkdir -p into %empty-directory
This converts the instances of the pattern for which we have a proper
substitution in lit.  This will make it easier to replace it
appropriately with Windows equivalents.
2018-03-06 14:30:54 -08:00
Pavel Yaskevich
170ccbd36d [Mangling/ABI] NFC: Fix Frontend/APINotes/Index tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Nathan Hawes
351238a199 [ASTWalker/index] Walk into the trailing where clause on extension decls so we don't miss the type references there. 2017-10-27 19:27:10 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
Rintaro Ishizaki
3337d0330f [test] Add missing ':' for FileCheck directives (#10572)
In FileCheck tests, check prefixes must be immediately followed by ':'.
2017-06-27 07:25:07 +09:00
Nathan Hawes
88cb9885da [indexer] Walk into where clauses on protocols and associated types
We were missing any references there previously.
Resolves rdar://problem/31982002.
2017-05-04 12:04:56 -07:00
Nathan Hawes
9abeb0d97a [indexer] Don't index closure params. Resolves rdar://problem/31905371. 2017-05-01 23:28:36 -07:00
Nathan Hawes
0127469a27 Merge pull request #8889 from nathawes/rdar31665007-index-memberwise-init-arglabels-as-property-references
[indexer] Index the the arg labels of memberwise initializers as references to the properties they correspond to
2017-04-20 16:53:32 -07:00
Nathan Hawes
081500a4d0 [indexer] Index the the arg labels of memberwise initializers as references to the properties they correspond to
Resolves rdar://problem/31665007
2017-04-20 13:28:50 -07:00
Argyrios Kyrtzidis
e152d4ac1f [index] Mark indexed methods as 'dynamic' when appropriate
'dynamic' for indexing purposes means the method is overridable.
2017-04-19 11:48:52 -07:00
swift-ci
19b1036c54 Merge pull request #8828 from akyrtzi/index-accessors-handling 2017-04-17 23:18:31 -07:00
Argyrios Kyrtzidis
dc7373c05b [index] Improve handling of property accessors
- Report accessor function definitions for stored properties as well
- Fix issue where a call to a computed accessor was not reported if its parent was a statement
- Take into account if the stored property is member or not to adjust the symbol kind for the accessor
2017-04-17 22:25:08 -07:00
Max Moiseev
3cbcd716f5 Merge branch 'master' into new-integer-protocols 2017-03-31 10:03:20 -07:00
Xi Ge
1a402c1c43 Index: compare interface types of potential witnesses to make sure we handle overloads properly. (#8434) 2017-03-30 11:49:54 -07:00
Xi Ge
0ccbfdb933 Index: Record override-of relationship between a decl in protocol extension and the protocol requirements it can provide default implementations for. (#8418) 2017-03-29 19:39:39 -07:00
Max Moiseev
b9fb3badc8 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-03-22 12:30:24 -07:00
Nathan Hawes
28719efd7a [indexer] Fix missing references to protocol properties
Only accessors uses were being reported previously. Resolves rdar://problem/30773201
2017-03-07 16:19:19 -08:00
Max Moiseev
835b8809d2 Merge branch 'master' into new-integer-protocols 2017-03-07 16:18:54 -08:00
Argyrios Kyrtzidis
154765293d [swift-ide-test/test] Print out symbol-info for index symbol relations
This is to make sure we get the right symbol-info when forming a symbol relation
2017-03-06 11:29:12 -08:00
Erik Eckstein
a04a29af4f mangling: efficient mangling of repeated substitutions
Instead of appending a character for each substitution, we now prefix the substitution with the repeat count, e.g.
AbbbbB -> A5B

The same is done for known-type substitutions, e.g.
SiSiSi -> S3i

This significantly shrinks mangled names which contain large lists of the same type, like
  func foo(_ x: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int))

rdar://problem/30707433
2017-03-05 17:41:43 -08:00
Nathan Hawes
df8efc2de4 Merge pull request #7846 from nathawes/rdar25616751
[indexer] Fix missing references for inherits of associated types
2017-03-01 18:05:10 -08:00
Nathan Hawes
85805f38ad [indexer] Fix missing references for inherits of associated types
E.g. MissedRef in:
protocol Proto { associatedtype T : MissedRef }

This resolved rdar://problem/25616751
2017-03-01 11:55:02 -08:00
Nathan Hawes
583f74017b [indexer] Add RelationContainedBy from references to their containing functions
Resolves rdar://problem/30765261
2017-02-28 16:55:18 -08:00
Nathan Hawes
2684564590 [indexer] report defs/refs of parameters without a separate external name 2017-02-28 11:55:34 -08:00
Erik Eckstein
7995d3d35a SourceKit: Use new mangling for USR generation. 2017-02-23 12:47:10 -08:00
Nathan Hawes
50113b74cf [indexer] Fix all function references being reported with the call role regardless of them actually being called or not 2017-02-22 13:37:32 -08:00
Argyrios Kyrtzidis
4b1d99fcc3 [index] Relate extension members with the extension symbol. 2017-02-19 20:10:33 -08:00
Argyrios Kyrtzidis
a13289835e [index] For extensions, relate the symbol reference that gets extended and base references with the extension symbol.
They were getting related with the original extended symbol, which was incorrect.
2017-02-19 18:19:39 -08:00
Argyrios Kyrtzidis
560bb99c02 [index] Provide distinct USRs for extension symbols
For indexing purposes we need to be able to treat extensions as distinct symbols.
rdar://30512293
2017-02-14 11:15:45 -08:00
Max Moiseev
06a45cb8fd Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-27 16:36:41 -08:00
Nathan Hawes
8ccccc6f74 [indexer] Fix crash in initVarRefIndexSymbols by handling func/var references in ImportDecls
IndexSwiftASTWalker::initVarRefIndexSymbols wasn't handling getCurrentExpr() returning a nullptr
as it does when processing a reference to someVar in the below import:
import var SomeModule.someVar

This patch fixes rdar://problem/30118572 and adds tests for import var/func references.
2017-01-26 09:15:42 -08:00
Max Moiseev
d128ed42b0 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-19 14:16:32 -08:00
Max Moiseev
a167238d1d Fixing more tests 2017-01-12 15:54:56 -08:00
Nathan Hawes
92f6d81455 [indexer] Fix incorrect RelationCalledBy for pseudo accessors 2017-01-11 16:07:09 -08:00