diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-06-07 12:12:07 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-06-07 12:16:45 +0200 |
commit | f5dae8bc9f8ab63c3f16579906d82bafcbcac5c7 (patch) | |
tree | e0f6fe29cf48f415a35247697e12033b4a024e3c /src/plugins/qmljseditor/qmljsquickfix.cpp | |
parent | c3caf282cec12d2a2db75e4b9e1a635641a3ac4a (diff) | |
download | qt-creator-f5dae8bc9f8ab63c3f16579906d82bafcbcac5c7.tar.gz |
Refactored the quickfix engine.
Diffstat (limited to 'src/plugins/qmljseditor/qmljsquickfix.cpp')
-rw-r--r-- | src/plugins/qmljseditor/qmljsquickfix.cpp | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/plugins/qmljseditor/qmljsquickfix.cpp b/src/plugins/qmljseditor/qmljsquickfix.cpp index cd64160934..db4fb16ab7 100644 --- a/src/plugins/qmljseditor/qmljsquickfix.cpp +++ b/src/plugins/qmljseditor/qmljsquickfix.cpp @@ -29,10 +29,20 @@ #include "qmljsquickfix.h" #include "qmljseditor.h" +#include "qmljs/parser/qmljsast_p.h" +#include <QtGui/QApplication> #include <QtCore/QDebug> using namespace QmlJSEditor::Internal; +class QmlJSQuickFixState: public TextEditor::QuickFixState +{ +public: + SemanticInfo semanticInfo; +}; + + + QmlJSQuickFixOperation::QmlJSQuickFixOperation(TextEditor::BaseTextEditor *editor) : TextEditor::QuickFixOperation(editor) { @@ -42,6 +52,33 @@ QmlJSQuickFixOperation::~QmlJSQuickFixOperation() { } +QmlJS::Document::Ptr QmlJSQuickFixOperation::document() const +{ + return _semanticInfo.document; +} + +const QmlJS::Snapshot &QmlJSQuickFixOperation::snapshot() const +{ + return _semanticInfo.snapshot; +} + +const SemanticInfo &QmlJSQuickFixOperation::semanticInfo() const +{ + return _semanticInfo; +} + +int QmlJSQuickFixOperation::match(TextEditor::QuickFixState *state) +{ + QmlJSQuickFixState *s = static_cast<QmlJSQuickFixState *>(state); + _semanticInfo = s->semanticInfo; + return check(); +} + +unsigned QmlJSQuickFixOperation::position(const QmlJS::AST::SourceLocation &loc) const +{ + return position(loc.startLine, loc.startColumn); +} + void QmlJSQuickFixOperation::move(const QmlJS::AST::SourceLocation &loc, int to) { move(position(loc.startColumn, loc.startColumn), to); @@ -70,6 +107,14 @@ QmlJSQuickFixCollector::~QmlJSQuickFixCollector() { } +bool QmlJSQuickFixCollector::supportsEditor(TextEditor::ITextEditable *editable) +{ + if (qobject_cast<QmlJSTextEditor *>(editable->widget()) != 0) + return true; + + return false; +} + TextEditor::QuickFixState *QmlJSQuickFixCollector::initializeCompletion(TextEditor::ITextEditable *editable) { if (QmlJSTextEditor *editor = qobject_cast<QmlJSTextEditor *>(editable->widget())) { @@ -81,16 +126,16 @@ TextEditor::QuickFixState *QmlJSQuickFixCollector::initializeCompletion(TextEdit return 0; } - // ### TODO create the quickfix state - return 0; + QmlJSQuickFixState *state = new QmlJSQuickFixState; + state->semanticInfo = info; + return state; } return 0; } -QList<TextEditor::QuickFixOperation::Ptr> QmlJSQuickFixCollector::quickFixOperations(TextEditor::BaseTextEditor *) const +QList<TextEditor::QuickFixOperation::Ptr> QmlJSQuickFixCollector::quickFixOperations(TextEditor::BaseTextEditor *editor) const { QList<TextEditor::QuickFixOperation::Ptr> quickFixOperations; - return quickFixOperations; } |