28 const TextDocumentItem &item = params.textDocument;
29 m_codeModelManager->newOpenFile(QQmlLSUtils::lspUriToQmlUrl(item.uri), item.version,
30 QString::fromUtf8(item.text));
35 QByteArray url = QQmlLSUtils::lspUriToQmlUrl(params.textDocument.uri);
36 auto openDoc = m_codeModelManager->openDocumentByUrl(url);
39 qCWarning(lspServerLog) <<
"Ignoring changes to non open or closed document"
40 << QString::fromUtf8(url);
43 const auto &changes = params.contentChanges;
45 QMutexLocker l(document->mutex());
46 for (
const auto &change : changes) {
48 document->setPlainText(QString::fromUtf8(change.text));
52 const auto &range = *change.range;
53 const auto &rangeStart = range.start;
55 document->findBlockByNumber(rangeStart.line).position() + rangeStart.character;
56 const auto &rangeEnd = range.end;
58 document->findBlockByNumber(rangeEnd.line).position() + rangeEnd.character;
60 document->setPlainText(document->toPlainText().replace(start, end - start,
61 QString::fromUtf8(change.text)));
63 document->setVersion(params.textDocument.version);
64 qCDebug(lspServerLog).noquote()
65 <<
"text is\n:----------" << document->toPlainText() <<
"\n_________";
67 m_codeModelManager->addOpenToUpdate(url);
72 QObject::connect(server->notifySignals(),
73 &QLspNotifySignals::receivedDidOpenTextDocumentNotification,
this,
74 &TextSynchronization::didOpenTextDocument);
76 QObject::connect(server->notifySignals(),
77 &QLspNotifySignals::receivedDidChangeTextDocumentNotification,
this,
78 &TextSynchronization::didDidChangeTextDocument);
80 QObject::connect(server->notifySignals(),
81 &QLspNotifySignals::receivedDidCloseTextDocumentNotification,
this,
82 &TextSynchronization::didCloseTextDocument);
91 QLspSpecification::InitializeResult &serverInfo)
93 TextDocumentSyncOptions syncOptions;
94 syncOptions.openClose =
true;
95 syncOptions.change = TextDocumentSyncKind::Incremental;
96 serverInfo.capabilities.textDocumentSync = syncOptions;
void didDidChangeTextDocument(const QLspSpecification::DidChangeTextDocumentParams ¶ms)
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override
QString name() const override
void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, QLspSpecification::InitializeResult &) override
void didCloseTextDocument(const QLspSpecification::DidCloseTextDocumentParams ¶ms)