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.
|
/// 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 ||
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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'),
|
||||||
|
|||||||
Reference in New Issue
Block a user