mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -89,14 +89,8 @@ public:
|
||||
/// The "override" keyword.
|
||||
OverrideKeyword,
|
||||
|
||||
/// The "throws" keyword.
|
||||
ThrowsKeyword,
|
||||
|
||||
/// The "rethrows" keyword.
|
||||
RethrowsKeyword,
|
||||
|
||||
/// The "async" keyword.
|
||||
AsyncKeyword,
|
||||
/// The "throws", "rethrows" and "async" keyword.
|
||||
EffectsSpecifierKeyword,
|
||||
|
||||
/// The keyword part of a declaration before the name, like "func".
|
||||
DeclIntroducer,
|
||||
@@ -223,9 +217,7 @@ public:
|
||||
static bool chunkHasText(ChunkKind Kind) {
|
||||
return Kind == ChunkKind::AccessControlKeyword ||
|
||||
Kind == ChunkKind::OverrideKeyword ||
|
||||
Kind == ChunkKind::ThrowsKeyword ||
|
||||
Kind == ChunkKind::RethrowsKeyword ||
|
||||
Kind == ChunkKind::AsyncKeyword ||
|
||||
Kind == ChunkKind::EffectsSpecifierKeyword ||
|
||||
Kind == ChunkKind::DeclAttrKeyword ||
|
||||
Kind == ChunkKind::DeclIntroducer ||
|
||||
Kind == ChunkKind::Keyword ||
|
||||
|
||||
@@ -385,9 +385,7 @@ void CodeCompletionString::print(raw_ostream &OS) const {
|
||||
case ChunkKind::DeclAttrKeyword:
|
||||
case ChunkKind::DeclAttrParamKeyword:
|
||||
case ChunkKind::OverrideKeyword:
|
||||
case ChunkKind::ThrowsKeyword:
|
||||
case ChunkKind::RethrowsKeyword:
|
||||
case ChunkKind::AsyncKeyword:
|
||||
case ChunkKind::EffectsSpecifierKeyword:
|
||||
case ChunkKind::DeclIntroducer:
|
||||
case ChunkKind::Text:
|
||||
case ChunkKind::LeftParen:
|
||||
@@ -1377,9 +1375,7 @@ Optional<unsigned> CodeCompletionString::getFirstTextChunkIndex(
|
||||
case ChunkKind::Whitespace:
|
||||
case ChunkKind::AccessControlKeyword:
|
||||
case ChunkKind::OverrideKeyword:
|
||||
case ChunkKind::ThrowsKeyword:
|
||||
case ChunkKind::RethrowsKeyword:
|
||||
case ChunkKind::AsyncKeyword:
|
||||
case ChunkKind::EffectsSpecifierKeyword:
|
||||
case ChunkKind::DeclIntroducer:
|
||||
case ChunkKind::CallParameterColon:
|
||||
case ChunkKind::CallParameterTypeBegin:
|
||||
@@ -1433,9 +1429,7 @@ void CodeCompletionString::getName(raw_ostream &OS) const {
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
case ChunkKind::ThrowsKeyword:
|
||||
case ChunkKind::RethrowsKeyword:
|
||||
case ChunkKind::AsyncKeyword:
|
||||
case ChunkKind::EffectsSpecifierKeyword:
|
||||
shouldPrint = true; // Even when they're annotations.
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
|
||||
void addThrows() {
|
||||
addChunkWithTextNoCopy(
|
||||
CodeCompletionString::Chunk::ChunkKind::ThrowsKeyword,
|
||||
CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
|
||||
" throws");
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public:
|
||||
|
||||
void addAsync() {
|
||||
addChunkWithTextNoCopy(
|
||||
CodeCompletionString::Chunk::ChunkKind::AsyncKeyword,
|
||||
CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
|
||||
" async");
|
||||
}
|
||||
|
||||
@@ -253,7 +253,8 @@ public:
|
||||
|
||||
void addRethrows() {
|
||||
addChunkWithTextNoCopy(
|
||||
CodeCompletionString::Chunk::ChunkKind::RethrowsKeyword, " rethrows");
|
||||
CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword,
|
||||
" rethrows");
|
||||
}
|
||||
|
||||
void addAnnotatedLeftParen() {
|
||||
|
||||
@@ -100,9 +100,7 @@ class AnnotatingResultPrinter {
|
||||
case ChunkKind::Keyword:
|
||||
case ChunkKind::OverrideKeyword:
|
||||
case ChunkKind::AccessControlKeyword:
|
||||
case ChunkKind::ThrowsKeyword:
|
||||
case ChunkKind::RethrowsKeyword:
|
||||
case ChunkKind::AsyncKeyword:
|
||||
case ChunkKind::EffectsSpecifierKeyword:
|
||||
case ChunkKind::DeclIntroducer:
|
||||
printWithTag("keyword", C.getText());
|
||||
break;
|
||||
|
||||
@@ -38,9 +38,7 @@ static std::string toInsertableString(CodeCompletionResult *Result) {
|
||||
switch (C.getKind()) {
|
||||
case CodeCompletionString::Chunk::ChunkKind::AccessControlKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::OverrideKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::ThrowsKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::RethrowsKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::AsyncKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::EffectsSpecifierKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::DeclAttrKeyword:
|
||||
case CodeCompletionString::Chunk::ChunkKind::DeclIntroducer:
|
||||
case CodeCompletionString::Chunk::ChunkKind::Keyword:
|
||||
|
||||
@@ -40,8 +40,8 @@ func test1(_ x: S1) {
|
||||
// S1_DOT: {name:method4}({params:{t:Int}, {t:Int}})
|
||||
// S1_DOT: {name:method5}({params:{t:&Int}, {n:b:}{t: &Int}})
|
||||
// FIXME: put throws in a range!
|
||||
// S1_DOT: {name:method6}({params:{l:c:}{t: Int}}){throws: throws}
|
||||
// S1_DOT: {name:method7}({params:{l:callback:}{t: () throws -> ()}}){throws: rethrows}
|
||||
// S1_DOT: {name:method6}({params:{l:c:}{t: Int}}) throws
|
||||
// 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:v1}
|
||||
// S1_DOT: {name:v2}
|
||||
|
||||
@@ -120,7 +120,6 @@ struct CodeCompletionInfo {
|
||||
struct DescriptionStructure {
|
||||
IndexRange baseName;
|
||||
IndexRange parameterRange;
|
||||
IndexRange throwsRange;
|
||||
};
|
||||
|
||||
Optional<DescriptionStructure> descriptionStructure;
|
||||
|
||||
@@ -271,12 +271,6 @@ static void getResultStructure(
|
||||
if (C.is(ChunkKind::BraceStmtWithCursor))
|
||||
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)) {
|
||||
CodeCompletionInfo::ParameterStructure param;
|
||||
|
||||
|
||||
@@ -2263,8 +2263,6 @@ bool SKGroupedCodeCompletionConsumer::handleResult(const CodeCompletionInfo &R)
|
||||
R.descriptionStructure->baseName);
|
||||
addRange(structure, KeyBodyOffset, KeyBodyLength,
|
||||
R.descriptionStructure->parameterRange);
|
||||
addRange(structure, KeyThrowOffset, KeyThrowLength,
|
||||
R.descriptionStructure->throwsRange);
|
||||
|
||||
if (R.parametersStructure) {
|
||||
auto params = structure.setArray(KeySubStructure);
|
||||
|
||||
@@ -83,8 +83,6 @@ UID_KEYS = [
|
||||
KEY('NameLength', 'key.namelength'),
|
||||
KEY('BodyOffset', 'key.bodyoffset'),
|
||||
KEY('BodyLength', 'key.bodylength'),
|
||||
KEY('ThrowOffset', 'key.throwoffset'),
|
||||
KEY('ThrowLength', 'key.throwlength'),
|
||||
KEY('DocOffset', 'key.docoffset'),
|
||||
KEY('DocLength', 'key.doclength'),
|
||||
KEY('IsLocal', 'key.is_local'),
|
||||
|
||||
Reference in New Issue
Block a user