forked from qt-creator/qt-creator
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:
@@ -45,6 +45,16 @@ QmlJSRefactoringChanges::QmlJSRefactoringChanges(ModelManagerInterface *modelMan
|
||||
Q_ASSERT(modelManager);
|
||||
}
|
||||
|
||||
const Snapshot &QmlJSRefactoringChanges::snapshot() const
|
||||
{
|
||||
return m_snapshot;
|
||||
}
|
||||
|
||||
QmlJSRefactoringFile QmlJSRefactoringChanges::file(const QString &fileName)
|
||||
{
|
||||
return QmlJSRefactoringFile(fileName, this);
|
||||
}
|
||||
|
||||
void QmlJSRefactoringChanges::indentSelection(const QTextCursor &selection) const
|
||||
{
|
||||
// ### shares code with QmlJSTextEditor::indent
|
||||
@@ -68,3 +78,43 @@ void QmlJSRefactoringChanges::fileChanged(const QString &fileName)
|
||||
{
|
||||
m_modelManager->updateSourceFiles(QStringList(fileName), true);
|
||||
}
|
||||
|
||||
|
||||
QmlJSRefactoringFile::QmlJSRefactoringFile()
|
||||
{ }
|
||||
|
||||
QmlJSRefactoringFile::QmlJSRefactoringFile(const QString &fileName, QmlJSRefactoringChanges *refactoringChanges)
|
||||
: RefactoringFile(fileName, refactoringChanges)
|
||||
{ }
|
||||
|
||||
QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document)
|
||||
: RefactoringFile()
|
||||
, m_qmljsDocument(document)
|
||||
{
|
||||
m_fileName = document->fileName();
|
||||
m_editor = editor;
|
||||
}
|
||||
|
||||
Document::Ptr QmlJSRefactoringFile::qmljsDocument() const
|
||||
{
|
||||
if (!m_qmljsDocument) {
|
||||
const QString source = document()->toPlainText();
|
||||
const QString name = fileName();
|
||||
const Snapshot &snapshot = refactoringChanges()->snapshot();
|
||||
|
||||
m_qmljsDocument = snapshot.documentFromSource(source, name);
|
||||
m_qmljsDocument->parse();
|
||||
}
|
||||
|
||||
return m_qmljsDocument;
|
||||
}
|
||||
|
||||
unsigned QmlJSRefactoringFile::startOf(const QmlJS::AST::SourceLocation &loc) const
|
||||
{
|
||||
return position(loc.startLine, loc.startColumn);
|
||||
}
|
||||
|
||||
QmlJSRefactoringChanges *QmlJSRefactoringFile::refactoringChanges() const
|
||||
{
|
||||
return static_cast<QmlJSRefactoringChanges *>(m_refactoringChanges);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user