Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
49416fe8
Commit
49416fe8
authored
Apr 01, 2010
by
Christian Kamm
Browse files
QmlJS: Add a path->document list hash to Snapshot.
Also change the filename->document map to a hash. Reviewed-by: Roberto Raggi
parent
cadd9a6a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsdocument.cpp
View file @
49416fe8
...
...
@@ -250,8 +250,10 @@ Snapshot::~Snapshot()
void
Snapshot
::
insert
(
const
Document
::
Ptr
&
document
)
{
if
(
document
&&
(
document
->
qmlProgram
()
||
document
->
jsProgram
()))
if
(
document
&&
(
document
->
qmlProgram
()
||
document
->
jsProgram
()))
{
_documents
.
insert
(
document
->
fileName
(),
document
);
_documentsByPath
.
insert
(
document
->
path
(),
document
);
}
}
void
Snapshot
::
insertLibraryInfo
(
const
QString
&
path
,
const
LibraryInfo
&
info
)
...
...
src/libs/qmljs/qmljsdocument.h
View file @
49416fe8
...
...
@@ -131,9 +131,10 @@ public:
class
QMLJS_EXPORT
Snapshot
{
typedef
QMap
<
QString
,
Document
::
Ptr
>
_Base
;
QMap
<
QString
,
Document
::
Ptr
>
_documents
;
QMap
<
QString
,
LibraryInfo
>
_libraries
;
typedef
QHash
<
QString
,
Document
::
Ptr
>
_Base
;
QHash
<
QString
,
Document
::
Ptr
>
_documents
;
QMultiHash
<
QString
,
Document
::
Ptr
>
_documentsByPath
;
QHash
<
QString
,
LibraryInfo
>
_libraries
;
public:
Snapshot
();
...
...
@@ -151,6 +152,9 @@ public:
Document
::
Ptr
document
(
const
QString
&
fileName
)
const
{
return
_documents
.
value
(
fileName
);
}
QList
<
Document
::
Ptr
>
documentsInDirectory
(
const
QString
&
path
)
const
{
return
_documentsByPath
.
values
(
path
);
}
LibraryInfo
libraryInfo
(
const
QString
&
path
)
const
{
return
_libraries
.
value
(
path
);
}
...
...
src/libs/qmljs/qmljslink.cpp
View file @
49416fe8
...
...
@@ -21,8 +21,6 @@ Link::Link(Context *context, const Document::Ptr &doc, const Snapshot &snapshot,
,
_context
(
context
)
,
_importPaths
(
importPaths
)
{
foreach
(
Document
::
Ptr
doc
,
snapshot
)
_documentByPath
.
insert
(
doc
->
path
(),
doc
);
linkImports
();
}
...
...
@@ -161,7 +159,7 @@ void Link::populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Pt
// implicit imports:
// qml files in the same directory are available without explicit imports
foreach
(
Document
::
Ptr
otherDoc
,
_
documentByPath
.
values
(
doc
->
path
()))
{
foreach
(
Document
::
Ptr
otherDoc
,
_
snapshot
.
documentsInDirectory
(
doc
->
path
()))
{
if
(
otherDoc
==
doc
)
continue
;
...
...
@@ -206,13 +204,14 @@ void Link::importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
ObjectValue
*
importNamespace
=
typeEnv
;
// directory import
if
(
_documentByPath
.
contains
(
path
))
{
QList
<
Document
::
Ptr
>
documentsInDirectory
=
_snapshot
.
documentsInDirectory
(
path
);
if
(
!
documentsInDirectory
.
isEmpty
())
{
if
(
import
->
importId
)
{
importNamespace
=
engine
()
->
newObject
(
/*prototype =*/
0
);
typeEnv
->
setProperty
(
import
->
importId
->
asString
(),
importNamespace
);
}
foreach
(
Document
::
Ptr
importedDoc
,
_
document
ByPath
.
values
(
path
)
)
{
foreach
(
Document
::
Ptr
importedDoc
,
document
sInDirectory
)
{
const
QString
targetName
=
importedDoc
->
componentName
();
importNamespace
->
setProperty
(
targetName
,
importedDoc
->
bind
()
->
rootObjectValue
());
}
...
...
src/libs/qmljs/qmljslink.h
View file @
49416fe8
...
...
@@ -56,7 +56,6 @@ private:
Document
::
Ptr
_doc
;
Snapshot
_snapshot
;
Interpreter
::
Context
*
_context
;
QMultiHash
<
QString
,
Document
::
Ptr
>
_documentByPath
;
const
QStringList
_importPaths
;
QList
<
DiagnosticMessage
>
_diagnosticMessages
;
...
...
Write
Preview
Supports
Markdown
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