Merge remote-tracking branch 'origin/master' into master-next

This commit is contained in:
swift-ci
2018-08-01 18:29:04 -07:00
7 changed files with 92 additions and 4 deletions

View File

@@ -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()) {