Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
5f04fbba
Commit
5f04fbba
authored
Dec 09, 2010
by
Christian Kamm
Browse files
QmlJS indenter: Fix for expressions starting with numbers or strings.
Reviewed-by: Roberto Raggi
parent
abd4a7b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljscodeformatter.cpp
View file @
5f04fbba
...
...
@@ -693,6 +693,8 @@ bool CodeFormatter::tryStatement()
case
List
:
case
Property
:
case
Function
:
case
Number
:
case
String
:
enter
(
expression
);
// look at the token again
m_tokenIndex
-=
1
;
...
...
tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro
View file @
5f04fbba
...
...
@@ -12,11 +12,11 @@ include($$SRCDIR/libs/utils/utils-lib.pri)
SOURCES
+=
\
tst_qmlcodeformatter
.
cpp
\
$$
SRCDIR
/
plugins
/
qmljs
editor
/
qmljseditor
codeformatter
.
cpp
\
$$
SRCDIR
/
plugins
/
qmljs
tools
/
qmljsqtstyle
codeformatter
.
cpp
\
$$
SRCDIR
/
plugins
/
texteditor
/
basetextdocumentlayout
.
cpp
HEADERS
+=
\
$$
SRCDIR
/
plugins
/
qmljs
editor
/
qmljseditorcodeformatter
.
h
\
$$
SRCDIR
/
plugins
/
texteditor
/
basetextdocumentlayout
.
h
\
$$
SRCDIR
/
plugins
/
qmljs
tools
/
qmljseditorcodeformatter
.
h
\
$$
SRCDIR
/
plugins
/
texteditor
/
basetextdocumentlayout
.
h
INCLUDEPATH
+=
$$
SRCDIR
/
plugins
$$
SRCDIR
/
libs
tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
View file @
5f04fbba
...
...
@@ -4,9 +4,9 @@
#include
<QTextDocument>
#include
<QTextBlock>
#include
<qmljs
editor/qmljseditor
codeformatter.h>
#include
<qmljs
tools/qmljsqtstyle
codeformatter.h>
using
namespace
QmlJS
Editor
;
using
namespace
QmlJS
Tools
;
class
tst_QMLCodeFormatter
:
public
QObject
{
...
...
@@ -27,6 +27,7 @@ private Q_SLOTS:
void
signalDeclarations
();
void
ifBinding1
();
void
ifBinding2
();
void
ifBinding3
();
void
ifStatementWithoutBraces1
();
void
ifStatementWithoutBraces2
();
void
ifStatementWithBraces1
();
...
...
@@ -431,6 +432,36 @@ void tst_QMLCodeFormatter::ifBinding2()
checkIndent
(
data
);
}
void
tst_QMLCodeFormatter
::
ifBinding3
()
{
QList
<
Line
>
data
;
data
<<
Line
(
"A.Rectangle {"
)
<<
Line
(
" foo: bar"
)
<<
Line
(
" x: if (a) 1"
)
<<
Line
(
" x: if (a)"
)
<<
Line
(
" 1"
)
<<
Line
(
" x: if (a) 1;"
)
<<
Line
(
" x: if (a)"
)
<<
Line
(
" 1;"
)
<<
Line
(
" x: if (a) 1; else 2"
)
<<
Line
(
" x: if (a) 1"
)
<<
Line
(
" else 2"
)
<<
Line
(
" x: if (a) 1;"
)
<<
Line
(
" else 2"
)
<<
Line
(
" x: if (a) 1;"
)
<<
Line
(
" else"
)
<<
Line
(
" 2"
)
<<
Line
(
" x: if (a)"
)
<<
Line
(
" 1"
)
<<
Line
(
" else"
)
<<
Line
(
" 2"
)
<<
Line
(
" x: if (a) 1; else 2;"
)
<<
Line
(
" x: 1"
)
<<
Line
(
"}"
)
;
checkIndent
(
data
);
}
void
tst_QMLCodeFormatter
::
ifStatementWithoutBraces1
()
{
QList
<
Line
>
data
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment