forked from qt-creator/qt-creator
QmlDesigner: Move source location into Category
Change-Id: Id3979a854be03aae0fa2ef062bc9d84ecb08d5ae Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "staticstring.h"
|
||||
|
||||
#include <sqlite/sourcelocation.h>
|
||||
#include <utils/smallstring.h>
|
||||
#include <utils/span.h>
|
||||
#include <utils/utility.h>
|
||||
@@ -1155,6 +1156,14 @@ template<typename TraceEvent, Tracing isEnabled>
|
||||
class Category
|
||||
{
|
||||
public:
|
||||
class SourceLocation
|
||||
{
|
||||
public:
|
||||
template<typename String>
|
||||
friend void convertToString(String &, SourceLocation)
|
||||
{}
|
||||
};
|
||||
|
||||
using IsActive = std::false_type;
|
||||
using ArgumentType = typename TraceEvent::ArgumentType;
|
||||
using ArgumentsStringType = typename TraceEvent::ArgumentsStringType;
|
||||
@@ -1207,6 +1216,38 @@ class Category<TraceEvent, Tracing::IsEnabled>
|
||||
{};
|
||||
|
||||
public:
|
||||
class SourceLocation : public Sqlite::source_location
|
||||
{
|
||||
public:
|
||||
consteval SourceLocation(
|
||||
const char *fileName = __builtin_FILE(),
|
||||
const char *functionName = __builtin_FUNCTION(),
|
||||
const uint_least32_t line = __builtin_LINE())
|
||||
: Sqlite::source_location(Sqlite::source_location::current(fileName, functionName, line))
|
||||
{}
|
||||
|
||||
template<typename String>
|
||||
friend void convertToString(String &string, SourceLocation sourceLocation)
|
||||
{
|
||||
using NanotraceHR::dictonary;
|
||||
using NanotraceHR::keyValue;
|
||||
auto dict = dictonary(
|
||||
keyValue("file", sourceLocation.file_name()),
|
||||
keyValue("function", sourceLocation.function_name()),
|
||||
keyValue("line", sourceLocation.line()));
|
||||
convertToString(string, dict);
|
||||
|
||||
string.append(',');
|
||||
convertToString(string, "id");
|
||||
string.append(':');
|
||||
string.append('\"');
|
||||
string.append(sourceLocation.file_name());
|
||||
string.append(':');
|
||||
string.append(sourceLocation.line());
|
||||
string.append('\"');
|
||||
}
|
||||
};
|
||||
|
||||
using IsActive = std::true_type;
|
||||
using ArgumentType = typename TraceEvent::ArgumentType;
|
||||
using ArgumentsStringType = typename TraceEvent::ArgumentsStringType;
|
||||
|
@@ -162,7 +162,6 @@ extend_qtc_library(QmlDesignerCore
|
||||
SOURCES_PREFIX tracing
|
||||
SOURCES
|
||||
qmldesignertracing.cpp qmldesignertracing.h
|
||||
qmldesignertracingsourcelocation.h
|
||||
)
|
||||
|
||||
extend_qtc_library(QmlDesignerCore
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include "abstractproperty.h"
|
||||
#include "auxiliarydata.h"
|
||||
|
||||
#include <tracing/qmldesignertracingsourcelocation.h>
|
||||
#include <tracing/qmldesignertracing.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTextStream;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <projectstorage/projectstorageinterface.h>
|
||||
#include <projectstorage/projectstoragetypes.h>
|
||||
#include <projectstorageids.h>
|
||||
#include <tracing/qmldesignertracingsourcelocation.h>
|
||||
#include <tracing/qmldesignertracing.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
@@ -40,6 +40,7 @@ constexpr NanotraceHR::Tracing tracingStatus()
|
||||
}
|
||||
|
||||
using Category = NanotraceHR::StringCategory<tracingStatus()>;
|
||||
using SourceLocation = Category::SourceLocation;
|
||||
using AsynchronousToken = Category::AsynchronousTokenType;
|
||||
[[gnu::pure]] QMLDESIGNERCORE_EXPORT Category &category();
|
||||
|
||||
|
@@ -1,56 +0,0 @@
|
||||
// Copyright (C) 2025 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nanotrace/nanotracehr.h>
|
||||
#include <sqlite/sourcelocation.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
namespace ModelTracing {
|
||||
|
||||
#ifdef ENABLE_MODEL_TRACING
|
||||
class SourceLocation : public Sqlite::source_location
|
||||
{
|
||||
public:
|
||||
consteval SourceLocation(const char *fileName = __builtin_FILE(),
|
||||
const char *functionName = __builtin_FUNCTION(),
|
||||
const uint_least32_t line = __builtin_LINE())
|
||||
: Sqlite::source_location(Sqlite::source_location::current(fileName, functionName, line))
|
||||
{}
|
||||
|
||||
template<typename String>
|
||||
friend void convertToString(String &string, SourceLocation sourceLocation)
|
||||
{
|
||||
using NanotraceHR::dictonary;
|
||||
using NanotraceHR::keyValue;
|
||||
auto dict = dictonary(keyValue("file", sourceLocation.file_name()),
|
||||
keyValue("function", sourceLocation.function_name()),
|
||||
keyValue("line", sourceLocation.line()));
|
||||
convertToString(string, dict);
|
||||
|
||||
string.append(',');
|
||||
convertToString(string, "id");
|
||||
string.append(':');
|
||||
string.append('\"');
|
||||
string.append(sourceLocation.file_name());
|
||||
string.append(':');
|
||||
string.append(sourceLocation.line());
|
||||
string.append('\"');
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
class SourceLocation
|
||||
{
|
||||
public:
|
||||
template<typename String>
|
||||
friend void convertToString(String &, SourceLocation)
|
||||
{}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace ModelTracing
|
||||
|
||||
} // namespace QmlDesigner
|
Reference in New Issue
Block a user