Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
e0f55073
Commit
e0f55073
authored
Jul 09, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified SemanticInfo::Use.
parent
8c64c97c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
61 deletions
+16
-61
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+12
-56
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+4
-5
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
e0f55073
...
...
@@ -215,7 +215,7 @@ protected:
if
(
member
->
identifier
()
!=
id
)
continue
;
else
if
(
member
->
line
()
<
line
||
(
member
->
line
()
==
line
&&
member
->
column
()
<=
column
))
{
localUses
[
member
].
append
(
SemanticInfo
::
Use
(
ast
,
line
,
column
,
id
->
size
()));
localUses
[
member
].
append
(
SemanticInfo
::
Use
(
line
,
column
,
id
->
size
()));
return
true
;
}
}
...
...
@@ -251,7 +251,7 @@ protected:
}
Identifier
*
id
=
identifier
(
ast
->
identifier_token
);
externalUses
[
id
].
append
(
SemanticInfo
::
Use
(
ast
,
line
,
column
,
id
->
size
()));
externalUses
[
id
].
append
(
SemanticInfo
::
Use
(
line
,
column
,
id
->
size
()));
return
false
;
}
...
...
@@ -283,7 +283,7 @@ protected:
}
Identifier
*
id
=
identifier
(
ast
->
identifier_token
);
externalUses
[
id
].
append
(
SemanticInfo
::
Use
(
ast
,
line
,
column
,
id
->
size
()));
externalUses
[
id
].
append
(
SemanticInfo
::
Use
(
line
,
column
,
id
->
size
()));
for
(
TemplateArgumentListAST
*
arg
=
ast
->
template_arguments
;
arg
;
arg
=
arg
->
next
)
accept
(
arg
);
...
...
@@ -902,7 +902,6 @@ void CPPEditor::updateMethodBoxIndex()
static
void
highlightUses
(
QTextDocument
*
doc
,
const
QTextCharFormat
&
format
,
TranslationUnit
*
translationUnit
,
const
QList
<
SemanticInfo
::
Use
>
&
uses
,
QList
<
QTextEdit
::
ExtraSelection
>
*
selections
)
{
...
...
@@ -910,34 +909,18 @@ static void highlightUses(QTextDocument *doc,
return
;
foreach
(
const
SemanticInfo
::
Use
&
use
,
uses
)
{
NameAST
*
name
=
use
.
name
;
bool
generated
=
false
;
QTextEdit
::
ExtraSelection
sel
;
for
(
unsigned
tk
=
name
->
firstToken
(),
end
=
name
->
lastToken
();
tk
!=
end
;
++
tk
)
{
if
(
translationUnit
->
tokenAt
(
tk
).
generated
)
{
generated
=
true
;
break
;
}
}
if
(
!
generated
)
{
unsigned
startLine
,
startColumn
;
unsigned
endLine
,
endColumn
;
unsigned
identifier_token
=
name
->
firstToken
();
sel
.
format
=
format
;
sel
.
cursor
=
QTextCursor
(
doc
);
translationUnit
->
getTokenStartPosition
(
identifier_token
,
&
startLine
,
&
startColumn
)
;
translationUnit
->
getTokenEndPosition
(
identifier_token
,
&
endLine
,
&
endColumn
)
;
const
int
anchor
=
doc
->
findBlockByNumber
(
use
.
line
-
1
).
position
()
+
use
.
column
-
1
;
const
int
position
=
anchor
+
use
.
length
;
QTextEdit
::
ExtraSelection
sel
;
sel
.
cursor
=
QTextCursor
(
doc
);
sel
.
cursor
.
setPosition
(
doc
->
findBlockByNumber
(
startLine
-
1
).
position
()
+
startColumn
-
1
);
sel
.
cursor
.
setPosition
(
doc
->
findBlockByNumber
(
endLine
-
1
).
position
()
+
endColumn
-
1
,
QTextCursor
::
KeepAnchor
);
sel
.
format
=
format
;
sel
.
cursor
.
setPosition
(
anchor
);
sel
.
cursor
.
setPosition
(
position
,
QTextCursor
::
KeepAnchor
);
selections
->
append
(
sel
);
}
selections
->
append
(
sel
);
}
}
...
...
@@ -1641,8 +1624,6 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
TranslationUnit
*
translationUnit
=
semanticInfo
.
doc
->
translationUnit
();
SemanticInfo
::
LocalUseIterator
it
(
semanticInfo
.
localUses
);
while
(
it
.
hasNext
())
{
it
.
next
();
...
...
@@ -1661,36 +1642,11 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
if
(
!
good
)
continue
;
highlightUses
(
document
(),
format
,
translationUnit
,
uses
,
&
selections
);
break
;
// done
}
#if 0
SemanticInfo::ExternalUseIterator it2(semanticInfo.externalUses);
while (it2.hasNext()) {
it2.next();
const QList<Use> &uses = it2.value();
bool good = false;
foreach (const Use &use, uses) {
unsigned l = line;
unsigned c = column + 1; // convertCursorPosition() returns a 0-based column number.
if (l == use.line && c >= use.column && c <= (use.column + use.length)) {
good = true;
break;
}
}
if (! good)
continue;
highlightUses(document(), format, translationUnit, uses, &selections);
highlightUses
(
document
(),
format
,
uses
,
&
selections
);
break
;
// done
}
#endif
setExtraSelections
(
CodeSemanticsSelection
,
selections
);
}
SemanticHighlighter
::
Source
CPPEditor
::
currentSource
()
...
...
src/plugins/cppeditor/cppeditor.h
View file @
e0f55073
...
...
@@ -31,7 +31,6 @@
#define CPPEDITOR_H
#include "cppeditorenums.h"
#include <ASTfwd.h>
#include <cplusplus/CppDocument.h>
#include <texteditor/basetexteditor.h>
...
...
@@ -67,15 +66,15 @@ class SemanticInfo
{
public:
struct
Use
{
CPlusPlus
::
NameAST
*
name
;
unsigned
line
;
unsigned
column
;
unsigned
length
;
Use
()
{}
Use
()
:
line
(
0
),
column
(
0
),
length
(
0
)
{}
Use
(
CPlusPlus
::
NameAST
*
name
,
unsigned
line
,
unsigned
column
,
unsigned
length
)
:
name
(
name
),
line
(
line
),
column
(
column
),
length
(
length
)
{}
Use
(
unsigned
line
,
unsigned
column
,
unsigned
length
)
:
line
(
line
),
column
(
column
),
length
(
length
)
{}
};
typedef
QHash
<
CPlusPlus
::
Symbol
*
,
QList
<
Use
>
>
LocalUseMap
;
...
...
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