Android: JavaParser, adjust paths from build to source directory

Since we copy the java files to the build directory, we need to adjust
the path that the java compiler emits for error messages.

For that the JavaParser needs to know the source directory, which is
the android package source dir and the build directory. The
AndroidDeployQtStep thus needs more information then just the
input json file and now stores the path to the .pro file to both
retrieve the input file and the android package source directory.

Task-number: QTCREATORBUG-10904
Change-Id: Ib5141b35b610bc2eee568a096fc5e930f9eb2e47
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Daniel Teske
2014-01-08 09:33:21 +01:00
parent 02314e24f0
commit 498d198104
5 changed files with 70 additions and 37 deletions

View File

@@ -31,6 +31,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/task.h>
#include <QFileInfo>
using namespace Android::Internal;
using namespace ProjectExplorer;
@@ -56,6 +57,16 @@ void JavaParser::setProjectFileList(const QStringList &fileList)
m_fileList = fileList;
}
void JavaParser::setBuildDirectory(const Utils::FileName &buildDirectory)
{
m_buildDirectory = buildDirectory;
}
void JavaParser::setSourceDirectory(const Utils::FileName &sourceDirectory)
{
m_sourceDirectory = sourceDirectory;
}
void JavaParser::parse(const QString &line)
{
if (m_javaRegExp.indexIn(line) > -1) {
@@ -63,16 +74,24 @@ void JavaParser::parse(const QString &line)
int lineno = m_javaRegExp.cap(3).toInt(&ok);
if (!ok)
lineno = -1;
QString file = m_javaRegExp.cap(2);
for (int i = 0; i < m_fileList.size(); i++)
if (m_fileList[i].endsWith(file)) {
file = m_fileList[i];
break;
}
Utils::FileName file = Utils::FileName::fromUserInput(m_javaRegExp.cap(2));
if (file.isChildOf(m_buildDirectory)) {
Utils::FileName relativePath = file.relativeChildPath(m_buildDirectory);
file = m_sourceDirectory;
file.appendPath(relativePath.toString());
}
if (file.toFileInfo().isRelative()) {
for (int i = 0; i < m_fileList.size(); i++)
if (m_fileList[i].endsWith(file.toString())) {
file = Utils::FileName::fromString(m_fileList[i]);
break;
}
}
Task task(Task::Error,
m_javaRegExp.cap(4).trimmed(),
Utils::FileName::fromString(file) /* filename */,
file /* filename */,
lineno,
Constants::TASK_CATEGORY_COMPILE);
emit addTask(task);