forked from qt-creator/qt-creator
ClangSupport: Use simpler structures in some cases
The patch is mostly mechanical, but contains also a few spurious changes from values references for some local variables, foreach -> ranged for etc that I coulnd't resist. Change-Id: I58f0bd972546895eb318607cbfbd7ac35caf3f23 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -101,16 +101,16 @@ void ClangCodeModelServer::registerTranslationUnitsForEditor(const ClangBackEnd:
|
||||
try {
|
||||
DocumentResetInfos toReset;
|
||||
QVector<FileContainer> toCreate;
|
||||
categorizeFileContainers(message.fileContainers(), toCreate, toReset);
|
||||
categorizeFileContainers(message.fileContainers, toCreate, toReset);
|
||||
|
||||
const std::vector<Document> createdDocuments = documents.create(toCreate);
|
||||
for (const auto &document : createdDocuments)
|
||||
documentProcessors().create(document);
|
||||
const std::vector<Document> resetDocuments_ = resetDocuments(toReset);
|
||||
|
||||
unsavedFiles.createOrUpdate(message.fileContainers());
|
||||
documents.setUsedByCurrentEditor(message.currentEditorFilePath());
|
||||
documents.setVisibleInEditors(message.visibleEditorFilePaths());
|
||||
unsavedFiles.createOrUpdate(message.fileContainers);
|
||||
documents.setUsedByCurrentEditor(message.currentEditorFilePath);
|
||||
documents.setVisibleInEditors(message.visibleEditorFilePaths);
|
||||
|
||||
processSuspendResumeJobs(documents.documents());
|
||||
processInitialJobsForDocuments(createdDocuments + resetDocuments_);
|
||||
@@ -125,7 +125,7 @@ void ClangCodeModelServer::updateTranslationUnitsForEditor(const UpdateTranslati
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::updateTranslationUnitsForEditor");
|
||||
|
||||
try {
|
||||
const auto newerFileContainers = documents.newerFileContainers(message.fileContainers());
|
||||
const auto newerFileContainers = documents.newerFileContainers(message.fileContainers);
|
||||
if (newerFileContainers.size() > 0) {
|
||||
std::vector<Document> updateDocuments = documents.update(newerFileContainers);
|
||||
unsavedFiles.createOrUpdate(newerFileContainers);
|
||||
@@ -151,12 +151,12 @@ void ClangCodeModelServer::unregisterTranslationUnitsForEditor(const ClangBackEn
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::unregisterTranslationUnitsForEditor");
|
||||
|
||||
try {
|
||||
for (const auto &fileContainer : message.fileContainers()) {
|
||||
for (const auto &fileContainer : message.fileContainers) {
|
||||
const Document &document = documents.document(fileContainer);
|
||||
documentProcessors().remove(document);
|
||||
}
|
||||
documents.remove(message.fileContainers());
|
||||
unsavedFiles.remove(message.fileContainers());
|
||||
documents.remove(message.fileContainers);
|
||||
unsavedFiles.remove(message.fileContainers);
|
||||
} catch (const std::exception &exception) {
|
||||
qWarning() << "Error in ClangCodeModelServer::unregisterTranslationUnitsForEditor:" << exception.what();
|
||||
}
|
||||
@@ -176,7 +176,7 @@ void ClangCodeModelServer::registerProjectPartsForEditor(const RegisterProjectPa
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::registerProjectPartsForEditor");
|
||||
|
||||
try {
|
||||
projects.createOrUpdate(message.projectContainers());
|
||||
projects.createOrUpdate(message.projectContainers);
|
||||
std::vector<Document> affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();
|
||||
|
||||
resetDocuments(toDocumentResetInfos(affectedDocuments));
|
||||
@@ -193,7 +193,7 @@ void ClangCodeModelServer::unregisterProjectPartsForEditor(const UnregisterProje
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::unregisterProjectPartsForEditor");
|
||||
|
||||
try {
|
||||
projects.remove(message.projectPartIds());
|
||||
projects.remove(message.projectPartIds);
|
||||
} catch (const std::exception &exception) {
|
||||
qWarning() << "Error in ClangCodeModelServer::unregisterProjectPartsForEditor:" << exception.what();
|
||||
}
|
||||
@@ -205,8 +205,8 @@ void ClangCodeModelServer::registerUnsavedFilesForEditor(const RegisterUnsavedFi
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::registerUnsavedFilesForEditor");
|
||||
|
||||
try {
|
||||
unsavedFiles.createOrUpdate(message.fileContainers());
|
||||
documents.updateDocumentsWithChangedDependencies(message.fileContainers());
|
||||
unsavedFiles.createOrUpdate(message.fileContainers);
|
||||
documents.updateDocumentsWithChangedDependencies(message.fileContainers);
|
||||
|
||||
updateDocumentAnnotationsTimer.start(updateDocumentAnnotationsTimeOutInMs);
|
||||
} catch (const std::exception &exception) {
|
||||
@@ -220,8 +220,8 @@ void ClangCodeModelServer::unregisterUnsavedFilesForEditor(const UnregisterUnsav
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::unregisterUnsavedFilesForEditor");
|
||||
|
||||
try {
|
||||
unsavedFiles.remove(message.fileContainers());
|
||||
documents.updateDocumentsWithChangedDependencies(message.fileContainers());
|
||||
unsavedFiles.remove(message.fileContainers);
|
||||
documents.updateDocumentsWithChangedDependencies(message.fileContainers);
|
||||
} catch (const std::exception &exception) {
|
||||
qWarning() << "Error in ClangCodeModelServer::unregisterUnsavedFilesForEditor:" << exception.what();
|
||||
}
|
||||
@@ -233,15 +233,15 @@ void ClangCodeModelServer::completeCode(const ClangBackEnd::CompleteCodeMessage
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::completeCode");
|
||||
|
||||
try {
|
||||
Document document = documents.document(message.filePath(), message.projectPartId());
|
||||
Document document = documents.document(message.filePath, message.projectPartId);
|
||||
DocumentProcessor processor = documentProcessors().processor(document);
|
||||
|
||||
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::CompleteCode);
|
||||
jobRequest.line = message.line();
|
||||
jobRequest.column = message.column();
|
||||
jobRequest.funcNameStartLine = message.funcNameStartLine();
|
||||
jobRequest.funcNameStartColumn = message.funcNameStartColumn();
|
||||
jobRequest.ticketNumber = message.ticketNumber();
|
||||
jobRequest.line = message.line;
|
||||
jobRequest.column = message.column;
|
||||
jobRequest.funcNameStartLine = message.funcNameStartLine;
|
||||
jobRequest.funcNameStartColumn = message.funcNameStartColumn;
|
||||
jobRequest.ticketNumber = message.ticketNumber;
|
||||
|
||||
processor.addJob(jobRequest);
|
||||
processor.process();
|
||||
@@ -256,8 +256,8 @@ void ClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnot
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::requestDocumentAnnotations");
|
||||
|
||||
try {
|
||||
auto document = documents.document(message.fileContainer().filePath(),
|
||||
message.fileContainer().projectPartId());
|
||||
auto document = documents.document(message.fileContainer.filePath,
|
||||
message.fileContainer.projectPartId);
|
||||
|
||||
DocumentProcessor processor = documentProcessors().processor(document);
|
||||
processor.addJob(JobRequest::Type::RequestDocumentAnnotations);
|
||||
@@ -270,13 +270,13 @@ void ClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnot
|
||||
template <class MessageType>
|
||||
static void fillJobRequest(JobRequest &jobRequest, const MessageType &message)
|
||||
{
|
||||
jobRequest.line = message.line();
|
||||
jobRequest.column = message.column();
|
||||
jobRequest.ticketNumber = message.ticketNumber();
|
||||
jobRequest.textCodecName = message.fileContainer().textCodecName();
|
||||
jobRequest.line = message.line;
|
||||
jobRequest.column = message.column;
|
||||
jobRequest.ticketNumber = message.ticketNumber;
|
||||
jobRequest.textCodecName = message.fileContainer.textCodecName;
|
||||
// The unsaved files might get updater later, so take the current
|
||||
// revision for the request.
|
||||
jobRequest.documentRevision = message.fileContainer().documentRevision();
|
||||
jobRequest.documentRevision = message.fileContainer.documentRevision;
|
||||
}
|
||||
|
||||
void ClangCodeModelServer::requestReferences(const RequestReferencesMessage &message)
|
||||
@@ -285,13 +285,13 @@ void ClangCodeModelServer::requestReferences(const RequestReferencesMessage &mes
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::requestReferences");
|
||||
|
||||
try {
|
||||
const Document document = documents.document(message.fileContainer().filePath(),
|
||||
message.fileContainer().projectPartId());
|
||||
const Document document = documents.document(message.fileContainer.filePath,
|
||||
message.fileContainer.projectPartId);
|
||||
DocumentProcessor processor = documentProcessors().processor(document);
|
||||
|
||||
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestReferences);
|
||||
fillJobRequest(jobRequest, message);
|
||||
jobRequest.localReferences = message.local();
|
||||
jobRequest.localReferences = message.local;
|
||||
processor.addJob(jobRequest);
|
||||
processor.process();
|
||||
} catch (const std::exception &exception) {
|
||||
@@ -305,9 +305,8 @@ void ClangCodeModelServer::requestFollowSymbol(const RequestFollowSymbolMessage
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::requestFollowSymbol");
|
||||
|
||||
try {
|
||||
auto projectPartId = message.fileContainer().projectPartId();
|
||||
Document document = documents.document(message.fileContainer().filePath(),
|
||||
projectPartId);
|
||||
const Utf8String &projectPartId = message.fileContainer.projectPartId;
|
||||
Document document = documents.document(message.fileContainer.filePath, projectPartId);
|
||||
DocumentProcessor processor = documentProcessors().processor(document);
|
||||
|
||||
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::FollowSymbol);
|
||||
@@ -324,8 +323,8 @@ void ClangCodeModelServer::requestToolTip(const RequestToolTipMessage &message)
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::requestToolTip");
|
||||
|
||||
try {
|
||||
const Document document = documents.document(message.fileContainer().filePath(),
|
||||
message.fileContainer().projectPartId());
|
||||
const Document document = documents.document(message.fileContainer.filePath,
|
||||
message.fileContainer.projectPartId);
|
||||
DocumentProcessor processor = documentProcessors().processor(document);
|
||||
|
||||
JobRequest jobRequest = processor.createJobRequest(JobRequest::Type::RequestToolTip);
|
||||
@@ -344,8 +343,8 @@ void ClangCodeModelServer::updateVisibleTranslationUnits(const UpdateVisibleTran
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::updateVisibleTranslationUnits");
|
||||
|
||||
try {
|
||||
documents.setUsedByCurrentEditor(message.currentEditorFilePath());
|
||||
documents.setVisibleInEditors(message.visibleEditorFilePaths());
|
||||
documents.setUsedByCurrentEditor(message.currentEditorFilePath);
|
||||
documents.setVisibleInEditors(message.visibleEditorFilePaths);
|
||||
processSuspendResumeJobs(documents.documents());
|
||||
|
||||
updateDocumentAnnotationsTimer.start(0);
|
||||
@@ -442,7 +441,7 @@ void ClangCodeModelServer::categorizeFileContainers(const QVector<FileContainer>
|
||||
{
|
||||
for (const FileContainer &fileContainer : fileContainers) {
|
||||
const std::vector<Document> matching = documents.filtered([&](const Document &document) {
|
||||
return document.filePath() == fileContainer.filePath();
|
||||
return document.filePath() == fileContainer.filePath;
|
||||
});
|
||||
if (matching.empty())
|
||||
toCreate.push_back(fileContainer);
|
||||
@@ -457,7 +456,7 @@ std::vector<Document> ClangCodeModelServer::resetDocuments(const DocumentResetIn
|
||||
|
||||
for (const DocumentResetInfo &info : infos) {
|
||||
const Document &document = info.documentToRemove;
|
||||
QTC_CHECK(document.filePath() == info.fileContainer.filePath());
|
||||
QTC_CHECK(document.filePath() == info.fileContainer.filePath);
|
||||
|
||||
documents.remove({document.fileContainer()});
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ namespace ClangBackEnd {
|
||||
|
||||
bool operator==(const FileContainer &fileContainer, const Document &document)
|
||||
{
|
||||
return fileContainer.filePath() == document.filePath()
|
||||
&& fileContainer.projectPartId() == document.projectPart().id();
|
||||
return fileContainer.filePath == document.filePath()
|
||||
&& fileContainer.projectPartId == document.projectPart().id();
|
||||
}
|
||||
|
||||
bool operator==(const Document &document, const FileContainer &fileContainer)
|
||||
@@ -65,8 +65,8 @@ std::vector<Document> Documents::create(const QVector<FileContainer> &fileContai
|
||||
std::vector<Document> createdDocuments;
|
||||
|
||||
for (const FileContainer &fileContainer : fileContainers) {
|
||||
if (fileContainer.hasUnsavedFileContent())
|
||||
updateDocumentsWithChangedDependency(fileContainer.filePath());
|
||||
if (fileContainer.hasUnsavedFileContent)
|
||||
updateDocumentsWithChangedDependency(fileContainer.filePath);
|
||||
|
||||
createdDocuments.push_back(createDocument(fileContainer));
|
||||
}
|
||||
@@ -84,7 +84,7 @@ std::vector<Document> Documents::update(const QVector<FileContainer> &fileContai
|
||||
const std::vector<Document> documents = updateDocument(fileContainer);
|
||||
createdDocuments.insert(createdDocuments.end(), documents.begin(), documents.end());
|
||||
|
||||
updateDocumentsWithChangedDependency(fileContainer.filePath());
|
||||
updateDocumentsWithChangedDependency(fileContainer.filePath);
|
||||
}
|
||||
|
||||
return createdDocuments;
|
||||
@@ -136,11 +136,10 @@ const Document &Documents::document(const Utf8String &filePath, const Utf8String
|
||||
|
||||
const Document &Documents::document(const FileContainer &fileContainer) const
|
||||
{
|
||||
return document(fileContainer.filePath(), fileContainer.projectPartId());
|
||||
return document(fileContainer.filePath, fileContainer.projectPartId);
|
||||
}
|
||||
|
||||
bool Documents::hasDocument(const Utf8String &filePath,
|
||||
const Utf8String &projectPartId) const
|
||||
bool Documents::hasDocument(const Utf8String &filePath, const Utf8String &projectPartId) const
|
||||
{
|
||||
return hasDocument(FileContainer(filePath, projectPartId));
|
||||
}
|
||||
@@ -183,7 +182,7 @@ void Documents::updateDocumentsWithChangedDependency(const Utf8String &filePath)
|
||||
void Documents::updateDocumentsWithChangedDependencies(const QVector<FileContainer> &fileContainers)
|
||||
{
|
||||
for (const FileContainer &fileContainer : fileContainers)
|
||||
updateDocumentsWithChangedDependency(fileContainer.filePath());
|
||||
updateDocumentsWithChangedDependency(fileContainer.filePath);
|
||||
}
|
||||
|
||||
std::vector<Document> Documents::setDocumentsDirtyIfProjectPartChanged()
|
||||
@@ -204,7 +203,7 @@ QVector<FileContainer> Documents::newerFileContainers(const QVector<FileContaine
|
||||
|
||||
auto documentIsNewer = [this] (const FileContainer &fileContainer) {
|
||||
try {
|
||||
return document(fileContainer).documentRevision() != fileContainer.documentRevision();
|
||||
return document(fileContainer).documentRevision() != fileContainer.documentRevision;
|
||||
} catch (const DocumentDoesNotExistException &) {
|
||||
return true;
|
||||
}
|
||||
@@ -225,27 +224,27 @@ const ClangFileSystemWatcher *Documents::clangFileSystemWatcher() const
|
||||
|
||||
Document Documents::createDocument(const FileContainer &fileContainer)
|
||||
{
|
||||
const Document::FileExistsCheck checkIfFileExists = fileContainer.hasUnsavedFileContent()
|
||||
const Document::FileExistsCheck checkIfFileExists = fileContainer.hasUnsavedFileContent
|
||||
? Document::FileExistsCheck::DoNotCheck
|
||||
: Document::FileExistsCheck::Check;
|
||||
|
||||
documents_.emplace_back(fileContainer.filePath(),
|
||||
projectParts.project(fileContainer.projectPartId()),
|
||||
fileContainer.fileArguments(),
|
||||
*this,
|
||||
checkIfFileExists);
|
||||
documents_.emplace_back(fileContainer.filePath,
|
||||
projectParts.project(fileContainer.projectPartId),
|
||||
fileContainer.fileArguments,
|
||||
*this,
|
||||
checkIfFileExists);
|
||||
|
||||
documents_.back().setDocumentRevision(fileContainer.documentRevision());
|
||||
documents_.back().setDocumentRevision(fileContainer.documentRevision);
|
||||
|
||||
return documents_.back();
|
||||
}
|
||||
|
||||
std::vector<Document> Documents::updateDocument(const FileContainer &fileContainer)
|
||||
{
|
||||
const auto documents = findAllDocumentsWithFilePath(fileContainer.filePath());
|
||||
const auto documents = findAllDocumentsWithFilePath(fileContainer.filePath);
|
||||
|
||||
for (auto document : documents)
|
||||
document.setDocumentRevision(fileContainer.documentRevision());
|
||||
document.setDocumentRevision(fileContainer.documentRevision);
|
||||
|
||||
return documents;
|
||||
}
|
||||
@@ -304,8 +303,8 @@ void Documents::checkIfProjectPartsExists(const QVector<FileContainer> &fileCont
|
||||
Utf8StringVector notExistingProjectParts;
|
||||
|
||||
for (const FileContainer &fileContainer : fileContainers) {
|
||||
if (!projectParts.hasProjectPart(fileContainer.projectPartId()))
|
||||
notExistingProjectParts.push_back(fileContainer.projectPartId());
|
||||
if (!projectParts.hasProjectPart(fileContainer.projectPartId))
|
||||
notExistingProjectParts.push_back(fileContainer.projectPartId);
|
||||
}
|
||||
|
||||
if (!notExistingProjectParts.isEmpty())
|
||||
@@ -317,8 +316,8 @@ void Documents::checkIfDocumentsDoNotExist(const QVector<FileContainer> &fileCon
|
||||
{
|
||||
for (const FileContainer &fileContainer : fileContainers) {
|
||||
if (hasDocument(fileContainer)) {
|
||||
throw DocumentAlreadyExistsException(fileContainer.filePath(),
|
||||
fileContainer.projectPartId());
|
||||
throw DocumentAlreadyExistsException(fileContainer.filePath,
|
||||
fileContainer.projectPartId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,9 +325,9 @@ void Documents::checkIfDocumentsDoNotExist(const QVector<FileContainer> &fileCon
|
||||
void Documents::checkIfDocumentsForFilePathsExist(const QVector<FileContainer> &fileContainers) const
|
||||
{
|
||||
for (const FileContainer &fileContainer : fileContainers) {
|
||||
if (!hasDocumentWithFilePath(fileContainer.filePath())) {
|
||||
throw DocumentDoesNotExistException(fileContainer.filePath(),
|
||||
fileContainer.projectPartId());
|
||||
if (!hasDocumentWithFilePath(fileContainer.filePath)) {
|
||||
throw DocumentDoesNotExistException(fileContainer.filePath,
|
||||
fileContainer.projectPartId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,8 +344,8 @@ void Documents::removeDocuments(const QVector<FileContainer> &fileContainers)
|
||||
|
||||
if (!processedFileContainers.isEmpty()) {
|
||||
const FileContainer fileContainer = processedFileContainers.first();
|
||||
throw DocumentDoesNotExistException(fileContainer.filePath(),
|
||||
fileContainer.projectPartId());
|
||||
throw DocumentDoesNotExistException(fileContainer.filePath,
|
||||
fileContainer.projectPartId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -414,27 +414,27 @@ ToolTipInfo ToolTipInfoCollector::qDocInfo(const Cursor &cursor) const
|
||||
|
||||
if (cursor.kind() == CXCursor_Constructor) {
|
||||
const ToolTipInfo parentInfo = qDocInfo(cursor.semanticParent());
|
||||
result.setQdocIdCandidates(parentInfo.qdocIdCandidates());
|
||||
result.setQdocMark(parentInfo.qdocMark());
|
||||
result.setQdocCategory(ToolTipInfo::Unknown);
|
||||
result.qdocIdCandidates = parentInfo.qdocIdCandidates;
|
||||
result.qdocMark = parentInfo.qdocMark;
|
||||
result.qdocCategory = ToolTipInfo::Unknown;
|
||||
return result;
|
||||
}
|
||||
|
||||
result.setQdocIdCandidates(qDocIdCandidates(cursor));
|
||||
result.setQdocMark(qdocMark(cursor));
|
||||
result.setQdocCategory(qdocCategory(cursor));
|
||||
result.qdocIdCandidates = qDocIdCandidates(cursor);
|
||||
result.qdocMark = qdocMark(cursor);
|
||||
result.qdocCategory = qdocCategory(cursor);
|
||||
|
||||
if (cursor.type().kind() == CXType_Record) {
|
||||
result.setQdocIdCandidates(qDocIdCandidates(cursor.type().declaration()));
|
||||
result.qdocIdCandidates = qDocIdCandidates(cursor.type().declaration());
|
||||
return result;
|
||||
}
|
||||
|
||||
if (cursor.kind() == CXCursor_VarDecl || cursor.kind() == CXCursor_FieldDecl) {
|
||||
result.setQdocMark(typeName(cursor.type()));
|
||||
result.qdocMark = typeName(cursor.type());
|
||||
// maybe template instantiation
|
||||
if (cursor.type().kind() == CXType_Unexposed && cursor.type().canonical().kind() == CXType_Record) {
|
||||
result.setQdocIdCandidates(qDocIdCandidates(cursor.type().canonical().declaration()));
|
||||
result.setQdocCategory(ToolTipInfo::ClassOrNamespace);
|
||||
result.qdocIdCandidates = qDocIdCandidates(cursor.type().canonical().declaration());
|
||||
result.qdocCategory = ToolTipInfo::ClassOrNamespace;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -442,9 +442,9 @@ ToolTipInfo ToolTipInfoCollector::qDocInfo(const Cursor &cursor) const
|
||||
// TODO: Handle also RValueReference()
|
||||
if (cursor.type().isLValueReference()) {
|
||||
const Cursor pointeeTypeDeclaration = cursor.type().pointeeType().declaration();
|
||||
result.setQdocIdCandidates(qDocIdCandidates(pointeeTypeDeclaration));
|
||||
result.setQdocMark(pointeeTypeDeclaration.spelling());
|
||||
result.setQdocCategory(qdocCategory(pointeeTypeDeclaration));
|
||||
result.qdocIdCandidates = qDocIdCandidates(pointeeTypeDeclaration);
|
||||
result.qdocMark = pointeeTypeDeclaration.spelling();
|
||||
result.qdocCategory = qdocCategory(pointeeTypeDeclaration);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -506,17 +506,17 @@ ToolTipInfo ToolTipInfoCollector::collect(uint line, uint column) const
|
||||
QTC_CHECK(referenced.isValid());
|
||||
|
||||
ToolTipInfo info;
|
||||
info.setText(text(cursor, referenced));
|
||||
info.setBriefComment(referenced.briefComment());
|
||||
info.text = text(cursor, referenced);
|
||||
info.briefComment = referenced.briefComment();
|
||||
|
||||
{
|
||||
ToolTipInfo qDocToolTipInfo = qDocInfo(referenced);
|
||||
info.setQdocIdCandidates(qDocToolTipInfo.qdocIdCandidates());
|
||||
info.setQdocMark(qDocToolTipInfo.qdocMark());
|
||||
info.setQdocCategory(qDocToolTipInfo.qdocCategory());
|
||||
info.qdocIdCandidates = qDocToolTipInfo.qdocIdCandidates;
|
||||
info.qdocMark = qDocToolTipInfo.qdocMark;
|
||||
info.qdocCategory = qDocToolTipInfo.qdocCategory;
|
||||
}
|
||||
|
||||
info.setSizeInBytes(sizeInBytes(cursor));
|
||||
info.sizeInBytes = sizeInBytes(cursor);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -95,64 +95,64 @@ void CodeCompletionsExtractor::extractCompletionKind()
|
||||
{
|
||||
switch (currentCxCodeCompleteResult.CursorKind) {
|
||||
case CXCursor_FunctionTemplate:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::TemplateFunctionCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::TemplateFunctionCompletionKind;
|
||||
break;
|
||||
case CXCursor_CXXMethod:
|
||||
extractMethodCompletionKind();
|
||||
break;
|
||||
case CXCursor_FunctionDecl:
|
||||
case CXCursor_ConversionFunction:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::FunctionCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::FunctionCompletionKind;
|
||||
break;
|
||||
case CXCursor_VariableRef:
|
||||
case CXCursor_VarDecl:
|
||||
case CXCursor_FieldDecl:
|
||||
case CXCursor_ParmDecl:
|
||||
case CXCursor_NonTypeTemplateParameter:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::VariableCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::VariableCompletionKind;
|
||||
break;
|
||||
case CXCursor_StructDecl:
|
||||
case CXCursor_UnionDecl:
|
||||
case CXCursor_ClassDecl:
|
||||
case CXCursor_TemplateTypeParameter:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::ClassCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::ClassCompletionKind;
|
||||
break;
|
||||
case CXCursor_TypedefDecl:
|
||||
case CXCursor_TypeAliasDecl:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::TypeAliasCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::TypeAliasCompletionKind;
|
||||
break;
|
||||
case CXCursor_ClassTemplatePartialSpecialization:
|
||||
case CXCursor_ClassTemplate:
|
||||
case CXCursor_TemplateTemplateParameter:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::TemplateClassCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::TemplateClassCompletionKind;
|
||||
break;
|
||||
case CXCursor_Namespace:
|
||||
case CXCursor_NamespaceAlias:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::NamespaceCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::NamespaceCompletionKind;
|
||||
break;
|
||||
case CXCursor_EnumDecl:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::EnumerationCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::EnumerationCompletionKind;
|
||||
break;
|
||||
case CXCursor_EnumConstantDecl:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::EnumeratorCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::EnumeratorCompletionKind;
|
||||
break;
|
||||
case CXCursor_Constructor:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::ConstructorCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::ConstructorCompletionKind;
|
||||
break;
|
||||
case CXCursor_Destructor:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::DestructorCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::DestructorCompletionKind;
|
||||
break;
|
||||
case CXCursor_MacroDefinition:
|
||||
extractMacroCompletionKind();
|
||||
break;
|
||||
case CXCursor_NotImplemented:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::KeywordCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::KeywordCompletionKind;
|
||||
break;
|
||||
case CXCursor_OverloadCandidate:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::FunctionOverloadCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::FunctionOverloadCompletionKind;
|
||||
break;
|
||||
default:
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::Other);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::Other;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void CodeCompletionsExtractor::extractText()
|
||||
for (uint chunkIndex = 0; chunkIndex < completionChunkCount; ++chunkIndex) {
|
||||
const CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(currentCxCodeCompleteResult.CompletionString, chunkIndex);
|
||||
if (chunkKind == CXCompletionChunk_TypedText) {
|
||||
currentCodeCompletion_.setText(CodeCompletionChunkConverter::chunkText(currentCxCodeCompleteResult.CompletionString, chunkIndex));
|
||||
currentCodeCompletion_.text = CodeCompletionChunkConverter::chunkText(currentCxCodeCompleteResult.CompletionString, chunkIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -177,17 +177,17 @@ void CodeCompletionsExtractor::extractMethodCompletionKind()
|
||||
ClangString annotation = clang_getCompletionAnnotation(cxCompletionString, annotationIndex);
|
||||
|
||||
if (annotation == Utf8StringLiteral("qt_signal")) {
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::SignalCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::SignalCompletionKind;
|
||||
return;
|
||||
}
|
||||
|
||||
if (annotation == Utf8StringLiteral("qt_slot")) {
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::SlotCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::SlotCompletionKind;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::FunctionCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::FunctionCompletionKind;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::extractMacroCompletionKind()
|
||||
@@ -199,19 +199,19 @@ void CodeCompletionsExtractor::extractMacroCompletionKind()
|
||||
for (uint chunkIndex = 0; chunkIndex < completionChunkCount; ++chunkIndex) {
|
||||
CXCompletionChunkKind kind = clang_getCompletionChunkKind(cxCompletionString, chunkIndex);
|
||||
if (kind == CXCompletionChunk_Placeholder) {
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::FunctionCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::FunctionCompletionKind;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentCodeCompletion_.setCompletionKind(CodeCompletion::PreProcessorCompletionKind);
|
||||
currentCodeCompletion_.completionKind = CodeCompletion::PreProcessorCompletionKind;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::extractPriority()
|
||||
{
|
||||
CXCompletionString cxCompletionString = cxCodeCompleteResults->Results[cxCodeCompleteResultIndex].CompletionString;
|
||||
quint32 priority = clang_getCompletionPriority(cxCompletionString);
|
||||
currentCodeCompletion_.setPriority(priority);
|
||||
currentCodeCompletion_.priority = priority;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::extractAvailability()
|
||||
@@ -221,16 +221,16 @@ void CodeCompletionsExtractor::extractAvailability()
|
||||
|
||||
switch (cxAvailabilityKind) {
|
||||
case CXAvailability_Available:
|
||||
currentCodeCompletion_.setAvailability(CodeCompletion::Available);
|
||||
currentCodeCompletion_.availability = CodeCompletion::Available;
|
||||
break;
|
||||
case CXAvailability_Deprecated:
|
||||
currentCodeCompletion_.setAvailability(CodeCompletion::Deprecated);
|
||||
currentCodeCompletion_.availability = CodeCompletion::Deprecated;
|
||||
break;
|
||||
case CXAvailability_NotAvailable:
|
||||
currentCodeCompletion_.setAvailability(CodeCompletion::NotAvailable);
|
||||
currentCodeCompletion_.availability = CodeCompletion::NotAvailable;
|
||||
break;
|
||||
case CXAvailability_NotAccessible:
|
||||
currentCodeCompletion_.setAvailability(CodeCompletion::NotAccessible);
|
||||
currentCodeCompletion_.availability = CodeCompletion::NotAccessible;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ void CodeCompletionsExtractor::extractHasParameters()
|
||||
const CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(currentCxCodeCompleteResult.CompletionString, chunkIndex);
|
||||
if (chunkKind == CXCompletionChunk_LeftParen) {
|
||||
const CXCompletionChunkKind nextChunkKind = clang_getCompletionChunkKind(currentCxCodeCompleteResult.CompletionString, chunkIndex + 1);
|
||||
currentCodeCompletion_.setHasParameters(nextChunkKind != CXCompletionChunk_RightParen);
|
||||
currentCodeCompletion_.hasParameters = nextChunkKind != CXCompletionChunk_RightParen;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -252,12 +252,12 @@ void CodeCompletionsExtractor::extractBriefComment()
|
||||
{
|
||||
ClangString briefComment = clang_getCompletionBriefComment(currentCxCodeCompleteResult.CompletionString);
|
||||
|
||||
currentCodeCompletion_.setBriefComment(briefComment);
|
||||
currentCodeCompletion_.briefComment = briefComment;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::extractCompletionChunks()
|
||||
{
|
||||
currentCodeCompletion_.setChunks(CodeCompletionChunkConverter::extract(currentCxCodeCompleteResult.CompletionString));
|
||||
currentCodeCompletion_.chunks = CodeCompletionChunkConverter::extract(currentCxCodeCompleteResult.CompletionString);
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::adaptPriority()
|
||||
@@ -271,36 +271,36 @@ void CodeCompletionsExtractor::adaptPriority()
|
||||
|
||||
void CodeCompletionsExtractor::decreasePriorityForNonAvailableCompletions()
|
||||
{
|
||||
if (currentCodeCompletion_.availability() != CodeCompletion::Available)
|
||||
currentCodeCompletion_.setPriority(currentCodeCompletion_.priority() * 100);
|
||||
if (currentCodeCompletion_.availability != CodeCompletion::Available)
|
||||
currentCodeCompletion_.priority = currentCodeCompletion_.priority * 100;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::decreasePriorityForDestructors()
|
||||
{
|
||||
if (currentCodeCompletion_.completionKind() == CodeCompletion::DestructorCompletionKind)
|
||||
currentCodeCompletion_.setPriority(currentCodeCompletion_.priority() * 100);
|
||||
if (currentCodeCompletion_.completionKind == CodeCompletion::DestructorCompletionKind)
|
||||
currentCodeCompletion_.priority = currentCodeCompletion_.priority * 100;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::decreasePriorityForSignals()
|
||||
{
|
||||
if (currentCodeCompletion_.completionKind() == CodeCompletion::SignalCompletionKind)
|
||||
currentCodeCompletion_.setPriority(currentCodeCompletion_.priority() * 100);
|
||||
if (currentCodeCompletion_.completionKind == CodeCompletion::SignalCompletionKind)
|
||||
currentCodeCompletion_.priority = currentCodeCompletion_.priority * 100;
|
||||
}
|
||||
|
||||
void CodeCompletionsExtractor::decreasePriorityForQObjectInternals()
|
||||
{
|
||||
quint32 priority = currentCodeCompletion_.priority();
|
||||
quint32 priority = currentCodeCompletion_.priority;
|
||||
|
||||
if (currentCodeCompletion_.text().startsWith("qt_"))
|
||||
if (currentCodeCompletion_.text.startsWith("qt_"))
|
||||
priority *= 100;
|
||||
|
||||
if (currentCodeCompletion_.text() == Utf8StringLiteral("metaObject"))
|
||||
if (currentCodeCompletion_.text == Utf8StringLiteral("metaObject"))
|
||||
priority *= 10;
|
||||
|
||||
if (currentCodeCompletion_.text() == Utf8StringLiteral("staticMetaObject"))
|
||||
if (currentCodeCompletion_.text == Utf8StringLiteral("staticMetaObject"))
|
||||
priority *= 100;
|
||||
|
||||
currentCodeCompletion_.setPriority(priority);
|
||||
currentCodeCompletion_.priority = priority;
|
||||
}
|
||||
|
||||
bool isOperator(CXCursorKind cxCursorKind, const Utf8String &name)
|
||||
@@ -312,12 +312,12 @@ bool isOperator(CXCursorKind cxCursorKind, const Utf8String &name)
|
||||
|
||||
void CodeCompletionsExtractor::decreasePriorityForOperators()
|
||||
{
|
||||
quint32 priority = currentCodeCompletion_.priority();
|
||||
quint32 priority = currentCodeCompletion_.priority;
|
||||
|
||||
if (isOperator(currentCxCodeCompleteResult.CursorKind, currentCodeCompletion().text()))
|
||||
if (isOperator(currentCxCodeCompleteResult.CursorKind, currentCodeCompletion().text))
|
||||
priority *= 100;
|
||||
|
||||
currentCodeCompletion_.setPriority(priority);
|
||||
currentCodeCompletion_.priority = priority;
|
||||
}
|
||||
|
||||
bool CodeCompletionsExtractor::hasText(const Utf8String &text, CXCompletionString cxCompletionString) const
|
||||
@@ -342,10 +342,10 @@ const CodeCompletion &CodeCompletionsExtractor::currentCodeCompletion() const
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const CodeCompletionsExtractor &extractor)
|
||||
{
|
||||
os << "name: " << extractor.currentCodeCompletion().text()
|
||||
<< ", kind: " << extractor.currentCodeCompletion().completionKind()
|
||||
<< ", priority: " << extractor.currentCodeCompletion().priority()
|
||||
<< ", kind: " << extractor.currentCodeCompletion().availability();
|
||||
os << "name: " << extractor.currentCodeCompletion().text
|
||||
<< ", kind: " << extractor.currentCodeCompletion().completionKind
|
||||
<< ", priority: " << extractor.currentCodeCompletion().priority
|
||||
<< ", kind: " << extractor.currentCodeCompletion().availability;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ ProjectPart::ProjectPart(const Utf8String &projectPartId,
|
||||
}
|
||||
|
||||
ProjectPart::ProjectPart(const ProjectPartContainer &projectContainer)
|
||||
: d(std::make_shared<ProjectPartData>(projectContainer.projectPartId()))
|
||||
: d(std::make_shared<ProjectPartData>(projectContainer.projectPartId))
|
||||
{
|
||||
setArguments(projectContainer.arguments());
|
||||
setArguments(projectContainer.arguments);
|
||||
}
|
||||
|
||||
ProjectPart::~ProjectPart() = default;
|
||||
|
||||
@@ -93,11 +93,11 @@ const std::vector<ProjectPart> &ProjectParts::projects() const
|
||||
|
||||
void ProjectParts::createOrUpdateProjectPart(const ProjectPartContainer &projectContainer)
|
||||
{
|
||||
auto findIterator = findProjectPart(projectContainer.projectPartId());
|
||||
auto findIterator = findProjectPart(projectContainer.projectPartId);
|
||||
if (findIterator == projects_.cend())
|
||||
projects_.push_back(ProjectPart(projectContainer));
|
||||
else
|
||||
findIterator->setArguments(projectContainer.arguments());
|
||||
findIterator->setArguments(projectContainer.arguments);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ const TimePoint UnsavedFiles::lastChangeTimePoint() const
|
||||
|
||||
void UnsavedFiles::updateUnsavedFileWithFileContainer(const FileContainer &fileContainer)
|
||||
{
|
||||
if (fileContainer.hasUnsavedFileContent())
|
||||
if (fileContainer.hasUnsavedFileContent)
|
||||
addOrUpdateUnsavedFile(fileContainer);
|
||||
else
|
||||
removeUnsavedFile(fileContainer);
|
||||
@@ -131,7 +131,7 @@ void UnsavedFiles::updateUnsavedFileWithFileContainer(const FileContainer &fileC
|
||||
|
||||
void UnsavedFiles::removeUnsavedFile(const FileContainer &fileContainer)
|
||||
{
|
||||
const Utf8String filePath = fileContainer.filePath();
|
||||
const Utf8String &filePath = fileContainer.filePath;
|
||||
auto removeBeginIterator = std::partition(d->unsavedFiles.begin(),
|
||||
d->unsavedFiles.end(),
|
||||
[filePath] (const UnsavedFile &unsavedFile) { return filePath != unsavedFile.filePath(); });
|
||||
@@ -141,8 +141,8 @@ void UnsavedFiles::removeUnsavedFile(const FileContainer &fileContainer)
|
||||
|
||||
void UnsavedFiles::addOrUpdateUnsavedFile(const FileContainer &fileContainer)
|
||||
{
|
||||
const Utf8String filePath = fileContainer.filePath();
|
||||
const Utf8String fileContent = fileContainer.unsavedFileContent();
|
||||
const Utf8String &filePath = fileContainer.filePath;
|
||||
const Utf8String &fileContent = fileContainer.unsavedFileContent;
|
||||
auto isSameFile = [filePath] (const UnsavedFile &unsavedFile) { return filePath == unsavedFile.filePath(); };
|
||||
|
||||
auto unsavedFileIterator = std::find_if(d->unsavedFiles.begin(), d->unsavedFiles.end(), isSameFile);
|
||||
|
||||
Reference in New Issue
Block a user