Commit c1d7f409 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

Clang: Rename/remove projectPartId



Change-Id: I91e95acd37152eda4e25c0b8abf46d36523fd2b9
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent cf0e3f2d
......@@ -166,19 +166,12 @@ FileContainer Document::fileContainer() const
checkIfNull();
return FileContainer(d->filePath,
d->projectPart.projectPartId(),
d->projectPart.id(),
Utf8String(),
false,
d->documentRevision);
}
Utf8String Document::projectPartId() const
{
checkIfNull();
return d->projectPart.projectPartId();
}
const ProjectPart &Document::projectPart() const
{
checkIfNull();
......@@ -298,7 +291,7 @@ TranslationUnitUpdateInput Document::createUpdateInput() const
updateInput.filePath = filePath();
updateInput.fileArguments = fileArguments();
updateInput.unsavedFiles = d->documents.unsavedFiles();
updateInput.projectId = projectPart().projectPartId();
updateInput.projectId = projectPart().id();
updateInput.projectArguments = projectPart().arguments();
return updateInput;
......@@ -426,14 +419,15 @@ bool Document::isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) cons
bool operator==(const Document &first, const Document &second)
{
return first.filePath() == second.filePath() && first.projectPartId() == second.projectPartId();
return first.filePath() == second.filePath()
&& first.projectPart().id() == second.projectPart().id();
}
void PrintTo(const Document &document, ::std::ostream *os)
{
*os << "Document("
<< document.filePath().constData() << ", "
<< document.projectPartId().constData() << ", "
<< document.projectPart().id().constData() << ", "
<< document.documentRevision() << ")";
}
......
......@@ -82,7 +82,6 @@ public:
Utf8StringVector fileArguments() const;
FileContainer fileContainer() const;
Utf8String projectPartId() const;
const ProjectPart &projectPart() const;
const TimePoint lastProjectPartChangeTimePoint() const;
bool isProjectPartOutdated() const;
......
......@@ -26,6 +26,7 @@
#include "clangdocumentprocessors.h"
#include "clangdocument.h"
#include "clangexceptions.h"
#include "projectpart.h"
namespace ClangBackEnd {
......@@ -48,9 +49,9 @@ static bool operator<(const DocumentId &lhs, const DocumentId &rhs)
DocumentProcessor DocumentProcessors::create(const Document &document)
{
const DocumentId id{document.filePath(), document.projectPartId()};
const DocumentId id{document.filePath(), document.projectPart().id()};
if (m_processors.contains(id))
throw DocumentProcessorAlreadyExists(document.filePath(), document.projectPartId());
throw DocumentProcessorAlreadyExists(document.filePath(), document.projectPart().id());
const DocumentProcessor element(document, m_documents, m_unsavedFiles, m_projects, m_client);
m_processors.insert(id, element);
......@@ -60,11 +61,11 @@ DocumentProcessor DocumentProcessors::create(const Document &document)
DocumentProcessor DocumentProcessors::processor(const Document &document)
{
const DocumentId id{document.filePath(), document.projectPartId()};
const DocumentId id{document.filePath(), document.projectPart().id()};
const auto it = m_processors.find(id);
if (it == m_processors.end())
throw DocumentProcessorDoesNotExist(document.filePath(), document.projectPartId());
throw DocumentProcessorDoesNotExist(document.filePath(), document.projectPart().id());
return *it;
}
......@@ -76,11 +77,11 @@ QList<DocumentProcessor> DocumentProcessors::processors() const
void DocumentProcessors::remove(const Document &document)
{
const DocumentId id{document.filePath(), document.projectPartId()};
const DocumentId id{document.filePath(), document.projectPart().id()};
const int itemsRemoved = m_processors.remove(id);
if (itemsRemoved != 1)
throw DocumentProcessorDoesNotExist(document.filePath(), document.projectPartId());
throw DocumentProcessorDoesNotExist(document.filePath(), document.projectPart().id());
}
JobRequests DocumentProcessors::process()
......
......@@ -43,7 +43,8 @@ namespace ClangBackEnd {
bool operator==(const FileContainer &fileContainer, const Document &document)
{
return fileContainer.filePath() == document.filePath() && fileContainer.projectPartId() == document.projectPartId();
return fileContainer.filePath() == document.filePath()
&& fileContainer.projectPartId() == document.projectPart().id();
}
bool operator==(const Document &document, const FileContainer &fileContainer)
......
......@@ -77,11 +77,11 @@ JobRequest Jobs::createJobRequest(const Document &document,
jobRequest.type = type;
jobRequest.requirements = JobRequest::requirementsForType(type);
jobRequest.filePath = document.filePath();
jobRequest.projectPartId = document.projectPartId();
jobRequest.projectPartId = document.projectPart().id();
jobRequest.unsavedFilesChangeTimePoint = m_unsavedFiles.lastChangeTimePoint();
jobRequest.documentRevision = document.documentRevision();
jobRequest.preferredTranslationUnit = preferredTranslationUnit;
const ProjectPart &projectPart = m_projectParts.project(document.projectPartId());
const ProjectPart &projectPart = m_projectParts.project(document.projectPart().id());
jobRequest.projectChangeTimePoint = projectPart.lastChangeTimePoint();
return jobRequest;
......
......@@ -27,6 +27,7 @@
#include "clangjobs.h"
#include "clangtranslationunits.h"
#include "projectpart.h"
#include <utils/qtcassert.h>
......@@ -109,7 +110,7 @@ bool SupportiveTranslationUnitInitializer::abortIfDocumentIsClosed()
{
QTC_CHECK(m_isDocumentClosedChecker);
if (m_isDocumentClosedChecker(m_document.filePath(), m_document.projectPartId())) {
if (m_isDocumentClosedChecker(m_document.filePath(), m_document.projectPart().id())) {
m_state = State::Aborted;
return true;
}
......
......@@ -95,7 +95,7 @@ void ProjectPart::clear()
updateLastChangeTimePoint();
}
Utf8String ProjectPart::projectPartId() const
Utf8String ProjectPart::id() const
{
return d->projectPartId;
}
......@@ -123,7 +123,7 @@ void ProjectPart::updateLastChangeTimePoint()
bool operator==(const ProjectPart &first, const ProjectPart &second)
{
return first.projectPartId() == second.projectPartId();
return first.id() == second.id();
}
} // namespace ClangBackEnd
......
......@@ -41,9 +41,8 @@ class ProjectPartData;
class ProjectPart
{
public:
ProjectPart(const Utf8String &projectPartId = Utf8String());
ProjectPart(const Utf8String &projectPartId,
std::initializer_list<Utf8String> arguments);
ProjectPart(const Utf8String &id = Utf8String());
ProjectPart(const Utf8String &id, std::initializer_list<Utf8String> arguments);
ProjectPart(const ProjectPartContainer &projectContainer);
~ProjectPart();
......@@ -55,7 +54,7 @@ public:
void clear();
Utf8String projectPartId() const;
Utf8String id() const;
void setArguments(const Utf8StringVector &arguments_);
const Utf8StringVector arguments() const;
......
......@@ -43,7 +43,7 @@ void ProjectParts::remove(const Utf8StringVector &projectPartIds)
const auto removeBeginIterator = std::remove_if(projects_.begin(), projects_.end(),
[&processedProjectPartFilePaths] (ProjectPart &project) {
const bool isRemoved = processedProjectPartFilePaths.removeFast(project.projectPartId());
const bool isRemoved = processedProjectPartFilePaths.removeFast(project.id());
if (isRemoved)
project.clear();
......@@ -75,14 +75,14 @@ const ProjectPart &ProjectParts::project(const Utf8String &projectPartId) const
std::vector<ProjectPart>::const_iterator ProjectParts::findProjectPart(const Utf8String &projectPartId) const
{
return std::find_if(projects_.begin(), projects_.end(), [projectPartId] (const ProjectPart &project) {
return project.projectPartId() == projectPartId;
return project.id() == projectPartId;
});
}
std::vector<ProjectPart>::iterator ProjectParts::findProjectPart(const Utf8String &projectPartId)
{
return std::find_if(projects_.begin(), projects_.end(), [projectPartId] (const ProjectPart &project) {
return project.projectPartId() == projectPartId;
return project.id() == projectPartId;
});
}
......
......@@ -59,7 +59,7 @@ MATCHER_P3(IsDocument, filePath, projectPartId, documentRevision,
)
{
return arg.filePath() == filePath
&& arg.projectPartId() == projectPartId
&& arg.projectPart().id() == projectPartId
&& arg.documentRevision() == documentRevision;
}
......
......@@ -47,7 +47,7 @@ TEST(ProjectPart, CreateProjectPart)
ClangBackEnd::ProjectPart project(projectPath);
ASSERT_THAT(project.projectPartId(), projectPath);
ASSERT_THAT(project.id(), projectPath);
}
TEST(ProjectPart, CreateProjectPartWithProjectPartContainer)
......@@ -56,7 +56,7 @@ TEST(ProjectPart, CreateProjectPartWithProjectPartContainer)
ClangBackEnd::ProjectPart project(projectContainer);
ASSERT_THAT(project.projectPartId(), Utf8StringLiteral("pathToProjectPart.pro"));
ASSERT_THAT(project.id(), Utf8StringLiteral("pathToProjectPart.pro"));
ASSERT_THAT(project.arguments(), Contains(Utf8StringLiteral("-O")));
}
......@@ -141,7 +141,7 @@ TEST(ProjectPart, ProjectPartProjectPartIdIsEmptyfterRemoving)
projects.remove({projectContainer.projectPartId()});
ASSERT_TRUE(project.projectPartId().isEmpty());
ASSERT_TRUE(project.id().isEmpty());
}
TEST(ProjectPart, ThrowsForNotExistingProjectPartButRemovesAllExistingProject)
......@@ -167,7 +167,7 @@ TEST(ProjectPart, ProjectPartIsClearedAfterRemove)
projects.remove({projectContainer.projectPartId()});
ASSERT_THAT(project.projectPartId(), Utf8String());
ASSERT_THAT(project.id(), Utf8String());
ASSERT_THAT(project.arguments().count(), 0);
ASSERT_THAT(project.lastChangeTimePoint(), Gt(lastChangeTimePoint));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment