1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "gradleparser.h" |
6 | |
7 | #include "services/builder/task.h" |
8 | #include "services/builder/fileutils.h" |
9 | |
10 | const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem" ; |
11 | |
12 | GradleParser::GradleParser() |
13 | { |
14 | setObjectName(QLatin1String("GradleParser" )); |
15 | } |
16 | |
17 | void GradleParser::stdOutput(const QString &line, OutputPane::OutputFormat format) |
18 | { |
19 | QString newContent = line; |
20 | emit outputAdded(newContent, format); |
21 | |
22 | IOutputParser::stdOutput(newContent, format); |
23 | } |
24 | |
25 | void GradleParser::stdError(const QString &line) |
26 | { |
27 | QString newContent = line; |
28 | QRegExp exp("/.*:(\\d*):" ); |
29 | int ret = newContent.indexOf(exp); |
30 | QString filePath; |
31 | int lineNumber = -1; |
32 | if (ret != -1) { |
33 | QStringList list = newContent.split(":" ); |
34 | if (list.count() > 1) { |
35 | filePath = list.at(0); |
36 | lineNumber = list.at(1).toInt(); |
37 | } |
38 | } |
39 | |
40 | Utils::FileName fileName; |
41 | if (QFileInfo(filePath).isFile()) { |
42 | fileName = Utils::FileName::fromUserInput(filePath); |
43 | } else { |
44 | fileName = Utils::FileName(); |
45 | } |
46 | |
47 | taskAdded(Task(Task::Error, |
48 | line, |
49 | fileName, |
50 | lineNumber, |
51 | TASK_CATEGORY_BUILDSYSTEM), 1, 0); |
52 | } |
53 | |
54 | void GradleParser::taskAdded(const Task &task, int linkedLines, int skippedLines) |
55 | { |
56 | emit addTask(task, linkedLines, skippedLines); |
57 | } |
58 | |