diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index d1f52f4fb6a1fcf9216f1e3193872fd0672222a9..418f7f023baa5895ee5f77fa5a48ab8ae2eb6054 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1305,14 +1305,17 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
     QTextBlock block;
     const SimpleToken tk = tokenUnderCursor(tc, &block);
 
+    const int beginOfToken = block.position() + tk.begin();
+    const int endOfToken = block.position() + tk.end();
+
     // Handle include directives
     if (tk.is(T_STRING_LITERAL) || tk.is(T_ANGLE_STRING_LITERAL)) {
         const unsigned lineno = cursor.blockNumber() + 1;
         foreach (const Document::Include &incl, doc->includes()) {
             if (incl.line() == lineno && incl.resolved()) {
                 link.fileName = incl.fileName();
-                link.pos = cursor.block().position() + tk.position() + 1;
-                link.length = tk.length() - 2;
+                link.begin = beginOfToken + 1;
+                link.end = endOfToken - 1;
                 return link;
             }
         }
@@ -1326,12 +1329,7 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
     if (!lastSymbol)
         return link;
 
-    const int nameStart = tk.position();
-    const int nameLength = tk.length();
-    const int endOfName = block.position() + nameStart + nameLength;
-
-    const QString name = block.text().mid(nameStart, nameLength);
-    tc.setPosition(endOfName);
+    tc.setPosition(endOfToken);
 
     // Evaluate the type of the expression under the cursor
     ExpressionUnderCursor expressionUnderCursor;
@@ -1384,8 +1382,8 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
                 def = findDefinition(symbol);
 
             link = linkToSymbol(def ? def : symbol);
-            link.pos = block.position() + nameStart;
-            link.length = nameLength;
+            link.begin = beginOfToken;
+            link.end = endOfToken;
             return link;
 
         // This would jump to the type of a name
@@ -1400,13 +1398,13 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
         }
     } else {
         // Handle macro uses
-        const Document::MacroUse *use = doc->findMacroUseAt(endOfName - 1);
+        const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1);
         if (use) {
             const Macro &macro = use->macro();
             link.fileName = macro.fileName();
             link.line = macro.line();
-            link.pos = use->begin();
-            link.length = use->end() - use->begin();
+            link.begin = use->begin();
+            link.end = use->end();
             return link;
         }
     }
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 0bbd9287507a00d19788935c39fd896ef9606e8c..26dc1b054aefad425538a5b35f61d0c6fa3d332a 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -4144,8 +4144,8 @@ void BaseTextEditor::showLink(const Link &link)
 
     QTextEdit::ExtraSelection sel;
     sel.cursor = textCursor();
-    sel.cursor.setPosition(link.pos);
-    sel.cursor.setPosition(link.pos + link.length, QTextCursor::KeepAnchor);
+    sel.cursor.setPosition(link.begin);
+    sel.cursor.setPosition(link.end, QTextCursor::KeepAnchor);
     sel.format = d->m_linkFormat;
     sel.format.setFontUnderline(true);
     setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index b876a41457e570aeeae429e1820cdebc621af151..ace18421d303a42ed83bbda2376de3d571b6f18d 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -567,21 +567,21 @@ protected:
         Link(const QString &fileName = QString(),
              int line = 0,
              int column = 0)
-            : pos(-1)
-            , length(-1)
+            : begin(-1)
+            , end(-1)
             , fileName(fileName)
             , line(line)
             , column(column)
         {}
 
         bool isValid() const
-        { return !(pos == -1 || length == -1); }
+        { return begin != end; }
 
         bool operator==(const Link &other) const
-        { return pos == other.pos && length == other.length; }
+        { return begin == other.begin && end == other.end; }
 
-        int pos;           // Link position
-        int length;        // Link length
+        int begin;           // Link position
+        int end;           // Link end position
 
         QString fileName;  // Target file
         int line;          // Target line