qmljs: Use C++11’s override and remove virtual where applicable

Fixes warning: prefer using 'override' or (rarely) 'final' instead of
'virtual' [modernize-use-override]

Change-Id: I17955fd0fdb052678228f1bda32cd8d3b4298998
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
Alessandro Portale
2018-06-22 15:11:29 +02:00
parent 64b8f98a35
commit 4b13170565
4 changed files with 121 additions and 121 deletions

View File

@@ -53,12 +53,12 @@ protected:
BlockData data;
};
virtual void saveBlockData(QTextBlock *block, const BlockData &data) const
void saveBlockData(QTextBlock *block, const BlockData &data) const override
{
block->setUserData(new FormatterData(data));
}
virtual bool loadBlockData(const QTextBlock &block, BlockData *data) const
bool loadBlockData(const QTextBlock &block, BlockData *data) const override
{
if (!block.userData())
return false;
@@ -67,12 +67,12 @@ protected:
return true;
}
virtual void saveLexerState(QTextBlock *block, int state) const
void saveLexerState(QTextBlock *block, int state) const override
{
block->setUserState(state);
}
virtual int loadLexerState(const QTextBlock &block) const
int loadLexerState(const QTextBlock &block) const override
{
return block.userState();
}
@@ -464,7 +464,7 @@ protected:
loc.length += 2;
}
virtual bool preVisit(Node *ast)
bool preVisit(Node *ast) override
{
SourceLocation firstLoc;
if (ExpressionNode *expr = ast->expressionCast())
@@ -486,7 +486,7 @@ protected:
return true;
}
virtual void postVisit(Node *ast)
void postVisit(Node *ast) override
{
SourceLocation lastLoc;
if (ExpressionNode *expr = ast->expressionCast())
@@ -525,14 +525,14 @@ protected:
}
}
virtual bool visit(UiPragma *ast)
bool visit(UiPragma *ast) override
{
out("pragma ", ast->pragmaToken);
accept(ast->pragmaType);
return false;
}
virtual bool visit(UiImport *ast)
bool visit(UiImport *ast) override
{
out("import ", ast->importToken);
if (!ast->fileName.isNull())
@@ -550,7 +550,7 @@ protected:
return false;
}
virtual bool visit(UiObjectDefinition *ast)
bool visit(UiObjectDefinition *ast) override
{
accept(ast->qualifiedTypeNameId);
out(" ");
@@ -558,7 +558,7 @@ protected:
return false;
}
virtual bool visit(UiObjectInitializer *ast)
bool visit(UiObjectInitializer *ast) override
{
out(ast->lbraceToken);
if (ast->members)
@@ -568,7 +568,7 @@ protected:
return false;
}
virtual bool visit(UiParameterList *list)
bool visit(UiParameterList *list) override
{
for (UiParameterList *it = list; it; it = it->next) {
out(it->propertyTypeToken);
@@ -580,7 +580,7 @@ protected:
return false;
}
virtual bool visit(UiPublicMember *ast)
bool visit(UiPublicMember *ast) override
{
if (ast->type == UiPublicMember::Property) {
if (ast->isDefaultMember)
@@ -618,7 +618,7 @@ protected:
return false;
}
virtual bool visit(UiObjectBinding *ast)
bool visit(UiObjectBinding *ast) override
{
if (ast->hasOnToken) {
accept(ast->qualifiedTypeNameId);
@@ -634,7 +634,7 @@ protected:
return false;
}
virtual bool visit(UiScriptBinding *ast)
bool visit(UiScriptBinding *ast) override
{
accept(ast->qualifiedId);
out(": ", ast->colonToken);
@@ -642,7 +642,7 @@ protected:
return false;
}
virtual bool visit(UiArrayBinding *ast)
bool visit(UiArrayBinding *ast) override
{
accept(ast->qualifiedId);
out(ast->colonToken);
@@ -654,16 +654,16 @@ protected:
return false;
}
virtual bool visit(ThisExpression *ast) { out(ast->thisToken); return true; }
virtual bool visit(NullExpression *ast) { out(ast->nullToken); return true; }
virtual bool visit(TrueLiteral *ast) { out(ast->trueToken); return true; }
virtual bool visit(FalseLiteral *ast) { out(ast->falseToken); return true; }
virtual bool visit(IdentifierExpression *ast) { out(ast->identifierToken); return true; }
virtual bool visit(StringLiteral *ast) { out(ast->literalToken); return true; }
virtual bool visit(NumericLiteral *ast) { out(ast->literalToken); return true; }
virtual bool visit(RegExpLiteral *ast) { out(ast->literalToken); return true; }
bool visit(ThisExpression *ast) override { out(ast->thisToken); return true; }
bool visit(NullExpression *ast) override { out(ast->nullToken); return true; }
bool visit(TrueLiteral *ast) override { out(ast->trueToken); return true; }
bool visit(FalseLiteral *ast) override { out(ast->falseToken); return true; }
bool visit(IdentifierExpression *ast) override { out(ast->identifierToken); return true; }
bool visit(StringLiteral *ast) override { out(ast->literalToken); return true; }
bool visit(NumericLiteral *ast) override { out(ast->literalToken); return true; }
bool visit(RegExpLiteral *ast) override { out(ast->literalToken); return true; }
virtual bool visit(ArrayLiteral *ast)
bool visit(ArrayLiteral *ast) override
{
out(ast->lbracketToken);
if (ast->elements)
@@ -676,7 +676,7 @@ protected:
return false;
}
virtual bool visit(ObjectLiteral *ast)
bool visit(ObjectLiteral *ast) override
{
out(ast->lbraceToken);
lnAcceptIndented(ast->properties);
@@ -685,7 +685,7 @@ protected:
return false;
}
virtual bool visit(ElementList *ast)
bool visit(ElementList *ast) override
{
for (ElementList *it = ast; it; it = it->next) {
if (it->elision)
@@ -700,7 +700,7 @@ protected:
return false;
}
virtual bool visit(PropertyAssignmentList *ast)
bool visit(PropertyAssignmentList *ast) override
{
for (PropertyAssignmentList *it = ast; it; it = it->next) {
PropertyNameAndValue *assignment = AST::cast<PropertyNameAndValue *>(it->assignment);
@@ -739,7 +739,7 @@ protected:
return false;
}
virtual bool visit(NestedExpression *ast)
bool visit(NestedExpression *ast) override
{
out(ast->lparenToken);
accept(ast->expression);
@@ -747,11 +747,11 @@ protected:
return false;
}
virtual bool visit(IdentifierPropertyName *ast) { out(ast->id.toString()); return true; }
virtual bool visit(StringLiteralPropertyName *ast) { out(ast->id.toString()); return true; }
virtual bool visit(NumericLiteralPropertyName *ast) { out(QString::number(ast->id)); return true; }
bool visit(IdentifierPropertyName *ast) override { out(ast->id.toString()); return true; }
bool visit(StringLiteralPropertyName *ast) override { out(ast->id.toString()); return true; }
bool visit(NumericLiteralPropertyName *ast) override { out(QString::number(ast->id)); return true; }
virtual bool visit(ArrayMemberExpression *ast)
bool visit(ArrayMemberExpression *ast) override
{
accept(ast->base);
out(ast->lbracketToken);
@@ -760,7 +760,7 @@ protected:
return false;
}
virtual bool visit(FieldMemberExpression *ast)
bool visit(FieldMemberExpression *ast) override
{
accept(ast->base);
out(ast->dotToken);
@@ -768,7 +768,7 @@ protected:
return false;
}
virtual bool visit(NewMemberExpression *ast)
bool visit(NewMemberExpression *ast) override
{
out("new ", ast->newToken);
accept(ast->base);
@@ -778,14 +778,14 @@ protected:
return false;
}
virtual bool visit(NewExpression *ast)
bool visit(NewExpression *ast) override
{
out("new ", ast->newToken);
accept(ast->expression);
return false;
}
virtual bool visit(CallExpression *ast)
bool visit(CallExpression *ast) override
{
accept(ast->base);
out(ast->lparenToken);
@@ -795,84 +795,84 @@ protected:
return false;
}
virtual bool visit(PostIncrementExpression *ast)
bool visit(PostIncrementExpression *ast) override
{
accept(ast->base);
out(ast->incrementToken);
return false;
}
virtual bool visit(PostDecrementExpression *ast)
bool visit(PostDecrementExpression *ast) override
{
accept(ast->base);
out(ast->decrementToken);
return false;
}
virtual bool visit(PreIncrementExpression *ast)
bool visit(PreIncrementExpression *ast) override
{
out(ast->incrementToken);
accept(ast->expression);
return false;
}
virtual bool visit(PreDecrementExpression *ast)
bool visit(PreDecrementExpression *ast) override
{
out(ast->decrementToken);
accept(ast->expression);
return false;
}
virtual bool visit(DeleteExpression *ast)
bool visit(DeleteExpression *ast) override
{
out("delete ", ast->deleteToken);
accept(ast->expression);
return false;
}
virtual bool visit(VoidExpression *ast)
bool visit(VoidExpression *ast) override
{
out("void ", ast->voidToken);
accept(ast->expression);
return false;
}
virtual bool visit(TypeOfExpression *ast)
bool visit(TypeOfExpression *ast) override
{
out("typeof ", ast->typeofToken);
accept(ast->expression);
return false;
}
virtual bool visit(UnaryPlusExpression *ast)
bool visit(UnaryPlusExpression *ast) override
{
out(ast->plusToken);
accept(ast->expression);
return false;
}
virtual bool visit(UnaryMinusExpression *ast)
bool visit(UnaryMinusExpression *ast) override
{
out(ast->minusToken);
accept(ast->expression);
return false;
}
virtual bool visit(TildeExpression *ast)
bool visit(TildeExpression *ast) override
{
out(ast->tildeToken);
accept(ast->expression);
return false;
}
virtual bool visit(NotExpression *ast)
bool visit(NotExpression *ast) override
{
out(ast->notToken);
accept(ast->expression);
return false;
}
virtual bool visit(BinaryExpression *ast)
bool visit(BinaryExpression *ast) override
{
++_binaryExpDepth;
accept(ast->left);
@@ -893,7 +893,7 @@ protected:
return false;
}
virtual bool visit(ConditionalExpression *ast)
bool visit(ConditionalExpression *ast) override
{
accept(ast->expression);
out(" ? ", ast->questionToken);
@@ -903,7 +903,7 @@ protected:
return false;
}
virtual bool visit(Block *ast)
bool visit(Block *ast) override
{
out(ast->lbraceToken);
lnAcceptIndented(ast->statements);
@@ -912,14 +912,14 @@ protected:
return false;
}
virtual bool visit(VariableStatement *ast)
bool visit(VariableStatement *ast) override
{
out("var ", ast->declarationKindToken);
accept(ast->declarations);
return false;
}
virtual bool visit(VariableDeclaration *ast)
bool visit(VariableDeclaration *ast) override
{
out(ast->identifierToken);
if (ast->expression) {
@@ -929,13 +929,13 @@ protected:
return false;
}
virtual bool visit(EmptyStatement *ast)
bool visit(EmptyStatement *ast) override
{
out(ast->semicolonToken);
return false;
}
virtual bool visit(IfStatement *ast)
bool visit(IfStatement *ast) override
{
out(ast->ifToken);
out(" ");
@@ -955,7 +955,7 @@ protected:
return false;
}
virtual bool visit(DoWhileStatement *ast)
bool visit(DoWhileStatement *ast) override
{
out(ast->doToken);
acceptBlockOrIndented(ast->statement, true);
@@ -967,7 +967,7 @@ protected:
return false;
}
virtual bool visit(WhileStatement *ast)
bool visit(WhileStatement *ast) override
{
out(ast->whileToken);
out(" ");
@@ -978,7 +978,7 @@ protected:
return false;
}
virtual bool visit(ForStatement *ast)
bool visit(ForStatement *ast) override
{
out(ast->forToken);
out(" ");
@@ -993,7 +993,7 @@ protected:
return false;
}
virtual bool visit(LocalForStatement *ast)
bool visit(LocalForStatement *ast) override
{
out(ast->forToken);
out(" ");
@@ -1010,7 +1010,7 @@ protected:
return false;
}
virtual bool visit(ForEachStatement *ast)
bool visit(ForEachStatement *ast) override
{
out(ast->forToken);
out(" ");
@@ -1023,7 +1023,7 @@ protected:
return false;
}
virtual bool visit(LocalForEachStatement *ast)
bool visit(LocalForEachStatement *ast) override
{
out(ast->forToken);
out(" ");
@@ -1038,7 +1038,7 @@ protected:
return false;
}
virtual bool visit(ContinueStatement *ast)
bool visit(ContinueStatement *ast) override
{
out(ast->continueToken);
if (!ast->label.isNull()) {
@@ -1048,7 +1048,7 @@ protected:
return false;
}
virtual bool visit(BreakStatement *ast)
bool visit(BreakStatement *ast) override
{
out(ast->breakToken);
if (!ast->label.isNull()) {
@@ -1058,7 +1058,7 @@ protected:
return false;
}
virtual bool visit(ReturnStatement *ast)
bool visit(ReturnStatement *ast) override
{
out(ast->returnToken);
if (ast->expression) {
@@ -1068,7 +1068,7 @@ protected:
return false;
}
virtual bool visit(ThrowStatement *ast)
bool visit(ThrowStatement *ast) override
{
out(ast->throwToken);
if (ast->expression) {
@@ -1078,7 +1078,7 @@ protected:
return false;
}
virtual bool visit(WithStatement *ast)
bool visit(WithStatement *ast) override
{
out(ast->withToken);
out(" ");
@@ -1089,7 +1089,7 @@ protected:
return false;
}
virtual bool visit(SwitchStatement *ast)
bool visit(SwitchStatement *ast) override
{
out(ast->switchToken);
out(" ");
@@ -1101,7 +1101,7 @@ protected:
return false;
}
virtual bool visit(CaseBlock *ast)
bool visit(CaseBlock *ast) override
{
out(ast->lbraceToken);
newLine();
@@ -1117,7 +1117,7 @@ protected:
return false;
}
virtual bool visit(CaseClause *ast)
bool visit(CaseClause *ast) override
{
out("case ", ast->caseToken);
accept(ast->expression);
@@ -1127,7 +1127,7 @@ protected:
return false;
}
virtual bool visit(DefaultClause *ast)
bool visit(DefaultClause *ast) override
{
out(ast->defaultToken);
out(ast->colonToken);
@@ -1135,7 +1135,7 @@ protected:
return false;
}
virtual bool visit(LabelledStatement *ast)
bool visit(LabelledStatement *ast) override
{
out(ast->identifierToken);
out(": ", ast->colonToken);
@@ -1143,7 +1143,7 @@ protected:
return false;
}
virtual bool visit(TryStatement *ast)
bool visit(TryStatement *ast) override
{
out("try ", ast->tryToken);
accept(ast->statement);
@@ -1158,7 +1158,7 @@ protected:
return false;
}
virtual bool visit(Catch *ast)
bool visit(Catch *ast) override
{
out(ast->catchToken);
out(" ");
@@ -1169,19 +1169,19 @@ protected:
return false;
}
virtual bool visit(Finally *ast)
bool visit(Finally *ast) override
{
out("finally ", ast->finallyToken);
accept(ast->statement);
return false;
}
virtual bool visit(FunctionDeclaration *ast)
bool visit(FunctionDeclaration *ast) override
{
return visit(static_cast<FunctionExpression *>(ast));
}
virtual bool visit(FunctionExpression *ast)
bool visit(FunctionExpression *ast) override
{
out("function ", ast->functionToken);
if (!ast->name.isNull())
@@ -1200,7 +1200,7 @@ protected:
}
virtual bool visit(UiHeaderItemList *ast)
bool visit(UiHeaderItemList *ast) override
{
for (UiHeaderItemList *it = ast; it; it = it->next) {
accept(it->headerItem);
@@ -1210,7 +1210,7 @@ protected:
return false;
}
virtual bool visit(UiObjectMemberList *ast)
bool visit(UiObjectMemberList *ast) override
{
for (UiObjectMemberList *it = ast; it; it = it->next) {
accept(it->member);
@@ -1220,7 +1220,7 @@ protected:
return false;
}
virtual bool visit(UiArrayMemberList *ast)
bool visit(UiArrayMemberList *ast) override
{
for (UiArrayMemberList *it = ast; it; it = it->next) {
accept(it->member);
@@ -1232,7 +1232,7 @@ protected:
return false;
}
virtual bool visit(UiQualifiedId *ast)
bool visit(UiQualifiedId *ast) override
{
for (UiQualifiedId *it = ast; it; it = it->next) {
out(it->identifierToken);
@@ -1242,13 +1242,13 @@ protected:
return false;
}
virtual bool visit(UiQualifiedPragmaId *ast)
bool visit(UiQualifiedPragmaId *ast) override
{
out(ast->identifierToken);
return false;
}
virtual bool visit(Elision *ast)
bool visit(Elision *ast) override
{
for (Elision *it = ast; it; it = it->next) {
if (it->next)
@@ -1257,7 +1257,7 @@ protected:
return false;
}
virtual bool visit(ArgumentList *ast)
bool visit(ArgumentList *ast) override
{
for (ArgumentList *it = ast; it; it = it->next) {
accept(it->expression);
@@ -1269,7 +1269,7 @@ protected:
return false;
}
virtual bool visit(StatementList *ast)
bool visit(StatementList *ast) override
{
for (StatementList *it = ast; it; it = it->next) {
// ### work around parser bug: skip empty statements with wrong tokens
@@ -1285,7 +1285,7 @@ protected:
return false;
}
virtual bool visit(SourceElements *ast)
bool visit(SourceElements *ast) override
{
for (SourceElements *it = ast; it; it = it->next) {
accept(it->element);
@@ -1295,7 +1295,7 @@ protected:
return false;
}
virtual bool visit(VariableDeclarationList *ast)
bool visit(VariableDeclarationList *ast) override
{
for (VariableDeclarationList *it = ast; it; it = it->next) {
accept(it->declaration);
@@ -1305,7 +1305,7 @@ protected:
return false;
}
virtual bool visit(CaseClauses *ast)
bool visit(CaseClauses *ast) override
{
for (CaseClauses *it = ast; it; it = it->next) {
accept(it->clause);
@@ -1315,7 +1315,7 @@ protected:
return false;
}
virtual bool visit(FormalParameterList *ast)
bool visit(FormalParameterList *ast) override
{
for (FormalParameterList *it = ast; it; it = it->next) {
if (it->commaToken.isValid())