Files
qt-creator/src/plugins/qmljseditor/qmljsquickfix.h

108 lines
3.5 KiB
C
Raw Normal View History

/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QMLJSQUICKFIX_H
#define QMLJSQUICKFIX_H
2010-06-07 12:12:07 +02:00
#include "qmljseditor.h"
#include <texteditor/quickfix.h>
#include <qmljs/parser/qmljsastfwd_p.h>
2010-06-07 12:12:07 +02:00
#include <qmljs/qmljsdocument.h>
2010-06-09 15:56:03 +02:00
namespace QmlJS {
class ModelManagerInterface;
}
2010-06-09 15:56:03 +02:00
namespace QmlJSEditor {
class QmlJSRefactoringChanges;
namespace Internal {
class QmlJSQuickFixOperation: public TextEditor::QuickFixOperation
{
Q_DISABLE_COPY(QmlJSQuickFixOperation)
public:
QmlJSQuickFixOperation(TextEditor::BaseTextEditor *editor);
virtual ~QmlJSQuickFixOperation();
2010-06-07 12:12:07 +02:00
QmlJS::Document::Ptr document() const;
const QmlJS::Snapshot &snapshot() const;
const SemanticInfo &semanticInfo() const;
virtual int check() = 0;
virtual int match(TextEditor::QuickFixState *state);
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;
2010-06-07 12:12:07 +02:00
using TextEditor::QuickFixOperation::position;
virtual void apply();
QmlJSRefactoringChanges *qmljsRefactoringChanges() const;
virtual TextEditor::RefactoringChanges *refactoringChanges() const;
2010-06-07 12:12:07 +02:00
unsigned position(const QmlJS::AST::SourceLocation &loc) const;
// 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);
2010-06-07 12:12:07 +02:00
private:
SemanticInfo _semanticInfo;
QmlJSRefactoringChanges *_refactoringChanges;
};
class QmlJSQuickFixCollector: public TextEditor::QuickFixCollector
{
Q_OBJECT
public:
QmlJSQuickFixCollector();
virtual ~QmlJSQuickFixCollector();
2010-06-07 12:12:07 +02:00
virtual bool supportsEditor(TextEditor::ITextEditable *editor);
virtual TextEditor::QuickFixState *initializeCompletion(TextEditor::ITextEditable *editable);
virtual QList<TextEditor::QuickFixOperation::Ptr> quickFixOperations(TextEditor::BaseTextEditor *editor) const;
};
} // end of namespace Internal
} // end of namespace QmlJSEditor
#endif // QMLJSQUICKFIX_H