forked from qt-creator/qt-creator
Utils: replace LineColumn with Text::Position
Change-Id: Ia69547374efec7412717cbed1eb4162162a89d39 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
committed by
Jarek Kobus
parent
268da290b2
commit
1acd2499e2
@@ -89,7 +89,6 @@ add_qtc_library(Utils
|
|||||||
launcherpackets.cpp launcherpackets.h
|
launcherpackets.cpp launcherpackets.h
|
||||||
launchersocket.cpp launchersocket.h
|
launchersocket.cpp launchersocket.h
|
||||||
layoutbuilder.cpp layoutbuilder.h
|
layoutbuilder.cpp layoutbuilder.h
|
||||||
linecolumn.h
|
|
||||||
link.cpp link.h
|
link.cpp link.h
|
||||||
listmodel.h
|
listmodel.h
|
||||||
listutils.h
|
listutils.h
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
// Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "utils_global.h"
|
|
||||||
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT LineColumn
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool isValid() const
|
|
||||||
{
|
|
||||||
return line > 0 && column >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend bool operator==(LineColumn first, LineColumn second)
|
|
||||||
{
|
|
||||||
return first.isValid() && first.line == second.line && first.column == second.column;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend bool operator!=(LineColumn first, LineColumn second)
|
|
||||||
{
|
|
||||||
return !(first == second);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
int line = 0;
|
|
||||||
int column = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Utils
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Utils::LineColumn)
|
|
||||||
@@ -185,7 +185,6 @@ Project {
|
|||||||
"launchersocket.h",
|
"launchersocket.h",
|
||||||
"layoutbuilder.cpp",
|
"layoutbuilder.cpp",
|
||||||
"layoutbuilder.h",
|
"layoutbuilder.h",
|
||||||
"linecolumn.h",
|
|
||||||
"link.cpp",
|
"link.cpp",
|
||||||
"link.h",
|
"link.h",
|
||||||
"listmodel.h",
|
"listmodel.h",
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/linecolumn.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
#include <utils/linecolumn.h>
|
|
||||||
#include <utils/treeviewcombobox.h>
|
#include <utils/treeviewcombobox.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <utils/linecolumn.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -184,8 +183,8 @@ void CppOutlineWidget::updateIndexNow()
|
|||||||
void CppOutlineWidget::updateTextCursor(const QModelIndex &proxyIndex)
|
void CppOutlineWidget::updateTextCursor(const QModelIndex &proxyIndex)
|
||||||
{
|
{
|
||||||
QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
||||||
Utils::LineColumn lineColumn
|
Utils::Text::Position lineColumn
|
||||||
= m_editor->cppEditorDocument()->outlineModel().lineColumnFromIndex(index);
|
= m_editor->cppEditorDocument()->outlineModel().positionFromIndex(index);
|
||||||
if (!lineColumn.isValid())
|
if (!lineColumn.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include <cplusplus/Scope.h>
|
#include <cplusplus/Scope.h>
|
||||||
#include <cplusplus/Symbols.h>
|
#include <cplusplus/Symbols.h>
|
||||||
|
|
||||||
#include <utils/linecolumn.h>
|
|
||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
@@ -239,9 +238,9 @@ Utils::Link OutlineModel::linkFromIndex(const QModelIndex &sourceIndex) const
|
|||||||
return symbol->toLink();
|
return symbol->toLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::LineColumn OutlineModel::lineColumnFromIndex(const QModelIndex &sourceIndex) const
|
Utils::Text::Position OutlineModel::positionFromIndex(const QModelIndex &sourceIndex) const
|
||||||
{
|
{
|
||||||
Utils::LineColumn lineColumn;
|
Utils::Text::Position lineColumn;
|
||||||
CPlusPlus::Symbol *symbol = symbolFromIndex(sourceIndex);
|
CPlusPlus::Symbol *symbol = symbolFromIndex(sourceIndex);
|
||||||
if (!symbol)
|
if (!symbol)
|
||||||
return lineColumn;
|
return lineColumn;
|
||||||
@@ -252,7 +251,7 @@ Utils::LineColumn OutlineModel::lineColumnFromIndex(const QModelIndex &sourceInd
|
|||||||
|
|
||||||
OutlineModel::Range OutlineModel::rangeFromIndex(const QModelIndex &sourceIndex) const
|
OutlineModel::Range OutlineModel::rangeFromIndex(const QModelIndex &sourceIndex) const
|
||||||
{
|
{
|
||||||
Utils::LineColumn lineColumn = lineColumnFromIndex(sourceIndex);
|
Utils::Text::Position lineColumn = positionFromIndex(sourceIndex);
|
||||||
return {lineColumn, lineColumn};
|
return {lineColumn, lineColumn};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <utils/dropsupport.h>
|
#include <utils/dropsupport.h>
|
||||||
|
#include <utils/textutils.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
@@ -44,8 +45,8 @@ public:
|
|||||||
|
|
||||||
bool isGenerated(const QModelIndex &sourceIndex) const;
|
bool isGenerated(const QModelIndex &sourceIndex) const;
|
||||||
Utils::Link linkFromIndex(const QModelIndex &sourceIndex) const;
|
Utils::Link linkFromIndex(const QModelIndex &sourceIndex) const;
|
||||||
Utils::LineColumn lineColumnFromIndex(const QModelIndex &sourceIndex) const;
|
Utils::Text::Position positionFromIndex(const QModelIndex &sourceIndex) const;
|
||||||
using Range = std::pair<Utils::LineColumn, Utils::LineColumn>;
|
using Range = std::pair<Utils::Text::Position, Utils::Text::Position>;
|
||||||
Range rangeFromIndex(const QModelIndex &sourceIndex) const;
|
Range rangeFromIndex(const QModelIndex &sourceIndex) const;
|
||||||
|
|
||||||
// line is 1-based and column is 0-based
|
// line is 1-based and column is 0-based
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <sqlitesessionchangeset.h>
|
#include <sqlitesessionchangeset.h>
|
||||||
#include <sqlitevalue.h>
|
#include <sqlitevalue.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/linecolumn.h>
|
|
||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
#include <qmldesigner/designercore/imagecache/imagecachestorageinterface.h>
|
#include <qmldesigner/designercore/imagecache/imagecachestorageinterface.h>
|
||||||
|
|
||||||
@@ -42,11 +41,6 @@ std::ostream &operator<<(std::ostream &out, const monostate &)
|
|||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn)
|
|
||||||
{
|
|
||||||
return out << "(" << lineColumn.line << ", " << lineColumn.column << ")";
|
|
||||||
}
|
|
||||||
namespace {
|
namespace {
|
||||||
const char * toText(Utils::Language language)
|
const char * toText(Utils::Language language)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class LineColumn;
|
|||||||
class SmallStringView;
|
class SmallStringView;
|
||||||
class FilePath;
|
class FilePath;
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn);
|
|
||||||
std::ostream &operator<<(std::ostream &out, const Utils::Language &language);
|
std::ostream &operator<<(std::ostream &out, const Utils::Language &language);
|
||||||
std::ostream &operator<<(std::ostream &out, const Utils::LanguageVersion &languageVersion);
|
std::ostream &operator<<(std::ostream &out, const Utils::LanguageVersion &languageVersion);
|
||||||
std::ostream &operator<<(std::ostream &out, const Utils::LanguageExtension &languageExtension);
|
std::ostream &operator<<(std::ostream &out, const Utils::LanguageExtension &languageExtension);
|
||||||
|
|||||||
Reference in New Issue
Block a user