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;
41 QList<QLspSpecification::TextEdit>
result;
54 if (!
file.field(Fields::isValid).value().toBool(
false)) {
59 envPtr->clearReferenceCache();
62 if (!qmlFile || !qmlFile->isValid()) {
70 0, u
"Failed to parse %1"_s.arg(
file.canonicalFilePath()) });
80 QLspSpecification::TextEdit formattedText;
83 file.writeOutForFile(ow, WriteOutCheck::None);
85 const auto &code = qmlFile->code();
89 formattedText.range = QLspSpecification::Range{ QLspSpecification::Position{ 0, 0 },
90 QLspSpecification::Position{ endLine + 1, 0 } };
92 result.append(formattedText);
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) const
QString canonicalFilePath() const
Represents an error message connected to the dom.
AttributesSequence attributesSequence
A QmlFile, when loaded in a DomEnvironment that has the DomCreationOption::WithSemanticAnalysis,...
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 noexcept
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
This class sends a result or an error when going out of scope.
void setError(const QQmlLSUtilsErrorMessage &error)