forked from qt-creator/qt-creator
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:
@@ -2,10 +2,13 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmljsbind.h"
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include "qmljsdocument.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include <QtCore/QVersionNumber>
|
||||
#include <QtCore/QLibraryInfo>
|
||||
@@ -164,7 +167,8 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
|
||||
|
||||
void Bind::throwRecursionDepthError()
|
||||
{
|
||||
_diagnosticMessages->append(DiagnosticMessage(Severity::Error, SourceLocation(), tr("Hit maximal recursion depth in AST visit.")));
|
||||
_diagnosticMessages->append(DiagnosticMessage(Severity::Error, SourceLocation(),
|
||||
Tr::tr("Hit maximal recursion depth in AST visit.")));
|
||||
}
|
||||
|
||||
void Bind::accept(Node *node)
|
||||
@@ -212,7 +216,7 @@ bool Bind::visit(UiImport *ast)
|
||||
}
|
||||
if (!version.isValid() && (!qtVersion.isNull() && qtVersion.majorVersion() < 6)) {
|
||||
_diagnosticMessages->append(
|
||||
errorMessage(ast, tr("package import requires a version number")));
|
||||
errorMessage(ast, Tr::tr("package import requires a version number")));
|
||||
}
|
||||
const QString importId = ast->importId.toString();
|
||||
|
||||
@@ -322,7 +326,7 @@ bool Bind::visit(UiInlineComponent *ast)
|
||||
if (!_currentComponentName.isEmpty()) {
|
||||
_currentComponentName += ".";
|
||||
_diagnosticMessages->append(
|
||||
errorMessage(ast, tr("Nested inline components are not supported")));
|
||||
errorMessage(ast, Tr::tr("Nested inline components are not supported")));
|
||||
}
|
||||
_currentComponentName += ast->name.toString();
|
||||
_rootObjectValue = nullptr;
|
||||
|
||||
@@ -17,7 +17,6 @@ class Document;
|
||||
class QMLJS_EXPORT Bind: protected AST::Visitor
|
||||
{
|
||||
Q_DISABLE_COPY(Bind)
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::Bind)
|
||||
|
||||
public:
|
||||
Bind(Document *doc, QList<DiagnosticMessage> *messages,
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmljscheck.h"
|
||||
|
||||
#include "qmljsbind.h"
|
||||
#include "qmljsevaluate.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -1161,7 +1164,7 @@ bool Check::visit(UiPublicMember *ast)
|
||||
const Value *init = evaluator(ast->statement);
|
||||
QString preferredType;
|
||||
if (init->asNumberValue())
|
||||
preferredType = tr("'int' or 'real'");
|
||||
preferredType = Tr::tr("'int' or 'real'");
|
||||
else if (init->asStringValue())
|
||||
preferredType = "'string'";
|
||||
else if (init->asBooleanValue())
|
||||
@@ -1216,7 +1219,7 @@ bool Check::visit(IdentifierExpression *)
|
||||
// if (const Reference *ref = value_cast<Reference>(_lastValue)) {
|
||||
// _lastValue = _context->lookupReference(ref);
|
||||
// if (!_lastValue)
|
||||
// error(ast->identifierToken, tr("could not resolve"));
|
||||
// error(ast->identifierToken, Tr::tr("could not resolve"));
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
@@ -1233,7 +1236,7 @@ bool Check::visit(FieldMemberExpression *)
|
||||
// const ObjectValue *obj = _lastValue->asObjectValue();
|
||||
// if (!obj) {
|
||||
// error(locationFromRange(ast->base->firstSourceLocation(), ast->base->lastSourceLocation()),
|
||||
// tr("does not have members"));
|
||||
// Tr::tr("does not have members"));
|
||||
// }
|
||||
// if (!obj || ast->name.isEmpty()) {
|
||||
// _lastValue = 0;
|
||||
@@ -1241,7 +1244,7 @@ bool Check::visit(FieldMemberExpression *)
|
||||
// }
|
||||
// _lastValue = obj->lookupMember(ast->name.toString(), _context);
|
||||
// if (!_lastValue)
|
||||
// error(ast->identifierToken, tr("unknown member"));
|
||||
// error(ast->identifierToken, Tr::tr("unknown member"));
|
||||
// return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ class Imports;
|
||||
|
||||
class QMLJS_EXPORT Check: protected AST::Visitor
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::Check)
|
||||
|
||||
typedef QSet<QString> StringSet;
|
||||
|
||||
public:
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
|
||||
#include "qmljsfindexportedcpptypes.h"
|
||||
|
||||
#include <qmljs/qmljsinterpreter.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include "qmljsdocument.h"
|
||||
#include "qmljsinterpreter.h"
|
||||
#include "qmljstr.h"
|
||||
|
||||
#include <cplusplus/Overview.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
#include <cplusplus/cppmodelmanagerbase.h>
|
||||
@@ -250,7 +252,7 @@ protected:
|
||||
Document::DiagnosticMessage::Warning,
|
||||
_doc->filePath(),
|
||||
line, column,
|
||||
QmlJS::FindExportedCppTypes::tr(
|
||||
QmlJS::Tr::tr(
|
||||
"The type will only be available in the QML editors when the type name is a string literal."));
|
||||
return false;
|
||||
}
|
||||
@@ -311,7 +313,7 @@ protected:
|
||||
Document::DiagnosticMessage::Warning,
|
||||
_doc->filePath(),
|
||||
line, column,
|
||||
QmlJS::FindExportedCppTypes::tr(
|
||||
QmlJS::Tr::tr(
|
||||
"The module URI cannot be determined by static analysis. The type will not be available\n"
|
||||
"globally in the QML editor. You can add a \"// @uri My.Module.Uri\" annotation to let\n"
|
||||
"the QML editor know about a likely URI."));
|
||||
@@ -493,7 +495,7 @@ protected:
|
||||
Document::DiagnosticMessage::Warning,
|
||||
_doc->filePath(),
|
||||
line, column,
|
||||
QmlJS::FindExportedCppTypes::tr(
|
||||
QmlJS::Tr::tr(
|
||||
"must be a string literal to be available in the QML editor"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace QmlJS {
|
||||
|
||||
class QMLJS_EXPORT FindExportedCppTypes
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJSTools::FindExportedCppTypes)
|
||||
public:
|
||||
FindExportedCppTypes(const CPlusPlus::Snapshot &snapshot);
|
||||
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
|
||||
#include "qmljsinterpreter.h"
|
||||
|
||||
#include "qmljsconstants.h"
|
||||
#include "qmljscontext.h"
|
||||
#include "qmljsevaluate.h"
|
||||
#include "qmljsinterpreter.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljsscopeastpath.h"
|
||||
#include "qmljsscopebuilder.h"
|
||||
#include "qmljsscopechain.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljstypedescriptionreader.h"
|
||||
#include "qmljsvalueowner.h"
|
||||
|
||||
@@ -1340,13 +1343,11 @@ CppQmlTypesLoader::BuiltinObjects CppQmlTypesLoader::loadQmlTypes(const QFileInf
|
||||
error = file.errorString();
|
||||
}
|
||||
if (!error.isEmpty()) {
|
||||
errors->append(TypeDescriptionReader::tr(
|
||||
"Errors while loading qmltypes from %1:\n%2").arg(
|
||||
errors->append(Tr::tr("Errors while loading qmltypes from %1:\n%2").arg(
|
||||
qmlTypeFile.absoluteFilePath(), error));
|
||||
}
|
||||
if (!warning.isEmpty()) {
|
||||
warnings->append(TypeDescriptionReader::tr(
|
||||
"Warnings while loading qmltypes from %1:\n%2").arg(
|
||||
warnings->append(Tr::tr("Warnings while loading qmltypes from %1:\n%2").arg(
|
||||
qmlTypeFile.absoluteFilePath(), warning));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include "qmljslink.h"
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
#include "qmljsdocument.h"
|
||||
|
||||
#include "qmljsbind.h"
|
||||
#include "qmljsutils.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljsconstants.h"
|
||||
#include "qmljsdocument.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filepath.h>
|
||||
@@ -293,7 +295,7 @@ void LinkPrivate::populateImportedTypes(Imports *imports, const Document::Ptr &d
|
||||
imports->setImportFailed();
|
||||
if (info.ast()) {
|
||||
error(doc, info.ast()->fileNameToken,
|
||||
Link::tr("File or directory not found."));
|
||||
Tr::tr("File or directory not found."));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -455,7 +457,7 @@ Import LinkPrivate::importNonFile(const Document::Ptr &doc, const ImportInfo &im
|
||||
error(doc,
|
||||
locationFromRange(importInfo.ast()->firstSourceLocation(),
|
||||
importInfo.ast()->lastSourceLocation()),
|
||||
Link::tr(
|
||||
Tr::tr(
|
||||
"QML module not found (%1).\n\n"
|
||||
"Import paths:\n"
|
||||
"%2\n\n"
|
||||
@@ -525,19 +527,19 @@ bool LinkPrivate::importLibrary(const Document::Ptr &doc,
|
||||
if (!(optional || (toImport.flags & QmlDirParser::Import::Optional))) {
|
||||
error(doc,
|
||||
errorLoc,
|
||||
Link::tr("Implicit import '%1' of QML module '%2' not found.\n\n"
|
||||
"Import paths:\n"
|
||||
"%3\n\n"
|
||||
"For qmake projects, use the QML_IMPORT_PATH variable to add import "
|
||||
"paths.\n"
|
||||
"For Qbs projects, declare and set a qmlImportPaths property in "
|
||||
"your product "
|
||||
"to add import paths.\n"
|
||||
"For qmlproject projects, use the importPaths property to add "
|
||||
"import paths.\n"
|
||||
"For CMake projects, make sure QML_IMPORT_PATH variable is in "
|
||||
"CMakeCache.txt.\n")
|
||||
.arg(importName,
|
||||
Tr::tr("Implicit import '%1' of QML module '%2' not found.\n\n"
|
||||
"Import paths:\n"
|
||||
"%3\n\n"
|
||||
"For qmake projects, use the QML_IMPORT_PATH variable to add import "
|
||||
"paths.\n"
|
||||
"For Qbs projects, declare and set a qmlImportPaths property in "
|
||||
"your product "
|
||||
"to add import paths.\n"
|
||||
"For qmlproject projects, use the importPaths property to add "
|
||||
"import paths.\n"
|
||||
"For CMake projects, make sure QML_IMPORT_PATH variable is in "
|
||||
"CMakeCache.txt.\n")
|
||||
.arg(importName,
|
||||
importInfo.name(),
|
||||
Utils::transform(m_importPaths, [](const Utils::FilePath &p) {
|
||||
return p.toString();
|
||||
@@ -569,8 +571,9 @@ bool LinkPrivate::importLibrary(const Document::Ptr &doc,
|
||||
if (!optional && errorLoc.isValid()) {
|
||||
appendDiagnostic(doc, DiagnosticMessage(
|
||||
Severity::ReadingTypeInfoWarning, errorLoc,
|
||||
Link::tr("QML module contains C++ plugins, "
|
||||
"currently reading type information... %1").arg(import->info.name())));
|
||||
Tr::tr("QML module contains C++ plugins, "
|
||||
"currently reading type information... %1")
|
||||
.arg(import->info.name())));
|
||||
import->valid = false;
|
||||
}
|
||||
} else if (libraryInfo.pluginTypeInfoStatus() == LibraryInfo::DumpError
|
||||
|
||||
@@ -18,7 +18,6 @@ class LinkPrivate;
|
||||
class QMLJS_EXPORT Link
|
||||
{
|
||||
Q_DISABLE_COPY(Link)
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::Link)
|
||||
|
||||
public:
|
||||
Link(Link &&) = delete;
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
|
||||
#include "qmljsbind.h"
|
||||
#include "qmljsconstants.h"
|
||||
#include "qmljsdialect.h"
|
||||
#include "qmljsfindexportedcpptypes.h"
|
||||
#include "qmljsinterpreter.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljsplugindumper.h"
|
||||
#include "qmljsdialect.h"
|
||||
#include "qmljsviewercontext.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
#include "qmljsviewercontext.h"
|
||||
|
||||
#include <cplusplus/cppmodelmanagerbase.h>
|
||||
#include <utils/algorithm.h>
|
||||
@@ -343,7 +345,7 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QList<Utils::FileP
|
||||
addFuture(result);
|
||||
|
||||
if (sourceFiles.count() > 1)
|
||||
addTaskInternal(result, tr("Parsing QML Files"), Constants::TASK_INDEX);
|
||||
addTaskInternal(result, Tr::tr("Parsing QML Files"), Constants::TASK_INDEX);
|
||||
|
||||
if (sourceFiles.count() > 1 && !m_shouldScanImports) {
|
||||
bool scan = false;
|
||||
@@ -1209,7 +1211,7 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
||||
workingCopyInternal(), pathToScan,
|
||||
this, true, true, false);
|
||||
addFuture(result);
|
||||
addTaskInternal(result, tr("Scanning QML Imports"), Constants::TASK_IMPORT_SCAN);
|
||||
addTaskInternal(result, Tr::tr("Scanning QML Imports"), Constants::TASK_IMPORT_SCAN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmljsplugindumper.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include <qmljs/qmljsinterpreter.h>
|
||||
#include <qmljs/qmljsviewercontext.h>
|
||||
#include "qmljsinterpreter.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
#include "qmljsviewercontext.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filesystemwatcher.h>
|
||||
@@ -170,16 +171,16 @@ void PluginDumper::dumpAllPlugins()
|
||||
|
||||
static QString noTypeinfoError(const FilePath &libraryPath)
|
||||
{
|
||||
return PluginDumper::tr("QML module does not contain information about components contained in plugins.\n\n"
|
||||
"Module path: %1\n"
|
||||
"See \"Using QML Modules with Plugins\" in the documentation.").arg(
|
||||
return Tr::tr("QML module does not contain information about components contained in plugins.\n\n"
|
||||
"Module path: %1\n"
|
||||
"See \"Using QML Modules with Plugins\" in the documentation.").arg(
|
||||
libraryPath.toUserOutput());
|
||||
}
|
||||
|
||||
static QString qmldumpErrorMessage(const FilePath &libraryPath, const QString &error)
|
||||
{
|
||||
return noTypeinfoError(libraryPath) + "\n\n" +
|
||||
PluginDumper::tr("Automatic type dump of QML module failed.\nErrors:\n%1").
|
||||
Tr::tr("Automatic type dump of QML module failed.\nErrors:\n%1").
|
||||
arg(error) + QLatin1Char('\n');
|
||||
}
|
||||
|
||||
@@ -187,19 +188,19 @@ static QString qmldumpFailedMessage(const FilePath &libraryPath, const QString &
|
||||
{
|
||||
QString firstLines = QStringList(error.split('\n').mid(0, 10)).join('\n');
|
||||
return noTypeinfoError(libraryPath) + "\n\n" +
|
||||
PluginDumper::tr("Automatic type dump of QML module failed.\n"
|
||||
"First 10 lines or errors:\n"
|
||||
"\n"
|
||||
"%1"
|
||||
"\n"
|
||||
"Check General Messages for details."
|
||||
).arg(firstLines);
|
||||
Tr::tr("Automatic type dump of QML module failed.\n"
|
||||
"First 10 lines or errors:\n"
|
||||
"\n"
|
||||
"%1"
|
||||
"\n"
|
||||
"Check General Messages for details."
|
||||
).arg(firstLines);
|
||||
}
|
||||
|
||||
static void printParseWarnings(const FilePath &libraryPath, const QString &warning)
|
||||
{
|
||||
ModelManagerInterface::writeWarning(
|
||||
PluginDumper::tr("Warnings while parsing QML type information of %1:\n"
|
||||
Tr::tr("Warnings while parsing QML type information of %1:\n"
|
||||
"%2").arg(libraryPath.toUserOutput(), warning));
|
||||
}
|
||||
|
||||
@@ -209,24 +210,24 @@ static QString qmlPluginDumpErrorMessage(QtcProcess *process)
|
||||
const QString binary = process->commandLine().executable().toUserOutput();
|
||||
switch (process->error()) {
|
||||
case QProcess::FailedToStart:
|
||||
errorMessage = PluginDumper::tr("\"%1\" failed to start: %2").arg(binary, process->errorString());
|
||||
errorMessage = Tr::tr("\"%1\" failed to start: %2").arg(binary, process->errorString());
|
||||
break;
|
||||
case QProcess::Crashed:
|
||||
errorMessage = PluginDumper::tr("\"%1\" crashed.").arg(binary);
|
||||
errorMessage = Tr::tr("\"%1\" crashed.").arg(binary);
|
||||
break;
|
||||
case QProcess::Timedout:
|
||||
errorMessage = PluginDumper::tr("\"%1\" timed out.").arg(binary);
|
||||
errorMessage = Tr::tr("\"%1\" timed out.").arg(binary);
|
||||
break;
|
||||
case QProcess::ReadError:
|
||||
case QProcess::WriteError:
|
||||
errorMessage = PluginDumper::tr("I/O error running \"%1\".").arg(binary);
|
||||
errorMessage = Tr::tr("I/O error running \"%1\".").arg(binary);
|
||||
break;
|
||||
case QProcess::UnknownError:
|
||||
if (process->exitCode())
|
||||
errorMessage = PluginDumper::tr("\"%1\" returned exit code %2.").arg(binary).arg(process->exitCode());
|
||||
errorMessage = Tr::tr("\"%1\" returned exit code %2.").arg(binary).arg(process->exitCode());
|
||||
break;
|
||||
}
|
||||
errorMessage += '\n' + PluginDumper::tr("Arguments: %1").arg(process->commandLine().arguments());
|
||||
errorMessage += '\n' + Tr::tr("Arguments: %1").arg(process->commandLine().arguments());
|
||||
if (process->error() != QProcess::FailedToStart) {
|
||||
const QString stdErr = QString::fromLocal8Bit(process->readAllRawStandardError());
|
||||
if (!stdErr.isEmpty()) {
|
||||
@@ -344,7 +345,7 @@ QFuture<PluginDumper::QmlTypeDescription> PluginDumper::loadQmlTypeDescription(c
|
||||
CppQmlTypesLoader::parseQmlTypeDescriptions(reader.data(), &objs, &apis, &deps,
|
||||
&error, &warning, p.toString());
|
||||
if (!error.isEmpty()) {
|
||||
result.errors += tr("Failed to parse \"%1\".\nError: %2").arg(p.toUserOutput(), error);
|
||||
result.errors += Tr::tr("Failed to parse \"%1\".\nError: %2").arg(p.toUserOutput(), error);
|
||||
} else {
|
||||
result.objects += objs.values();
|
||||
result.moduleApis += apis;
|
||||
@@ -546,7 +547,7 @@ void PluginDumper::prepareLibraryInfo(LibraryInfo &libInfo,
|
||||
libInfo.setPluginTypeInfoStatus(LibraryInfo::TypeInfoFileDone);
|
||||
} else {
|
||||
printParseWarnings(libraryPath, errors.join(QLatin1Char('\n')));
|
||||
errs.prepend(tr("Errors while reading typeinfo files:"));
|
||||
errs.prepend(Tr::tr("Errors while reading typeinfo files:"));
|
||||
libInfo.setPluginTypeInfoStatus(LibraryInfo::TypeInfoFileError, errs.join(QLatin1Char('\n')));
|
||||
}
|
||||
|
||||
@@ -635,7 +636,7 @@ void PluginDumper::dump(const Plugin &plugin)
|
||||
errorMessage = noTypeinfoError(plugin.qmldirPath);
|
||||
} else {
|
||||
errorMessage = qmldumpErrorMessage(plugin.qmldirPath,
|
||||
tr("Could not locate the helper application for dumping type information from C++ plugins.\n"
|
||||
Tr::tr("Could not locate the helper application for dumping type information from C++ plugins.\n"
|
||||
"Please build the qmldump application on the Qt version options page."));
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "qqmljsparser_p.h"
|
||||
#endif
|
||||
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include <QFile>
|
||||
@@ -110,7 +111,7 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
|
||||
file.close();
|
||||
return readFromSource(QString::fromLocal8Bit(source));
|
||||
}
|
||||
addError(tr("Cannot find file %1.").arg(fileName));
|
||||
addError(Tr::tr("Cannot find file %1.").arg(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,14 +158,14 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
|
||||
bool SimpleAbstractStreamReader::readDocument(AST::UiProgram * ast)
|
||||
{
|
||||
if (!ast) {
|
||||
addError(tr("Could not parse document."));
|
||||
addError(Tr::tr("Could not parse document."));
|
||||
return false;
|
||||
}
|
||||
|
||||
AST::UiObjectDefinition *uiObjectDefinition = AST::cast<AST::UiObjectDefinition *>(
|
||||
ast->members->member);
|
||||
if (!uiObjectDefinition) {
|
||||
addError(tr("Expected document to contain a single object definition."));
|
||||
addError(Tr::tr("Expected document to contain a single object definition."));
|
||||
return false;
|
||||
}
|
||||
readChild(uiObjectDefinition);
|
||||
@@ -237,7 +238,7 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
|
||||
AST::ExpressionStatement *expStmt = AST::cast<AST::ExpressionStatement *>(
|
||||
uiScriptBinding->statement);
|
||||
if (!expStmt) {
|
||||
addError(tr("Expected expression statement after colon."),
|
||||
addError(Tr::tr("Expected expression statement after colon."),
|
||||
uiScriptBinding->statement->firstSourceLocation());
|
||||
return std::make_pair(QVariant(), SourceLocation());
|
||||
}
|
||||
@@ -339,7 +340,7 @@ static Q_LOGGING_CATEGORY(simpleReaderLog, "qtc.qmljs.simpleReader", QtWarningMs
|
||||
|
||||
if (m_currentNode.toStrongRef().data()->propertyNames().contains(name)) {
|
||||
auto previousSourceLoc = m_currentNode.toStrongRef().data()->property(name).nameLocation;
|
||||
addError(tr("Property is defined twice, previous definition at %1:%2")
|
||||
addError(Tr::tr("Property is defined twice, previous definition at %1:%2")
|
||||
.arg(QString::number(previousSourceLoc.startLine),
|
||||
QString::number(previousSourceLoc.startColumn)),
|
||||
currentSourceLocation());
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
#include <QVariant>
|
||||
#include <QWeakPointer>
|
||||
|
||||
// for Q_DECLARE_TR_FUNCTIONS
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace QmlJS {
|
||||
|
||||
#ifndef QT_CREATOR
|
||||
@@ -84,8 +81,6 @@ using namespace QQmlJS;
|
||||
|
||||
class QMLJS_EXPORT SimpleAbstractStreamReader
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::SimpleAbstractStreamReader)
|
||||
|
||||
public:
|
||||
SimpleAbstractStreamReader();
|
||||
virtual ~SimpleAbstractStreamReader();
|
||||
@@ -124,8 +119,6 @@ private:
|
||||
|
||||
class QMLJS_EXPORT SimpleReader: public SimpleAbstractStreamReader
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::SimpleReader)
|
||||
|
||||
public:
|
||||
SimpleReader();
|
||||
SimpleReaderNode::Ptr readFile(const QString &fileName);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "parser/qmljsengine_p.h"
|
||||
|
||||
#include "qmljsinterpreter.h"
|
||||
#include "qmljstr.h"
|
||||
#include "qmljsutils.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -69,18 +70,18 @@ QString TypeDescriptionReader::warningMessage() const
|
||||
void TypeDescriptionReader::readDocument(UiProgram *ast)
|
||||
{
|
||||
if (!ast) {
|
||||
addError(SourceLocation(), tr("Could not parse document."));
|
||||
addError(SourceLocation(), Tr::tr("Could not parse document."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ast->headers || ast->headers->next || !AST::cast<AST::UiImport *>(ast->headers->headerItem)) {
|
||||
addError(SourceLocation(), tr("Expected a single import."));
|
||||
addError(SourceLocation(), Tr::tr("Expected a single import."));
|
||||
return;
|
||||
}
|
||||
|
||||
UiImport *import = AST::cast<AST::UiImport *>(ast->headers->headerItem);
|
||||
if (toString(import->importUri) != QLatin1String("QtQuick.tooling")) {
|
||||
addError(import->importToken, tr("Expected import of QtQuick.tooling."));
|
||||
addError(import->importToken, Tr::tr("Expected import of QtQuick.tooling."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,24 +89,24 @@ void TypeDescriptionReader::readDocument(UiProgram *ast)
|
||||
if (UiVersionSpecifier *uiVersion = import->version) {
|
||||
version = ComponentVersion(import->version->majorVersion, import->version->minorVersion);
|
||||
if (version.majorVersion() != 1) {
|
||||
addError(uiVersion->majorToken, tr("Major version different from 1 not supported."));
|
||||
addError(uiVersion->majorToken, Tr::tr("Major version different from 1 not supported."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ast->members || !ast->members->member || ast->members->next) {
|
||||
addError(SourceLocation(), tr("Expected document to contain a single object definition."));
|
||||
addError(SourceLocation(), Tr::tr("Expected document to contain a single object definition."));
|
||||
return;
|
||||
}
|
||||
|
||||
UiObjectDefinition *module = AST::cast<UiObjectDefinition *>(ast->members->member);
|
||||
if (!module) {
|
||||
addError(SourceLocation(), tr("Expected document to contain a single object definition."));
|
||||
addError(SourceLocation(), Tr::tr("Expected document to contain a single object definition."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (toString(module->qualifiedTypeNameId) != QLatin1String("Module")) {
|
||||
addError(SourceLocation(), tr("Expected document to contain a Module {} member."));
|
||||
addError(SourceLocation(), Tr::tr("Expected document to contain a Module {} member."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,12 +162,12 @@ void TypeDescriptionReader::readDependencies(UiScriptBinding *ast)
|
||||
{
|
||||
ExpressionStatement *stmt = AST::cast<ExpressionStatement*>(ast->statement);
|
||||
if (!stmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected dependency definitions"));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected dependency definitions"));
|
||||
return;
|
||||
}
|
||||
ArrayPattern *exp = AST::cast<ArrayPattern *>(stmt->expression);
|
||||
if (!exp) {
|
||||
addError(stmt->expression->firstSourceLocation(), tr("Expected dependency definitions"));
|
||||
addError(stmt->expression->firstSourceLocation(), Tr::tr("Expected dependency definitions"));
|
||||
return;
|
||||
}
|
||||
for (PatternElementList *l = exp->elements; l; l = l->next) {
|
||||
@@ -219,7 +220,7 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
|
||||
}
|
||||
|
||||
if (fmo->className().isEmpty()) {
|
||||
addError(ast->firstSourceLocation(), tr("Component definition is missing a name binding."));
|
||||
addError(ast->firstSourceLocation(), Tr::tr("Component definition is missing a name binding."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -250,7 +251,7 @@ void TypeDescriptionReader::readModuleApi(UiObjectDefinition *ast)
|
||||
}
|
||||
|
||||
if (!apiInfo.version.isValid()) {
|
||||
addError(ast->firstSourceLocation(), tr("ModuleApi definition has no or invalid version binding."));
|
||||
addError(ast->firstSourceLocation(), Tr::tr("ModuleApi definition has no or invalid version binding."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -287,7 +288,7 @@ void TypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isM
|
||||
}
|
||||
|
||||
if (fmm.methodName().isEmpty()) {
|
||||
addError(ast->firstSourceLocation(), tr("Method or signal is missing a name script binding."));
|
||||
addError(ast->firstSourceLocation(), Tr::tr("Method or signal is missing a name script binding."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -307,7 +308,7 @@ void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, FakeMetaObject
|
||||
UiObjectMember *member = it->member;
|
||||
UiScriptBinding *script = AST::cast<UiScriptBinding *>(member);
|
||||
if (!script) {
|
||||
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
|
||||
addWarning(member->firstSourceLocation(), Tr::tr("Expected script binding."));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -327,7 +328,7 @@ void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, FakeMetaObject
|
||||
}
|
||||
|
||||
if (name.isEmpty() || type.isEmpty()) {
|
||||
addError(ast->firstSourceLocation(), tr("Property object is missing a name or type script binding."));
|
||||
addError(ast->firstSourceLocation(), Tr::tr("Property object is missing a name or type script binding."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -342,7 +343,7 @@ void TypeDescriptionReader::readEnum(UiObjectDefinition *ast, FakeMetaObject::Pt
|
||||
UiObjectMember *member = it->member;
|
||||
UiScriptBinding *script = AST::cast<UiScriptBinding *>(member);
|
||||
if (!script) {
|
||||
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
|
||||
addWarning(member->firstSourceLocation(), Tr::tr("Expected script binding."));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -365,7 +366,7 @@ void TypeDescriptionReader::readParameter(UiObjectDefinition *ast, FakeMetaMetho
|
||||
UiObjectMember *member = it->member;
|
||||
UiScriptBinding *script = AST::cast<UiScriptBinding *>(member);
|
||||
if (!script) {
|
||||
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
|
||||
addWarning(member->firstSourceLocation(), Tr::tr("Expected script binding."));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -391,19 +392,19 @@ QString TypeDescriptionReader::readStringBinding(UiScriptBinding *ast)
|
||||
QTC_ASSERT(ast, return QString());
|
||||
|
||||
if (!ast->statement) {
|
||||
addError(ast->colonToken, tr("Expected string after colon."));
|
||||
addError(ast->colonToken, Tr::tr("Expected string after colon."));
|
||||
return QString();
|
||||
}
|
||||
|
||||
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected string after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected string after colon."));
|
||||
return QString();
|
||||
}
|
||||
|
||||
StringLiteral *stringLit = AST::cast<StringLiteral *>(expStmt->expression);
|
||||
if (!stringLit) {
|
||||
addError(expStmt->firstSourceLocation(), tr("Expected string after colon."));
|
||||
addError(expStmt->firstSourceLocation(), Tr::tr("Expected string after colon."));
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -415,20 +416,20 @@ bool TypeDescriptionReader::readBoolBinding(AST::UiScriptBinding *ast)
|
||||
QTC_ASSERT(ast, return false);
|
||||
|
||||
if (!ast->statement) {
|
||||
addError(ast->colonToken, tr("Expected boolean after colon."));
|
||||
addError(ast->colonToken, Tr::tr("Expected boolean after colon."));
|
||||
return false;
|
||||
}
|
||||
|
||||
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected boolean after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected boolean after colon."));
|
||||
return false;
|
||||
}
|
||||
|
||||
TrueLiteral *trueLit = AST::cast<TrueLiteral *>(expStmt->expression);
|
||||
FalseLiteral *falseLit = AST::cast<FalseLiteral *>(expStmt->expression);
|
||||
if (!trueLit && !falseLit) {
|
||||
addError(expStmt->firstSourceLocation(), tr("Expected true or false after colon."));
|
||||
addError(expStmt->firstSourceLocation(), Tr::tr("Expected true or false after colon."));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -440,19 +441,19 @@ double TypeDescriptionReader::readNumericBinding(AST::UiScriptBinding *ast)
|
||||
QTC_ASSERT(ast, return qQNaN());
|
||||
|
||||
if (!ast->statement) {
|
||||
addError(ast->colonToken, tr("Expected numeric literal after colon."));
|
||||
addError(ast->colonToken, Tr::tr("Expected numeric literal after colon."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected numeric literal after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
NumericLiteral *numericLit = AST::cast<NumericLiteral *>(expStmt->expression);
|
||||
if (!numericLit) {
|
||||
addError(expStmt->firstSourceLocation(), tr("Expected numeric literal after colon."));
|
||||
addError(expStmt->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -464,19 +465,19 @@ ComponentVersion TypeDescriptionReader::readNumericVersionBinding(UiScriptBindin
|
||||
ComponentVersion invalidVersion;
|
||||
|
||||
if (!ast || !ast->statement) {
|
||||
addError((ast ? ast->colonToken : SourceLocation()), tr("Expected numeric literal after colon."));
|
||||
addError((ast ? ast->colonToken : SourceLocation()), Tr::tr("Expected numeric literal after colon."));
|
||||
return invalidVersion;
|
||||
}
|
||||
|
||||
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected numeric literal after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
|
||||
return invalidVersion;
|
||||
}
|
||||
|
||||
NumericLiteral *numericLit = AST::cast<NumericLiteral *>(expStmt->expression);
|
||||
if (!numericLit) {
|
||||
addError(expStmt->firstSourceLocation(), tr("Expected numeric literal after colon."));
|
||||
addError(expStmt->firstSourceLocation(), Tr::tr("Expected numeric literal after colon."));
|
||||
return invalidVersion;
|
||||
}
|
||||
|
||||
@@ -489,7 +490,7 @@ int TypeDescriptionReader::readIntBinding(AST::UiScriptBinding *ast)
|
||||
int i = static_cast<int>(v);
|
||||
|
||||
if (i != v) {
|
||||
addError(ast->firstSourceLocation(), tr("Expected integer after colon."));
|
||||
addError(ast->firstSourceLocation(), Tr::tr("Expected integer after colon."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -501,26 +502,26 @@ void TypeDescriptionReader::readExports(UiScriptBinding *ast, FakeMetaObject::Pt
|
||||
QTC_ASSERT(ast, return);
|
||||
|
||||
if (!ast->statement) {
|
||||
addError(ast->colonToken, tr("Expected array of strings after colon."));
|
||||
addError(ast->colonToken, Tr::tr("Expected array of strings after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected array of strings after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected array of strings after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayPattern *arrayLit = AST::cast<ArrayPattern *>(expStmt->expression);
|
||||
if (!arrayLit) {
|
||||
addError(expStmt->firstSourceLocation(), tr("Expected array of strings after colon."));
|
||||
addError(expStmt->firstSourceLocation(), Tr::tr("Expected array of strings after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (PatternElementList *it = arrayLit->elements; it; it = it->next) {
|
||||
StringLiteral *stringLit = AST::cast<StringLiteral *>(it->element->initializer);
|
||||
if (!stringLit) {
|
||||
addError(arrayLit->firstSourceLocation(), tr("Expected array literal with only string literal members."));
|
||||
addError(arrayLit->firstSourceLocation(), Tr::tr("Expected array literal with only string literal members."));
|
||||
return;
|
||||
}
|
||||
QString exp = stringLit->value.toString();
|
||||
@@ -529,7 +530,7 @@ void TypeDescriptionReader::readExports(UiScriptBinding *ast, FakeMetaObject::Pt
|
||||
ComponentVersion version(exp.mid(spaceIdx + 1));
|
||||
|
||||
if (spaceIdx == -1 || !version.isValid()) {
|
||||
addError(stringLit->firstSourceLocation(), tr("Expected string literal to contain 'Package/Name major.minor' or 'Name major.minor'."));
|
||||
addError(stringLit->firstSourceLocation(), Tr::tr("Expected string literal to contain 'Package/Name major.minor' or 'Name major.minor'."));
|
||||
continue;
|
||||
}
|
||||
QString package;
|
||||
@@ -547,19 +548,19 @@ void TypeDescriptionReader::readMetaObjectRevisions(UiScriptBinding *ast, FakeMe
|
||||
QTC_ASSERT(ast, return);
|
||||
|
||||
if (!ast->statement) {
|
||||
addError(ast->colonToken, tr("Expected array of numbers after colon."));
|
||||
addError(ast->colonToken, Tr::tr("Expected array of numbers after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
ExpressionStatement *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected array of numbers after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected array of numbers after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayPattern *arrayLit = AST::cast<ArrayPattern *>(expStmt->expression);
|
||||
if (!arrayLit) {
|
||||
addError(expStmt->firstSourceLocation(), tr("Expected array of numbers after colon."));
|
||||
addError(expStmt->firstSourceLocation(), Tr::tr("Expected array of numbers after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -568,19 +569,19 @@ void TypeDescriptionReader::readMetaObjectRevisions(UiScriptBinding *ast, FakeMe
|
||||
for (PatternElementList *it = arrayLit->elements; it; it = it->next, ++exportIndex) {
|
||||
NumericLiteral *numberLit = cast<NumericLiteral *>(it->element->initializer);
|
||||
if (!numberLit) {
|
||||
addError(arrayLit->firstSourceLocation(), tr("Expected array literal with only number literal members."));
|
||||
addError(arrayLit->firstSourceLocation(), Tr::tr("Expected array literal with only number literal members."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (exportIndex >= exportCount) {
|
||||
addError(numberLit->firstSourceLocation(), tr("Meta object revision without matching export."));
|
||||
addError(numberLit->firstSourceLocation(), Tr::tr("Meta object revision without matching export."));
|
||||
return;
|
||||
}
|
||||
|
||||
const double v = numberLit->value;
|
||||
const int metaObjectRevision = static_cast<int>(v);
|
||||
if (metaObjectRevision != v) {
|
||||
addError(numberLit->firstSourceLocation(), tr("Expected integer."));
|
||||
addError(numberLit->firstSourceLocation(), Tr::tr("Expected integer."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -593,13 +594,13 @@ void TypeDescriptionReader::readEnumValues(AST::UiScriptBinding *ast, LanguageUt
|
||||
if (!ast)
|
||||
return;
|
||||
if (!ast->statement) {
|
||||
addError(ast->colonToken, tr("Expected object literal after colon."));
|
||||
addError(ast->colonToken, Tr::tr("Expected object literal after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto *expStmt = AST::cast<ExpressionStatement *>(ast->statement);
|
||||
if (!expStmt) {
|
||||
addError(ast->statement->firstSourceLocation(), tr("Expected expression after colon."));
|
||||
addError(ast->statement->firstSourceLocation(), Tr::tr("Expected expression after colon."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -611,7 +612,7 @@ void TypeDescriptionReader::readEnumValues(AST::UiScriptBinding *ast, LanguageUt
|
||||
continue;
|
||||
}
|
||||
}
|
||||
addError(it->firstSourceLocation(), tr("Expected strings as enum keys."));
|
||||
addError(it->firstSourceLocation(), Tr::tr("Expected strings as enum keys."));
|
||||
}
|
||||
} else if (auto *arrayLit = AST::cast<ArrayPattern *>(expStmt->expression)) {
|
||||
for (PatternElementList *it = arrayLit->elements; it; it = it->next) {
|
||||
@@ -621,10 +622,10 @@ void TypeDescriptionReader::readEnumValues(AST::UiScriptBinding *ast, LanguageUt
|
||||
continue;
|
||||
}
|
||||
}
|
||||
addError(it->firstSourceLocation(), tr("Expected strings as enum keys."));
|
||||
addError(it->firstSourceLocation(), Tr::tr("Expected strings as enum keys."));
|
||||
}
|
||||
} else {
|
||||
addError(ast->statement->firstSourceLocation(),
|
||||
tr("Expected either array or object literal as enum definition."));
|
||||
Tr::tr("Expected either array or object literal as enum definition."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
|
||||
#include <languageutils/fakemetaobject.h>
|
||||
|
||||
// for Q_DECLARE_TR_FUNCTIONS
|
||||
#include <QCoreApplication>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QIODevice;
|
||||
class QBuffer;
|
||||
@@ -28,8 +25,6 @@ class UiScriptBinding;
|
||||
|
||||
class QMLJS_EXPORT TypeDescriptionReader
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::TypeDescriptionReader)
|
||||
|
||||
public:
|
||||
explicit TypeDescriptionReader(const QString &fileName, const QString &data);
|
||||
~TypeDescriptionReader();
|
||||
|
||||
Reference in New Issue
Block a user