mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 02:26:29 +03:00
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
#include "lspdocumentclient.hpp"
|
|
#include "lspclientserver.hpp"
|
|
#include <eepp/system/filesystem.hpp>
|
|
#include <eepp/system/iostreamstring.hpp>
|
|
|
|
using namespace EE::System;
|
|
|
|
namespace ecode {
|
|
|
|
LSPDocumentClient::LSPDocumentClient( LSPClientServer* server, TextDocument* doc ) :
|
|
mServer( server ), mDoc( doc ) {
|
|
notifyOpen();
|
|
}
|
|
|
|
void LSPDocumentClient::onDocumentTextChanged() {
|
|
mModified = true;
|
|
++mVersion;
|
|
mLastModified.restart();
|
|
}
|
|
|
|
void LSPDocumentClient::onDocumentUndoRedo( const TextDocument::UndoRedo& /*eventType*/ ) {}
|
|
|
|
void LSPDocumentClient::onDocumentCursorChange( const TextPosition& ) {}
|
|
|
|
void LSPDocumentClient::onDocumentSelectionChange( const TextRange& ) {}
|
|
|
|
void LSPDocumentClient::onDocumentLineCountChange( const size_t& /*lastCount*/,
|
|
const size_t& /*newCount*/ ) {}
|
|
|
|
void LSPDocumentClient::onDocumentLineChanged( const Int64& /*lineIndex*/ ) {}
|
|
|
|
void LSPDocumentClient::onDocumentSaved( TextDocument* ) {
|
|
mServer->getThreadPool()->run( [&]() { mServer->didSave( mDoc ); } );
|
|
}
|
|
|
|
void LSPDocumentClient::onDocumentClosed( TextDocument* ) {
|
|
mServer->didClose( mDoc );
|
|
mDoc = nullptr;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
LSPClientServer* LSPDocumentClient::getServer() const {
|
|
return mServer;
|
|
}
|
|
|
|
int LSPDocumentClient::getVersion() const {
|
|
return mVersion;
|
|
}
|
|
|
|
void LSPDocumentClient::notifyOpen() {
|
|
eeASSERT( mDoc );
|
|
mServer->didOpen( mDoc, ++mVersion );
|
|
}
|
|
|
|
} // namespace ecode
|