[CodeCompletion/SourceKit] Consolidate some chunk kinds

Consolidate ThrowsKeyword, RethrowsKeyword, and AsyncKeyword to
EffectsSpecifierKeyword.
Abolish 'key.throwsoffset' and 'key.throwslength' as they aren't used.
This commit is contained in:
Rintaro Ishizaki
2020-12-14 12:25:30 -08:00
parent 5a7af5c673
commit 4286c44e72
10 changed files with 14 additions and 42 deletions

View File

@@ -89,14 +89,8 @@ public:
/// The "override" keyword. /// The "override" keyword.
OverrideKeyword, OverrideKeyword,
/// The "throws" keyword. /// The "throws", "rethrows" and "async" keyword.
ThrowsKeyword, EffectsSpecifierKeyword,
/// The "rethrows" keyword.
RethrowsKeyword,
/// The "async" keyword.
AsyncKeyword,
/// The keyword part of a declaration before the name, like "func". /// The keyword part of a declaration before the name, like "func".
DeclIntroducer, DeclIntroducer,
@@ -223,9 +217,7 @@ public:
static bool chunkHasText(ChunkKind Kind) { static bool chunkHasText(ChunkKind Kind) {
return Kind == ChunkKind::AccessControlKeyword || return Kind == ChunkKind::AccessControlKeyword ||
Kind == ChunkKind::OverrideKeyword || Kind == ChunkKind::OverrideKeyword ||
Kind == ChunkKind::ThrowsKeyword || Kind == ChunkKind::EffectsSpecifierKeyword ||
Kind == ChunkKind::RethrowsKeyword ||
Kind == ChunkKind::AsyncKeyword ||
Kind == ChunkKind::DeclAttrKeyword || Kind == ChunkKind::DeclAttrKeyword ||
Kind == ChunkKind::DeclIntroducer || Kind == ChunkKind::DeclIntroducer ||
Kind == ChunkKind::Keyword || Kind == ChunkKind::Keyword ||

View File

@@ -385,9 +385,7 @@ void CodeCompletionString::print(raw_ostream &OS) const {
case ChunkKind::DeclAttrKeyword: case ChunkKind::DeclAttrKeyword:
case ChunkKind::DeclAttrParamKeyword: case ChunkKind::DeclAttrParamKeyword:
case ChunkKind::OverrideKeyword: case ChunkKind::OverrideKeyword:
case ChunkKind::ThrowsKeyword: case ChunkKind::EffectsSpecifierKeyword:
case ChunkKind::RethrowsKeyword:
case ChunkKind::AsyncKeyword:
case ChunkKind::DeclIntroducer: case ChunkKind::DeclIntroducer:
case ChunkKind::Text: case ChunkKind::Text:
case ChunkKind::LeftParen: case ChunkKind::LeftParen:
@@ -1377,9 +1375,7 @@ Optional<unsigned> CodeCompletionString::getFirstTextChunkIndex(
case ChunkKind::Whitespace: case ChunkKind::Whitespace:
case ChunkKind::AccessControlKeyword: case ChunkKind::AccessControlKeyword:
case ChunkKind::OverrideKeyword: case ChunkKind::OverrideKeyword:
case ChunkKind::ThrowsKeyword: case ChunkKind::EffectsSpecifierKeyword:
case ChunkKind::RethrowsKeyword:
case ChunkKind::AsyncKeyword:
case ChunkKind::DeclIntroducer: case ChunkKind::DeclIntroducer:
case ChunkKind::CallParameterColon: case ChunkKind::CallParameterColon:
case ChunkKind::CallParameterTypeBegin: case ChunkKind::CallParameterTypeBegin:
@@ -1433,9 +1429,7 @@ void CodeCompletionString::getName(raw_ostream &OS) const {
--i; --i;
continue; continue;
} }
case ChunkKind::ThrowsKeyword: case ChunkKind::EffectsSpecifierKeyword:
case ChunkKind::RethrowsKeyword:
case ChunkKind::AsyncKeyword:
shouldPrint = true; // Even when they're annotations. shouldPrint = true; // Even when they're annotations.
break; break;
default: default:

View File

@@ -226,7 +226,7 @@ public:
void addThrows() { void addThrows() {
addChunkWithTextNoCopy( addChunkWithTextNoCopy(
CodeCompletionString::Chunk::ChunkKind::ThrowsKeyword, CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
" throws"); " throws");
} }
@@ -237,7 +237,7 @@ public:
void addAsync() { void addAsync() {
addChunkWithTextNoCopy( addChunkWithTextNoCopy(
CodeCompletionString::Chunk::ChunkKind::AsyncKeyword, CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
" async"); " async");
} }
@@ -253,7 +253,8 @@ public:
void addRethrows() { void addRethrows() {
addChunkWithTextNoCopy( addChunkWithTextNoCopy(
CodeCompletionString::Chunk::ChunkKind::RethrowsKeyword, " rethrows"); CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
" rethrows");
} }
void addAnnotatedLeftParen() { void addAnnotatedLeftParen() {

View File

@@ -100,9 +100,7 @@ class AnnotatingResultPrinter {
case ChunkKind::Keyword: case ChunkKind::Keyword:
case ChunkKind::OverrideKeyword: case ChunkKind::OverrideKeyword:
case ChunkKind::AccessControlKeyword: case ChunkKind::AccessControlKeyword:
case ChunkKind::ThrowsKeyword: case ChunkKind::EffectsSpecifierKeyword:
case ChunkKind::RethrowsKeyword:
case ChunkKind::AsyncKeyword:
case ChunkKind::DeclIntroducer: case ChunkKind::DeclIntroducer:
printWithTag("keyword", C.getText()); printWithTag("keyword", C.getText());
break; break;

View File

@@ -38,9 +38,7 @@ static std::string toInsertableString(CodeCompletionResult *Result) {
switch (C.getKind()) { switch (C.getKind()) {
case CodeCompletionString::Chunk::ChunkKind::AccessControlKeyword: case CodeCompletionString::Chunk::ChunkKind::AccessControlKeyword:
case CodeCompletionString::Chunk::ChunkKind::OverrideKeyword: case CodeCompletionString::Chunk::ChunkKind::OverrideKeyword:
case CodeCompletionString::Chunk::ChunkKind::ThrowsKeyword: case CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword:
case CodeCompletionString::Chunk::ChunkKind::RethrowsKeyword:
case CodeCompletionString::Chunk::ChunkKind::AsyncKeyword:
case CodeCompletionString::Chunk::ChunkKind::DeclAttrKeyword: case CodeCompletionString::Chunk::ChunkKind::DeclAttrKeyword:
case CodeCompletionString::Chunk::ChunkKind::DeclIntroducer: case CodeCompletionString::Chunk::ChunkKind::DeclIntroducer:
case CodeCompletionString::Chunk::ChunkKind::Keyword: case CodeCompletionString::Chunk::ChunkKind::Keyword:

View File

@@ -40,8 +40,8 @@ func test1(_ x: S1) {
// S1_DOT: {name:method4}({params:{t:Int}, {t:Int}}) // S1_DOT: {name:method4}({params:{t:Int}, {t:Int}})
// S1_DOT: {name:method5}({params:{t:&Int}, {n:b:}{t: &Int}}) // S1_DOT: {name:method5}({params:{t:&Int}, {n:b:}{t: &Int}})
// FIXME: put throws in a range! // FIXME: put throws in a range!
// S1_DOT: {name:method6}({params:{l:c:}{t: Int}}){throws: throws} // S1_DOT: {name:method6}({params:{l:c:}{t: Int}}) throws
// S1_DOT: {name:method7}({params:{l:callback:}{t: () throws -> ()}}){throws: rethrows} // S1_DOT: {name:method7}({params:{l:callback:}{t: () throws -> ()}}) rethrows
// S1_DOT: {name:method8}({params:{l:d:}{t: (T, U) -> T}, {n:e:}{t: (T) -> U}}) // S1_DOT: {name:method8}({params:{l:d:}{t: (T, U) -> T}, {n:e:}{t: (T) -> U}})
// S1_DOT: {name:v1} // S1_DOT: {name:v1}
// S1_DOT: {name:v2} // S1_DOT: {name:v2}

View File

@@ -120,7 +120,6 @@ struct CodeCompletionInfo {
struct DescriptionStructure { struct DescriptionStructure {
IndexRange baseName; IndexRange baseName;
IndexRange parameterRange; IndexRange parameterRange;
IndexRange throwsRange;
}; };
Optional<DescriptionStructure> descriptionStructure; Optional<DescriptionStructure> descriptionStructure;

View File

@@ -271,12 +271,6 @@ static void getResultStructure(
if (C.is(ChunkKind::BraceStmtWithCursor)) if (C.is(ChunkKind::BraceStmtWithCursor))
break; break;
if (C.is(ChunkKind::ThrowsKeyword) ||
C.is(ChunkKind::RethrowsKeyword)) {
structure.throwsRange.begin = textSize;
structure.throwsRange.end = textSize + C.getText().size();
}
if (C.is(ChunkKind::CallParameterBegin)) { if (C.is(ChunkKind::CallParameterBegin)) {
CodeCompletionInfo::ParameterStructure param; CodeCompletionInfo::ParameterStructure param;

View File

@@ -2263,8 +2263,6 @@ bool SKGroupedCodeCompletionConsumer::handleResult(const CodeCompletionInfo &R)
R.descriptionStructure->baseName); R.descriptionStructure->baseName);
addRange(structure, KeyBodyOffset, KeyBodyLength, addRange(structure, KeyBodyOffset, KeyBodyLength,
R.descriptionStructure->parameterRange); R.descriptionStructure->parameterRange);
addRange(structure, KeyThrowOffset, KeyThrowLength,
R.descriptionStructure->throwsRange);
if (R.parametersStructure) { if (R.parametersStructure) {
auto params = structure.setArray(KeySubStructure); auto params = structure.setArray(KeySubStructure);

View File

@@ -83,8 +83,6 @@ UID_KEYS = [
KEY('NameLength', 'key.namelength'), KEY('NameLength', 'key.namelength'),
KEY('BodyOffset', 'key.bodyoffset'), KEY('BodyOffset', 'key.bodyoffset'),
KEY('BodyLength', 'key.bodylength'), KEY('BodyLength', 'key.bodylength'),
KEY('ThrowOffset', 'key.throwoffset'),
KEY('ThrowLength', 'key.throwlength'),
KEY('DocOffset', 'key.docoffset'), KEY('DocOffset', 'key.docoffset'),
KEY('DocLength', 'key.doclength'), KEY('DocLength', 'key.doclength'),
KEY('IsLocal', 'key.is_local'), KEY('IsLocal', 'key.is_local'),