QuickFix: Move helpers from QuickFixData to RefactoringFile.

Makes them easy to use everywhere. Also when calling
QuickFixData::textOf and friends, it wasn't really clear which file
they would run on.
This commit is contained in:
Christian Kamm
2010-08-13 12:49:11 +02:00
parent bbe64796a0
commit 7a5df3c39d
14 changed files with 212 additions and 318 deletions

View File

@@ -40,12 +40,40 @@ class ModelManagerInterface;
namespace QmlJSEditor {
class QmlJSRefactoringChanges;
class QmlJSRefactoringFile: public TextEditor::RefactoringFile
{
public:
QmlJSRefactoringFile();
QmlJSRefactoringFile(const QString &fileName, QmlJSRefactoringChanges *refactoringChanges);
QmlJSRefactoringFile(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document);
QmlJS::Document::Ptr qmljsDocument() const;
/*!
\returns the offset in the document for the start position of the given
source location.
*/
unsigned startOf(const QmlJS::AST::SourceLocation &loc) const;
private:
QmlJSRefactoringChanges *refactoringChanges() const;
mutable QmlJS::Document::Ptr m_qmljsDocument;
};
class QmlJSRefactoringChanges: public TextEditor::RefactoringChanges
{
public:
QmlJSRefactoringChanges(QmlJS::ModelManagerInterface *modelManager,
const QmlJS::Snapshot &snapshot);
const QmlJS::Snapshot &snapshot() const;
QmlJSRefactoringFile file(const QString &fileName);
private:
virtual void indentSelection(const QTextCursor &selection) const;
virtual void fileChanged(const QString &fileName);