Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
kdevelop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rolf Eike Beer
kdevelop
Commits
ee1912a4
Commit
ee1912a4
authored
Aug 04, 2013
by
Milian Wolff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build contexts for UiObjectInitializer nodes.
parent
3e9f4dea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
2 deletions
+62
-2
duchain/contextbuilder.cpp
duchain/contextbuilder.cpp
+16
-2
duchain/contextbuilder.h
duchain/contextbuilder.h
+3
-0
duchain/tests/testcontexts.cpp
duchain/tests/testcontexts.cpp
+41
-0
duchain/tests/testcontexts.h
duchain/tests/testcontexts.h
+2
-0
No files found.
duchain/contextbuilder.cpp
View file @
ee1912a4
...
...
@@ -71,6 +71,11 @@ void ContextBuilder::setParseSession(ParseSession* session)
m_session
=
session
;
}
Editor
*
ContextBuilder
::
editor
()
const
{
return
m_editor
.
data
();
}
bool
ContextBuilder
::
visit
(
QmlJS
::
AST
::
FunctionDeclaration
*
node
)
{
const
QualifiedIdentifier
functionName
(
node
->
name
.
toString
());
...
...
@@ -95,7 +100,16 @@ bool ContextBuilder::visit(QmlJS::AST::FunctionDeclaration* node)
return
false
;
}
Editor
*
ContextBuilder
::
editor
()
const
bool
ContextBuilder
::
visit
(
QmlJS
::
AST
::
UiObjectInitializer
*
node
)
{
return
m_editor
.
data
();
const
RangeInRevision
range
(
m_session
->
locationToRange
(
node
->
lbraceToken
).
end
,
m_session
->
locationToRange
(
node
->
rbraceToken
).
start
);
openContext
(
node
,
range
,
DUContext
::
Class
);
return
true
;
}
void
ContextBuilder
::
endVisit
(
QmlJS
::
AST
::
UiObjectInitializer
*
/*node*/
)
{
closeContext
();
}
duchain/contextbuilder.h
View file @
ee1912a4
...
...
@@ -65,7 +65,10 @@ public:
void
setParseSession
(
ParseSession
*
session
);
using
Visitor
::
visit
;
using
Visitor
::
endVisit
;
virtual
bool
visit
(
QmlJS
::
AST
::
FunctionDeclaration
*
node
);
virtual
bool
visit
(
QmlJS
::
AST
::
UiObjectInitializer
*
node
);
virtual
void
endVisit
(
QmlJS
::
AST
::
UiObjectInitializer
*
node
);
Editor
*
editor
()
const
;
...
...
duchain/tests/testcontexts.cpp
View file @
ee1912a4
...
...
@@ -103,4 +103,45 @@ void TestContexts::testFunctionContext_data()
<<
RangeInRevision
(
0
,
16
,
1
,
0
);
}
void
TestContexts
::
testQMLContext
()
{
const
IndexedString
file
(
"testQMLContext.qml"
);
ParseSession
session
(
file
,
"Text {
\n
"
" id: main
\n
"
" Text {
\n
"
" id: child1
\n
"
" }
\n
"
" Text {
\n
"
" id: child2
\n
"
" }
\n
"
"}
\n
"
);
QVERIFY
(
session
.
ast
());
QCOMPARE
(
session
.
language
(),
QmlJS
::
Document
::
QmlLanguage
);
ContextBuilder
builder
;
builder
.
setParseSession
(
&
session
);
ReferencedTopDUContext
top
=
builder
.
build
(
file
,
session
.
ast
());
QVERIFY
(
top
);
DUChainReadLocker
lock
;
QCOMPARE
(
top
->
type
(),
DUContext
::
Global
);
QCOMPARE
(
top
->
childContexts
().
count
(),
1
);
DUContext
*
mainCtx
=
top
->
childContexts
().
first
();
QCOMPARE
(
mainCtx
->
type
(),
DUContext
::
Class
);
QCOMPARE
(
mainCtx
->
range
(),
RangeInRevision
(
0
,
6
,
8
,
0
));
QCOMPARE
(
mainCtx
->
childContexts
().
size
(),
2
);
DUContext
*
child1Ctx
=
mainCtx
->
childContexts
().
first
();
QCOMPARE
(
child1Ctx
->
type
(),
DUContext
::
Class
);
QCOMPARE
(
child1Ctx
->
range
(),
RangeInRevision
(
2
,
8
,
4
,
2
));
QCOMPARE
(
child1Ctx
->
childContexts
().
size
(),
0
);
DUContext
*
child2Ctx
=
mainCtx
->
childContexts
().
last
();
QCOMPARE
(
child2Ctx
->
type
(),
DUContext
::
Class
);
QCOMPARE
(
child2Ctx
->
range
(),
RangeInRevision
(
5
,
8
,
7
,
2
));
QCOMPARE
(
child2Ctx
->
childContexts
().
size
(),
0
);
}
#include "testcontexts.moc"
duchain/tests/testcontexts.h
View file @
ee1912a4
...
...
@@ -33,6 +33,8 @@ private slots:
void
testFunctionContext
();
void
testFunctionContext_data
();
void
testQMLContext
();
};
#endif // TESTCONTEXTS_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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