[sourcekit] Response "edit" immediately if client needs nothing

If the client doesn't want anything as the response of
'editor.replacetext' requests, we don't even need parsing.

rdar://problem/74984613
This commit is contained in:
Rintaro Ishizaki
2021-03-05 09:17:49 -08:00
parent c4f6fc32c5
commit 40dc8e1bd4
7 changed files with 50 additions and 1 deletions

View File

@@ -2016,7 +2016,8 @@ void SwiftEditorDocument::readSyntaxInfo(EditorConsumer &Consumer, bool ReportDi
"same time is not supported. Use the syntax tree to compute the "
"document structure.");
}
} else {
} else if (Consumer.documentStructureEnabled() ||
Consumer.syntaxMapEnabled()) {
ide::SyntaxModelContext ModelContext(Impl.SyntaxInfo->getSourceFile());
SwiftEditorSyntaxWalker SyntaxWalker(
@@ -2500,6 +2501,14 @@ void SwiftLangSupport::editorReplaceText(StringRef Name,
SyntaxCache->addEdit(Offset, Offset + Length, Buf->getBufferSize());
}
// If client doesn't need any information, we doen't need to parse it.
if (!Consumer.documentStructureEnabled() &&
!Consumer.syntaxMapEnabled() &&
!Consumer.diagnosticsEnabled() &&
!Consumer.syntaxTreeEnabled()) {
return;
}
SyntaxParsingCache *SyntaxCachePtr = nullptr;
if (SyntaxCache.hasValue()) {
SyntaxCachePtr = SyntaxCache.getPointer();