Commit Graph

119 Commits

Author SHA1 Message Date
Nathan Hawes
07ebaccfd3 [Refactoring] SyntacticRename should walk into ObjC Keypath components when matching name locations.
It wasn't previously so missed them.

Resolves rdar://61573935
2021-03-12 15:17:57 +10:00
shreyaa-sharmaa
2b11d7acc7 Task SR-14138 Replace std::transform with llvm::transform 2021-02-04 12:58:33 +05:30
Slava Pestov
e675bee26c AST: Split off DependencyCollector.h from EvaluatorDependencies.h
Also remove some unnecessary #includes from DependencyCollector.h,
which necessitated adding #includes in various other files.
2020-12-23 00:00:25 -05:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
swift_jenkins
fb946baf59 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-28 11:08:22 -07:00
Frederick Kellison-Linn
352adc3b5d Remove Argument from UnresolvedMemberExpr
Instead, an expresison like `.foo()` is represented as an `UnresolvedMemberExpr` nested inside a `CallExpr`.
2020-08-26 22:42:30 -04:00
swift-ci
ae09b1eb08 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-04 18:03:56 -07:00
Anthony Latsis
b26310ee97 TypeLoc: Offload TypeLoc off the ASTWalker 2020-08-04 18:13:28 +03:00
swift_jenkins
abb1d170fc Merge remote-tracking branch 'origin/master' into master-next 2020-06-11 00:38:31 -07:00
Robert Widmann
fb8fdd9644 Replace resolveCustomAttrType with a Request 2020-06-10 19:31:41 -07:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
swift_jenkins
e6e25df038 Merge remote-tracking branch 'origin/master' into master-next 2020-05-06 14:35:31 -07:00
Nathan Hawes
78b7bce3a0 [IDE][Refactoring] Update syntactic rename to support braceless multiple trailing closures. 2020-05-06 01:56:41 -04:00
swift_jenkins
6253fd4753 Merge remote-tracking branch 'origin/master' into master-next 2020-05-04 14:57:15 -07: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
swift_jenkins
6cc93e4718 Merge remote-tracking branch 'origin/master' into master-next 2020-04-13 13:18:50 -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
Alex Langford
17b25bad5d Include clang SourceManager header where needed
These files were using clang::SourceManager with only a forward declaration.
Most likely another header was previously including the SourceManager header so
that these files got the header included transitively.
2020-03-03 12:36:11 -08:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
c1444dea18 SR-11889: Fixed code review issues 2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
Nathan Hawes
b9d5672ca1 [SourceKit] Add a global-configuration request to control SourceKit's behavior around .swiftsourceinfo files
SwiftSourceInfo files provide source location information for decls coming from
loaded modules. For most IDE use cases it either has an undesirable impact on
performance with no benefit (code completion), results in stale locations being
used instead of more up-to-date indexer locations (cursor info), or has no
observable effect (live diagnostics, which are filtered to just those with a
location in the primary file).

For non-IDE clients of SourceKit though, cursor info providing declaration
locations for symbols from other modules is useful, so add a global
configuration option (and a new request to set it) to control whether
.swiftsourceinfo files are loaded or not based on use case (they are loaded by
default).
2019-12-03 13:15:20 -08:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
Xi Ge
8f1a9b4789 IDE+Evaluator: refactor range info resolver to an IDE evaluator request. NFC 2019-07-17 12:20:09 -07:00
Xi Ge
8915cf8c4d Sourcekit/Evaluator: refactor cursor-info resolver to using the evaluator model. NFC
This change adds a new IDE request ID zone and refactors the cursor-info resolver
to use the request evaluator model.
2019-07-16 09:55:16 -07:00
Doug Gregor
1284878ad8 [SE-0258] Rename init(initialValue:) --> init(wrappedValue:).
Addresses core team decision on acceptance of property wrappers.

Fixes rdar://problem/48871069.
2019-07-10 14:26:53 -07:00
Nathan Hawes
e08a6c1994 [IDE][Index][test] Update sourcekit/indexing support for latest property wrapper changes
The backing property for 'foo' is now '_foo', and the projected value '$foo'.
This updates Indexing to report occurrences of foo within both $foo and
_foo occurrences (rather than just $foo - the old _foo).

FindRelatedIdents was similarlar updated, so it reports 'foo' ranges in both
_foo and $foo.

CursorInfo now reports the USR, documentation, and location of foo when invoked
occurrences of $foo or _foo, but now leaves the name, type, and annotated
declaration of _foo/$foo as is. Having the same USR ensures rename invoked on
any of them will still rename via foo. Reporting foo's documentation comment
instead is just to present something more useful to the user.
2019-06-28 10:15:00 -07:00
Nathan Hawes
c7e8b3f693 [test] Update Index/refactoring property wrapper tests to use wrappedValue rather than value
Plus other small cleanups to comments and variable names.
2019-06-26 18:37:47 -07:00
Nathan Hawes
91e2e35a77 [IDE] Update CursorInfo and FindRelatedIdents to treat property wrapper backing properties as the underlying property
This is the final piece to get rename and findRelatedIdents to include all foo
and $foo occurrences, for example, in the set of occurrences to be renamed or
shown, regardless of whether they were initiated on a foo or $foo.

Resolves rdar://problem/51695783.
2019-06-26 18:37:47 -07:00
Nathan Hawes
d389652998 [IDE][Index] Renaming a wrapped property should also rename the synthesized $-prefixed backing property
This patch achieves this by updating indexing to reporting the position of
`foo` in occurrences of `$foo` as an occurrence of the `foo` symbol, so
that renames initiated on occurrences of the `foo` symbol will also result
in occurrences of the `$foo` symbol being updated correctly. This also means
find-references on foo will show places where $foo is used.

Making rename work in the other direction (invoking rename on $foo upating foo
occurrences too) is still todo.
2019-06-26 18:37:47 -07:00
Nathan Hawes
a565430239 [IDE][Index] Fix syntax coloring, index, and rename support for custom attributes
This fixes custom attribute syntax highlighting on parameters and functions
(where function builders can be applied). They weren't being walked in
the function position previously and were walked out of source order in the
parameter position.

It also fixes rename of the property wrapper and function builder type
names that can appear in custom attributes, as well as rename of property
wrapper constructors, that can appear after the type names, e.g.
`@Wrapper(initialValue: 10)`. The index now also records these constructor
occurrences, along with implicit occurrences whenever a constructor is
called via default value assignment, e.g. `@Wrapper var foo = 10`, so that
finding calls/references to the constructor includes these locations.

Resolves rdar://problem/49036613
Resolves rdar://problem/50073641
2019-06-26 18:37:47 -07:00
Ben Langmuir
effab8c522 Handle dynamic member lookup in annotation and cursor info
Ensure the various entity walkers handle the implicit subscript
reference correctly (usually by ignoring it) and fall through to the
underlying declarations.

rdar://49028895
2019-04-16 15:37:32 -07:00
Ben Langmuir
6af24d083c [index] Fix dynamicMemberLookup subscript reference implicit role
When building the implicit subscript expression, set the "implicit" bit
correctly and pass it through in the indexer so that we get implicit
refernces to the subscript. This would be useful for e.g. searching for
all uses of the dynamic subscript.
2019-04-16 15:37:32 -07:00
Nathan Hawes
e568d97e72 [sourcekitd][CursorInfo] Make sure we handle the implict VarDelcs being introduced in CastStmt bodies
When CursorInfo finds a reference to a VarDecl that's implicit but has a parent
VarDecl (according to VarDecl::getParentVarDecl), act as if we found the parent
instead.
2019-03-20 14:38:08 -07:00
Nathan Hawes
43c2f27783 [Refactoring][Migrator] Fix rename of callsites with a trailing closure argument
A label range of 0 length was being reported as the label of trailing closure
arguments, just before the opening '{'.

For the rename refactoring, this meant that if the corresponding parameter had
an external label (e.g. 'a') the occurrence would be treated as not matching the
expected symbol name, and so not be updated at all.

For the migrator, when renaming a function with an unlabelled closure for its
last parameter to have a label, it would incorrectly insert the new label in
front of the opening '{' on all of that function's callsites with trailing
closures.

Resolves rdar://problem/42162571
2018-12-19 16:24:14 -08:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
Slava Pestov
5213f80e7e IDE: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-22 20:56:56 -07:00
Rintaro Ishizaki
dc76149150 [IDE] Use getStartLoc() for matching pattern ranges
For Example `getLoc()` for `foo as Ty`(`IsPattern`) is at 'as'. We
should try to resolve this at position of 'foo'.
2018-05-11 15:34:42 +09:00
Robert Widmann
03580d2fe5 Add a parameter list to EnumElementDecl
This models, but does not plumb through, default arguments.
2018-03-28 00:05:56 -04:00
Nathan Hawes
80e10b188b [CursorInfo] Fix crash on instance variables used directly in if or for when declared in a generic context
For example:
class Foo<T> {
  let test: Bool = false
  let items: [Int] = []
  func foo() {
    if test {} // crashes on test
    for i in items {} // crashes on items
  }
}

We were picking up the incorrect containing type (Bool rather than Foo<T>).
Resolves rdar://problem/36871908.
2018-01-25 14:51:08 -08:00
Argyrios Kyrtzidis
14116f84a1 [sourcekitd] Fix cursor resolving when pointing inside string interpolations of return statements
rdar://36336648
2018-01-09 11:46:15 -08:00
Nathan Hawes
340d9089a0 [Refactoring] Local rename in lazy block failing
Some of the implicit decls generated for lazy vars have invalid source ranges.
For now, just always walk into implicit decls when looking for name locations.

Resolves rdar://problem/35255644.
2017-12-14 10:52:13 -08:00
Nathan Hawes
d769791414 [rename] Make sure we walk the base of the subscript expression before trying to resolve any reference on the '[' 2017-12-01 19:35:43 -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
Nathan Hawes
c4e87f0861 [Refactoring] Fix local rename missing occurrences in string interpolations
NameMatcher checked if a StringLiteralExpr was a string segment in an
interpolated string by checking if the parent expression was an
InterpolatedStringLiteralExpr. That's only true pre-type-checking, and unlike
global rename, local rename  uses the type-checked AST.
2017-11-17 20:16:59 -08:00
Slava Pestov
a70a1f0d36 IDE: Fix bug in SourceEntityWalker subscript handling
We weren't passing the lvalue access kind to the subscript.
This was causing a test to fail with the next patch.
2017-11-13 22:19:25 -08:00
Slava Pestov
0715eaeaed AST: Move SourceEntityWalker to IDE 2017-11-13 22:10:41 -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
Rintaro Ishizaki
53e514518b [IDE] Add SourceFile property to ResolvedCursorInfo 2017-10-16 00:24:30 -07:00
Kacper Harasim
8cd677eb1f [Refactoring] SR-6051 Expansion of switch statement missing cases (#12281) 2017-10-13 09:37:58 -07:00