Commit 2ede9773 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Introduced token-based operations for QML/JS quick-fixes.

parent 31748e73
......@@ -33,6 +33,35 @@
using namespace QmlJSEditor::Internal;
QmlJSQuickFixOperation::QmlJSQuickFixOperation(TextEditor::BaseTextEditor *editor)
: TextEditor::QuickFixOperation(editor)
{
}
QmlJSQuickFixOperation::~QmlJSQuickFixOperation()
{
}
void QmlJSQuickFixOperation::move(const QmlJS::AST::SourceLocation &loc, int to)
{
move(position(loc.startColumn, loc.startColumn), to);
}
void QmlJSQuickFixOperation::replace(const QmlJS::AST::SourceLocation &loc, const QString &replacement)
{
replace(position(loc.startLine, loc.startColumn), replacement);
}
void QmlJSQuickFixOperation::remove(const QmlJS::AST::SourceLocation &loc)
{
remove(position(loc.startLine, loc.startColumn));
}
void QmlJSQuickFixOperation::copy(const QmlJS::AST::SourceLocation &loc, int to)
{
copy(position(loc.startLine, loc.startColumn), to);
}
QmlJSQuickFixCollector::QmlJSQuickFixCollector()
{
}
......
......@@ -31,6 +31,7 @@
#define QMLJSQUICKFIX_H
#include <texteditor/quickfix.h>
#include <qmljs/parser/qmljsastfwd_p.h>
namespace QmlJSEditor {
......@@ -38,6 +39,31 @@ class ModelManagerInterface;
namespace Internal {
class QmlJSQuickFixOperation: public TextEditor::QuickFixOperation
{
Q_DISABLE_COPY(QmlJSQuickFixOperation)
public:
QmlJSQuickFixOperation(TextEditor::BaseTextEditor *editor);
virtual ~QmlJSQuickFixOperation();
protected:
using TextEditor::QuickFixOperation::move;
using TextEditor::QuickFixOperation::replace;
using TextEditor::QuickFixOperation::insert;
using TextEditor::QuickFixOperation::remove;
using TextEditor::QuickFixOperation::flip;
using TextEditor::QuickFixOperation::copy;
using TextEditor::QuickFixOperation::textOf;
using TextEditor::QuickFixOperation::charAt;
// token based operations
void move(const QmlJS::AST::SourceLocation &loc, int to);
void replace(const QmlJS::AST::SourceLocation &loc, const QString &replacement);
void remove(const QmlJS::AST::SourceLocation &loc);
void copy(const QmlJS::AST::SourceLocation &loc, int to);
};
class QmlJSQuickFixCollector: public TextEditor::QuickFixCollector
{
Q_OBJECT
......
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