Commit Graph

15 Commits

Author SHA1 Message Date
Alex Hoppen
8fd025625b [SourceKit] Use NameMatcher that is rewritten in Swift for syntactic rename 2023-11-17 09:30:04 -08:00
Alex Hoppen
5ed83ff616 [SourceKit] Update tests to use find-local-rename-ranges instead of invoking the local rename refactoring action
The local rename refactoring action will be removed in a follow-up commit.
2023-11-15 11:20:26 -08:00
Alex Hoppen
ca4abab9a9 Merge pull request #58746 from ahoppen/pr/enum-assoc-value-is-call
[Index] Consider construction of enums with associated values as a function call
2022-05-13 16:39:07 +02:00
Alex Hoppen
74cd03b098 [Index] Consider construction of enums with associated values as a function call
For enum cases with associated values, their construction is modelled by a function. E.g. if you have
```swift
enum Foo {
  case first(associated: Int)
}
```

then `Foo.first` is a function of type `(Int) -> Foo`. But if you write `Foo.first(associated: 2)` in source code, we consider this construct as a referenced, not a call. This causes us to miss renaming of associated value labels during local refactoring.

rdar://84061868
2022-05-09 22:22:31 +02:00
Alex Hoppen
d2f7d518ed [Refactoring] Always walk parent decl context of value decl for local rename
Previously, we only walked the parent scope of the decl context that declared the value to rename if it was a TopLevelCodeDecl. But also functions can have locally declared types that can be used in sibling scopes. Thus, we always need to walk the parent DeclContext of the one declaring the value we are renaming.

rdar://89836229
2022-05-09 17:04:36 +02:00
Alex Hoppen
6d2582f5b8 [Refactoring] Fix an issue where refactoring misses to refactor references after prefix operators
The removed `else if` branch caused the argument to the `-` operator to be be reported as `Mismatch`. I couldn’t figure out what that branch was for, so I removed it.

rdar://91588948
2022-05-04 09:04:30 +02:00
Josh Soref
5bbb9489a5 spelling: capture
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-21 15:53:30 -04:00
Alex Hoppen
a535203096 [Refactoring] Only rename variables in capture lists once
Inside capture lists like `{ [test] in }`, `test` refers to both the newly declared, captured variable and the referenced variable it is initialized from. We currently try to rename it twice, yielding invalid, confusing results. Make sure to only record this situation once.

Fixes rdar://78522816 [SR-14661]
2021-07-09 11:38:37 +02:00
Colton Schlosser
07675a75e0 [refactoring] Fix error when renaming nested type at constructor - init() has no declaration location
Resolves SR-11077
2019-07-10 21:02:00 -04:00
Nathan Hawes
9291201e32 [sourcekitd][Refactoring] Fix renaming of var decls in fallthrough case statements
We weren't renaming all occurrences of 'x' in the cases like the below:

  case .first(let x), .second(let x):
    print("foo \(x)")
    fallthrough
  case .third(let x):
    print("bar \(x)")

We would previously only rename occurrences within the case statement the query
was made in (ignoring fallthroughs) and for cases with multiple patterns (as in
the first case above) we would only rename the occurrence in the first pattern.
2019-03-20 14:38:08 -07:00
gregomni
ff04fbdae8 Fix name lookup and parser so that where clauses decl refs in case statements correctly bind to the current pattern instead of always to the first pattern. Thus the hacky var decl juggling in where clauses in SILGen can be deleted. 2018-08-28 19:18:56 -07:00
Rintaro Ishizaki
a6f7a8ea35 [Parser] Set local discriminator to ParamDecls
We have to discriminate between params and local variables.
2018-05-11 15:37:40 +09: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
Rintaro Ishizaki
df10afd1a2 [Parse] Discriminate local variables
Set local discriminator for all local `VarDecl`s. Otherwise, they cannot
be discriminated with USRs. This change is needed for rename refactoring which
uses USR for discrimiating variable names.

https://bugs.swift.org/browse/SR-7205,
rdar://problem/34701880
2018-05-11 15:34:42 +09: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