Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
5308a4a2
Commit
5308a4a2
authored
Aug 17, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed CppEditor::findLinkAt() to use the correct line and column positions from the editor.
parent
be9a3c94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+14
-9
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
5308a4a2
...
@@ -1071,11 +1071,11 @@ void CPPEditor::switchDeclarationDefinition()
...
@@ -1071,11 +1071,11 @@ void CPPEditor::switchDeclarationDefinition()
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
if
(
Document
::
Ptr
thisDocument
=
snapshot
.
document
(
file
()
->
fileName
()))
{
if
(
Document
::
Ptr
thisDocument
=
snapshot
.
document
(
file
()
->
fileName
()))
{
int
line
=
0
,
column
=
0
;
int
line
=
0
,
positionInBlock
=
0
;
convertPosition
(
position
(),
&
line
,
&
column
);
convertPosition
(
position
(),
&
line
,
&
positionInBlock
);
Scope
*
scope
=
thisDocument
->
scopeAt
(
line
,
column
);
Scope
*
scope
=
thisDocument
->
scopeAt
(
line
,
positionInBlock
+
1
);
Symbol
*
lastVisibleSymbol
=
thisDocument
->
lastVisibleSymbolAt
(
line
,
column
);
Symbol
*
lastVisibleSymbol
=
thisDocument
->
lastVisibleSymbolAt
(
line
,
positionInBlock
+
1
);
Scope
*
functionScope
=
0
;
Scope
*
functionScope
=
0
;
if
(
scope
->
isFunction
())
if
(
scope
->
isFunction
())
...
@@ -1159,12 +1159,15 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
...
@@ -1159,12 +1159,15 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
return
link
;
return
link
;
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
int
line
=
0
,
column
=
0
;
int
line
Number
=
0
,
positionInBlock
=
0
;
convertPosition
(
cursor
.
position
(),
&
line
,
&
column
);
convertPosition
(
cursor
.
position
(),
&
line
Number
,
&
positionInBlock
);
Document
::
Ptr
doc
=
snapshot
.
document
(
file
()
->
fileName
());
Document
::
Ptr
doc
=
snapshot
.
document
(
file
()
->
fileName
());
if
(
!
doc
)
if
(
!
doc
)
return
link
;
return
link
;
const
unsigned
line
=
lineNumber
;
const
unsigned
column
=
positionInBlock
+
1
;
QTextCursor
tc
=
cursor
;
QTextCursor
tc
=
cursor
;
// Make sure we're not at the start of a word
// Make sure we're not at the start of a word
...
@@ -1188,7 +1191,7 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
...
@@ -1188,7 +1191,7 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
for
(
int
i
=
0
;
i
<
tokens
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
tokens
.
size
();
++
i
)
{
const
Token
&
tk
=
tokens
.
at
(
i
);
const
Token
&
tk
=
tokens
.
at
(
i
);
if
(((
unsigned
)
column
)
>=
tk
.
begin
()
&&
((
unsigned
)
column
)
<=
tk
.
end
())
{
if
(((
unsigned
)
positionInBlock
)
>=
tk
.
begin
()
&&
((
unsigned
)
positionInBlock
)
<=
tk
.
end
())
{
if
(
i
>=
2
&&
tokens
.
at
(
i
).
is
(
T_IDENTIFIER
)
&&
tokens
.
at
(
i
-
1
).
is
(
T_LPAREN
)
if
(
i
>=
2
&&
tokens
.
at
(
i
).
is
(
T_IDENTIFIER
)
&&
tokens
.
at
(
i
-
1
).
is
(
T_LPAREN
)
&&
(
tokens
.
at
(
i
-
2
).
is
(
T_SIGNAL
)
||
tokens
.
at
(
i
-
2
).
is
(
T_SLOT
)))
{
&&
(
tokens
.
at
(
i
-
2
).
is
(
T_SIGNAL
)
||
tokens
.
at
(
i
-
2
).
is
(
T_SLOT
)))
{
...
@@ -1273,7 +1276,7 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
...
@@ -1273,7 +1276,7 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
if
(
Symbol
*
d
=
r
.
declaration
())
{
if
(
Symbol
*
d
=
r
.
declaration
())
{
if
(
d
->
isDeclaration
()
||
d
->
isFunction
())
{
if
(
d
->
isDeclaration
()
||
d
->
isFunction
())
{
if
(
file
()
->
fileName
()
==
QString
::
fromUtf8
(
d
->
fileName
(),
d
->
fileNameLength
()))
{
if
(
file
()
->
fileName
()
==
QString
::
fromUtf8
(
d
->
fileName
(),
d
->
fileNameLength
()))
{
if
(
unsigned
(
line
)
==
d
->
line
()
&&
unsigned
(
column
)
>=
d
->
column
())
{
// ### TODO: check the end
if
(
unsigned
(
line
Number
)
==
d
->
line
()
&&
unsigned
(
positionInBlock
)
>=
d
->
column
())
{
// ### TODO: check the end
result
=
r
;
// take the symbol under cursor.
result
=
r
;
// take the symbol under cursor.
break
;
break
;
}
}
...
@@ -1286,9 +1289,11 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
...
@@ -1286,9 +1289,11 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
Symbol
*
def
=
0
;
Symbol
*
def
=
0
;
if
(
resolveTarget
)
{
if
(
resolveTarget
)
{
Symbol
*
lastVisibleSymbol
=
doc
->
lastVisibleSymbolAt
(
line
,
column
);
def
=
findDefinition
(
symbol
,
snapshot
);
def
=
findDefinition
(
symbol
,
snapshot
);
if
(
def
==
doc
->
lastVisibleSymbol
At
(
line
,
column
)
)
if
(
def
==
lastVisibleSymbol
)
def
=
0
;
// jump to declaration then.
def
=
0
;
// jump to declaration then.
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment