forked from qt-creator/qt-creator
ProjectExplorer: Make CustomParser creation available outside PE plugin
This would allow usage from other places, like the CMakeProjectManager plugin. Change-Id: Idf12b6688c9ac3c71b5614dce37babbeab7f6748 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -212,7 +212,7 @@ void BuildStep::setupOutputFormatter(OutputFormatter *formatter)
|
||||
{
|
||||
if (auto bc = qobject_cast<BuildConfiguration *>(projectConfiguration())) {
|
||||
for (const Id id : bc->customParsers()) {
|
||||
if (Internal::CustomParser * const parser = Internal::CustomParser::createFromId(id))
|
||||
if (auto parser = createCustomParserFromId(id))
|
||||
formatter->addLineParser(parser);
|
||||
}
|
||||
|
||||
|
@@ -173,6 +173,15 @@ CustomParsersAspect::CustomParsersAspect(Target *target)
|
||||
});
|
||||
}
|
||||
|
||||
OutputTaskParser *createCustomParserFromId(Utils::Id id)
|
||||
{
|
||||
const CustomParserSettings parser = findOrDefault(ProjectExplorerPlugin::customParsers(),
|
||||
[id](const CustomParserSettings &p) { return p.id == id; });
|
||||
if (parser.id.isValid())
|
||||
return new Internal::CustomParser(parser);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CustomParsersAspect::fromMap(const Store &map)
|
||||
{
|
||||
m_parsers = transform(map.value(settingsKey()).toList(), &Id::fromSetting);
|
||||
@@ -198,15 +207,6 @@ void CustomParser::setSettings(const CustomParserSettings &settings)
|
||||
m_warning = settings.warning;
|
||||
}
|
||||
|
||||
CustomParser *CustomParser::createFromId(Utils::Id id)
|
||||
{
|
||||
const CustomParserSettings parser = findOrDefault(ProjectExplorerPlugin::customParsers(),
|
||||
[id](const CustomParserSettings &p) { return p.id == id; });
|
||||
if (parser.id.isValid())
|
||||
return new CustomParser(parser);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OutputLineParser::Result CustomParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
const CustomParserExpression::CustomParserChannel channel = type == StdErrFormat
|
||||
|
@@ -80,6 +80,7 @@ public:
|
||||
void setParsers(const QList<Utils::Id> &parsers) { m_parsers = parsers; }
|
||||
QList<Utils::Id> parsers() const { return m_parsers; }
|
||||
|
||||
|
||||
struct Data : BaseAspect::Data
|
||||
{
|
||||
QList<Utils::Id> parsers;
|
||||
@@ -92,6 +93,8 @@ private:
|
||||
QList<Utils::Id> m_parsers;
|
||||
};
|
||||
|
||||
PROJECTEXPLORER_EXPORT ProjectExplorer::OutputTaskParser *createCustomParserFromId(Utils::Id id);
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class CustomParser : public ProjectExplorer::OutputTaskParser
|
||||
@@ -101,8 +104,6 @@ public:
|
||||
|
||||
void setSettings(const CustomParserSettings &settings);
|
||||
|
||||
static CustomParser *createFromId(Utils::Id id);
|
||||
|
||||
private:
|
||||
Result handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
|
@@ -822,7 +822,7 @@ void RunControl::setupFormatter(OutputFormatter *formatter) const
|
||||
QList<Utils::OutputLineParser *> parsers = OutputFormatterFactory::createFormatters(target());
|
||||
if (const auto customParsersAspect = aspect<CustomParsersAspect>()) {
|
||||
for (const Id id : std::as_const(customParsersAspect->parsers)) {
|
||||
if (CustomParser * const parser = CustomParser::createFromId(id))
|
||||
if (auto parser = createCustomParserFromId(id))
|
||||
parsers << parser;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user