QuickFix: Introduce CppRefactoringFile.

This commit is contained in:
Christian Kamm
2010-08-13 11:48:29 +02:00
parent 6c76866b12
commit bbe64796a0
8 changed files with 200 additions and 43 deletions

View File

@@ -30,6 +30,7 @@
#ifndef CPPREFACTORINGCHANGES_H
#define CPPREFACTORINGCHANGES_H
#include <ASTfwd.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/LookupContext.h>
@@ -40,6 +41,43 @@
namespace CppEditor {
class CppRefactoringChanges;
class CPPEDITOR_EXPORT CppRefactoringFile: public TextEditor::RefactoringFile
{
public:
CppRefactoringFile();
CppRefactoringFile(const QString &fileName, CppRefactoringChanges *refactoringChanges);
CPlusPlus::Document::Ptr cppDocument() const;
CPlusPlus::Scope *scopeAt(unsigned index) const;
bool isCursorOn(unsigned tokenIndex) const;
bool isCursorOn(const CPlusPlus::AST *ast) const;
Range range(int start, int end) const;
Range range(unsigned tokenIndex) const;
Range range(CPlusPlus::AST *ast) const;
const CPlusPlus::Token &tokenAt(unsigned index) const;
int startOf(unsigned index) const;
int startOf(const CPlusPlus::AST *ast) const;
int endOf(unsigned index) const;
int endOf(const CPlusPlus::AST *ast) const;
void startAndEndOf(unsigned index, int *start, int *end) const;
using TextEditor::RefactoringFile::textOf;
QString textOf(const CPlusPlus::AST *ast) const;
private:
CppRefactoringChanges *refactoringChanges() const;
mutable CPlusPlus::Document::Ptr m_cppDocument;
};
class CPPEDITOR_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChanges
{
public:
@@ -50,7 +88,7 @@ public:
const CPlusPlus::Snapshot &snapshot() const;
const CPlusPlus::LookupContext &context() const;
CPlusPlus::Document::Ptr document(const TextEditor::RefactoringFile &file) const;
CppRefactoringFile file(const QString &fileName);
private:
virtual void indentSelection(const QTextCursor &selection) const;