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-14 14:52:43 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-06-14 14:52:43 +02:00
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
#include "qmljstools_global.h"
|
|
|
|
|
|
2010-06-14 14:52:43 +02:00
|
|
|
#include <qmljs/qmljsdocument.h>
|
|
|
|
|
|
|
|
|
|
#include <texteditor/refactoringchanges.h>
|
|
|
|
|
|
2014-02-11 21:55:42 +02:00
|
|
|
namespace QmlJS { class ModelManagerInterface; }
|
2010-06-14 14:52:43 +02:00
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
namespace QmlJSTools {
|
2010-06-14 14:52:43 +02:00
|
|
|
|
2010-08-13 12:49:11 +02:00
|
|
|
class QmlJSRefactoringChanges;
|
2011-08-17 11:35:57 +02:00
|
|
|
class QmlJSRefactoringFile;
|
|
|
|
|
class QmlJSRefactoringChangesData;
|
2018-11-24 10:22:37 +01:00
|
|
|
using QmlJSRefactoringFilePtr = QSharedPointer<QmlJSRefactoringFile>;
|
2010-08-13 12:49:11 +02:00
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
class QMLJSTOOLS_EXPORT QmlJSRefactoringFile: public TextEditor::RefactoringFile
|
2010-08-13 12:49:11 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QmlJS::Document::Ptr qmljsDocument() const;
|
|
|
|
|
|
|
|
|
|
/*!
|
2023-03-24 12:07:30 +01:00
|
|
|
Returns the offset in the document for the start position of the given
|
2010-08-13 12:49:11 +02:00
|
|
|
source location.
|
|
|
|
|
*/
|
2020-02-28 17:51:32 +01:00
|
|
|
unsigned startOf(const QmlJS::SourceLocation &loc) const;
|
2010-08-13 12:49:11 +02:00
|
|
|
|
2010-09-30 16:12:24 +02:00
|
|
|
bool isCursorOn(QmlJS::AST::UiObjectMember *ast) const;
|
|
|
|
|
bool isCursorOn(QmlJS::AST::UiQualifiedId *ast) const;
|
2020-02-28 17:51:32 +01:00
|
|
|
bool isCursorOn(QmlJS::SourceLocation loc) const;
|
2010-09-30 16:12:24 +02:00
|
|
|
|
2011-08-17 11:35:57 +02:00
|
|
|
protected:
|
2021-05-28 12:02:36 +02:00
|
|
|
QmlJSRefactoringFile(const Utils::FilePath &filePath,
|
|
|
|
|
const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
2014-09-26 11:37:54 +02:00
|
|
|
QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor, QmlJS::Document::Ptr document);
|
2011-08-17 11:35:57 +02:00
|
|
|
|
|
|
|
|
QmlJSRefactoringChangesData *data() const;
|
2018-05-07 15:11:45 +02:00
|
|
|
void fileChanged() override;
|
2010-08-13 12:49:11 +02:00
|
|
|
|
|
|
|
|
mutable QmlJS::Document::Ptr m_qmljsDocument;
|
2011-08-17 11:35:57 +02:00
|
|
|
|
|
|
|
|
friend class QmlJSRefactoringChanges;
|
2010-08-13 12:49:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
class QMLJSTOOLS_EXPORT QmlJSRefactoringChanges: public TextEditor::RefactoringChanges
|
2010-06-14 14:52:43 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QmlJSRefactoringChanges(QmlJS::ModelManagerInterface *modelManager,
|
|
|
|
|
const QmlJS::Snapshot &snapshot);
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
static QmlJSRefactoringFilePtr file(TextEditor::TextEditorWidget *editor,
|
2011-08-17 11:35:57 +02:00
|
|
|
const QmlJS::Document::Ptr &document);
|
2021-05-28 12:02:36 +02:00
|
|
|
QmlJSRefactoringFilePtr file(const Utils::FilePath &filePath) const;
|
2010-08-13 12:49:11 +02:00
|
|
|
|
2011-08-17 11:35:57 +02:00
|
|
|
const QmlJS::Snapshot &snapshot() const;
|
2010-08-12 11:34:48 +02:00
|
|
|
|
2010-06-14 14:52:43 +02:00
|
|
|
private:
|
2011-08-17 11:35:57 +02:00
|
|
|
QmlJSRefactoringChangesData *data() const;
|
2010-06-14 14:52:43 +02:00
|
|
|
};
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
} // namespace QmlJSTools
|