summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSami Shalayel <[email protected]>2025-06-24 18:05:20 +0200
committerSami Shalayel <[email protected]>2025-07-01 12:57:49 +0200
commitfbb07fbfa49c810af2448c715d76bfe5eb45e4c8 (patch)
tree5599b864e6b92dacaea5802c9dd5a82209fe0bd5 /src
parent1179262490ae4be82c18a48726dda70c0a6827f6 (diff)
moc: add line numbers to properties, methods, etc
Those are needed by qmlls to be able to jump to C++ definitions. Task-number: QTBUG-119143 Task-number: QTBUG-128393 Change-Id: I4fb9394b0a22a02501bafdbe95a7cd8998adfe11 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/tools/moc/moc.cpp7
-rw-r--r--src/tools/moc/moc.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 14280712154..64fd334d467 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -259,6 +259,7 @@ bool Moc::parseEnum(EnumDef *def, ClassDef *containingClass)
return false; // anonymous enum
isTypdefEnum = true;
}
+ def->lineNumber = symbol().lineNum;
if (test(COLON)) { // C++11 strongly typed enum
// enum Foo : unsigned long { ... };
def->type = normalizeType(parseType().name);
@@ -464,6 +465,8 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro)
}
next(LPAREN, "Not a signal or slot declaration");
def->name = tempType.name;
+ def->lineNumber = symbol().lineNum;
+
scopedFunctionName = tempType.isScoped;
if (!test(RPAREN)) {
@@ -1366,6 +1369,7 @@ void Moc::createPropertyDef(PropertyDef &propDef, int propertyIndex, Moc::Proper
{
propDef.location = index;
propDef.relativeIndex = propertyIndex;
+ propDef.lineNumber = symbol().lineNum;
Type t = parseType();
QByteArray type = t.name;
@@ -2156,6 +2160,7 @@ QJsonObject FunctionDef::toJson(int index) const
if (revision > 0)
fdef["revision"_L1] = revision;
+ fdef["lineNumber"_L1] = lineNumber;
if (wasCloned)
fdef["isCloned"_L1] = true;
@@ -2220,6 +2225,7 @@ QJsonObject PropertyDef::toJson() const
prop["final"_L1] = final;
prop["required"_L1] = required;
prop["index"_L1] = relativeIndex;
+ prop["lineNumber"_L1] = lineNumber;
if (revision > 0)
prop["revision"_L1] = revision;
@@ -2231,6 +2237,7 @@ QJsonObject EnumDef::toJson(const ClassDef &cdef) const
QJsonObject def;
uint flags = this->flags | cdef.enumDeclarations.value(name);
def["name"_L1] = QString::fromUtf8(name);
+ def["lineNumber"_L1] = lineNumber;
if (!enumName.isEmpty())
def["alias"_L1] = QString::fromUtf8(enumName);
if (!type.isEmpty())
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index f08edb3f0d2..fcf000c655f 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -58,6 +58,7 @@ struct EnumDef
QFlags<QtMocConstants::EnumFlags> flags = {};
QJsonObject toJson(const ClassDef &cdef) const;
QByteArray qualifiedType(const ClassDef *cdef) const;
+ int lineNumber = 0;
};
Q_DECLARE_TYPEINFO(EnumDef, Q_RELOCATABLE_TYPE);
@@ -84,6 +85,7 @@ struct FunctionDef
enum Access { Private, Protected, Public };
Access access = Private;
int revision = 0;
+ int lineNumber = 0;
bool isConst = false;
bool isVirtual = false;
@@ -130,6 +132,7 @@ struct PropertyDef
bool final = false;
bool required = false;
int relativeIndex = -1; // property index in current metaobject
+ int lineNumber = 0;
qsizetype location = -1; // token index, used for error reporting