summaryrefslogtreecommitdiff
path: root/src/plugins/qmljseditor/qmljsquickfix.h
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2011-04-15 16:19:23 +0200
committerLeandro Melo <leandro.melo@nokia.com>2011-05-18 10:46:20 +0200
commitbec4f02495b97b17e0b0f8cb67d0909634c16228 (patch)
tree21759e0b9ebc6b0dca84f01875223020665d7843 /src/plugins/qmljseditor/qmljsquickfix.h
parentd835b769c7d6b37e59a8a74a0d68260d34e7a7f9 (diff)
downloadqt-creator-bec4f02495b97b17e0b0f8cb67d0909634c16228.tar.gz
New code assist API
This is a re-work of our completion engine. Primary goals are: - Allow the computation to run in a separate thread so the GUI is not locked. - Support a model-based approach. QStrings are still needed (filtering, etc), but internal structures are free to use more efficient representations. - Unifiy all kinds of *assist* into a more reusable and extensible framework. - Remove unnecessary dependencies on the text editor so we have more generic and easily "plugable" components (still things to be resolved).
Diffstat (limited to 'src/plugins/qmljseditor/qmljsquickfix.h')
-rw-r--r--src/plugins/qmljseditor/qmljsquickfix.h75
1 files changed, 14 insertions, 61 deletions
diff --git a/src/plugins/qmljseditor/qmljsquickfix.h b/src/plugins/qmljseditor/qmljsquickfix.h
index ca5dd5ce51..7529814829 100644
--- a/src/plugins/qmljseditor/qmljsquickfix.h
+++ b/src/plugins/qmljseditor/qmljsquickfix.h
@@ -40,6 +40,8 @@
#include <qmljs/qmljsdocument.h>
#include <qmljstools/qmljsrefactoringchanges.h>
+#include <QtCore/QSharedPointer>
+
namespace ExtensionSystem {
class IPlugin;
}
@@ -51,40 +53,12 @@ namespace QmlJS {
namespace QmlJSEditor {
namespace Internal {
-class QmlJSQuickFixCollector;
+class QmlJSQuickFixAssistInterface;
} // namespace Internal
-/*!
- Specialized QuickFixState for QML/JavaScript quick-fixes.
-
- This specialized state for QML/JavaScript quick-fixes also holds the
- QmlJSEditor::Internal::SemanticInfo for the document in the editor.
- */
-class QmlJSQuickFixState: public TextEditor::QuickFixState
-{
- friend class Internal::QmlJSQuickFixCollector;
-
-public:
- /// Creates a new state for the given editor.
- QmlJSQuickFixState(TextEditor::BaseTextEditorWidget *editor);
-
- SemanticInfo semanticInfo() const;
-
- /// \returns the snapshot holding the document of the editor.
- QmlJS::Snapshot snapshot() const;
-
- /// \returns the document of the editor
- QmlJS::Document::Ptr document() const;
-
- const QmlJSTools::QmlJSRefactoringFile currentFile() const;
-
-private:
- SemanticInfo _semanticInfo;
-};
/*!
- A quick-fix operation for the QML/JavaScript editor, which works on a
- QmlJSQuickFixState .
+ A quick-fix operation for the QML/JavaScript editor.
*/
class QmlJSQuickFixOperation: public TextEditor::QuickFixOperation
{
@@ -94,13 +68,12 @@ public:
/*!
Creates a new QmlJSQuickFixOperation.
- This operation will copy the complete state, in order to be able to perform
- its changes later on.
-
- \param state The state for which this operation was created.
+ \param interface The interface on which the operation is performed.
\param priority The priority for this operation.
*/
- explicit QmlJSQuickFixOperation(const QmlJSQuickFixState &state, int priority = -1);
+ explicit QmlJSQuickFixOperation(
+ const QSharedPointer<const Internal::QmlJSQuickFixAssistInterface> &interface,
+ int priority = -1);
virtual ~QmlJSQuickFixOperation();
virtual void perform();
@@ -111,14 +84,13 @@ protected:
virtual void performChanges(QmlJSTools::QmlJSRefactoringFile *currentFile,
QmlJSTools::QmlJSRefactoringChanges *refactoring) = 0;
- /// \returns A const-reference to the state of the operation.
- const QmlJSQuickFixState &state() const;
+ const Internal::QmlJSQuickFixAssistInterface *assistInterface() const;
/// \returns The name of the file for for which this operation is invoked.
QString fileName() const;
private:
- QmlJSQuickFixState _state;
+ QSharedPointer<const Internal::QmlJSQuickFixAssistInterface> m_interface;
};
class QmlJSQuickFixFactory: public TextEditor::QuickFixFactory
@@ -129,39 +101,20 @@ public:
QmlJSQuickFixFactory();
virtual ~QmlJSQuickFixFactory();
- virtual QList<TextEditor::QuickFixOperation::Ptr> matchingOperations(TextEditor::QuickFixState *state);
+ virtual QList<TextEditor::QuickFixOperation::Ptr>
+ matchingOperations(const QSharedPointer<const TextEditor::IAssistInterface> &interface);
/*!
Implement this method to match and create the appropriate
QmlJSQuickFixOperation objects.
*/
- virtual QList<QmlJSQuickFixOperation::Ptr> match(const QmlJSQuickFixState &state) = 0;
+ virtual QList<QmlJSQuickFixOperation::Ptr> match(
+ const QSharedPointer<const Internal::QmlJSQuickFixAssistInterface> &interface) = 0;
static QList<QmlJSQuickFixOperation::Ptr> noResult();
static QList<QmlJSQuickFixOperation::Ptr> singleResult(QmlJSQuickFixOperation *operation);
};
-namespace Internal {
-
-class QmlJSQuickFixCollector: public TextEditor::QuickFixCollector
-{
- Q_OBJECT
-
-public:
- QmlJSQuickFixCollector();
- virtual ~QmlJSQuickFixCollector();
-
- virtual bool supportsEditor(TextEditor::ITextEditor *editor) const;
- virtual bool supportsPolicy(TextEditor::CompletionPolicy policy) const;
- virtual TextEditor::QuickFixState *initializeCompletion(TextEditor::BaseTextEditorWidget *editor);
-
- virtual QList<TextEditor::QuickFixFactory *> quickFixFactories() const;
-
- /// Registers all quick-fixes in this plug-in as auto-released objects.
- static void registerQuickFixes(ExtensionSystem::IPlugin *plugIn);
-};
-
-} // namespace Internal
} // namespace QmlJSEditor
#endif // QMLJSQUICKFIX_H