Commit 8a6d767a authored by Christian Kamm's avatar Christian Kamm

Refactoring changes: Cleanup and improvements.

Previously RefactoringFiles were usually passed around by value.
However, since a RefactoringFile may sometimes own a QTextDocument
(when it was read from a file), that's not great and caused the
file to be reread after every copy.

With this change RefactoringFile becomes noncopyable and is always
owned by a shared pointer.

This change also allowed having const RefactoringFiles which is
useful because they can be safely used from other threads. See
CppRefactoringChanges::fileNoEditor.

Change-Id: I9045921d6d0f6349f9558ff2a3d8317ea172193b
Reviewed-on: http://codereview.qt.nokia.com/3084Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent a07acad5
......@@ -45,8 +45,8 @@ using namespace CPlusPlus;
QList<AST *> ASTPath::operator()(int line, int column)
{
_nodes.clear();
_line = line + 1;
_column = column + 1;
_line = line;
_column = column;
if (_doc) {
if (TranslationUnit *unit = _doc->translationUnit())
......
......@@ -54,9 +54,9 @@ public:
{}
QList<AST *> operator()(const QTextCursor &cursor)
{ return this->operator()(cursor.blockNumber(), cursor.positionInBlock()); }
{ return this->operator()(cursor.blockNumber() + 1, cursor.positionInBlock() + 1); }
/// line and column are 0-based!
/// line and column are 1-based!
QList<AST *> operator()(int line, int column);
#ifdef DEBUG_AST_PATH
......
......@@ -116,15 +116,17 @@ public:
}
virtual void performChanges(CppRefactoringFile *currentFile, CppRefactoringChanges *)
virtual void performChanges(const CppRefactoringFilePtr &currentFile,
const CppRefactoringChanges &)
{
ChangeSet changes;
int start = currentFile->endOf(compoundStatement->lbrace_token);
changes.insert(start, QLatin1String("\ncase ")
+ values.join(QLatin1String(":\nbreak;\ncase "))
+ QLatin1String(":\nbreak;"));
currentFile->change(changes);
currentFile->indent(currentFile->range(compoundStatement));
currentFile->setChangeSet(changes);
currentFile->appendIndentRange(currentFile->range(compoundStatement));
currentFile->apply();
}
CompoundStatementAST *compoundStatement;
......
......@@ -100,7 +100,7 @@ public:
CPlusPlus::DeclarationAST *sourceDeclaration;
CPlusPlus::FunctionDeclaratorAST *sourceFunctionDeclarator;
QSharedPointer<CppTools::CppRefactoringFile> targetFile;
CppTools::CppRefactoringFileConstPtr targetFile;
CPlusPlus::Function *targetFunction;
CPlusPlus::DeclarationAST *targetDeclaration;
CPlusPlus::FunctionDeclaratorAST *targetFunctionDeclarator;
......
......@@ -80,25 +80,24 @@ public:
"Add %1 Declaration").arg(type));
}
void performChanges(CppRefactoringFile *, CppRefactoringChanges *refactoring)
void performChanges(const CppRefactoringFilePtr &,
const CppRefactoringChanges &refactoring)
{
InsertionPointLocator locator(refactoring);
const InsertionLocation loc = locator.methodDeclarationInClass(
m_targetFileName, m_targetSymbol, m_xsSpec);
Q_ASSERT(loc.isValid());
CppRefactoringFile targetFile = refactoring->file(m_targetFileName);
int targetPosition1 = targetFile.position(loc.line(), loc.column());
int targetPosition2 = qMax(0, targetFile.position(loc.line(), 1) - 1);
CppRefactoringFilePtr targetFile = refactoring.file(m_targetFileName);
int targetPosition1 = targetFile->position(loc.line(), loc.column());
int targetPosition2 = qMax(0, targetFile->position(loc.line(), 1) - 1);
Utils::ChangeSet target;
target.insert(targetPosition1, loc.prefix() + m_decl);
targetFile.change(target);
targetFile.indent(Utils::ChangeSet::Range(targetPosition2, targetPosition1));
const int prefixLineCount = loc.prefix().count(QLatin1Char('\n'));
refactoring->activateEditor(m_targetFileName, loc.line() + prefixLineCount,
qMax(((int) loc.column()) - 1, 0));
targetFile->setChangeSet(target);
targetFile->appendIndentRange(Utils::ChangeSet::Range(targetPosition2, targetPosition1));
targetFile->setOpenEditor(true, targetPosition1);
targetFile->apply();
}
private:
......@@ -114,7 +113,7 @@ QList<CppQuickFixOperation::Ptr> DeclFromDef::match(
const QSharedPointer<const Internal::CppQuickFixAssistInterface> &interface)
{
const QList<AST *> &path = interface->path();
const CppRefactoringFile &file = interface->currentFile();
CppRefactoringFilePtr file = interface->currentFile();
FunctionDefinitionAST *funDef = 0;
int idx = 0;
......@@ -122,7 +121,7 @@ QList<CppQuickFixOperation::Ptr> DeclFromDef::match(
AST *node = path.at(idx);
if (idx > 1) {
if (DeclaratorIdAST *declId = node->asDeclaratorId()) {
if (file.isCursorOn(declId)) {
if (file->isCursorOn(declId)) {
if (FunctionDefinitionAST *candidate = path.at(idx - 2)->asFunctionDefinition()) {
if (funDef) {
return noResult();
......@@ -230,12 +229,12 @@ public:
.arg(dir.relativeFilePath(m_loc.fileName())));
}
void performChanges(CppRefactoringFile *,
CppRefactoringChanges *refactoring)
void performChanges(const CppRefactoringFilePtr &,
const CppRefactoringChanges &refactoring)
{
Q_ASSERT(m_loc.isValid());
CppRefactoringFile targetFile = refactoring->file(m_loc.fileName());
CppRefactoringFilePtr targetFile = refactoring.file(m_loc.fileName());
Overview oo;
oo.setShowFunctionSignatures(true);
......@@ -243,7 +242,7 @@ public:
oo.setShowArgumentNames(true);
// make target lookup context
Document::Ptr targetDoc = targetFile.cppDocument();
Document::Ptr targetDoc = targetFile->cppDocument();
Scope *targetScope = targetDoc->scopeAt(m_loc.line(), m_loc.column());
LookupContext targetContext(targetDoc, assistInterface()->snapshot());
ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope);
......@@ -272,18 +271,15 @@ public:
QString defText = oo.prettyType(tn, name) + "\n{\n}";
int targetPos = targetFile.position(m_loc.line(), m_loc.column());
int targetPos2 = qMax(0, targetFile.position(m_loc.line(), 1) - 1);
int targetPos = targetFile->position(m_loc.line(), m_loc.column());
int targetPos2 = qMax(0, targetFile->position(m_loc.line(), 1) - 1);
Utils::ChangeSet target;
target.insert(targetPos, m_loc.prefix() + defText + m_loc.suffix());
targetFile.change(target);
targetFile.indent(Utils::ChangeSet::Range(targetPos2, targetPos));
const int prefixLineCount = m_loc.prefix().count(QLatin1Char('\n'));
refactoring->activateEditor(m_loc.fileName(),
m_loc.line() + prefixLineCount,
0);
targetFile->setChangeSet(target);
targetFile->appendIndentRange(Utils::ChangeSet::Range(targetPos2, targetPos));
targetFile->setOpenEditor(true, targetPos);
targetFile->apply();
}
private:
......@@ -297,7 +293,7 @@ QList<CppQuickFixOperation::Ptr> DefFromDecl::match(
const QSharedPointer<const Internal::CppQuickFixAssistInterface> &interface)
{
const QList<AST *> &path = interface->path();
const CppRefactoringFile &file = interface->currentFile();
CppRefactoringFilePtr file = interface->currentFile();
int idx = path.size() - 1;
for (; idx >= 0; --idx) {
......@@ -311,9 +307,9 @@ QList<CppQuickFixOperation::Ptr> DefFromDecl::match(
&& decl->enclosingScope()
&& decl->enclosingScope()->isClass()) {
DeclaratorAST *declarator = simpleDecl->declarator_list->value;
if (file.isCursorOn(declarator->core_declarator)) {
if (file->isCursorOn(declarator->core_declarator)) {
CppRefactoringChanges refactoring(interface->snapshot());
InsertionPointLocator locator(&refactoring);
InsertionPointLocator locator(refactoring);
QList<CppQuickFixOperation::Ptr> results;
foreach (const InsertionLocation &loc, locator.methodDefinition(decl)) {
if (loc.isValid())
......
......@@ -71,24 +71,23 @@ QList<CppQuickFixOperation::Ptr> InsertQtPropertyMembers::match(
if (!klass)
return noResult();
CppRefactoringChanges refactoring(interface->snapshot());
const CppRefactoringFile &file = refactoring.file(interface->file()->fileName());
const QString propertyName = file.textOf(qtPropertyDeclaration->property_name);
CppRefactoringFilePtr file = interface->currentFile();
const QString propertyName = file->textOf(qtPropertyDeclaration->property_name);
QString getterName;
QString setterName;
QString signalName;
int generateFlags = 0;
for (QtPropertyDeclarationItemListAST *it = qtPropertyDeclaration->property_declaration_item_list;
it; it = it->next) {
const QString tokenString = file.tokenAt(it->value->item_name_token).spell();
const QString tokenString = file->tokenAt(it->value->item_name_token).spell();
if (tokenString == QLatin1String("READ")) {
getterName = file.textOf(it->value->expression);
getterName = file->textOf(it->value->expression);
generateFlags |= GenerateGetter;
} else if (tokenString == QLatin1String("WRITE")) {
setterName = file.textOf(it->value->expression);
setterName = file->textOf(it->value->expression);
generateFlags |= GenerateSetter;
} else if (tokenString == QLatin1String("NOTIFY")) {
signalName = file.textOf(it->value->expression);
signalName = file->textOf(it->value->expression);
generateFlags |= GenerateSignal;
}
}
......@@ -143,7 +142,8 @@ InsertQtPropertyMembers::Operation::Operation(
setDescription(desc);
}
void InsertQtPropertyMembers::Operation::performChanges(CppRefactoringFile *file, CppRefactoringChanges *refactoring)
void InsertQtPropertyMembers::Operation::performChanges(const CppRefactoringFilePtr &file,
const CppRefactoringChanges &refactoring)
{
InsertionPointLocator locator(refactoring);
Utils::ChangeSet declarations;
......@@ -190,13 +190,14 @@ void InsertQtPropertyMembers::Operation::performChanges(CppRefactoringFile *file
insertAndIndent(file, &declarations, storageLoc, storageDeclaration);
}
file->change(declarations);
file->setChangeSet(declarations);
file->apply();
}
void InsertQtPropertyMembers::Operation::insertAndIndent(RefactoringFile *file, ChangeSet *changeSet, const InsertionLocation &loc, const QString &text)
void InsertQtPropertyMembers::Operation::insertAndIndent(const RefactoringFilePtr &file, ChangeSet *changeSet, const InsertionLocation &loc, const QString &text)
{
int targetPosition1 = file->position(loc.line(), loc.column());
int targetPosition2 = qMax(0, file->position(loc.line(), 1) - 1);
changeSet->insert(targetPosition1, loc.prefix() + text + loc.suffix());
file->indent(Utils::ChangeSet::Range(targetPosition2, targetPosition1));
file->appendIndentRange(Utils::ChangeSet::Range(targetPosition2, targetPosition1));
}
......@@ -44,6 +44,7 @@ class Class;
namespace TextEditor {
class RefactoringFile;
typedef QSharedPointer<RefactoringFile> RefactoringFilePtr;
}
namespace Utils {
......@@ -83,11 +84,11 @@ private:
const QString &getterName, const QString &setterName, const QString &signalName,
const QString &storageName);
virtual void performChanges(CppTools::CppRefactoringFile *file,
CppTools::CppRefactoringChanges *refactoring);
virtual void performChanges(const CppTools::CppRefactoringFilePtr &file,
const CppTools::CppRefactoringChanges &refactoring);
private:
void insertAndIndent(TextEditor::RefactoringFile *file, Utils::ChangeSet *changeSet,
void insertAndIndent(const TextEditor::RefactoringFilePtr &file, Utils::ChangeSet *changeSet,
const CppTools::InsertionLocation &loc, const QString &text);
CPlusPlus::QtPropertyDeclarationAST *m_declaration;
......
......@@ -70,9 +70,9 @@ CppQuickFixOperation::~CppQuickFixOperation()
void CppQuickFixOperation::perform()
{
CppRefactoringChanges refactoring(m_interface->snapshot());
CppRefactoringFile current = refactoring.file(fileName());
CppRefactoringFilePtr current = refactoring.file(fileName());
performChanges(&current, &refactoring);
performChanges(current, refactoring);
}
const CppQuickFixAssistInterface *CppQuickFixOperation::assistInterface() const
......
......@@ -40,6 +40,7 @@ namespace CppTools {
class CppModelManagerInterface;
class CppRefactoringFile;
class CppRefactoringChanges;
typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
} // namespace CppTools
namespace ExtensionSystem {
......@@ -63,8 +64,8 @@ public:
virtual void perform();
protected:
virtual void performChanges(CppTools::CppRefactoringFile *currentFile,
CppTools::CppRefactoringChanges *refactoring) = 0;
virtual void performChanges(const CppTools::CppRefactoringFilePtr &currentFile,
const CppTools::CppRefactoringChanges &refactoring) = 0;
QString fileName() const;
......
......@@ -105,6 +105,7 @@ CppQuickFixAssistInterface::CppQuickFixAssistInterface(CPPEditorWidget *editor,
, m_editor(editor)
, m_semanticInfo(editor->semanticInfo())
, m_snapshot(CPlusPlus::CppModelManagerInterface::instance()->snapshot())
, m_currentFile(CppRefactoringChanges::file(editor, m_semanticInfo.doc))
, m_context(m_semanticInfo.doc, m_snapshot)
{
CPlusPlus::ASTPath astPath(m_semanticInfo.doc);
......@@ -136,19 +137,17 @@ CPPEditorWidget *CppQuickFixAssistInterface::editor() const
return m_editor;
}
const CppRefactoringFile CppQuickFixAssistInterface::currentFile() const
CppRefactoringFilePtr CppQuickFixAssistInterface::currentFile() const
{
CppRefactoringFile file(m_editor);
file.setCppDocument(m_semanticInfo.doc);
return file;
return m_currentFile;
}
bool CppQuickFixAssistInterface::isCursorOn(unsigned tokenIndex) const
{
return currentFile().isCursorOn(tokenIndex);
return currentFile()->isCursorOn(tokenIndex);
}
bool CppQuickFixAssistInterface::isCursorOn(const CPlusPlus::AST *ast) const
{
return currentFile().isCursorOn(ast);
return currentFile()->isCursorOn(ast);
}
......@@ -44,6 +44,7 @@
namespace CppTools {
class CppRefactoringFile;
typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
}
namespace CppEditor {
......@@ -62,7 +63,7 @@ public:
const CPlusPlus::LookupContext &context() const;
CPPEditorWidget *editor() const;
const CppTools::CppRefactoringFile currentFile() const;
CppTools::CppRefactoringFilePtr currentFile() const;
bool isCursorOn(unsigned tokenIndex) const;
bool isCursorOn(const CPlusPlus::AST *ast) const;
......@@ -71,6 +72,7 @@ private:
CPPEditorWidget *m_editor;
CppEditor::Internal::SemanticInfo m_semanticInfo;
CPlusPlus::Snapshot m_snapshot;
CppTools::CppRefactoringFilePtr m_currentFile;
CPlusPlus::LookupContext m_context;
QList<CPlusPlus::AST *> m_path;
};
......
This diff is collapsed.
......@@ -49,64 +49,101 @@ using namespace CPlusPlus;
using namespace CppTools;
using namespace Utils;
class CppTools::CppRefactoringChangesData : public TextEditor::RefactoringChangesData
{
public:
CppRefactoringChangesData(const Snapshot &snapshot)
: m_snapshot(snapshot)
, m_modelManager(Internal::CppModelManager::instance())
, m_workingCopy(m_modelManager->workingCopy())
{}
virtual void indentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const
{
// ### shares code with CPPEditor::indent()
QTextDocument *doc = selection.document();
QTextBlock block = doc->findBlock(selection.selectionStart());
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor);
// TODO: add similar method like above one
CppTools::QtStyleCodeFormatter codeFormatter(tabSettings,
CppToolsSettings::instance()->cppCodeStylePreferences()->settings());
codeFormatter.updateStateUntil(block);
do {
int indent;
int padding;
codeFormatter.indentFor(block, &indent, &padding);
tabSettings.indentLine(block, indent + padding, padding);
codeFormatter.updateLineStateChange(block);
block = block.next();
} while (block.isValid() && block != end);
}
virtual void fileChanged(const QString &fileName)
{
m_modelManager->updateSourceFiles(QStringList(fileName));
}
CPlusPlus::Snapshot m_snapshot;
CPlusPlus::CppModelManagerInterface *m_modelManager;
CPlusPlus::CppModelManagerInterface::WorkingCopy m_workingCopy;
};
CppRefactoringChanges::CppRefactoringChanges(const Snapshot &snapshot)
: m_snapshot(snapshot)
, m_modelManager(Internal::CppModelManager::instance())
: RefactoringChanges(new CppRefactoringChangesData(snapshot))
{
Q_ASSERT(m_modelManager);
m_workingCopy = m_modelManager->workingCopy();
}
const Snapshot &CppRefactoringChanges::snapshot() const
CppRefactoringChangesData *CppRefactoringChanges::data() const
{
return m_snapshot;
return static_cast<CppRefactoringChangesData *>(m_data.data());
}
CppRefactoringFile CppRefactoringChanges::file(const QString &fileName)
CppRefactoringFilePtr CppRefactoringChanges::file(TextEditor::BaseTextEditorWidget *editor, const Document::Ptr &document)
{
return CppRefactoringFile(fileName, this);
CppRefactoringFilePtr result(new CppRefactoringFile(editor));
result->setCppDocument(document);
return result;
}
void CppRefactoringChanges::indentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const
CppRefactoringFilePtr CppRefactoringChanges::file(const QString &fileName) const
{
// ### shares code with CPPEditor::indent()
QTextDocument *doc = selection.document();
CppRefactoringFilePtr result(new CppRefactoringFile(fileName, m_data));
return result;
}
QTextBlock block = doc->findBlock(selection.selectionStart());
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const QString &fileName) const
{
QTextDocument *document = 0;
if (data()->m_workingCopy.contains(fileName))
document = new QTextDocument(data()->m_workingCopy.source(fileName));
CppRefactoringFilePtr result(new CppRefactoringFile(document, fileName));
result->m_data = m_data;
const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor);
// TODO: add similar method like above one
CppTools::QtStyleCodeFormatter codeFormatter(tabSettings,
CppToolsSettings::instance()->cppCodeStylePreferences()->settings());
codeFormatter.updateStateUntil(block);
Document::Ptr cppDocument = data()->m_snapshot.document(fileName);
if (cppDocument)
result->setCppDocument(cppDocument);
do {
int indent;
int padding;
codeFormatter.indentFor(block, &indent, &padding);
tabSettings.indentLine(block, indent + padding, padding);
codeFormatter.updateLineStateChange(block);
block = block.next();
} while (block.isValid() && block != end);
return result;
}
void CppRefactoringChanges::fileChanged(const QString &fileName)
const Snapshot &CppRefactoringChanges::snapshot() const
{
m_modelManager->updateSourceFiles(QStringList(fileName));
return data()->m_snapshot;
}
CppRefactoringFile::CppRefactoringFile()
{ }
CppRefactoringFile::CppRefactoringFile(const QString &fileName, CppRefactoringChanges *refactoringChanges)
: RefactoringFile(fileName, refactoringChanges)
CppRefactoringFile::CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data)
: RefactoringFile(fileName, data)
{
const Snapshot &snapshot = refactoringChanges->snapshot();
const Snapshot &snapshot = this->data()->m_snapshot;
m_cppDocument = snapshot.document(fileName);
}
......@@ -124,7 +161,7 @@ Document::Ptr CppRefactoringFile::cppDocument() const
!m_cppDocument->translationUnit()->ast()) {
const QString source = document()->toPlainText();
const QString name = fileName();
const Snapshot &snapshot = refactoringChanges()->snapshot();
const Snapshot &snapshot = data()->m_snapshot;
const QByteArray contents = snapshot.preprocessedCode(source, name);
m_cppDocument = snapshot.documentFromSource(contents, name);
......@@ -233,7 +270,13 @@ const Token &CppRefactoringFile::tokenAt(unsigned index) const
return cppDocument()->translationUnit()->tokenAt(index);
}
CppRefactoringChanges *CppRefactoringFile::refactoringChanges() const
CppRefactoringChangesData *CppRefactoringFile::data() const
{
return static_cast<CppRefactoringChangesData *>(m_data.data());
}
void CppRefactoringFile::fileChanged()
{
return static_cast<CppRefactoringChanges *>(m_refactoringChanges);
m_cppDocument.clear();
RefactoringFile::fileChanged();
}
......@@ -45,14 +45,14 @@
namespace CppTools {
class CppRefactoringChanges;
class CppRefactoringFile;
class CppRefactoringChangesData;
typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
typedef QSharedPointer<const CppRefactoringFile> CppRefactoringFileConstPtr;
class CPPTOOLS_EXPORT CppRefactoringFile: public TextEditor::RefactoringFile
{
public:
CppRefactoringFile();
CppRefactoringFile(QTextDocument *document, const QString &fileName = QString());
CppRefactoringFile(TextEditor::BaseTextEditorWidget *editor);
CPlusPlus::Document::Ptr cppDocument() const;
void setCppDocument(CPlusPlus::Document::Ptr document);
......@@ -78,10 +78,12 @@ public:
QString textOf(const CPlusPlus::AST *ast) const;
protected:
CppRefactoringFile(const QString &fileName, CppRefactoringChanges *refactoringChanges);
CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
CppRefactoringFile(QTextDocument *document, const QString &fileName);
CppRefactoringFile(TextEditor::BaseTextEditorWidget *editor);
private:
CppRefactoringChanges *refactoringChanges() const;
CppRefactoringChangesData *data() const;
virtual void fileChanged();
mutable CPlusPlus::Document::Ptr m_cppDocument;
......@@ -93,21 +95,16 @@ class CPPTOOLS_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChang
public:
CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
const CPlusPlus::Snapshot &snapshot() const;
CppRefactoringFile file(const QString &fileName);
static CppRefactoringFilePtr file(TextEditor::BaseTextEditorWidget *editor,
const CPlusPlus::Document::Ptr &document);
CppRefactoringFilePtr file(const QString &fileName) const;
// safe to use from non-gui threads
CppRefactoringFileConstPtr fileNoEditor(const QString &fileName) const;
private:
virtual void indentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const;
virtual void fileChanged(const QString &fileName);
const CPlusPlus::Snapshot &snapshot() const;
private:
CPlusPlus::Document::Ptr m_thisDocument;
CPlusPlus::Snapshot m_snapshot;
CPlusPlus::LookupContext m_context;
CPlusPlus::CppModelManagerInterface *m_modelManager;
CPlusPlus::CppModelManagerInterface::WorkingCopy m_workingCopy;
CppRefactoringChangesData *data() const;
};
} // namespace CppTools
......
......@@ -287,7 +287,7 @@ InsertionLocation::InsertionLocation(const QString &fileName,
, m_column(column)
{}
InsertionPointLocator::InsertionPointLocator(CppRefactoringChanges *refactoringChanges)
InsertionPointLocator::InsertionPointLocator(const CppRefactoringChanges &refactoringChanges)
: m_refactoringChanges(refactoringChanges)
{
}
......@@ -297,7 +297,7 @@ InsertionLocation InsertionPointLocator::methodDeclarationInClass(
const Class *clazz,
AccessSpec xsSpec) const
{
const Document::Ptr doc = m_refactoringChanges->file(fileName).cppDocument();
const Document::Ptr doc = m_refactoringChanges.file(fileName)->cppDocument();
if (doc) {
FindInClass find(doc, clazz, xsSpec);
return find();
......@@ -434,11 +434,11 @@ QList<InsertionLocation> InsertionPointLocator::methodDefinition(
target = candidate;
}
Document::Ptr doc = m_refactoringChanges