Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
1bc838fd
Commit
1bc838fd
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Handle comments at the end of braceless control statements.
parent
64a167c2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/qmljs/qmljsindenter.cpp
+18
-1
18 additions, 1 deletion
src/libs/qmljs/qmljsindenter.cpp
src/libs/qmljs/qmljsindenter.h
+2
-0
2 additions, 0 deletions
src/libs/qmljs/qmljsindenter.h
src/libs/qmljs/qmljsscanner.h
+7
-4
7 additions, 4 deletions
src/libs/qmljs/qmljsscanner.h
with
27 additions
and
5 deletions
src/libs/qmljs/qmljsindenter.cpp
+
18
−
1
View file @
1bc838fd
...
@@ -309,6 +309,18 @@ bool QmlJSIndenter::okay(QChar typedIn, QChar okayCh) const
...
@@ -309,6 +309,18 @@ bool QmlJSIndenter::okay(QChar typedIn, QChar okayCh) const
return
typedIn
==
QChar
()
||
typedIn
==
okayCh
;
return
typedIn
==
QChar
()
||
typedIn
==
okayCh
;
}
}
QmlJSScanner
::
Token
QmlJSIndenter
::
lastToken
()
const
{
for
(
int
index
=
yyLinizerState
.
tokens
.
size
()
-
1
;
index
!=
-
1
;
--
index
)
{
const
QmlJSScanner
::
Token
&
token
=
yyLinizerState
.
tokens
.
at
(
index
);
if
(
token
.
isNot
(
QmlJSScanner
::
Token
::
Comment
))
return
token
;
}
return
QmlJSScanner
::
Token
();
}
/*
/*
Saves and restores the state of the global linizer. This enables
Saves and restores the state of the global linizer. This enables
backtracking.
backtracking.
...
@@ -473,7 +485,7 @@ bool QmlJSIndenter::matchBracelessControlStatement()
...
@@ -473,7 +485,7 @@ bool QmlJSIndenter::matchBracelessControlStatement()
int
delimDepth
=
0
;
int
delimDepth
=
0
;
if
(
!
yyLinizerState
.
tokens
.
isEmpty
())
{
if
(
!
yyLinizerState
.
tokens
.
isEmpty
())
{
const
QmlJSScanner
::
Token
&
tk
=
yyLinizerState
.
tokens
.
last
();
QmlJSScanner
::
Token
tk
=
lastToken
();
if
(
tk
.
is
(
QmlJSScanner
::
Token
::
Identifier
)
&&
if
(
tk
.
is
(
QmlJSScanner
::
Token
::
Identifier
)
&&
yyLinizerState
.
line
.
midRef
(
tk
.
offset
,
tk
.
length
)
==
QLatin1String
(
"else"
))
yyLinizerState
.
line
.
midRef
(
tk
.
offset
,
tk
.
length
)
==
QLatin1String
(
"else"
))
...
@@ -491,6 +503,10 @@ bool QmlJSIndenter::matchBracelessControlStatement()
...
@@ -491,6 +503,10 @@ bool QmlJSIndenter::matchBracelessControlStatement()
default:
default:
break
;
break
;
case
QmlJSScanner
::
Token
::
Comment
:
// skip comments
break
;
case
QmlJSScanner
::
Token
::
RightParenthesis
:
case
QmlJSScanner
::
Token
::
RightParenthesis
:
++
delimDepth
;
++
delimDepth
;
break
;
break
;
...
@@ -1056,3 +1072,4 @@ int QmlJSIndenter::indentForBottomLine(QTextBlock begin, QTextBlock end, QChar t
...
@@ -1056,3 +1072,4 @@ int QmlJSIndenter::indentForBottomLine(QTextBlock begin, QTextBlock end, QChar t
return
qMax
(
0
,
indent
);
return
qMax
(
0
,
indent
);
}
}
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsindenter.h
+
2
−
0
View file @
1bc838fd
...
@@ -84,6 +84,8 @@ private:
...
@@ -84,6 +84,8 @@ private:
int
indentForContinuationLine
();
int
indentForContinuationLine
();
int
indentForStandaloneLine
();
int
indentForStandaloneLine
();
QmlJSScanner
::
Token
lastToken
()
const
;
private:
private:
int
ppHardwareTabSize
;
int
ppHardwareTabSize
;
int
ppIndentSize
;
int
ppIndentSize
;
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsscanner.h
+
7
−
4
View file @
1bc838fd
...
@@ -41,11 +41,9 @@ namespace QmlJS {
...
@@ -41,11 +41,9 @@ namespace QmlJS {
class
QMLJS_EXPORT
QmlJSScanner
class
QMLJS_EXPORT
QmlJSScanner
{
{
public:
public:
struct
Token
{
struct
Token
{
int
offset
;
int
length
;
enum
Kind
{
enum
Kind
{
EndOfFile
,
Keyword
,
Keyword
,
Identifier
,
Identifier
,
String
,
String
,
...
@@ -62,8 +60,13 @@ public:
...
@@ -62,8 +60,13 @@ public:
Colon
,
Colon
,
Comma
,
Comma
,
Dot
Dot
}
kind
;
};
int
offset
;
int
length
;
Kind
kind
;
inline
Token
()
:
offset
(
0
),
length
(
0
),
kind
(
EndOfFile
)
{}
inline
Token
(
int
o
,
int
l
,
Kind
k
)
:
offset
(
o
),
length
(
l
),
kind
(
k
)
{}
inline
Token
(
int
o
,
int
l
,
Kind
k
)
:
offset
(
o
),
length
(
l
),
kind
(
k
)
{}
inline
int
begin
()
const
{
return
offset
;
}
inline
int
begin
()
const
{
return
offset
;
}
inline
int
end
()
const
{
return
offset
+
length
;
}
inline
int
end
()
const
{
return
offset
+
length
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment