QmlJS: Tr::Tr

Excluding the Qml parser, which needs to remain in sync with it's copy
in Qt.

Change-Id: I22f475f265dd74687e3239c4d6916c777798a447
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2023-01-24 14:39:05 +01:00
parent fc8b81f2cb
commit 17b28909a9
29 changed files with 276 additions and 577 deletions

View File

@@ -2,7 +2,10 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsstaticanalysismessage.h"
#include "qmljsconstants.h"
#include "qmljstr.h"
#include "parser/qmljsengine_p.h"
#include "parser/qmljsdiagnosticmessage_p.h"
@@ -19,8 +22,6 @@ namespace {
class StaticAnalysisMessages
{
Q_DECLARE_TR_FUNCTIONS(QmlJS::StaticAnalysisMessages)
public:
void newMsg(Type type, Enum severity, const QString &message, int placeholders = 0)
{
@@ -40,9 +41,9 @@ public:
static inline QString msgInvalidConstructor(const char *what)
{
return StaticAnalysisMessages::tr("Do not use \"%1\" as a constructor."
"\n\nFor more information, see the"
" \"Checking Code Syntax\" documentation.")
return Tr::tr("Do not use \"%1\" as a constructor."
"\n\nFor more information, see the"
" \"Checking Code Syntax\" documentation.")
.arg(QLatin1String(what));
}
@@ -51,63 +52,63 @@ StaticAnalysisMessages::StaticAnalysisMessages()
// When changing a message or severity, update the documentation, currently
// in creator-code-syntax.qdoc, accordingly.
newMsg(ErrInvalidEnumValue, Error,
tr("Invalid value for enum."));
Tr::tr("Invalid value for enum."));
newMsg(ErrEnumValueMustBeStringOrNumber, Error,
tr("Enum value must be a string or a number."));
Tr::tr("Enum value must be a string or a number."));
newMsg(ErrNumberValueExpected, Error,
tr("Number value expected."));
Tr::tr("Number value expected."));
newMsg(ErrBooleanValueExpected, Error,
tr("Boolean value expected."));
Tr::tr("Boolean value expected."));
newMsg(ErrStringValueExpected, Error,
tr("String value expected."));
Tr::tr("String value expected."));
newMsg(ErrInvalidUrl, Error,
tr("Invalid URL."));
Tr::tr("Invalid URL."));
newMsg(WarnFileOrDirectoryDoesNotExist, Warning,
tr("File or directory does not exist."));
Tr::tr("File or directory does not exist."));
newMsg(ErrInvalidColor, Error,
tr("Invalid color."));
Tr::tr("Invalid color."));
newMsg(ErrAnchorLineExpected, Error,
tr("Anchor line expected."));
Tr::tr("Anchor line expected."));
newMsg(ErrPropertiesCanOnlyHaveOneBinding, Error,
tr("Duplicate property binding."));
Tr::tr("Duplicate property binding."));
newMsg(ErrIdExpected, Error,
tr("Id expected."));
Tr::tr("Id expected."));
newMsg(ErrInvalidId, Error,
tr("Invalid id."));
Tr::tr("Invalid id."));
newMsg(ErrDuplicateId, Error,
tr("Duplicate id."));
Tr::tr("Duplicate id."));
newMsg(ErrInvalidPropertyName, Error,
tr("Invalid property name \"%1\"."), 1);
Tr::tr("Invalid property name \"%1\"."), 1);
newMsg(ErrDoesNotHaveMembers, Error,
tr("\"%1\" does not have members."), 1);
Tr::tr("\"%1\" does not have members."), 1);
newMsg(ErrInvalidMember, Error,
tr("\"%1\" is not a member of \"%2\"."), 2);
Tr::tr("\"%1\" is not a member of \"%2\"."), 2);
newMsg(WarnAssignmentInCondition, Warning,
tr("Assignment in condition."));
Tr::tr("Assignment in condition."));
newMsg(WarnCaseWithoutFlowControl, Warning,
tr("Unterminated non-empty case block."));
Tr::tr("Unterminated non-empty case block."));
newMsg(WarnEval, Warning,
tr("Do not use 'eval'."));
Tr::tr("Do not use 'eval'."));
newMsg(WarnUnreachable, Warning,
tr("Unreachable."));
Tr::tr("Unreachable."));
newMsg(WarnWith, Warning,
tr("Do not use 'with'."));
Tr::tr("Do not use 'with'."));
newMsg(WarnComma, Warning,
tr("Do not use comma expressions."));
Tr::tr("Do not use comma expressions."));
newMsg(WarnAlreadyFormalParameter, Warning,
tr("\"%1\" already is a formal parameter."), 1);
Tr::tr("\"%1\" already is a formal parameter."), 1);
newMsg(WarnUnnecessaryMessageSuppression, Warning,
tr("Unnecessary message suppression."));
Tr::tr("Unnecessary message suppression."));
newMsg(WarnAlreadyFunction, Warning,
tr("\"%1\" already is a function."), 1);
Tr::tr("\"%1\" already is a function."), 1);
newMsg(WarnVarUsedBeforeDeclaration, Warning,
tr("var \"%1\" is used before its declaration."), 1);
Tr::tr("var \"%1\" is used before its declaration."), 1);
newMsg(WarnAlreadyVar, Warning,
tr("\"%1\" already is a var."), 1);
Tr::tr("\"%1\" already is a var."), 1);
newMsg(WarnDuplicateDeclaration, Warning,
tr("\"%1\" is declared more than once."), 1);
Tr::tr("\"%1\" is declared more than once."), 1);
newMsg(WarnFunctionUsedBeforeDeclaration, Warning,
tr("Function \"%1\" is used before its declaration."), 1);
Tr::tr("Function \"%1\" is used before its declaration."), 1);
newMsg(WarnBooleanConstructor, Warning,
msgInvalidConstructor("Boolean"));
newMsg(WarnStringConstructor, Warning,
@@ -119,124 +120,124 @@ StaticAnalysisMessages::StaticAnalysisMessages()
newMsg(WarnFunctionConstructor, Warning,
msgInvalidConstructor("Function"));
newMsg(HintAnonymousFunctionSpacing, Hint,
tr("The 'function' keyword and the opening parenthesis should be separated by a single space."));
Tr::tr("The 'function' keyword and the opening parenthesis should be separated by a single space."));
newMsg(WarnBlock, Warning,
tr("Do not use stand-alone blocks."));
Tr::tr("Do not use stand-alone blocks."));
newMsg(WarnVoid, Warning,
tr("Do not use void expressions."));
Tr::tr("Do not use void expressions."));
newMsg(WarnConfusingPluses, Warning,
tr("Confusing pluses."));
Tr::tr("Confusing pluses."));
newMsg(WarnConfusingMinuses, Warning,
tr("Confusing minuses."));
Tr::tr("Confusing minuses."));
newMsg(HintDeclareVarsInOneLine, Hint,
tr("Declare all function vars on a single line."));
Tr::tr("Declare all function vars on a single line."));
newMsg(HintExtraParentheses, Hint,
tr("Unnecessary parentheses."));
Tr::tr("Unnecessary parentheses."));
newMsg(MaybeWarnEqualityTypeCoercion, MaybeWarning,
tr("== and != may perform type coercion, use === or !== to avoid it."));
Tr::tr("== and != may perform type coercion, use === or !== to avoid it."));
newMsg(WarnConfusingExpressionStatement, Warning,
tr("Expression statements should be assignments, calls or delete expressions only."));
Tr::tr("Expression statements should be assignments, calls or delete expressions only."));
newMsg(HintDeclarationsShouldBeAtStartOfFunction, Hint,
tr("Place var declarations at the start of a function."));
Tr::tr("Place var declarations at the start of a function."));
newMsg(HintOneStatementPerLine, Hint,
tr("Use only one statement per line."));
Tr::tr("Use only one statement per line."));
newMsg(ErrUnknownComponent, Error,
tr("Unknown component."));
Tr::tr("Unknown component."));
newMsg(ErrCouldNotResolvePrototypeOf, Error,
tr("Could not resolve the prototype \"%1\" of \"%2\"."), 2);
Tr::tr("Could not resolve the prototype \"%1\" of \"%2\"."), 2);
newMsg(ErrCouldNotResolvePrototype, Error,
tr("Could not resolve the prototype \"%1\"."), 1);
Tr::tr("Could not resolve the prototype \"%1\"."), 1);
newMsg(ErrPrototypeCycle, Error,
tr("Prototype cycle, the last non-repeated component is \"%1\"."), 1);
Tr::tr("Prototype cycle, the last non-repeated component is \"%1\"."), 1);
newMsg(ErrInvalidPropertyType, Error,
tr("Invalid property type \"%1\"."), 1);
Tr::tr("Invalid property type \"%1\"."), 1);
newMsg(WarnEqualityTypeCoercion, Error,
tr("== and != perform type coercion, use === or !== to avoid it."));
Tr::tr("== and != perform type coercion, use === or !== to avoid it."));
newMsg(WarnExpectedNewWithUppercaseFunction, Error,
tr("Calls of functions that start with an uppercase letter should use 'new'."));
Tr::tr("Calls of functions that start with an uppercase letter should use 'new'."));
newMsg(WarnNewWithLowercaseFunction, Error,
tr("Use 'new' only with functions that start with an uppercase letter."));
Tr::tr("Use 'new' only with functions that start with an uppercase letter."));
newMsg(WarnNumberConstructor, Error,
msgInvalidConstructor("Function"));
newMsg(HintBinaryOperatorSpacing, Hint,
tr("Use spaces around binary operators."));
Tr::tr("Use spaces around binary operators."));
newMsg(WarnUnintentinalEmptyBlock, Error,
tr("Unintentional empty block, use ({}) for empty object literal."));
Tr::tr("Unintentional empty block, use ({}) for empty object literal."));
newMsg(HintPreferNonVarPropertyType, Hint,
tr("Use %1 instead of 'var' or 'variant' to improve performance."), 1);
Tr::tr("Use %1 instead of 'var' or 'variant' to improve performance."), 1);
newMsg(ErrMissingRequiredProperty, Error,
tr("Missing property \"%1\"."), 1);
Tr::tr("Missing property \"%1\"."), 1);
newMsg(ErrObjectValueExpected, Error,
tr("Object value expected."));
Tr::tr("Object value expected."));
newMsg(ErrArrayValueExpected, Error,
tr("Array value expected."));
Tr::tr("Array value expected."));
newMsg(ErrDifferentValueExpected, Error,
tr("%1 value expected."), 1);
Tr::tr("%1 value expected."), 1);
newMsg(ErrSmallerNumberValueExpected, Error,
tr("Maximum number value is %1."), 1);
Tr::tr("Maximum number value is %1."), 1);
newMsg(ErrLargerNumberValueExpected, Error,
tr("Minimum number value is %1."), 1);
Tr::tr("Minimum number value is %1."), 1);
newMsg(ErrMaximumNumberValueIsExclusive, Error,
tr("Maximum number value is exclusive."));
Tr::tr("Maximum number value is exclusive."));
newMsg(ErrMinimumNumberValueIsExclusive, Error,
tr("Minimum number value is exclusive."));
Tr::tr("Minimum number value is exclusive."));
newMsg(ErrInvalidStringValuePattern, Error,
tr("String value does not match required pattern."));
Tr::tr("String value does not match required pattern."));
newMsg(ErrLongerStringValueExpected, Error,
tr("Minimum string value length is %1."), 1);
Tr::tr("Minimum string value length is %1."), 1);
newMsg(ErrShorterStringValueExpected, Error,
tr("Maximum string value length is %1."), 1);
Tr::tr("Maximum string value length is %1."), 1);
newMsg(ErrInvalidArrayValueLength, Error,
tr("%1 elements expected in array value."), 1);
Tr::tr("%1 elements expected in array value."), 1);
newMsg(WarnImperativeCodeNotEditableInVisualDesigner, Warning,
tr("Imperative code is not supported in Qt Design Studio."));
Tr::tr("Imperative code is not supported in Qt Design Studio."));
newMsg(WarnUnsupportedTypeInVisualDesigner, Warning,
tr("This type (%1) is not supported in Qt Design Studio."), 1);
Tr::tr("This type (%1) is not supported in Qt Design Studio."), 1);
newMsg(WarnReferenceToParentItemNotSupportedByVisualDesigner, Warning,
tr("Reference to parent item cannot be resolved correctly by Qt Design Studio."));
Tr::tr("Reference to parent item cannot be resolved correctly by Qt Design Studio."));
newMsg(WarnUndefinedValueForVisualDesigner, Warning,
tr("This visual property binding cannot be evaluated in the local context "
"and might not show up in Qt Design Studio as expected."));
Tr::tr("This visual property binding cannot be evaluated in the local context "
"and might not show up in Qt Design Studio as expected."));
newMsg(WarnStatesOnlyInRootItemForVisualDesigner, Warning,
tr("Qt Design Studio only supports states in the root item."));
Tr::tr("Qt Design Studio only supports states in the root item."));
newMsg(ErrInvalidIdeInVisualDesigner, Error,
tr("This id might be ambiguous and is not supported in Qt Design Studio."));
Tr::tr("This id might be ambiguous and is not supported in Qt Design Studio."));
newMsg(ErrUnsupportedRootTypeInVisualDesigner, Error,
tr("This type (%1) is not supported as a root element by Qt Design Studio."), 1);
Tr::tr("This type (%1) is not supported as a root element by Qt Design Studio."), 1);
newMsg(ErrUnsupportedRootTypeInQmlUi, Error,
tr("This type (%1) is not supported as a root element of a UI file (.ui.qml)."), 1);
Tr::tr("This type (%1) is not supported as a root element of a UI file (.ui.qml)."), 1);
newMsg(ErrUnsupportedTypeInQmlUi, Error,
tr("This type (%1) is not supported in a UI file (.ui.qml)."), 1);
Tr::tr("This type (%1) is not supported in a UI file (.ui.qml)."), 1);
newMsg(ErrFunctionsNotSupportedInQmlUi, Error,
tr("Functions are not supported in a UI file (.ui.qml)."));
Tr::tr("Functions are not supported in a UI file (.ui.qml)."));
newMsg(ErrBlocksNotSupportedInQmlUi, Error,
tr("JavaScript blocks are not supported in a UI file (.ui.qml)."));
Tr::tr("JavaScript blocks are not supported in a UI file (.ui.qml)."));
newMsg(ErrBehavioursNotSupportedInQmlUi, Error,
tr("Behavior type is not supported in a UI file (.ui.qml)."));
Tr::tr("Behavior type is not supported in a UI file (.ui.qml)."));
newMsg(ErrStatesOnlyInRootItemInQmlUi, Error,
tr("States are only supported in the root item in a UI file (.ui.qml)."));
Tr::tr("States are only supported in the root item in a UI file (.ui.qml)."));
newMsg(ErrReferenceToParentItemNotSupportedInQmlUi, Error,
tr("Referencing the parent of the root item is not supported in a UI file (.ui.qml)."));
Tr::tr("Referencing the parent of the root item is not supported in a UI file (.ui.qml)."));
newMsg(ErrDoNotMixTranslationFunctionsInQmlUi, Error,
tr("Do not mix translation functions in a UI file (.ui.qml)."));
Tr::tr("Do not mix translation functions in a UI file (.ui.qml)."));
newMsg(StateCannotHaveChildItem, Error,
tr("A State cannot have a child item (%1)."), 1);
Tr::tr("A State cannot have a child item (%1)."), 1);
newMsg(WarnDuplicateImport, Warning,
tr("Duplicate import (%1)."), 1);
Tr::tr("Duplicate import (%1)."), 1);
newMsg(ErrHitMaximumRecursion, Error,
tr("Hit maximum recursion limit when visiting AST."));
Tr::tr("Hit maximum recursion limit when visiting AST."));
newMsg(ErrTypeIsInstantiatedRecursively, Error,
tr("Type cannot be instantiated recursively (%1)."), 1);
Tr::tr("Type cannot be instantiated recursively (%1)."), 1);
newMsg(WarnLogicalValueDoesNotDependOnValues, Warning,
tr("Logical value does not depend on actual values."));
Tr::tr("Logical value does not depend on actual values."));
newMsg(ErrToManyComponentChildren, Error,
tr("Components are only allowed to have a single child element."));
Tr::tr("Components are only allowed to have a single child element."));
newMsg(WarnComponentRequiresChildren, Warning,
tr("Components require a child element."));
Tr::tr("Components require a child element."));
newMsg(ErrAliasReferRoot, Error,
tr("Do not reference the root item as alias."));
Tr::tr("Do not reference the root item as alias."));
newMsg(WarnAliasReferRootHierarchy, Warning,
tr("Avoid referencing the root item in a hierarchy."));
Tr::tr("Avoid referencing the root item in a hierarchy."));
}
} // anonymous namespace