mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -1709,10 +1709,16 @@ ImmutableTextSnapshotRef SwiftEditorDocument::initializeText(
|
||||
|
||||
ImmutableTextSnapshotRef SwiftEditorDocument::replaceText(
|
||||
unsigned Offset, unsigned Length, llvm::MemoryBuffer *Buf,
|
||||
bool ProvideSemanticInfo) {
|
||||
bool ProvideSemanticInfo, std::string &error) {
|
||||
|
||||
llvm::sys::ScopedLock L(Impl.AccessMtx);
|
||||
|
||||
// Validate offset and length.
|
||||
if ((Offset + Length) > Impl.EditableBuffer->getSize()) {
|
||||
error = "'offset' + 'length' is out of range";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Impl.Edited = true;
|
||||
llvm::StringRef Str = Buf->getBuffer();
|
||||
|
||||
@@ -2236,9 +2242,14 @@ void SwiftLangSupport::editorReplaceText(StringRef Name,
|
||||
StringRef PreEditTextRef(BufferStart + Offset, Length);
|
||||
PreEditText = PreEditTextRef.str();
|
||||
}
|
||||
std::string error;
|
||||
Snapshot = EditorDoc->replaceText(Offset, Length, Buf,
|
||||
Consumer.needsSemanticInfo());
|
||||
assert(Snapshot);
|
||||
Consumer.needsSemanticInfo(), error);
|
||||
if (!Snapshot) {
|
||||
assert(error.size());
|
||||
Consumer.handleRequestError(error.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
llvm::Optional<SyntaxParsingCache> SyntaxCache = llvm::None;
|
||||
if (EditorDoc->getSyntaxTree().hasValue()) {
|
||||
|
||||
Reference in New Issue
Block a user