Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flatpak-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
Marco Bubke
flatpak-qt-creator
Commits
eb53e71d
Commit
eb53e71d
authored
14 years ago
by
Christian Kamm
Browse files
Options
Downloads
Patches
Plain Diff
QmlJSEditor: Simplify Qml completion code.
parent
fc362809
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/qmljseditor/qmljscodecompletion.cpp
+37
-64
37 additions, 64 deletions
src/plugins/qmljseditor/qmljscodecompletion.cpp
src/plugins/qmljseditor/qmljscodecompletion.h
+11
-0
11 additions, 0 deletions
src/plugins/qmljseditor/qmljscodecompletion.h
with
48 additions
and
64 deletions
src/plugins/qmljseditor/qmljscodecompletion.cpp
+
37
−
64
View file @
eb53e71d
...
@@ -595,6 +595,31 @@ static bool isLiteral(AST::Node *ast)
...
@@ -595,6 +595,31 @@ static bool isLiteral(AST::Node *ast)
return
false
;
return
false
;
}
}
void
CodeCompletion
::
addCompletions
(
const
QHash
<
QString
,
const
Interpreter
::
Value
*>
&
newCompletions
,
const
QIcon
&
icon
)
{
QHashIterator
<
QString
,
const
Interpreter
::
Value
*>
it
(
newCompletions
);
while
(
it
.
hasNext
())
{
it
.
next
();
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
it
.
key
();
item
.
icon
=
icon
;
m_completions
.
append
(
item
);
}
}
void
CodeCompletion
::
addCompletions
(
const
QStringList
&
newCompletions
,
const
QIcon
&
icon
)
{
foreach
(
const
QString
&
text
,
newCompletions
)
{
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
text
;
item
.
icon
=
icon
;
m_completions
.
append
(
item
);
}
}
int
CodeCompletion
::
startCompletion
(
TextEditor
::
ITextEditable
*
editor
)
int
CodeCompletion
::
startCompletion
(
TextEditor
::
ITextEditable
*
editor
)
{
{
m_editor
=
editor
;
m_editor
=
editor
;
...
@@ -660,25 +685,8 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
...
@@ -660,25 +685,8 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
enumerateProperties
.
setGlobalCompletion
(
true
);
enumerateProperties
.
setGlobalCompletion
(
true
);
enumerateProperties
.
setEnumerateGeneratedSlots
(
true
);
enumerateProperties
.
setEnumerateGeneratedSlots
(
true
);
QHashIterator
<
QString
,
const
Interpreter
::
Value
*>
it
(
enumerateProperties
(
qmlScopeType
));
addCompletions
(
enumerateProperties
(
qmlScopeType
),
symbolIcon
);
while
(
it
.
hasNext
())
{
addCompletions
(
enumerateProperties
(
context
.
scopeChain
().
qmlTypes
),
symbolIcon
);
it
.
next
();
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
it
.
key
();
item
.
icon
=
symbolIcon
;
m_completions
.
append
(
item
);
}
it
=
enumerateProperties
(
context
.
scopeChain
().
qmlTypes
);
while
(
it
.
hasNext
())
{
it
.
next
();
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
it
.
key
();
item
.
icon
=
symbolIcon
;
m_completions
.
append
(
item
);
}
}
}
if
(
contextFinder
.
isInRhsOfBinding
()
&&
qmlScopeType
)
{
if
(
contextFinder
.
isInRhsOfBinding
()
&&
qmlScopeType
)
{
...
@@ -713,30 +721,18 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
...
@@ -713,30 +721,18 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
// It's a global completion.
// It's a global completion.
EnumerateProperties
enumerateProperties
(
&
context
);
EnumerateProperties
enumerateProperties
(
&
context
);
enumerateProperties
.
setGlobalCompletion
(
true
);
enumerateProperties
.
setGlobalCompletion
(
true
);
QHashIterator
<
QString
,
const
Interpreter
::
Value
*>
it
(
enumerateProperties
());
addCompletions
(
enumerateProperties
(),
symbolIcon
);
while
(
it
.
hasNext
())
{
it
.
next
();
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
it
.
key
();
item
.
icon
=
symbolIcon
;
m_completions
.
append
(
item
);
}
}
}
if
(
doJsKeywordCompletion
)
{
if
(
doJsKeywordCompletion
)
{
// add js keywords
// add js keywords
foreach
(
const
QString
&
word
,
Scanner
::
keywords
())
{
addCompletions
(
Scanner
::
keywords
(),
keywordIcon
);
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
word
;
item
.
icon
=
keywordIcon
;
m_completions
.
append
(
item
);
}
}
}
// add qml extra words
// add qml extra words
if
(
doQmlKeywordCompletion
&&
isQmlFile
)
{
if
(
doQmlKeywordCompletion
&&
isQmlFile
)
{
static
QStringList
qmlWords
;
static
QStringList
qmlWords
;
static
QStringList
qmlWordsAlsoInJs
;
if
(
qmlWords
.
isEmpty
())
{
if
(
qmlWords
.
isEmpty
())
{
qmlWords
<<
QLatin1String
(
"property"
)
qmlWords
<<
QLatin1String
(
"property"
)
...
@@ -744,29 +740,14 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
...
@@ -744,29 +740,14 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
<<
QLatin1String
(
"signal"
)
<<
QLatin1String
(
"signal"
)
<<
QLatin1String
(
"import"
);
<<
QLatin1String
(
"import"
);
}
}
if
(
qmlWordsAlsoInJs
.
isEmpty
())
{
foreach
(
const
QString
&
word
,
qmlWords
)
{
qmlWordsAlsoInJs
<<
QLatin1String
(
"default"
)
TextEditor
::
CompletionItem
item
(
this
);
<<
QLatin1String
(
"function"
);
item
.
text
=
word
;
item
.
icon
=
keywordIcon
;
m_completions
.
append
(
item
);
}
}
if
(
!
doJsKeywordCompletion
)
{
addCompletions
(
qmlWords
,
keywordIcon
);
{
if
(
!
doJsKeywordCompletion
)
TextEditor
::
CompletionItem
item
(
this
);
addCompletions
(
qmlWordsAlsoInJs
,
keywordIcon
);
item
.
text
=
QLatin1String
(
"default"
);
item
.
icon
=
keywordIcon
;
m_completions
.
append
(
item
);
}
{
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
QLatin1String
(
"function"
);
item
.
icon
=
keywordIcon
;
m_completions
.
append
(
item
);
}
}
}
}
}
}
...
@@ -787,15 +768,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
...
@@ -787,15 +768,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if
(
value
&&
completionOperator
==
QLatin1Char
(
'.'
))
{
// member completion
if
(
value
&&
completionOperator
==
QLatin1Char
(
'.'
))
{
// member completion
EnumerateProperties
enumerateProperties
(
&
context
);
EnumerateProperties
enumerateProperties
(
&
context
);
QHashIterator
<
QString
,
const
Interpreter
::
Value
*>
it
(
enumerateProperties
(
value
));
addCompletions
(
enumerateProperties
(
value
),
symbolIcon
);
while
(
it
.
hasNext
())
{
it
.
next
();
TextEditor
::
CompletionItem
item
(
this
);
item
.
text
=
it
.
key
();
item
.
icon
=
symbolIcon
;
m_completions
.
append
(
item
);
}
}
else
if
(
value
&&
completionOperator
==
QLatin1Char
(
'('
)
&&
m_startPosition
==
editor
->
position
())
{
}
else
if
(
value
&&
completionOperator
==
QLatin1Char
(
'('
)
&&
m_startPosition
==
editor
->
position
())
{
// function completion
// function completion
if
(
const
Interpreter
::
FunctionValue
*
f
=
value
->
asFunctionValue
())
{
if
(
const
Interpreter
::
FunctionValue
*
f
=
value
->
asFunctionValue
())
{
...
...
This diff is collapsed.
Click to expand it.
src/plugins/qmljseditor/qmljscodecompletion.h
+
11
−
0
View file @
eb53e71d
...
@@ -39,6 +39,12 @@ namespace TextEditor {
...
@@ -39,6 +39,12 @@ namespace TextEditor {
class
ITextEditable
;
class
ITextEditable
;
}
}
namespace
QmlJS
{
namespace
Interpreter
{
class
Value
;
}
}
namespace
QmlJSEditor
{
namespace
QmlJSEditor
{
class
ModelManagerInterface
;
class
ModelManagerInterface
;
...
@@ -74,6 +80,11 @@ private:
...
@@ -74,6 +80,11 @@ private:
bool
maybeTriggersCompletion
(
TextEditor
::
ITextEditable
*
editor
);
bool
maybeTriggersCompletion
(
TextEditor
::
ITextEditable
*
editor
);
bool
isDelimiter
(
const
QChar
&
ch
)
const
;
bool
isDelimiter
(
const
QChar
&
ch
)
const
;
void
addCompletions
(
const
QHash
<
QString
,
const
QmlJS
::
Interpreter
::
Value
*>
&
newCompletions
,
const
QIcon
&
icon
);
void
addCompletions
(
const
QStringList
&
newCompletions
,
const
QIcon
&
icon
);
ModelManagerInterface
*
m_modelManager
;
ModelManagerInterface
*
m_modelManager
;
TextEditor
::
ITextEditable
*
m_editor
;
TextEditor
::
ITextEditable
*
m_editor
;
int
m_startPosition
;
int
m_startPosition
;
...
...
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