8#include <QtQmlDom/private/qqmldomitem_p.h>
9#include <QtQmlDom/private/qqmldomindentinglinewriter_p.h>
10#include <QtQmlDom/private/qqmldomoutwriter_p.h>
23 return u
"QQmlDocumentFormatting"_s;
32 const QLspSpecification::InitializeParams &,
33 QLspSpecification::InitializeResult &serverCapabilities)
36 serverCapabilities.capabilities.documentFormattingProvider =
true;
50 if (!
file.field(Fields::isValid).value().toBool(
false)) {
51 qWarning() << u
"Invalid document will not be formatted"_s;
55 envPtr->clearReferenceCache();
58 if (!qmlFile || !qmlFile->isValid()) {
75 QLspSpecification::TextEdit formattedText;
81 const auto &code = qmlFile->code();
85 formattedText.range = QLspSpecification::Range{ QLspSpecification::Position{ 0, 0 },
86 QLspSpecification::Position{ endLine + 1, 0 } };
bool flush()
Flushes any buffered data to the file.
Implements a server for the language server protocol.
Represents a consistent set of types organized in modules, it is the top level of the DOM.
DomItem fileObject(GoTo option=GoTo::Strict)
Represents an error message connected to the dom.
AttributesSequence attributesSequence
static QByteArray lspUriToQmlUrl(const QByteArray &uri)
static QQmlLSUtilsTextPosition textRowAndColumnFrom(const QString &code, qsizetype offset)
Convert a text position from an offset into (line, column).
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype length() const
Returns the number of characters in this string.
OpenDocumentSnapshot snapshot
OpenDocument openDocumentByUrl(const QByteArray &url)
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
QNetworkRequest request(url)
decltype(auto) getRequestHandler()
QmlLsp::QQmlCodeModel * m_codeModel