summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2014-12-21 21:54:30 +0200
committerOrgad Shaneh <orgads@gmail.com>2015-01-12 10:23:37 +0100
commitc6a983d27179ebd26e692918e58d44aa77fc7f8a (patch)
tree6ef23b30a2e6c4a29c14acbb824e38bae026acdb /src/plugins/cppeditor
parent9c1b28fec265054ba4a9c13093ebcfc0f5b4c723 (diff)
downloadqt-creator-c6a983d27179ebd26e692918e58d44aa77fc7f8a.tar.gz
Core: Use FileName for file path in IDocument
Change-Id: I85f7398aee59d0d36f0e5c3bf88ff3c96002e394 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.cpp4
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp6
-rw-r--r--src/plugins/cppeditor/cppeditordocument.cpp17
-rw-r--r--src/plugins/cppeditor/cppeditordocument.h2
-rw-r--r--src/plugins/cppeditor/cppeditoroutline.cpp2
-rw-r--r--src/plugins/cppeditor/cppelementevaluator.cpp2
-rw-r--r--src/plugins/cppeditor/cppfollowsymbolundercursor.cpp4
-rw-r--r--src/plugins/cppeditor/cppincludehierarchy.cpp4
-rw-r--r--src/plugins/cppeditor/cppincludehierarchymodel.cpp4
-rw-r--r--src/plugins/cppeditor/cppquickfixassistant.cpp2
-rw-r--r--src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp2
11 files changed, 25 insertions, 24 deletions
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
index 7c189f52e2..7826148d30 100644
--- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
@@ -71,7 +71,7 @@ TextEditor::BaseTextEditor *currentEditor()
QString fileInCurrentEditor()
{
if (TextEditor::BaseTextEditor *editor = currentEditor())
- return editor->document()->filePath();
+ return editor->document()->filePath().toString();
return QString();
}
@@ -1364,7 +1364,7 @@ void CppCodeModelInspectorDialog::refresh()
TextEditor::BaseTextEditor *editor = currentEditor();
EditorDocumentHandle *editorDocument = 0;
if (editor) {
- const QString editorFilePath = editor->document()->filePath();
+ const QString editorFilePath = editor->document()->filePath().toString();
editorDocument = cmmi->editorDocument(editorFilePath);
if (auto *documentProcessor = BaseEditorDocumentProcessor::get(editorFilePath)) {
const CPlusPlus::Snapshot editorSnapshot = documentProcessor->snapshot();
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 3ea97b7324..e01f08c85c 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -637,7 +637,7 @@ AssistInterface *CppEditorWidget::createAssistInterface(AssistKind kind, AssistR
if (CppCompletionAssistProvider *cap =
qobject_cast<CppCompletionAssistProvider *>(cppEditorDocument()->completionAssistProvider())) {
return cap->createAssistInterface(
- textDocument()->filePath(),
+ textDocument()->filePath().toString(),
document(),
cppEditorDocument()->isObjCEnabled(),
position(),
@@ -766,7 +766,7 @@ void CppEditorWidget::abortDeclDefLink()
void CppEditorWidget::showPreProcessorWidget()
{
- const Utils::FileName fileName = Utils::FileName::fromString(textDocument()->filePath());
+ const Utils::FileName fileName = textDocument()->filePath();
// Check if this editor belongs to a project
QList<ProjectPart::Ptr> projectParts = d->m_modelManager->projectPart(fileName);
@@ -775,7 +775,7 @@ void CppEditorWidget::showPreProcessorWidget()
if (projectParts.isEmpty())
projectParts << d->m_modelManager->fallbackProjectPart();
- CppPreProcessorDialog preProcessorDialog(this, textDocument()->filePath(), projectParts);
+ CppPreProcessorDialog preProcessorDialog(this, textDocument()->filePath().toString(), projectParts);
if (preProcessorDialog.exec() == QDialog::Accepted) {
cppEditorDocument()->setPreprocessorSettings(
preProcessorDialog.projectPart(),
diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp
index 987ee522a5..3c68be7acf 100644
--- a/src/plugins/cppeditor/cppeditordocument.cpp
+++ b/src/plugins/cppeditor/cppeditordocument.cpp
@@ -68,14 +68,14 @@ class CppEditorDocumentHandle : public CppTools::EditorDocumentHandle
public:
CppEditorDocumentHandle(CppEditor::Internal::CppEditorDocument *cppEditorDocument)
: m_cppEditorDocument(cppEditorDocument)
- , m_registrationFilePath(cppEditorDocument->filePath())
+ , m_registrationFilePath(cppEditorDocument->filePath().toString())
{
mm()->registerEditorDocument(this);
}
~CppEditorDocumentHandle() { mm()->unregisterEditorDocument(m_registrationFilePath); }
- QString filePath() const { return m_cppEditorDocument->filePath(); }
+ QString filePath() const { return m_cppEditorDocument->filePath().toString(); }
QByteArray contents() const { return m_cppEditorDocument->contentsText(); }
unsigned revision() const { return m_cppEditorDocument->contentsRevision(); }
@@ -105,8 +105,8 @@ CppEditorDocument::CppEditorDocument()
connect(this, SIGNAL(aboutToReload()), this, SLOT(onAboutToReload()));
connect(this, SIGNAL(reloadFinished(bool)), this, SLOT(onReloadFinished()));
- connect(this, SIGNAL(filePathChanged(QString,QString)),
- this, SLOT(onFilePathChanged(QString,QString)));
+ connect(this, &IDocument::filePathChanged,
+ this, &CppEditorDocument::onFilePathChanged);
m_processorTimer.setSingleShot(true);
m_processorTimer.setInterval(processDocumentIntervalInMs);
@@ -196,12 +196,13 @@ void CppEditorDocument::onReloadFinished()
m_fileIsBeingReloaded = false;
}
-void CppEditorDocument::onFilePathChanged(const QString &oldPath, const QString &newPath)
+void CppEditorDocument::onFilePathChanged(const Utils::FileName &oldPath,
+ const Utils::FileName &newPath)
{
Q_UNUSED(oldPath);
if (!newPath.isEmpty()) {
- setMimeType(Core::MimeDatabase::findByFile(QFileInfo(newPath)).type());
+ setMimeType(Core::MimeDatabase::findByFile(newPath.toFileInfo()).type());
disconnect(this, SIGNAL(contentsChanged()), this, SLOT(scheduleProcessDocument()));
connect(this, SIGNAL(contentsChanged()), this, SLOT(scheduleProcessDocument()));
@@ -250,8 +251,8 @@ void CppEditorDocument::updatePreprocessorSettings()
const QString prefix = QLatin1String(Constants::CPP_PREPROCESSOR_PROJECT_PREFIX);
const QString &projectFile = ProjectExplorer::SessionManager::value(
- prefix + filePath()).toString();
- const QString directivesKey = projectFile + QLatin1Char(',') + filePath();
+ prefix + filePath().toString()).toString();
+ const QString directivesKey = projectFile + QLatin1Char(',') + filePath().toString();
const QByteArray additionalDirectives = ProjectExplorer::SessionManager::value(
directivesKey).toString().toUtf8();
diff --git a/src/plugins/cppeditor/cppeditordocument.h b/src/plugins/cppeditor/cppeditordocument.h
index ace78a6548..5fea535373 100644
--- a/src/plugins/cppeditor/cppeditordocument.h
+++ b/src/plugins/cppeditor/cppeditordocument.h
@@ -84,7 +84,7 @@ protected:
private slots:
void invalidateFormatterCache();
- void onFilePathChanged(const QString &oldPath, const QString &newPath);
+ void onFilePathChanged(const Utils::FileName &oldPath, const Utils::FileName &newPath);
void onMimeTypeChanged();
void onAboutToReload();
diff --git a/src/plugins/cppeditor/cppeditoroutline.cpp b/src/plugins/cppeditor/cppeditoroutline.cpp
index a5d1c776fc..7b26ac198e 100644
--- a/src/plugins/cppeditor/cppeditoroutline.cpp
+++ b/src/plugins/cppeditor/cppeditoroutline.cpp
@@ -195,7 +195,7 @@ void CppEditorOutline::updateNow()
return;
const CPlusPlus::Snapshot snapshot = cmmi->snapshot();
- const QString filePath = m_editorWidget->textDocument()->filePath();
+ const QString filePath = m_editorWidget->textDocument()->filePath().toString();
CPlusPlus::Document::Ptr document = snapshot.document(filePath);
if (!document)
return;
diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp
index 32960691de..7d0ce8f3f9 100644
--- a/src/plugins/cppeditor/cppelementevaluator.cpp
+++ b/src/plugins/cppeditor/cppelementevaluator.cpp
@@ -88,7 +88,7 @@ void CppElementEvaluator::execute()
return;
const Snapshot &snapshot = m_modelManager->snapshot();
- Document::Ptr doc = snapshot.document(m_editor->textDocument()->filePath());
+ Document::Ptr doc = snapshot.document(m_editor->textDocument()->filePath().toString());
if (!doc)
return;
diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
index 0f52de09fa..ac0600554b 100644
--- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
+++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
@@ -550,7 +550,7 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs
}
// Now we prefer the doc from the snapshot with macros expanded.
- Document::Ptr doc = snapshot.document(m_widget->textDocument()->filePath());
+ Document::Ptr doc = snapshot.document(m_widget->textDocument()->filePath().toString());
if (!doc) {
doc = documentFromSemanticInfo;
if (!doc)
@@ -645,7 +645,7 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs
if (Symbol *d = r.declaration()) {
if (d->isDeclaration() || d->isFunction()) {
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
- if (m_widget->textDocument()->filePath() == fileName) {
+ if (m_widget->textDocument()->filePath().toString() == fileName) {
if (unsigned(lineNumber) == d->line()
&& unsigned(positionInBlock) >= d->column()) { // TODO: check the end
result = r; // take the symbol under cursor.
diff --git a/src/plugins/cppeditor/cppincludehierarchy.cpp b/src/plugins/cppeditor/cppincludehierarchy.cpp
index ce5d145a1b..d4f6865e07 100644
--- a/src/plugins/cppeditor/cppincludehierarchy.cpp
+++ b/src/plugins/cppeditor/cppincludehierarchy.cpp
@@ -118,12 +118,12 @@ void CppIncludeHierarchyWidget::perform()
return;
m_model->clear();
- m_model->buildHierarchy(m_editor, widget->textDocument()->filePath());
+ m_model->buildHierarchy(m_editor, widget->textDocument()->filePath().toString());
if (m_model->isEmpty())
return;
m_inspectedFile->setText(widget->textDocument()->displayName());
- m_inspectedFile->setLink(TextEditorWidget::Link(widget->textDocument()->filePath()));
+ m_inspectedFile->setLink(TextEditorWidget::Link(widget->textDocument()->filePath().toString()));
//expand "Includes"
m_treeView->expand(m_model->index(0, 0));
diff --git a/src/plugins/cppeditor/cppincludehierarchymodel.cpp b/src/plugins/cppeditor/cppincludehierarchymodel.cpp
index a7fb9780bb..07bbe84e5e 100644
--- a/src/plugins/cppeditor/cppincludehierarchymodel.cpp
+++ b/src/plugins/cppeditor/cppincludehierarchymodel.cpp
@@ -174,7 +174,7 @@ void CppIncludeHierarchyModel::fetchMore(const QModelIndex &parent)
return;
if (parentItem->needChildrenPopulate()) {
- const QString editorFilePath = m_editor->document()->filePath();
+ const QString editorFilePath = m_editor->document()->filePath().toString();
QSet<QString> cyclic;
cyclic << editorFilePath;
CppIncludeHierarchyItem *item = parentItem->parent();
@@ -285,7 +285,7 @@ void CppIncludeHierarchyModel::buildHierarchyIncludes(const QString &currentFile
if (!m_editor)
return;
- const QString editorFilePath = m_editor->document()->filePath();
+ const QString editorFilePath = m_editor->document()->filePath().toString();
auto *documentProcessor = BaseEditorDocumentProcessor::get(editorFilePath);
QTC_ASSERT(documentProcessor, return);
const Snapshot editorDocumentSnapshot = documentProcessor->snapshot();
diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp
index b9a2c867e6..6bfb0e5d51 100644
--- a/src/plugins/cppeditor/cppquickfixassistant.cpp
+++ b/src/plugins/cppeditor/cppquickfixassistant.cpp
@@ -77,7 +77,7 @@ QList<TextEditor::QuickFixFactory *> CppQuickFixAssistProvider::quickFixFactorie
CppQuickFixInterface::CppQuickFixInterface(CppEditorWidget *editor,
TextEditor::AssistReason reason)
: AssistInterface(editor->document(), editor->position(),
- editor->textDocument()->filePath(), reason)
+ editor->textDocument()->filePath().toString(), reason)
, m_editor(editor)
, m_semanticInfo(editor->semanticInfo())
, m_snapshot(CppTools::CppModelManager::instance()->snapshot())
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
index 2637efc51d..685febfe69 100644
--- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
+++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
@@ -344,7 +344,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
BaseTextEditor *currentTextEditor = dynamic_cast<BaseTextEditor*>(currentEditor);
QVERIFY(currentTextEditor);
- QCOMPARE(currentTextEditor->document()->filePath(), targetTestFile->filePath());
+ QCOMPARE(currentTextEditor->document()->filePath().toString(), targetTestFile->filePath());
int expectedLine, expectedColumn;
currentTextEditor->convertPosition(targetTestFile->m_targetCursorPosition,
&expectedLine, &expectedColumn);