ecode: Add LSP Code Completion support in the auto-complete plugin.

This commit is contained in:
Martín Lucas Golini
2022-11-09 19:02:07 -03:00
parent 6eafc9b2c8
commit a2e0005e8c
14 changed files with 191 additions and 75 deletions

View File

@@ -16,11 +16,11 @@ LSPDocumentClient::LSPDocumentClient( LSPClientServer* server, TextDocument* doc
LSPDocumentClient::~LSPDocumentClient() {}
void LSPDocumentClient::onDocumentTextChanged( const DocumentContentChange& change ) {
mModified = true;
++mVersion;
if ( !change.text.empty() || change.range.start() != change.range.end() )
mDocChange.push_back( change );
mLastModified.restart();
// If several change event are being fired, the thread pool can't guaranteed that it will be
// executed in FIFO. Se we accumulate the events in a queue and fire them in correct order.
mServer->queueDidChange( mDoc->getURI(), mVersion, "", { change } );
mServer->getThreadPool()->run( [&, change]() { mServer->processDidChangeQueue(); } );
}
void LSPDocumentClient::onDocumentUndoRedo( const TextDocument::UndoRedo& /*eventType*/ ) {}
@@ -39,21 +39,13 @@ void LSPDocumentClient::onDocumentSaved( TextDocument* ) {
}
void LSPDocumentClient::onDocumentClosed( TextDocument* ) {
mServer->didClose( mDoc );
mServer->getThreadPool()->run( [&]() { mServer->didClose( mDoc ); } );
}
void LSPDocumentClient::onDocumentDirtyOnFileSystem( TextDocument* ) {}
void LSPDocumentClient::onDocumentMoved( TextDocument* ) {}
bool LSPDocumentClient::isDirty() const {
return mModified && mLastModified.getElapsedTime() > Milliseconds( 250.f );
}
void LSPDocumentClient::resetDirty() {
mModified = false;
}
TextDocument* LSPDocumentClient::getDoc() const {
return mDoc;
}
@@ -66,14 +58,6 @@ int LSPDocumentClient::getVersion() const {
return mVersion;
}
const std::vector<DocumentContentChange>& LSPDocumentClient::getDocChange() const {
return mDocChange;
}
void LSPDocumentClient::clearDocChange() {
mDocChange.clear();
}
void LSPDocumentClient::notifyOpen() {
eeASSERT( mDoc );
mServer->didOpen( mDoc, ++mVersion );