2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-06-03 15:49:29 +02:00
|
|
|
|
|
|
|
|
#include "qmljsquickfix.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
|
|
|
|
2017-12-15 09:34:02 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
|
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;
|
2023-11-17 12:44:49 +01:00
|
|
|
using TextEditor::RefactoringFileFactory;
|
2010-06-03 15:49:29 +02:00
|
|
|
|
2013-06-03 19:31:32 +02:00
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
|
|
|
|
|
using namespace Internal;
|
|
|
|
|
|
2023-02-06 15:32:00 +01:00
|
|
|
QmlJSQuickFixOperation::QmlJSQuickFixOperation(const QmlJSQuickFixAssistInterface *interface,
|
2012-10-10 23:27:16 +02:00
|
|
|
int priority)
|
2010-07-26 13:06:33 +02:00
|
|
|
: QuickFixOperation(priority)
|
2023-02-06 15:32:00 +01:00
|
|
|
, m_semanticInfo(interface->semanticInfo())
|
2010-06-07 12:12:07 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-12 13:46:18 +02:00
|
|
|
void QmlJSQuickFixOperation::perform()
|
|
|
|
|
{
|
2023-02-06 15:32:00 +01:00
|
|
|
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), semanticInfo().snapshot);
|
2023-11-16 15:45:02 +01:00
|
|
|
QmlJSRefactoringFilePtr current = refactoring.qmlJSFile(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
|
|
|
}
|
|
|
|
|
|
2023-02-06 15:32:00 +01:00
|
|
|
const QmlJSTools::SemanticInfo &QmlJSQuickFixOperation::semanticInfo() const
|
2010-07-26 13:06:33 +02:00
|
|
|
{
|
2023-02-06 15:32:00 +01:00
|
|
|
return m_semanticInfo;
|
2010-06-07 12:12:07 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-20 12:35:13 +02:00
|
|
|
Utils::FilePath QmlJSQuickFixOperation::fileName() const
|
2010-06-14 17:15:53 +02:00
|
|
|
{
|
2023-02-06 15:32:00 +01:00
|
|
|
return semanticInfo().document->fileName();
|
2010-06-14 17:15:53 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-03 19:31:32 +02:00
|
|
|
} // namespace QmlJSEditor
|