2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-06-03 15:49:29 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2010-06-03 15:49:29 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-06-03 15:49:29 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-06-03 15:49:29 +02:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-06-03 15:49:29 +02:00
|
|
|
|
|
|
|
#include "qmljsquickfix.h"
|
2010-06-14 15:02:05 +02:00
|
|
|
#include "qmljscomponentfromobjectdef.h"
|
2010-06-03 15:49:29 +02:00
|
|
|
#include "qmljseditor.h"
|
2011-04-15 16:19:23 +02:00
|
|
|
#include "qmljsquickfixassist.h"
|
2010-06-14 14:52:43 +02:00
|
|
|
|
2010-07-26 13:06:33 +02:00
|
|
|
#include <extensionsystem/iplugin.h>
|
2010-06-14 14:52:43 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2013-09-02 14:04:12 +02:00
|
|
|
#include <qmljs/parser/qmljsast_p.h>
|
2010-06-14 14:52:43 +02:00
|
|
|
|
2010-07-26 13:06:33 +02:00
|
|
|
using namespace QmlJS;
|
|
|
|
using namespace QmlJS::AST;
|
2010-11-11 10:05:05 +01:00
|
|
|
using namespace QmlJSTools;
|
2010-06-14 14:52:43 +02:00
|
|
|
using TextEditor::RefactoringChanges;
|
2010-06-03 15:49:29 +02:00
|
|
|
|
2013-06-03 19:31:32 +02:00
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
|
|
|
using namespace Internal;
|
|
|
|
|
2012-10-10 23:27:16 +02:00
|
|
|
QmlJSQuickFixOperation::QmlJSQuickFixOperation(const QmlJSQuickFixInterface &interface,
|
|
|
|
int priority)
|
2010-07-26 13:06:33 +02:00
|
|
|
: QuickFixOperation(priority)
|
2011-04-15 16:19:23 +02:00
|
|
|
, m_interface(interface)
|
2010-06-07 12:12:07 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-12 13:46:18 +02:00
|
|
|
void QmlJSQuickFixOperation::perform()
|
|
|
|
{
|
2015-02-03 23:48:57 +02:00
|
|
|
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(),
|
2011-04-15 16:19:23 +02:00
|
|
|
m_interface->semanticInfo().snapshot);
|
2011-08-17 11:35:57 +02:00
|
|
|
QmlJSRefactoringFilePtr current = refactoring.file(fileName());
|
2010-08-12 13:46:18 +02:00
|
|
|
|
2011-08-17 11:35:57 +02:00
|
|
|
performChanges(current, refactoring);
|
2010-08-12 13:46:18 +02:00
|
|
|
}
|
|
|
|
|
2011-04-15 16:19:23 +02:00
|
|
|
const QmlJSQuickFixAssistInterface *QmlJSQuickFixOperation::assistInterface() const
|
2010-07-26 13:06:33 +02:00
|
|
|
{
|
2011-04-15 16:19:23 +02:00
|
|
|
return m_interface.data();
|
2010-06-07 12:12:07 +02:00
|
|
|
}
|
|
|
|
|
2010-06-14 17:15:53 +02:00
|
|
|
QString QmlJSQuickFixOperation::fileName() const
|
|
|
|
{
|
2011-04-15 16:19:23 +02:00
|
|
|
return m_interface->semanticInfo().document->fileName();
|
2010-06-14 17:15:53 +02:00
|
|
|
}
|
|
|
|
|
2010-09-30 16:12:24 +02:00
|
|
|
|
2012-10-10 23:27:16 +02:00
|
|
|
void QmlJSQuickFixFactory::matchingOperations(const QuickFixInterface &interface,
|
|
|
|
QuickFixOperations &result)
|
2010-09-30 16:12:24 +02:00
|
|
|
{
|
2012-10-10 23:27:16 +02:00
|
|
|
match(interface.staticCast<const QmlJSQuickFixAssistInterface>(), result);
|
2010-09-30 16:12:24 +02:00
|
|
|
}
|
2013-06-03 19:31:32 +02:00
|
|
|
|
|
|
|
} // namespace QmlJSEditor
|