aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-02-02 12:52:07 +0100
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-02-07 14:01:52 +0000
commitc020f2448b9e9dde6f0f38912dd9ac0d30d27a27 (patch)
treebeffe6fedffa9d673d60350e87bff3ce7d731a71 /src/libs/3rdparty/cplusplus
parent31f1713c759e5bf76299171c86273b5960dec7ff (diff)
CPlusPlus: Add toLink method to the Symbol
Basically move it from CppTools to CPlusPlus to be able to use it there. Change-Id: I0af80f93bdc029824397ceafdf940cb86c4382b0 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus')
-rw-r--r--src/libs/3rdparty/cplusplus/Symbol.cpp17
-rw-r--r--src/libs/3rdparty/cplusplus/Symbol.h3
2 files changed, 20 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Symbol.cpp b/src/libs/3rdparty/cplusplus/Symbol.cpp
index e98b33a8a7..e9c7edb0dc 100644
--- a/src/libs/3rdparty/cplusplus/Symbol.cpp
+++ b/src/libs/3rdparty/cplusplus/Symbol.cpp
@@ -32,6 +32,7 @@
#include "cppassert.h"
+#include <utils/link.h>
using namespace CPlusPlus;
@@ -435,3 +436,19 @@ void Symbol::copy(Symbol *other)
_isGenerated = other->_isGenerated;
_isDeprecated = other->_isDeprecated;
}
+
+Utils::Link Symbol::toLink() const
+{
+ const QString filename = QString::fromUtf8(fileName(), static_cast<int>(fileNameLength()));
+
+ int line = static_cast<int>(this->line());
+ int column = static_cast<int>(this->column());
+
+ if (column)
+ --column;
+
+ if (isGenerated())
+ column = 0;
+
+ return Utils::Link(filename, line, column);
+}
diff --git a/src/libs/3rdparty/cplusplus/Symbol.h b/src/libs/3rdparty/cplusplus/Symbol.h
index 417217e469..e4c8eea152 100644
--- a/src/libs/3rdparty/cplusplus/Symbol.h
+++ b/src/libs/3rdparty/cplusplus/Symbol.h
@@ -22,6 +22,7 @@
#include "CPlusPlusForwardDeclarations.h"
+namespace Utils { struct Link; }
namespace CPlusPlus {
@@ -197,6 +198,8 @@ public:
/// Returns true if this Symbol is an Objective-C @property declaration.
bool isObjCPropertyDeclaration() const;
+ Utils::Link toLink() const;
+
virtual const Scope *asScope() const { return 0; }
virtual const Enum *asEnum() const { return 0; }
virtual const Function *asFunction() const { return 0; }