diff options
| author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-07-07 15:17:58 +0200 |
|---|---|---|
| committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-07-10 14:04:01 +0000 |
| commit | 91c497b1aebaf4b24ac1e5b884940820c6a0a88c (patch) | |
| tree | 93b31416fcb560450e64a9295443c701f93ae50d /src/plugins/cpptools/baseeditordocumentparser.cpp | |
| parent | a32a9b3d2a82d38edde1b4b55cbdececd7f5333d (diff) | |
| download | qt-creator-91c497b1aebaf4b24ac1e5b884940820c6a0a88c.tar.gz | |
CppTools: Make updateProjectPart() const
...and rename to "determineProjectPart".
This is in preparation for a follow-up change. determineProjectPart()
should not set any state.
Change-Id: Iad7be8638fd97a79a4227a944896ac9af0a36862
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/baseeditordocumentparser.cpp')
| -rw-r--r-- | src/plugins/cpptools/baseeditordocumentparser.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/plugins/cpptools/baseeditordocumentparser.cpp b/src/plugins/cpptools/baseeditordocumentparser.cpp index 7f1e74785b..d24e341b1f 100644 --- a/src/plugins/cpptools/baseeditordocumentparser.cpp +++ b/src/plugins/cpptools/baseeditordocumentparser.cpp @@ -45,7 +45,7 @@ namespace CppTools { the "best" project part for a file. Derived classes are expected to implement update() by using the protected - mutex, updateProjectPart() and by respecting the options set by the client. + mutex, determineProjectPart() and by respecting the options set by the client. */ BaseEditorDocumentParser::BaseEditorDocumentParser(const QString &filePath) @@ -115,33 +115,35 @@ BaseEditorDocumentParser *BaseEditorDocumentParser::get(const QString &filePath) return 0; } -void BaseEditorDocumentParser::updateProjectPart() +ProjectPart::Ptr BaseEditorDocumentParser::determineProjectPart() const { - if (m_manuallySetProjectPart) { - m_projectPart = m_manuallySetProjectPart; - return; - } + if (m_manuallySetProjectPart) + return m_manuallySetProjectPart; + + ProjectPart::Ptr projectPart = m_projectPart; CppModelManager *cmm = CppModelManager::instance(); QList<ProjectPart::Ptr> projectParts = cmm->projectPart(m_filePath); if (projectParts.isEmpty()) { - if (m_projectPart) + if (projectPart) // File is not directly part of any project, but we got one before. We will re-use it, // because re-calculating this can be expensive when the dependency table is big. - return; + return projectPart; // Fall-back step 1: Get some parts through the dependency table: projectParts = cmm->projectPartFromDependencies(Utils::FileName::fromString(m_filePath)); if (projectParts.isEmpty()) // Fall-back step 2: Use fall-back part from the model manager: - m_projectPart = cmm->fallbackProjectPart(); + projectPart = cmm->fallbackProjectPart(); else - m_projectPart = projectParts.first(); + projectPart = projectParts.first(); } else { - if (!projectParts.contains(m_projectPart)) + if (!projectParts.contains(projectPart)) // Apparently the project file changed, so update our project part. - m_projectPart = projectParts.first(); + projectPart = projectParts.first(); } + + return projectPart; } bool BaseEditorDocumentParser::editorDefinesChanged() const |
