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
Q
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
Tobias Hunger
qt-creator
Commits
d20cdc64
Commit
d20cdc64
authored
Dec 08, 2009
by
Thorbjørn Lindeijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'origin/1.3'
parents
b63e6e93
4bbb9219
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
17 deletions
+27
-17
src/libs/cplusplus/BackwardsScanner.cpp
src/libs/cplusplus/BackwardsScanner.cpp
+7
-5
src/libs/cplusplus/BackwardsScanner.h
src/libs/cplusplus/BackwardsScanner.h
+1
-1
src/libs/cplusplus/ResolveExpression.cpp
src/libs/cplusplus/ResolveExpression.cpp
+1
-0
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+18
-11
No files found.
src/libs/cplusplus/BackwardsScanner.cpp
View file @
d20cdc64
...
...
@@ -71,13 +71,14 @@ const SimpleToken &BackwardsScanner::fetchToken(int i)
}
else
{
++
_blocksTokenized
;
const
QString
blockText
=
_block
.
text
();
QString
blockText
=
_block
.
text
();
_text
.
prepend
(
QLatin1Char
(
'\n'
));
_text
.
prepend
(
blockText
);
QList
<
SimpleToken
>
adaptedTokens
;
for
(
int
i
=
0
;
i
<
_tokens
.
size
();
++
i
)
{
SimpleToken
t
=
_tokens
.
at
(
i
);
t
.
setPosition
(
t
.
position
()
+
blockText
.
length
());
t
.
setPosition
(
t
.
position
()
+
blockText
.
length
()
+
1
);
t
.
setText
(
_text
.
midRef
(
t
.
position
(),
t
.
length
()));
adaptedTokens
.
append
(
t
);
}
...
...
@@ -248,8 +249,9 @@ int BackwardsScanner::startOfBlock(int index) const
return
start
;
}
int
BackwardsScanner
::
indentation
(
int
index
)
const
QString
BackwardsScanner
::
indentationString
(
int
index
)
const
{
SimpleToken
newline
=
operator
[](
startOfLine
(
index
+
1
));
return
newline
.
position
();
const
SimpleToken
tokenAfterNewline
=
operator
[](
startOfLine
(
index
+
1
));
const
int
newlinePos
=
qMax
(
0
,
_text
.
lastIndexOf
(
QLatin1Char
(
'\n'
),
tokenAfterNewline
.
position
()));
return
_text
.
mid
(
newlinePos
,
tokenAfterNewline
.
position
()
-
newlinePos
);
}
src/libs/cplusplus/BackwardsScanner.h
View file @
d20cdc64
...
...
@@ -61,7 +61,7 @@ public:
// n-la token is [startToken - n]
SimpleToken
operator
[](
int
index
)
const
;
// ### deprecate
int
indentation
(
int
index
)
const
;
QString
indentationString
(
int
index
)
const
;
int
startOfLine
(
int
index
)
const
;
int
startOfMatchingBrace
(
int
index
)
const
;
...
...
src/libs/cplusplus/ResolveExpression.cpp
View file @
d20cdc64
...
...
@@ -641,6 +641,7 @@ ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, i
foreach
(
Symbol
*
typedefCandidate
,
typedefCandidates
)
{
if
(
typedefCandidate
->
isTypedef
()
&&
typedefCandidate
->
type
()
->
isNamedType
())
{
ty
=
typedefCandidate
->
type
();
lastVisibleSymbol
=
typedefCandidate
;
break
;
}
}
...
...
src/plugins/cppeditor/cppeditor.cpp
View file @
d20cdc64
...
...
@@ -1700,37 +1700,44 @@ static void indentCPPBlock(const CPPEditor::TabSettings &ts,
ts
.
indentLine
(
block
,
indent
);
}
static
int
indentationColumn
(
const
TextEditor
::
TabSettings
&
tabSettings
,
const
BackwardsScanner
&
scanner
,
int
index
)
{
return
tabSettings
.
indentationColumn
(
scanner
.
indentationString
(
index
));
}
void
CPPEditor
::
indentBlock
(
QTextDocument
*
doc
,
QTextBlock
block
,
QChar
typedChar
)
{
QTextCursor
tc
(
block
);
tc
.
movePosition
(
QTextCursor
::
EndOfBlock
);
const
TabSettings
&
ts
=
tabSettings
();
BackwardsScanner
tk
(
tc
,
QString
(),
400
);
const
int
tokenCount
=
tk
.
startToken
();
const
int
indentSize
=
tabSettings
().
m_indentSize
;
if
(
tokenCount
!=
0
)
{
const
SimpleToken
firstToken
=
tk
[
0
];
if
(
firstToken
.
is
(
T_COLON
))
{
const
int
indent
=
tk
.
indentation
(
-
1
)
+
// indentation of the previous newline
indentSize
;
tabSettings
().
indentLine
(
block
,
indent
);
const
int
previousLineIndent
=
indentationColumn
(
ts
,
tk
,
-
1
);
ts
.
indentLine
(
block
,
previousLineIndent
+
ts
.
m_indentSize
);
return
;
}
else
if
((
firstToken
.
is
(
T_PUBLIC
)
||
firstToken
.
is
(
T_PROTECTED
)
||
firstToken
.
is
(
T_PRIVATE
)
||
firstToken
.
is
(
T_Q_SIGNALS
)
||
firstToken
.
is
(
T_Q_SLOTS
))
&&
tk
.
size
()
>
1
&&
tk
[
1
].
is
(
T_COLON
))
{
const
int
startOfBlock
=
tk
.
startOfBlock
(
0
);
if
(
startOfBlock
!=
0
)
{
const
int
indent
=
tk
.
indentation
(
startOfBlock
);
t
abSettings
()
.
indentLine
(
block
,
indent
);
const
int
indent
=
indentationColumn
(
ts
,
tk
,
startOfBlock
);
t
s
.
indentLine
(
block
,
indent
);
return
;
}
}
else
if
(
firstToken
.
is
(
T_CASE
)
||
firstToken
.
is
(
T_DEFAULT
))
{
const
int
startOfBlock
=
tk
.
startOfBlock
(
0
);
if
(
startOfBlock
!=
0
)
{
const
int
indent
=
tk
.
indentation
(
startOfBlock
);
t
abSettings
()
.
indentLine
(
block
,
indent
);
const
int
indent
=
indentationColumn
(
ts
,
tk
,
startOfBlock
);
t
s
.
indentLine
(
block
,
indent
);
return
;
}
return
;
...
...
@@ -1749,15 +1756,15 @@ void CPPEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedCha
const
QString
spell
=
tk
.
text
(
tokenIndex
);
if
(
tk
[
tokenIndex
].
followsNewline
()
&&
(
spell
.
startsWith
(
QLatin1String
(
"QT_"
))
||
spell
.
startsWith
(
QLatin1String
(
"Q_"
))))
{
const
int
indent
=
tk
.
indentation
(
tokenIndex
);
t
abSettings
()
.
indentLine
(
block
,
indent
);
const
int
indent
=
indentationColumn
(
ts
,
tk
,
tokenIndex
);
t
s
.
indentLine
(
block
,
indent
);
return
;
}
}
const
TextEditor
::
TextBlockIterator
begin
(
doc
->
begin
());
const
TextEditor
::
TextBlockIterator
end
(
block
.
next
());
indentCPPBlock
(
t
abSettings
()
,
block
,
begin
,
end
,
typedChar
);
indentCPPBlock
(
t
s
,
block
,
begin
,
end
,
typedChar
);
}
bool
CPPEditor
::
event
(
QEvent
*
e
)
...
...
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