Commit 27f6b2ce authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Renamed CppRefactoringChanges::parsedDocumentForFile().

parent eb749ec3
......@@ -933,8 +933,7 @@ int CppQuickFixOperation::match(TextEditor::QuickFixState *state)
_document = s->info.doc;
if (_refactoringChanges)
delete _refactoringChanges;
CPPEditor *cppEditor = qobject_cast<CPPEditor*>(editor());
_refactoringChanges = new CppRefactoringChanges(s->info.snapshot, cppEditor->modelManager());
_refactoringChanges = new CppRefactoringChanges(s->info.snapshot);
return match(s->path);
}
......
......@@ -34,13 +34,12 @@ using namespace CppTools;
using namespace TextEditor;
using namespace CppEditor;
CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot,
CppModelManagerInterface *modelManager)
CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot)
: m_snapshot(snapshot)
, m_modelManager(modelManager)
, m_workingCopy(modelManager->workingCopy())
, m_modelManager(CppTools::CppModelManagerInterface::instance())
{
Q_ASSERT(modelManager);
Q_ASSERT(m_modelManager);
m_workingCopy = m_modelManager->workingCopy();
}
QStringList CppRefactoringChanges::apply()
......@@ -50,17 +49,14 @@ QStringList CppRefactoringChanges::apply()
return changedFiles;
}
Document::Ptr CppRefactoringChanges::parsedDocumentForFile(const QString &fileName) const
Document::Ptr CppRefactoringChanges::document(const QString &fileName) const
{
Document::Ptr doc = m_snapshot.document(fileName);
QString source;
unsigned editorRevision = 0;
if (m_workingCopy.contains(fileName)) {
QPair<QString, unsigned> workingCopy = m_workingCopy.get(fileName);
if (doc && doc->editorRevision() == workingCopy.second)
return doc;
else
source = workingCopy.first;
const QPair<QString, unsigned> workingCopy = m_workingCopy.get(fileName);
source = workingCopy.first;
editorRevision = workingCopy.second;
} else {
QFile file(fileName);
if (! file.open(QFile::ReadOnly))
......@@ -71,7 +67,8 @@ Document::Ptr CppRefactoringChanges::parsedDocumentForFile(const QString &fileNa
}
const QByteArray contents = m_snapshot.preprocessedCode(source, fileName);
doc = m_snapshot.documentFromSource(contents, fileName);
Document::Ptr doc = m_snapshot.documentFromSource(contents, fileName);
doc->setEditorRevision(editorRevision);
doc->check();
return doc;
}
......@@ -42,14 +42,14 @@ namespace CppEditor {
class CPPEDITOR_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChanges
{
public:
CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot, CppTools::CppModelManagerInterface *modelManager);
CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
virtual QStringList apply();
const CPlusPlus::Snapshot &snapshot() const
{ return m_snapshot; }
CPlusPlus::Document::Ptr parsedDocumentForFile(const QString &fileName) const;
CPlusPlus::Document::Ptr document(const QString &fileName) const;
private:
CPlusPlus::Snapshot m_snapshot;
......
......@@ -103,7 +103,7 @@ QStringList RefactoringChanges::apply()
}
QTextCursor changeSetCursor = editor->textCursor();
Utils::ChangeSet changeSet = m_changesByFile[fileName];
Utils::ChangeSet changeSet = m_changesByFile.value(fileName);
changeSet.apply(&changeSetCursor);
foreach (const CursorPair &cursorPair, cursorPairs) {
......
......@@ -57,7 +57,7 @@ public:
virtual QStringList apply();
int positionInFile(const QString &fileName, int line, int column = 0) const;
Q_DECL_DEPRECATED int positionInFile(const QString &fileName, int line, int column = 0) const;
static BaseTextEditor *editorForFile(const QString &fileName,
bool openIfClosed = false);
......
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