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
5cff896f
Commit
5cff896f
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Get rid off QmlJSEditor::m_idRevisions & co.
parent
e622d706
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/qmljseditor/qmljseditor.cpp
+22
-12
22 additions, 12 deletions
src/plugins/qmljseditor/qmljseditor.cpp
src/plugins/qmljseditor/qmljseditor.h
+3
-2
3 additions, 2 deletions
src/plugins/qmljseditor/qmljseditor.h
with
25 additions
and
14 deletions
src/plugins/qmljseditor/qmljseditor.cpp
+
22
−
12
View file @
5cff896f
...
@@ -125,13 +125,14 @@ bool shouldInsertMatchingText(const QTextCursor &tc)
...
@@ -125,13 +125,14 @@ bool shouldInsertMatchingText(const QTextCursor &tc)
class
FindIdDeclarations
:
protected
Visitor
class
FindIdDeclarations
:
protected
Visitor
{
{
public:
public:
typedef
Q
Map
<
QString
,
QList
<
AST
::
SourceLocation
>
>
Result
;
typedef
Q
Hash
<
QString
,
QList
<
AST
::
SourceLocation
>
>
Result
;
Result
operator
()(
AST
::
Node
*
node
)
Result
operator
()(
Document
::
Ptr
doc
)
{
{
_ids
.
clear
();
_ids
.
clear
();
_maybeIds
.
clear
();
_maybeIds
.
clear
();
accept
(
node
);
if
(
doc
&&
doc
->
qmlProgram
())
doc
->
qmlProgram
()
->
accept
(
this
);
return
_ids
;
return
_ids
;
}
}
...
@@ -428,6 +429,14 @@ protected:
...
@@ -428,6 +429,14 @@ protected:
}
// end of anonymous namespace
}
// end of anonymous namespace
int
SemanticInfo
::
revision
()
const
{
if
(
document
)
return
document
->
documentRevision
();
return
0
;
}
QmlJSEditorEditable
::
QmlJSEditorEditable
(
QmlJSTextEditor
*
editor
)
QmlJSEditorEditable
::
QmlJSEditorEditable
(
QmlJSTextEditor
*
editor
)
:
BaseTextEditorEditable
(
editor
)
:
BaseTextEditorEditable
(
editor
)
{
{
...
@@ -443,7 +452,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
...
@@ -443,7 +452,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
m_modelManager
(
0
),
m_modelManager
(
0
),
m_typeSystem
(
0
)
m_typeSystem
(
0
)
{
{
m_idsRevision
=
-
1
;
setParenthesesMatchingEnabled
(
true
);
setParenthesesMatchingEnabled
(
true
);
setMarksVisible
(
true
);
setMarksVisible
(
true
);
setCodeFoldingSupported
(
true
);
setCodeFoldingSupported
(
true
);
...
@@ -531,10 +539,6 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
...
@@ -531,10 +539,6 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
return
;
return
;
}
}
FindIdDeclarations
updateIds
;
m_idsRevision
=
document
()
->
revision
();
m_ids
=
updateIds
(
doc
->
qmlProgram
());
if
(
doc
->
ast
())
{
if
(
doc
->
ast
())
{
// got a correctly parsed (or recovered) file.
// got a correctly parsed (or recovered) file.
...
@@ -543,6 +547,11 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
...
@@ -543,6 +547,11 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
SemanticInfo
sem
;
SemanticInfo
sem
;
sem
.
document
=
doc
;
sem
.
document
=
doc
;
sem
.
ranges
=
createRanges
(
document
(),
doc
);
sem
.
ranges
=
createRanges
(
document
(),
doc
);
// Refresh the ids
FindIdDeclarations
updateIds
;
sem
.
idLocations
=
updateIds
(
doc
);
m_semanticInfo
=
sem
;
m_semanticInfo
=
sem
;
if
(
doc
->
isParsedCorrectly
())
{
if
(
doc
->
isParsedCorrectly
())
{
...
@@ -630,7 +639,7 @@ void QmlJSTextEditor::updateUses()
...
@@ -630,7 +639,7 @@ void QmlJSTextEditor::updateUses()
void
QmlJSTextEditor
::
updateUsesNow
()
void
QmlJSTextEditor
::
updateUsesNow
()
{
{
if
(
document
()
->
revision
()
!=
m_
idsR
evision
)
{
if
(
document
()
->
revision
()
!=
m_
semanticInfo
.
r
evision
()
)
{
updateUses
();
updateUses
();
return
;
return
;
}
}
...
@@ -638,7 +647,7 @@ void QmlJSTextEditor::updateUsesNow()
...
@@ -638,7 +647,7 @@ void QmlJSTextEditor::updateUsesNow()
m_updateUsesTimer
->
stop
();
m_updateUsesTimer
->
stop
();
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
foreach
(
const
AST
::
SourceLocation
&
loc
,
m_
id
s
.
value
(
wordUnderCursor
()))
{
foreach
(
const
AST
::
SourceLocation
&
loc
,
m_
semanticInfo
.
idLocation
s
.
value
(
wordUnderCursor
()))
{
if
(
!
loc
.
isValid
())
if
(
!
loc
.
isValid
())
continue
;
continue
;
...
@@ -673,7 +682,7 @@ void QmlJSTextEditor::renameIdUnderCursor()
...
@@ -673,7 +682,7 @@ void QmlJSTextEditor::renameIdUnderCursor()
if
(
ok
)
{
if
(
ok
)
{
Utils
::
ChangeSet
changeSet
;
Utils
::
ChangeSet
changeSet
;
foreach
(
const
AST
::
SourceLocation
&
loc
,
m_
id
s
.
value
(
id
))
{
foreach
(
const
AST
::
SourceLocation
&
loc
,
m_
semanticInfo
.
idLocation
s
.
value
(
id
))
{
changeSet
.
replace
(
loc
.
offset
,
loc
.
length
,
newId
);
changeSet
.
replace
(
loc
.
offset
,
loc
.
length
,
newId
);
}
}
...
@@ -849,7 +858,7 @@ void QmlJSTextEditor::contextMenuEvent(QContextMenuEvent *e)
...
@@ -849,7 +858,7 @@ void QmlJSTextEditor::contextMenuEvent(QContextMenuEvent *e)
}
}
const
QString
id
=
wordUnderCursor
();
const
QString
id
=
wordUnderCursor
();
const
QList
<
AST
::
SourceLocation
>
&
locations
=
m_
id
s
.
value
(
id
);
const
QList
<
AST
::
SourceLocation
>
&
locations
=
m_
semanticInfo
.
idLocation
s
.
value
(
id
);
if
(
!
locations
.
isEmpty
())
{
if
(
!
locations
.
isEmpty
())
{
menu
->
addSeparator
();
menu
->
addSeparator
();
QAction
*
a
=
menu
->
addAction
(
tr
(
"Rename id '%1'..."
).
arg
(
id
));
QAction
*
a
=
menu
->
addAction
(
tr
(
"Rename id '%1'..."
).
arg
(
id
));
...
@@ -1013,3 +1022,4 @@ QString QmlJSTextEditor::insertParagraphSeparator(const QTextCursor &) const
...
@@ -1013,3 +1022,4 @@ QString QmlJSTextEditor::insertParagraphSeparator(const QTextCursor &) const
{
{
return
QLatin1String
(
"}
\n
"
);
return
QLatin1String
(
"}
\n
"
);
}
}
This diff is collapsed.
Click to expand it.
src/plugins/qmljseditor/qmljseditor.h
+
3
−
2
View file @
5cff896f
...
@@ -107,9 +107,12 @@ class SemanticInfo
...
@@ -107,9 +107,12 @@ class SemanticInfo
public:
public:
SemanticInfo
()
{}
SemanticInfo
()
{}
int
revision
()
const
;
public
:
// attributes
public
:
// attributes
QmlJS
::
Document
::
Ptr
document
;
QmlJS
::
Document
::
Ptr
document
;
QList
<
Range
>
ranges
;
QList
<
Range
>
ranges
;
QHash
<
QString
,
QList
<
QmlJS
::
AST
::
SourceLocation
>
>
idLocations
;
};
};
class
QmlJSTextEditor
:
public
TextEditor
::
BaseTextEditor
class
QmlJSTextEditor
:
public
TextEditor
::
BaseTextEditor
...
@@ -173,8 +176,6 @@ private:
...
@@ -173,8 +176,6 @@ private:
QTimer
*
m_updateUsesTimer
;
QTimer
*
m_updateUsesTimer
;
QComboBox
*
m_methodCombo
;
QComboBox
*
m_methodCombo
;
QList
<
Declaration
>
m_declarations
;
// ### remove me
QList
<
Declaration
>
m_declarations
;
// ### remove me
QMap
<
QString
,
QList
<
QmlJS
::
AST
::
SourceLocation
>
>
m_ids
;
// ### remove me
int
m_idsRevision
;
// ### remove me
QmlModelManagerInterface
*
m_modelManager
;
QmlModelManagerInterface
*
m_modelManager
;
QmlJS
::
TypeSystem
*
m_typeSystem
;
QmlJS
::
TypeSystem
*
m_typeSystem
;
QTextCharFormat
m_occurrencesFormat
;
QTextCharFormat
m_occurrencesFormat
;
...
...
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