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
b2bb919e
Commit
b2bb919e
authored
15 years ago
by
Christian Kamm
Browse files
Options
Downloads
Patches
Plain Diff
QmlJSEditor: Add completion for JS keywords and Qml reserved words.
Task-number: QTCREATORBUG-919 Reviewed-by: Roberto Raggi
parent
c21747a2
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/qmljsscanner.cpp
+10
-0
10 additions, 0 deletions
src/libs/qmljs/qmljsscanner.cpp
src/libs/qmljs/qmljsscanner.h
+1
-0
1 addition, 0 deletions
src/libs/qmljs/qmljsscanner.h
src/plugins/qmljseditor/qmljscodecompletion.cpp
+19
-0
19 additions, 0 deletions
src/plugins/qmljseditor/qmljscodecompletion.cpp
with
30 additions
and
0 deletions
src/libs/qmljs/qmljsscanner.cpp
+
10
−
0
View file @
b2bb919e
...
@@ -309,3 +309,13 @@ bool Scanner::isKeyword(const QString &text) const
...
@@ -309,3 +309,13 @@ bool Scanner::isKeyword(const QString &text) const
return
false
;
return
false
;
}
}
QStringList
Scanner
::
keywords
()
{
static
QStringList
words
;
if
(
words
.
isEmpty
())
{
for
(
const
QString
*
word
=
begin
(
js_keywords
);
word
!=
end
(
js_keywords
);
++
word
)
words
.
append
(
*
word
);
}
return
words
;
}
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsscanner.h
+
1
−
0
View file @
b2bb919e
...
@@ -87,6 +87,7 @@ public:
...
@@ -87,6 +87,7 @@ public:
int
state
()
const
;
int
state
()
const
;
bool
isKeyword
(
const
QString
&
text
)
const
;
bool
isKeyword
(
const
QString
&
text
)
const
;
static
QStringList
keywords
();
private:
private:
int
_state
;
int
_state
;
...
...
This diff is collapsed.
Click to expand it.
src/plugins/qmljseditor/qmljscodecompletion.cpp
+
19
−
0
View file @
b2bb919e
...
@@ -692,6 +692,25 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
...
@@ -692,6 +692,25 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
item
.
icon
=
symbolIcon
;
item
.
icon
=
symbolIcon
;
m_completions
.
append
(
item
);
m_completions
.
append
(
item
);
}
}
// add js keywords
foreach
(
const
QString
&
word
,
Scanner
::
keywords
())
{
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
word
;
m_completions
.
append
(
item
);
}
// add qml extra words
if
(
document
->
qmlProgram
())
{
static
QStringList
qmlWords
;
if
(
qmlWords
.
isEmpty
())
qmlWords
<<
"property"
<<
"readonly"
<<
"signal"
;
foreach
(
const
QString
&
word
,
qmlWords
)
{
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
word
;
m_completions
.
append
(
item
);
}
}
}
}
else
if
(
completionOperator
==
QLatin1Char
(
'.'
)
||
completionOperator
==
QLatin1Char
(
'('
))
{
else
if
(
completionOperator
==
QLatin1Char
(
'.'
)
||
completionOperator
==
QLatin1Char
(
'('
))
{
...
...
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