aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-02-27 10:49:14 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-03-02 10:35:50 +0100
commit8ab237edf170f5b0482dccf5169868e5c7c47771 (patch)
treecca2d3faa0a8553a452d9139ac7442c3da25c0f8 /tools/qmllint
parentd8f6f41c334d14c4712b1dc16554f80bb1290e24 (diff)
Restore offset/length in QQmlJS::DiagnosticMessage
This is needed in a few places outside of declarative, so this change restores the loc member in DiagnosticMessage and moves QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory. QQmlError is unaffected and retains only line/column. Amends d4d197d06279f9257647628f7e1ccc9ec763a6bb Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint')
-rw-r--r--tools/qmllint/main.cpp2
-rw-r--r--tools/qmllint/scopetree.cpp12
-rw-r--r--tools/qmllint/scopetree.h16
-rw-r--r--tools/qmllint/typedescriptionreader.h4
4 files changed, 17 insertions, 17 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index 0a0e669e94..fa601986b2 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -78,7 +78,7 @@ static bool lint_file(const QString &filename, const bool silent, const bool war
const auto diagnosticMessages = parser.diagnosticMessages();
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
qWarning().noquote() << QString::fromLatin1("%1:%2 : %3")
- .arg(filename).arg(m.line).arg(m.message);
+ .arg(filename).arg(m.loc.startLine).arg(m.message);
}
}
diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp
index 2ca3ed9a67..e7e0113f35 100644
--- a/tools/qmllint/scopetree.cpp
+++ b/tools/qmllint/scopetree.cpp
@@ -62,7 +62,7 @@ void ScopeTree::insertJSIdentifier(const QString &id, QQmlJS::AST::VariableScope
}
void ScopeTree::insertSignalIdentifier(const QString &id, const MetaMethod &method,
- const QQmlJS::AST::SourceLocation &loc,
+ const QQmlJS::SourceLocation &loc,
bool hasMultilineHandlerBody)
{
Q_ASSERT(m_scopeType == ScopeType::QMLScope);
@@ -77,7 +77,7 @@ void ScopeTree::insertPropertyIdentifier(const MetaProperty &property)
}
void ScopeTree::addUnmatchedSignalHandler(const QString &handler,
- const QQmlJS::AST::SourceLocation &location)
+ const QQmlJS::SourceLocation &location)
{
m_unmatchedSignalHandlers.append(qMakePair(handler, location));
}
@@ -87,13 +87,13 @@ bool ScopeTree::isIdInCurrentScope(const QString &id) const
return isIdInCurrentQMlScopes(id) || isIdInCurrentJSScopes(id);
}
-void ScopeTree::addIdToAccessed(const QString &id, const QQmlJS::AST::SourceLocation &location) {
+void ScopeTree::addIdToAccessed(const QString &id, const QQmlJS::SourceLocation &location) {
m_currentFieldMember = new FieldMemberList {id, QString(), location, {}};
m_accessedIdentifiers.push_back(std::unique_ptr<FieldMemberList>(m_currentFieldMember));
}
void ScopeTree::accessMember(const QString &name, const QString &parentType,
- const QQmlJS::AST::SourceLocation &location)
+ const QQmlJS::SourceLocation &location)
{
Q_ASSERT(m_currentFieldMember);
auto *fieldMember = new FieldMemberList {name, parentType, location, {}};
@@ -115,7 +115,7 @@ bool ScopeTree::isVisualRootScope() const
class IssueLocationWithContext
{
public:
- IssueLocationWithContext(const QString &code, const QQmlJS::AST::SourceLocation &location) {
+ IssueLocationWithContext(const QString &code, const QQmlJS::SourceLocation &location) {
int before = std::max(0,code.lastIndexOf('\n', location.offset));
m_beforeText = code.midRef(before + 1, int(location.offset - (before + 1)));
m_issueText = code.midRef(location.offset, location.length);
@@ -440,7 +440,7 @@ const ScopeTree *ScopeTree::currentQMLScope() const
}
void ScopeTree::printContext(ColorOutput &colorOut, const QString &code,
- const QQmlJS::AST::SourceLocation &location) const
+ const QQmlJS::SourceLocation &location) const
{
IssueLocationWithContext issueLocationWithContext {code, location};
colorOut.write(issueLocationWithContext.beforeText().toString(), Normal);
diff --git a/tools/qmllint/scopetree.h b/tools/qmllint/scopetree.h
index f5d1155a49..63f4310bf8 100644
--- a/tools/qmllint/scopetree.h
+++ b/tools/qmllint/scopetree.h
@@ -68,7 +68,7 @@ enum class ScopeType
struct MethodUsage
{
MetaMethod method;
- QQmlJS::AST::SourceLocation loc;
+ QQmlJS::SourceLocation loc;
bool hasMultilineHandlerBody;
};
@@ -112,16 +112,16 @@ public:
void insertJSIdentifier(const QString &id, QQmlJS::AST::VariableScope scope);
void insertSignalIdentifier(const QString &id, const MetaMethod &method,
- const QQmlJS::AST::SourceLocation &loc, bool hasMultilineHandlerBody);
+ const QQmlJS::SourceLocation &loc, bool hasMultilineHandlerBody);
// inserts property as qml identifier as well as the corresponding
void insertPropertyIdentifier(const MetaProperty &prop);
void addUnmatchedSignalHandler(const QString &handler,
- const QQmlJS::AST::SourceLocation &location);
+ const QQmlJS::SourceLocation &location);
bool isIdInCurrentScope(const QString &id) const;
- void addIdToAccessed(const QString &id, const QQmlJS::AST::SourceLocation &location);
+ void addIdToAccessed(const QString &id, const QQmlJS::SourceLocation &location);
void accessMember(const QString &name, const QString &parentType,
- const QQmlJS::AST::SourceLocation &location);
+ const QQmlJS::SourceLocation &location);
void resetMemberScope();
bool isVisualRootScope() const;
@@ -174,7 +174,7 @@ private:
{
QString m_name;
QString m_parentType;
- QQmlJS::AST::SourceLocation m_location;
+ QQmlJS::SourceLocation m_location;
std::unique_ptr<FieldMemberList> m_child;
};
@@ -188,7 +188,7 @@ private:
std::vector<std::unique_ptr<FieldMemberList>> m_accessedIdentifiers;
FieldMemberList *m_currentFieldMember = nullptr;
- QVector<QPair<QString, QQmlJS::AST::SourceLocation>> m_unmatchedSignalHandlers;
+ QVector<QPair<QString, QQmlJS::SourceLocation>> m_unmatchedSignalHandlers;
QVector<ScopeTree::Ptr> m_childScopes;
ScopeTree *m_parentScope;
@@ -211,7 +211,7 @@ private:
bool isIdInjectedFromSignal(const QString &id) const;
const ScopeTree *currentQMLScope() const;
void printContext(ColorOutput &colorOut, const QString &code,
- const QQmlJS::AST::SourceLocation &location) const;
+ const QQmlJS::SourceLocation &location) const;
bool checkMemberAccess(
const QString &code,
FieldMemberList *members,
diff --git a/tools/qmllint/typedescriptionreader.h b/tools/qmllint/typedescriptionreader.h
index 5fcbe3abc9..48c33bee3c 100644
--- a/tools/qmllint/typedescriptionreader.h
+++ b/tools/qmllint/typedescriptionreader.h
@@ -90,8 +90,8 @@ private:
void readMetaObjectRevisions(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope);
void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, MetaEnum *metaEnum);
- void addError(const QQmlJS::AST::SourceLocation &loc, const QString &message);
- void addWarning(const QQmlJS::AST::SourceLocation &loc, const QString &message);
+ void addError(const QQmlJS::SourceLocation &loc, const QString &message);
+ void addWarning(const QQmlJS::SourceLocation &loc, const QString &message);
QString m_fileName;
QString m_source;