Skip to content

Commit 4286c44

Browse files
committed
[CodeCompletion/SourceKit] Consolidate some chunk kinds
Consolidate ThrowsKeyword, RethrowsKeyword, and AsyncKeyword to EffectsSpecifierKeyword. Abolish 'key.throwsoffset' and 'key.throwslength' as they aren't used.
1 parent 5a7af5c commit 4286c44

File tree

10 files changed

+14
-42
lines changed

10 files changed

+14
-42
lines changed

include/swift/IDE/CodeCompletion.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,8 @@ class CodeCompletionStringChunk {
8989
/// The "override" keyword.
9090
OverrideKeyword,
9191

92-
/// The "throws" keyword.
93-
ThrowsKeyword,
94-
95-
/// The "rethrows" keyword.
96-
RethrowsKeyword,
97-
98-
/// The "async" keyword.
99-
AsyncKeyword,
92+
/// The "throws", "rethrows" and "async" keyword.
93+
EffectsSpecifierKeyword,
10094

10195
/// The keyword part of a declaration before the name, like "func".
10296
DeclIntroducer,
@@ -223,9 +217,7 @@ class CodeCompletionStringChunk {
223217
static bool chunkHasText(ChunkKind Kind) {
224218
return Kind == ChunkKind::AccessControlKeyword ||
225219
Kind == ChunkKind::OverrideKeyword ||
226-
Kind == ChunkKind::ThrowsKeyword ||
227-
Kind == ChunkKind::RethrowsKeyword ||
228-
Kind == ChunkKind::AsyncKeyword ||
220+
Kind == ChunkKind::EffectsSpecifierKeyword ||
229221
Kind == ChunkKind::DeclAttrKeyword ||
230222
Kind == ChunkKind::DeclIntroducer ||
231223
Kind == ChunkKind::Keyword ||

lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,7 @@ void CodeCompletionString::print(raw_ostream &OS) const {
385385
case ChunkKind::DeclAttrKeyword:
386386
case ChunkKind::DeclAttrParamKeyword:
387387
case ChunkKind::OverrideKeyword:
388-
case ChunkKind::ThrowsKeyword:
389-
case ChunkKind::RethrowsKeyword:
390-
case ChunkKind::AsyncKeyword:
388+
case ChunkKind::EffectsSpecifierKeyword:
391389
case ChunkKind::DeclIntroducer:
392390
case ChunkKind::Text:
393391
case ChunkKind::LeftParen:
@@ -1377,9 +1375,7 @@ Optional<unsigned> CodeCompletionString::getFirstTextChunkIndex(
13771375
case ChunkKind::Whitespace:
13781376
case ChunkKind::AccessControlKeyword:
13791377
case ChunkKind::OverrideKeyword:
1380-
case ChunkKind::ThrowsKeyword:
1381-
case ChunkKind::RethrowsKeyword:
1382-
case ChunkKind::AsyncKeyword:
1378+
case ChunkKind::EffectsSpecifierKeyword:
13831379
case ChunkKind::DeclIntroducer:
13841380
case ChunkKind::CallParameterColon:
13851381
case ChunkKind::CallParameterTypeBegin:
@@ -1433,9 +1429,7 @@ void CodeCompletionString::getName(raw_ostream &OS) const {
14331429
--i;
14341430
continue;
14351431
}
1436-
case ChunkKind::ThrowsKeyword:
1437-
case ChunkKind::RethrowsKeyword:
1438-
case ChunkKind::AsyncKeyword:
1432+
case ChunkKind::EffectsSpecifierKeyword:
14391433
shouldPrint = true; // Even when they're annotations.
14401434
break;
14411435
default:

lib/IDE/CodeCompletionResultBuilder.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class CodeCompletionResultBuilder {
226226

227227
void addThrows() {
228228
addChunkWithTextNoCopy(
229-
CodeCompletionString::Chunk::ChunkKind::ThrowsKeyword,
229+
CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
230230
" throws");
231231
}
232232

@@ -237,7 +237,7 @@ class CodeCompletionResultBuilder {
237237

238238
void addAsync() {
239239
addChunkWithTextNoCopy(
240-
CodeCompletionString::Chunk::ChunkKind::AsyncKeyword,
240+
CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
241241
" async");
242242
}
243243

@@ -253,7 +253,8 @@ class CodeCompletionResultBuilder {
253253

254254
void addRethrows() {
255255
addChunkWithTextNoCopy(
256-
CodeCompletionString::Chunk::ChunkKind::RethrowsKeyword, " rethrows");
256+
CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
257+
" rethrows");
257258
}
258259

259260
void addAnnotatedLeftParen() {

lib/IDE/CodeCompletionResultPrinter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ class AnnotatingResultPrinter {
100100
case ChunkKind::Keyword:
101101
case ChunkKind::OverrideKeyword:
102102
case ChunkKind::AccessControlKeyword:
103-
case ChunkKind::ThrowsKeyword:
104-
case ChunkKind::RethrowsKeyword:
105-
case ChunkKind::AsyncKeyword:
103+
case ChunkKind::EffectsSpecifierKeyword:
106104
case ChunkKind::DeclIntroducer:
107105
printWithTag("keyword", C.getText());
108106
break;

lib/IDE/REPLCodeCompletion.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ static std::string toInsertableString(CodeCompletionResult *Result) {
3838
switch (C.getKind()) {
3939
case CodeCompletionString::Chunk::ChunkKind::AccessControlKeyword:
4040
case CodeCompletionString::Chunk::ChunkKind::OverrideKeyword:
41-
case CodeCompletionString::Chunk::ChunkKind::ThrowsKeyword:
42-
case CodeCompletionString::Chunk::ChunkKind::RethrowsKeyword:
43-
case CodeCompletionString::Chunk::ChunkKind::AsyncKeyword:
41+
case CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword:
4442
case CodeCompletionString::Chunk::ChunkKind::DeclAttrKeyword:
4543
case CodeCompletionString::Chunk::ChunkKind::DeclIntroducer:
4644
case CodeCompletionString::Chunk::ChunkKind::Keyword:

test/SourceKit/CodeComplete/complete_structure.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func test1(_ x: S1) {
4040
// S1_DOT: {name:method4}({params:{t:Int}, {t:Int}})
4141
// S1_DOT: {name:method5}({params:{t:&Int}, {n:b:}{t: &Int}})
4242
// FIXME: put throws in a range!
43-
// S1_DOT: {name:method6}({params:{l:c:}{t: Int}}){throws: throws}
44-
// S1_DOT: {name:method7}({params:{l:callback:}{t: () throws -> ()}}){throws: rethrows}
43+
// S1_DOT: {name:method6}({params:{l:c:}{t: Int}}) throws
44+
// S1_DOT: {name:method7}({params:{l:callback:}{t: () throws -> ()}}) rethrows
4545
// S1_DOT: {name:method8}({params:{l:d:}{t: (T, U) -> T}, {n:e:}{t: (T) -> U}})
4646
// S1_DOT: {name:v1}
4747
// S1_DOT: {name:v2}

tools/SourceKit/include/SourceKit/Core/LangSupport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ struct CodeCompletionInfo {
120120
struct DescriptionStructure {
121121
IndexRange baseName;
122122
IndexRange parameterRange;
123-
IndexRange throwsRange;
124123
};
125124

126125
Optional<DescriptionStructure> descriptionStructure;

tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,6 @@ static void getResultStructure(
271271
if (C.is(ChunkKind::BraceStmtWithCursor))
272272
break;
273273

274-
if (C.is(ChunkKind::ThrowsKeyword) ||
275-
C.is(ChunkKind::RethrowsKeyword)) {
276-
structure.throwsRange.begin = textSize;
277-
structure.throwsRange.end = textSize + C.getText().size();
278-
}
279-
280274
if (C.is(ChunkKind::CallParameterBegin)) {
281275
CodeCompletionInfo::ParameterStructure param;
282276

tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,8 +2263,6 @@ bool SKGroupedCodeCompletionConsumer::handleResult(const CodeCompletionInfo &R)
22632263
R.descriptionStructure->baseName);
22642264
addRange(structure, KeyBodyOffset, KeyBodyLength,
22652265
R.descriptionStructure->parameterRange);
2266-
addRange(structure, KeyThrowOffset, KeyThrowLength,
2267-
R.descriptionStructure->throwsRange);
22682266

22692267
if (R.parametersStructure) {
22702268
auto params = structure.setArray(KeySubStructure);

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ def __init__(self, internal_name, external_name):
8383
KEY('NameLength', 'key.namelength'),
8484
KEY('BodyOffset', 'key.bodyoffset'),
8585
KEY('BodyLength', 'key.bodylength'),
86-
KEY('ThrowOffset', 'key.throwoffset'),
87-
KEY('ThrowLength', 'key.throwlength'),
8886
KEY('DocOffset', 'key.docoffset'),
8987
KEY('DocLength', 'key.doclength'),
9088
KEY('IsLocal', 'key.is_local'),

0 commit comments

Comments
 (0)