7#include <QtQml/private/qqmljsast_p.h>
8#include <QtQml/private/qqmljsastvisitor_p.h>
9#include <QtQml/private/qqmljsengine_p.h>
10#include <QtQml/private/qqmljslexer_p.h>
25 std::shared_ptr<AstComments> comments;
28 int expressionDepth = 0;
30 bool addSemicolons()
const {
return expressionDepth > 0; }
35 : lw(lw), comments(comments), loc2Str(loc2Str)
45 postOps[
n].append([
c,
this]() {
c->writePost(lw); });
51 for (
auto &op : postOps[
n]) {
81 if (cast<Block *>(ast)) {
84 if (finishWithSpaceOrNewline)
88 if (finishWithSpaceOrNewline)
89 postOps[ast].append([
this]() { this->
newLine(); });
95#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
296 if (
it->elision &&
it->element)
312 bool isStringLike = AST::cast<StringLiteralPropertyName *>(assignment->
name)
313 || cast<IdentifierPropertyName *>(assignment->
name);
567 case VariableScope::Const:
570 case VariableScope::Let:
573 case VariableScope::Var:
629 if (cast<Block *>(ast->
ko) || cast<IfStatement *>(ast->
ko)) {
859 const bool needParentheses = ast->
formals &&
907 if (
it->isSpreadElement)
922 if (
EmptyStatement *emptyStatement = cast<EmptyStatement *>(
it->statement)) {
923 if (loc2Str(emptyStatement->semicolonToken) !=
QLatin1String(
";"))
959 if (
auto id =
it->element->bindingIdentifier.toString(); !
id.startsWith(u
"arg#"))
961 if (
it->element->bindingTarget)
993 postOps[
el->expression].append([
this]() {
out(
";"); });
1018 if (
property->type == PatternProperty::Getter)
1020 else if (
property->type == PatternProperty::Setter)
1023 const bool scoped =
f->lbraceToken.length != 0;
1024 out(
f->functionToken);
1025 out(
f->lparenToken);
1027 out(
f->rparenToken);
1028 out(
f->lbraceToken);
1032 if (
f->body->next || scoped) {
1043 out(
f->rbraceToken);
1075#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
1192 out(
"/* ERROR: Hit recursion limit visiting AST, rewrite failed */");
1200 Rewriter rewriter(lw, comments, loc2Str,
n);
SourceLocation lbracketToken
ExpressionNode * expression
SourceLocation rbracketToken
SourceLocation rbracketToken
PatternElementList * elements
SourceLocation lbracketToken
SourceLocation commaToken
SourceLocation operatorToken
StatementList * statements
SourceLocation rbraceToken
SourceLocation lbraceToken
SourceLocation identifierToken
SourceLocation breakToken
SourceLocation rparenToken
SourceLocation lparenToken
CaseClauses * moreClauses
SourceLocation lbraceToken
SourceLocation rbraceToken
DefaultClause * defaultClause
ExpressionNode * expression
SourceLocation colonToken
StatementList * statements
SourceLocation identifierToken
SourceLocation lparenToken
SourceLocation catchToken
ExpressionNode * heritage
ClassElementList * elements
SourceLocation classToken
ExpressionNode * expression
SourceLocation identifierToken
SourceLocation continueToken
SourceLocation defaultToken
StatementList * statements
SourceLocation colonToken
ExpressionNode * expression
ExpressionNode * expression
SourceLocation whileToken
SourceLocation rparenToken
SourceLocation lparenToken
SourceLocation semicolonToken
SourceLocation falseToken
SourceLocation identifierToken
SourceLocation rparenToken
ExpressionNode * expression
SourceLocation lparenToken
ExpressionNode * expression
VariableDeclarationList * declarations
ExpressionNode * initialiser
SourceLocation rparenToken
ExpressionNode * condition
SourceLocation lparenToken
FormalParameterList * formals
SourceLocation rparenToken
SourceLocation lbraceToken
SourceLocation rbraceToken
SourceLocation lparenToken
SourceLocation identifierToken
SourceLocation identifierToken
SourceLocation rparenToken
SourceLocation lparenToken
ExpressionNode * expression
SourceLocation identifierToken
SourceLocation rparenToken
SourceLocation lparenToken
ExpressionNode * expression
ExpressionNode * expression
SourceLocation lparenToken
SourceLocation rparenToken
void accept(BaseVisitor *visitor)
virtual void accept0(BaseVisitor *visitor)=0
ExpressionNode * expression
SourceLocation literalToken
SourceLocation lbraceToken
SourceLocation rbraceToken
PatternPropertyList * properties
SourceLocation identifierToken
ExpressionNode * initializer
ExpressionNode * bindingTarget
bool isVariableDeclaration() const
PatternProperty * property
SourceLocation decrementToken
SourceLocation incrementToken
SourceLocation decrementToken
ExpressionNode * expression
ExpressionNode * expression
SourceLocation incrementToken
SourceLocation literalToken
ExpressionNode * expression
SourceLocation returnToken
SourceLocation literalToken
SourceLocation switchToken
ExpressionNode * expression
SourceLocation rparenToken
SourceLocation lparenToken
SourceLocation literalToken
ExpressionNode * expression
ExpressionNode * expression
SourceLocation throwToken
SourceLocation tildeToken
ExpressionNode * expression
Finally * finallyExpression
ExpressionNode * expression
ExpressionNode * expression
SourceLocation minusToken
ExpressionNode * expression
PatternElement * declaration
SourceLocation declarationKindToken
VariableDeclarationList * declarations
ExpressionNode * expression
ExpressionNode * expression
SourceLocation whileToken
SourceLocation lparenToken
SourceLocation rparenToken
SourceLocation rparenToken
SourceLocation lparenToken
ExpressionNode * expression
OutWriter & ensureNewline(int nNewlines=1)
int increaseIndent(int level=1)
int decreaseIndent(int level=1, int expectedIndent=-1)
OutWriter & write(QStringView v, LineWriter::TextAddType t=LineWriter::TextAddType::Normal)
bool visit(NumericLiteral *ast) override
void endVisit(WithStatement *) override
void endVisit(PatternElement *) override
void endVisit(DefaultClause *) override
bool visit(CaseBlock *ast) override
void endVisit(ImportsList *) override
void endVisit(Finally *) override
bool visit(PreDecrementExpression *ast) override
void endVisit(NameSpaceImport *) override
void endVisit(FieldMemberExpression *) override
bool visit(FormalParameterList *ast) override
void endVisit(Elision *) override
bool visit(UiArrayMemberList *) override
bool visit(ExpressionStatement *el) override
void endVisit(UiEnumMemberList *) override
bool visit(VoidExpression *ast) override
void endVisit(ThrowStatement *) override
bool visit(ExportClause *) override
bool visit(NotExpression *ast) override
void endVisit(ThisExpression *) override
void endVisit(PatternProperty *) override
bool visit(ThrowStatement *ast) override
bool visit(UiObjectBinding *) override
bool visit(ForEachStatement *ast) override
void endVisit(ForEachStatement *) override
bool visit(ExportDeclaration *) override
bool visit(FromClause *) override
void endVisit(PreIncrementExpression *) override
bool visit(ComputedPropertyName *) override
bool visit(Catch *ast) override
void endVisit(Type *) override
void endVisit(ImportSpecifier *) override
void endVisit(StringLiteralPropertyName *) override
void endVisit(IdentifierPropertyName *) override
void endVisit(WhileStatement *) override
bool visit(NewExpression *ast) override
bool visit(RegExpLiteral *ast) override
void endVisit(UiParameterList *) override
bool visit(WhileStatement *ast) override
void endVisit(DebuggerStatement *) override
void endVisit(ContinueStatement *) override
void endVisit(VariableDeclarationList *) override
bool visit(UiObjectMemberList *) override
void endVisit(ExportsList *) override
bool visit(UiVersionSpecifier *) override
void endVisit(DeleteExpression *) override
bool visit(LabelledStatement *ast) override
void out(const SourceLocation &loc)
bool visit(UiRequired *) override
bool visit(DebuggerStatement *) override
bool visit(WithStatement *ast) override
bool visit(NullExpression *ast) override
bool visit(UiParameterList *) override
bool visit(ContinueStatement *ast) override
void out(QStringView str)
void endVisit(UiAnnotation *) override
bool visit(PatternPropertyList *ast) override
void lnAcceptIndented(Node *node)
void endVisit(ExportClause *) override
bool acceptBlockOrIndented(Node *ast, bool finishWithSpaceOrNewline=false)
void endVisit(NumericLiteralPropertyName *) override
bool visit(NewMemberExpression *ast) override
void endVisit(TypeOfExpression *) override
void endVisit(IdentifierExpression *) override
bool visit(ClassDeclaration *ast) override
void endVisit(UnaryMinusExpression *) override
bool visit(UiPragmaValueList *) override
void postVisit(Node *n) override
void endVisit(NullExpression *) override
bool visit(CaseClause *ast) override
void endVisit(PatternPropertyList *) override
void endVisit(FormalParameterList *) override
bool visit(ForStatement *ast) override
bool visit(UiQualifiedId *) override
bool visit(DefaultClause *ast) override
void endVisit(ClassExpression *) override
bool visit(UiObjectDefinition *) override
void endVisit(UiProgram *) override
void endVisit(BinaryExpression *) override
void endVisit(TaggedTemplate *) override
void endVisit(EmptyStatement *) override
bool visit(StringLiteralPropertyName *ast) override
void endVisit(UnaryPlusExpression *) override
void endVisit(ESModule *) override
bool visit(EmptyStatement *ast) override
bool visit(ReturnStatement *ast) override
bool visit(ExportSpecifier *) override
bool visit(UiImport *) override
bool visit(PostIncrementExpression *ast) override
void endVisit(UiPublicMember *) override
bool visit(UiAnnotationList *) override
void endVisit(LabelledStatement *) override
void endVisit(SuperLiteral *) override
bool visit(UnaryMinusExpression *ast) override
bool visit(UiAnnotation *) override
bool visit(NestedExpression *ast) override
bool visit(NameSpaceImport *) override
bool visit(FieldMemberExpression *ast) override
void endVisit(ExpressionStatement *) override
bool visit(CaseClauses *ast) override
bool visit(IfStatement *ast) override
bool visit(PatternProperty *) override
void endVisit(CaseBlock *) override
void endVisit(DoWhileStatement *) override
bool visit(IdentifierExpression *ast) override
void endVisit(Block *) override
bool visit(YieldExpression *) override
bool visit(ImportDeclaration *) override
void endVisit(ArrayMemberExpression *) override
bool visit(UiArrayBinding *) override
void out(const char *str)
Rewriter(OutWriter &lw, std::shared_ptr< AstComments > comments, std::function< QStringView(SourceLocation)> loc2Str, Node *node)
void endVisit(UiEnumDeclaration *) override
void endVisit(UiObjectBinding *) override
bool visit(TaggedTemplate *) override
void endVisit(PreDecrementExpression *) override
void endVisit(CallExpression *) override
bool visit(ImportsList *) override
void endVisit(RegExpLiteral *) override
bool visit(ArrayPattern *ast) override
void endVisit(TypeAnnotation *) override
bool visit(DoWhileStatement *ast) override
bool visit(UiPublicMember *) override
bool visit(ClassExpression *) override
bool visit(StatementList *ast) override
void endVisit(UiRequired *) override
void endVisit(UiArrayMemberList *) override
void endVisit(PostDecrementExpression *) override
void endVisit(UiImport *) override
bool visit(SwitchStatement *ast) override
bool visit(FunctionExpression *ast) override
void endVisit(NotExpression *) override
bool visit(BreakStatement *ast) override
void outputScope(VariableScope scope)
bool visit(ESModule *) override
bool visit(ExportsList *) override
bool visit(UiInlineComponent *) override
void endVisit(Program *) override
void endVisit(YieldExpression *) override
void endVisit(UiObjectMemberList *) override
bool visit(NumericLiteralPropertyName *ast) override
bool visit(BinaryExpression *ast) override
void endVisit(UiAnnotationList *) override
void endVisit(TrueLiteral *) override
bool visit(VariableStatement *ast) override
void endVisit(NewMemberExpression *) override
void endVisit(Expression *) override
bool visit(Finally *ast) override
void endVisit(CaseClause *) override
void endVisit(UiPragmaValueList *) override
bool visit(TildeExpression *ast) override
bool visit(PatternElementList *ast) override
bool visit(ConditionalExpression *ast) override
bool visit(TypeExpression *) override
void endVisit(UiVersionSpecifier *) override
void endVisit(PostIncrementExpression *) override
void endVisit(UiHeaderItemList *) override
bool visit(TypeOfExpression *ast) override
bool visit(ArrayMemberExpression *ast) override
void endVisit(PatternElementList *) override
bool visit(UiHeaderItemList *) override
bool visit(ArgumentList *ast) override
bool visit(FunctionDeclaration *ast) override
void endVisit(ExportDeclaration *) override
void endVisit(ConditionalExpression *) override
void endVisit(UiSourceElement *) override
bool visit(PostDecrementExpression *ast) override
void endVisit(ForStatement *) override
void endVisit(FunctionDeclaration *) override
bool visit(Block *ast) override
void endVisit(StatementList *) override
bool visit(ClassElementList *) override
void endVisit(ExportSpecifier *) override
bool visit(PreIncrementExpression *ast) override
bool visit(FalseLiteral *ast) override
void endVisit(TryStatement *) override
void endVisit(BreakStatement *) override
bool visit(UiScriptBinding *) override
void endVisit(VoidExpression *) override
void endVisit(ClassDeclaration *) override
bool visit(NamedImports *) override
bool visit(ObjectPattern *ast) override
void endVisit(TemplateLiteral *) override
void endVisit(NewExpression *) override
bool visit(TrueLiteral *ast) override
void endVisit(CaseClauses *) override
void endVisit(UiScriptBinding *) override
bool visit(ImportSpecifier *) override
void endVisit(ImportDeclaration *) override
bool visit(ImportClause *) override
bool visit(Expression *el) override
bool visit(UnaryPlusExpression *ast) override
bool visit(PatternElement *ast) override
void endVisit(ComputedPropertyName *) override
bool visit(StringLiteral *ast) override
bool visit(DeleteExpression *ast) override
bool preVisit(Node *n) override
bool visit(Type *) override
bool visit(TryStatement *ast) override
bool visit(UiEnumMemberList *) override
void endVisit(FromClause *) override
bool visit(Program *) override
bool visit(UiSourceElement *) override
void endVisit(TypeExpression *) override
bool visit(TypeAnnotation *) override
void endVisit(ClassElementList *) override
bool visit(SuperLiteral *) override
bool visit(UiObjectInitializer *) override
void endVisit(TildeExpression *) override
bool visit(VariableDeclarationList *ast) override
void endVisit(StringLiteral *) override
void endVisit(Catch *) override
void endVisit(UiArrayBinding *) override
void endVisit(FalseLiteral *) override
void throwRecursionDepthError() override
void endVisit(VariableStatement *) override
bool visit(CallExpression *ast) override
void endVisit(UiPragma *) override
void endVisit(UiInlineComponent *) override
bool visit(UiProgram *) override
void endVisit(SwitchStatement *) override
void endVisit(ReturnStatement *) override
void endVisit(UiObjectInitializer *) override
bool visit(IdentifierPropertyName *ast) override
void endVisit(ObjectPattern *) override
void endVisit(UiQualifiedId *) override
void endVisit(IfStatement *) override
void endVisit(NamedImports *) override
void endVisit(NestedExpression *) override
void endVisit(ArrayPattern *) override
bool visit(UiPragma *) override
bool visit(ThisExpression *ast) override
bool visit(UiEnumDeclaration *) override
void endVisit(ImportClause *) override
bool visit(TemplateLiteral *ast) override
bool visit(Elision *ast) override
void endVisit(NumericLiteral *) override
void endVisit(UiObjectDefinition *) override
void endVisit(FunctionExpression *) override
void endVisit(ArgumentList *) override
constexpr QStringView left(qsizetype n) const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr bool isNull() const noexcept
Returns whether this string view is null - that is, whether {data() == nullptr}.
constexpr QStringView right(qsizetype n) const noexcept
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QSet< QString >::iterator it
void reformatAst(OutWriter &lw, std::shared_ptr< AstComments > comments, const std::function< QStringView(SourceLocation)> loc2Str, AST::Node *n)
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
QTextStream out(stdout)
[7]
\inmodule QtCore \reentrant