Skip to content

Commit d9eef8c

Browse files
committed
[SourceKit] Remove IsNonProtocolType parameter from rename locations
The parameter was never checked anywhere.
1 parent d095d0a commit d9eef8c

File tree

7 files changed

+19
-36
lines changed

7 files changed

+19
-36
lines changed

Diff for: include/swift/Refactoring/Refactoring.h

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct RenameLoc {
7373
NameUsage Usage;
7474
StringRef OldName;
7575
const bool IsFunctionLike;
76-
const bool IsNonProtocolType;
7776
};
7877

7978
/// An array of \c RenameLoc that also keeps the underlying string storage of

Diff for: lib/Refactoring/ExtractFunction.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ static SourceLoc getNewFuncInsertLoc(DeclContext *DC,
7878
return SourceLoc();
7979
}
8080

81-
static std::vector<NoteRegion>
82-
getNotableRegions(StringRef SourceText, unsigned NameOffset, StringRef Name,
83-
bool IsFunctionLike = false, bool IsNonProtocolType = false) {
81+
static std::vector<NoteRegion> getNotableRegions(StringRef SourceText,
82+
unsigned NameOffset,
83+
StringRef Name,
84+
bool IsFunctionLike = false) {
8485
auto InputBuffer =
8586
llvm::MemoryBuffer::getMemBufferCopy(SourceText, "<extract>");
8687

@@ -108,9 +109,9 @@ getNotableRegions(StringRef SourceText, unsigned NameOffset, StringRef Name,
108109
Matcher.resolve(llvm::makeArrayRef(UnresoledName), llvm::None);
109110
assert(!Resolved.empty() && "Failed to resolve generated func name loc");
110111

111-
RenameLoc RenameConfig = {LineAndCol.first, LineAndCol.second,
112+
RenameLoc RenameConfig = {LineAndCol.first, LineAndCol.second,
112113
NameUsage::Definition, /*OldName=*/Name,
113-
IsFunctionLike, IsNonProtocolType};
114+
IsFunctionLike};
114115
RenameRangeDetailCollector Renamer(SM, Name);
115116
Renamer.addSyntacticRenameRanges(Resolved.back(), RenameConfig);
116117
auto Ranges = Renamer.Ranges;

Diff for: lib/Refactoring/LocalRename.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ class RenameRangeCollector : public IndexDataConsumer {
219219
} else {
220220
assert(existingLoc->OldName == loc->OldName &&
221221
existingLoc->IsFunctionLike == loc->IsFunctionLike &&
222-
existingLoc->IsNonProtocolType == loc->IsNonProtocolType &&
223222
"Asked to do a different rename for the same location?");
224223
}
225224
}
@@ -253,7 +252,6 @@ RenameRangeCollector::indexSymbolToRenameLoc(const index::IndexSymbol &symbol) {
253252
}
254253

255254
bool isFunctionLike = false;
256-
bool isNonProtocolType = false;
257255

258256
switch (symbol.symInfo.Kind) {
259257
case index::SymbolKind::EnumConstant:
@@ -268,14 +266,11 @@ RenameRangeCollector::indexSymbolToRenameLoc(const index::IndexSymbol &symbol) {
268266
case index::SymbolKind::Class:
269267
case index::SymbolKind::Enum:
270268
case index::SymbolKind::Struct:
271-
isNonProtocolType = true;
272-
break;
273269
default:
274270
break;
275271
}
276272
StringRef oldName = stringStorage->copyString(symbol.name);
277-
return RenameLoc{symbol.line, symbol.column, usage,
278-
oldName, isFunctionLike, isNonProtocolType};
273+
return RenameLoc{symbol.line, symbol.column, usage, oldName, isFunctionLike};
279274
}
280275

281276
bool RefactoringActionLocalRename::isApplicable(

Diff for: tools/SourceKit/include/SourceKit/Core/LangSupport.h

-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,6 @@ struct RenameLocation {
907907
struct RenameLocations {
908908
StringRef OldName;
909909
const bool IsFunctionLike;
910-
const bool IsNonProtocolType;
911910
std::vector<RenameLocation> LineColumnLocs;
912911
};
913912

Diff for: tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1506,8 +1506,7 @@ getSyntacticRenameLocs(ArrayRef<RenameLocations> RenameLocations) {
15061506
for(const auto &Location: Locations.LineColumnLocs) {
15071507
RenameLocs.push_back({Location.Line, Location.Column,
15081508
getNameUsage(Location.Type), Locations.OldName,
1509-
Locations.IsFunctionLike,
1510-
Locations.IsNonProtocolType});
1509+
Locations.IsFunctionLike});
15111510
}
15121511
}
15131512
return RenameLocs;

Diff for: tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -4005,22 +4005,14 @@ buildRenameLocationsFromDict(const RequestDict &Req,
40054005
return true;
40064006
}
40074007

4008-
int64_t IsNonProtocolType = false;
4009-
if (RenameLocation.getInt64(KeyIsNonProtocolType, IsNonProtocolType, false)) {
4010-
Error = "missing key.is_non_protocol_type";
4011-
return true;
4012-
}
4013-
40144008
Optional<StringRef> OldName = RenameLocation.getString(KeyName);
40154009
if (!OldName.has_value()) {
40164010
Error = "missing key.name";
40174011
return true;
40184012
}
40194013

4020-
RenameLocations.push_back({*OldName,
4021-
static_cast<bool>(IsFunctionLike),
4022-
static_cast<bool>(IsNonProtocolType),
4023-
{}});
4014+
RenameLocations.push_back(
4015+
{*OldName, static_cast<bool>(IsFunctionLike), {}});
40244016
auto &LineCols = RenameLocations.back().LineColumnLocs;
40254017
bool Failed = RenameLocation.dictionaryArrayApply(KeyLocations,
40264018
[&](RequestDict LineAndCol) {

Diff for: tools/swift-refactor/swift-refactor.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,13 @@ std::vector<RefactorLoc> getLocsByLabelOrPosition(StringRef LabelOrLineCol,
243243
std::vector<RenameLoc> getRenameLocs(unsigned BufferID, SourceManager &SM,
244244
ArrayRef<RefactorLoc> Locs,
245245
StringRef OldName, StringRef NewName,
246-
bool IsFunctionLike,
247-
bool IsNonProtocolType) {
246+
bool IsFunctionLike) {
248247
std::vector<RenameLoc> Renames;
249-
llvm::transform(Locs, std::back_inserter(Renames),
250-
[&](const RefactorLoc &Loc) -> RenameLoc {
251-
return {Loc.Line, Loc.Column, Loc.Usage,
252-
OldName, IsFunctionLike, IsNonProtocolType};
253-
});
248+
llvm::transform(
249+
Locs, std::back_inserter(Renames),
250+
[&](const RefactorLoc &Loc) -> RenameLoc {
251+
return {Loc.Line, Loc.Column, Loc.Usage, OldName, IsFunctionLike};
252+
});
254253
return Renames;
255254
}
256255

@@ -392,10 +391,9 @@ int main(int argc, char *argv[]) {
392391
NewName = "";
393392
}
394393

395-
std::vector<RenameLoc>
396-
RenameLocs = getRenameLocs(BufferID, SM, Start, options::OldName, NewName,
397-
options::IsFunctionLike.getNumOccurrences(),
398-
options::IsNonProtocolType.getNumOccurrences());
394+
std::vector<RenameLoc> RenameLocs =
395+
getRenameLocs(BufferID, SM, Start, options::OldName, NewName,
396+
options::IsFunctionLike.getNumOccurrences());
399397

400398
switch (options::Action) {
401399
case RefactoringKind::GlobalRename: {

0 commit comments

Comments
 (0)