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
|
||||
launchersocket.cpp launchersocket.h
|
||||
layoutbuilder.cpp layoutbuilder.h
|
||||
linecolumn.h
|
||||
link.cpp link.h
|
||||
listmodel.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",
|
||||
"layoutbuilder.cpp",
|
||||
"layoutbuilder.h",
|
||||
"linecolumn.h",
|
||||
"link.cpp",
|
||||
"link.h",
|
||||
"listmodel.h",
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/linecolumn.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/textutils.h>
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <utils/linecolumn.h>
|
||||
#include <utils/treeviewcombobox.h>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <utils/linecolumn.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -184,8 +183,8 @@ void CppOutlineWidget::updateIndexNow()
|
||||
void CppOutlineWidget::updateTextCursor(const QModelIndex &proxyIndex)
|
||||
{
|
||||
QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
||||
Utils::LineColumn lineColumn
|
||||
= m_editor->cppEditorDocument()->outlineModel().lineColumnFromIndex(index);
|
||||
Utils::Text::Position lineColumn
|
||||
= m_editor->cppEditorDocument()->outlineModel().positionFromIndex(index);
|
||||
if (!lineColumn.isValid())
|
||||
return;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <cplusplus/Scope.h>
|
||||
#include <cplusplus/Symbols.h>
|
||||
|
||||
#include <utils/linecolumn.h>
|
||||
#include <utils/link.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
@@ -239,9 +238,9 @@ Utils::Link OutlineModel::linkFromIndex(const QModelIndex &sourceIndex) const
|
||||
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);
|
||||
if (!symbol)
|
||||
return lineColumn;
|
||||
@@ -252,7 +251,7 @@ Utils::LineColumn OutlineModel::lineColumnFromIndex(const QModelIndex &sourceInd
|
||||
|
||||
OutlineModel::Range OutlineModel::rangeFromIndex(const QModelIndex &sourceIndex) const
|
||||
{
|
||||
Utils::LineColumn lineColumn = lineColumnFromIndex(sourceIndex);
|
||||
Utils::Text::Position lineColumn = positionFromIndex(sourceIndex);
|
||||
return {lineColumn, lineColumn};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/dropsupport.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
@@ -44,8 +45,8 @@ public:
|
||||
|
||||
bool isGenerated(const QModelIndex &sourceIndex) const;
|
||||
Utils::Link linkFromIndex(const QModelIndex &sourceIndex) const;
|
||||
Utils::LineColumn lineColumnFromIndex(const QModelIndex &sourceIndex) const;
|
||||
using Range = std::pair<Utils::LineColumn, Utils::LineColumn>;
|
||||
Utils::Text::Position positionFromIndex(const QModelIndex &sourceIndex) const;
|
||||
using Range = std::pair<Utils::Text::Position, Utils::Text::Position>;
|
||||
Range rangeFromIndex(const QModelIndex &sourceIndex) const;
|
||||
|
||||
// line is 1-based and column is 0-based
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <sqlitesessionchangeset.h>
|
||||
#include <sqlitevalue.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/linecolumn.h>
|
||||
#include <variantproperty.h>
|
||||
#include <qmldesigner/designercore/imagecache/imagecachestorageinterface.h>
|
||||
|
||||
@@ -42,11 +41,6 @@ std::ostream &operator<<(std::ostream &out, const monostate &)
|
||||
} // namespace std
|
||||
|
||||
namespace Utils {
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn)
|
||||
{
|
||||
return out << "(" << lineColumn.line << ", " << lineColumn.column << ")";
|
||||
}
|
||||
namespace {
|
||||
const char * toText(Utils::Language language)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,6 @@ class LineColumn;
|
||||
class SmallStringView;
|
||||
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::LanguageVersion &languageVersion);
|
||||
std::ostream &operator<<(std::ostream &out, const Utils::LanguageExtension &languageExtension);
|
||||
|
||||
Reference in New Issue
Block a user