forked from qt-creator/qt-creator
Utils/all: Create an OutputFormatterFactory
Essentially following the scheme used for the various project configurations. This makes it possible to construct OutputFormatters by Id only, potentially reducing hard plugin dependencies and opening the road to have several output formatters per RunConfiguration/Outputpane/... Change-Id: I4b5fb6fb6be8b0d9a0859f178bb0effc3398b09e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -147,7 +147,7 @@ static QTextCharFormat linkFormat(const QTextCharFormat &inputFormat, const QStr
|
||||
class PythonOutputFormatter : public OutputFormatter
|
||||
{
|
||||
public:
|
||||
PythonOutputFormatter(Project *)
|
||||
PythonOutputFormatter()
|
||||
// Note that moc dislikes raw string literals.
|
||||
: filePattern("^(\\s*)(File \"([^\"]+)\", line (\\d+), .*$)")
|
||||
{
|
||||
@@ -217,6 +217,19 @@ private:
|
||||
const QRegularExpression filePattern;
|
||||
};
|
||||
|
||||
class PythonOutputFormatterFactory : public OutputFormatterFactory
|
||||
{
|
||||
public:
|
||||
PythonOutputFormatterFactory()
|
||||
{
|
||||
setFormatterCreator([](Target *t) -> OutputFormatter * {
|
||||
if (t->project()->mimeType() == Constants::C_PY_MIMETYPE)
|
||||
return new PythonOutputFormatter;
|
||||
return nullptr;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
class InterpreterAspect : public ProjectConfigurationAspect
|
||||
@@ -370,7 +383,6 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
|
||||
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
setOutputFormatter<PythonOutputFormatter>();
|
||||
setCommandLineGetter([this, interpreterAspect, argumentsAspect] {
|
||||
CommandLine cmd{interpreterAspect->currentInterpreter().command, {mainScript()}};
|
||||
cmd.addArgs(argumentsAspect->arguments(macroExpander()), CommandLine::Raw);
|
||||
@@ -810,7 +822,9 @@ class PythonPluginPrivate
|
||||
{
|
||||
public:
|
||||
PythonEditorFactory editorFactory;
|
||||
PythonOutputFormatterFactory outputFormatterFactory;
|
||||
PythonRunConfigurationFactory runConfigFactory;
|
||||
|
||||
RunWorkerFactory runWorkerFactory{
|
||||
RunWorkerFactory::make<SimpleTargetRunner>(),
|
||||
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
|
||||
|
||||
Reference in New Issue
Block a user