Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
0d5d6344
Commit
0d5d6344
authored
May 20, 2010
by
Christian Kamm
Browse files
QmlJS: Collect import version numbers in Bind.
parent
1cf95867
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsbind.cpp
View file @
0d5d6344
...
...
@@ -53,17 +53,17 @@ Bind::~Bind()
{
}
Q
StringList
Bind
::
fileImports
()
const
Q
List
<
Bind
::
ImportInfo
>
Bind
::
fileImports
()
const
{
return
_fileImports
;
}
Q
StringList
Bind
::
directoryImports
()
const
Q
List
<
Bind
::
ImportInfo
>
Bind
::
directoryImports
()
const
{
return
_directoryImports
;
}
Q
StringList
Bind
::
libraryImports
()
const
Q
List
<
Bind
::
ImportInfo
>
Bind
::
libraryImports
()
const
{
return
_libraryImports
;
}
...
...
@@ -185,14 +185,30 @@ bool Bind::visit(AST::Program *)
bool
Bind
::
visit
(
UiImport
*
ast
)
{
ImportInfo
info
;
info
.
majorVersion
=
QmlObjectValue
::
NoVersion
;
info
.
minorVersion
=
QmlObjectValue
::
NoVersion
;
if
(
ast
->
versionToken
.
isValid
())
{
const
QString
versionString
=
_doc
->
source
().
mid
(
ast
->
versionToken
.
offset
,
ast
->
versionToken
.
length
);
const
int
dotIdx
=
versionString
.
indexOf
(
QLatin1Char
(
'.'
));
if
(
dotIdx
!=
-
1
)
{
info
.
majorVersion
=
versionString
.
left
(
dotIdx
).
toInt
();
info
.
minorVersion
=
versionString
.
mid
(
dotIdx
+
1
).
toInt
();
}
}
if
(
ast
->
importUri
)
{
_libraryImports
+=
toString
(
ast
->
importUri
,
QLatin1Char
(
'/'
));
info
.
name
=
toString
(
ast
->
importUri
,
QLatin1Char
(
'/'
));
_libraryImports
+=
info
;
}
else
if
(
ast
->
fileName
)
{
const
QFileInfo
importFileInfo
(
_doc
->
path
()
+
QLatin1Char
(
'/'
)
+
ast
->
fileName
->
asString
());
info
.
name
=
importFileInfo
.
absoluteFilePath
();
if
(
importFileInfo
.
isFile
())
_fileImports
+=
i
mportFileInfo
.
absoluteFilePath
()
;
_fileImports
+=
i
nfo
;
else
if
(
importFileInfo
.
isDir
())
_directoryImports
+=
i
mportFileInfo
.
absoluteFilePath
()
;
_directoryImports
+=
i
nfo
;
//else
// error: file or directory does not exist
}
...
...
src/libs/qmljs/qmljsbind.h
View file @
0d5d6344
...
...
@@ -50,9 +50,15 @@ public:
Bind
(
Document
*
doc
);
virtual
~
Bind
();
QStringList
fileImports
()
const
;
QStringList
directoryImports
()
const
;
QStringList
libraryImports
()
const
;
struct
ImportInfo
{
QString
name
;
int
majorVersion
;
int
minorVersion
;
};
QList
<
ImportInfo
>
fileImports
()
const
;
QList
<
ImportInfo
>
directoryImports
()
const
;
QList
<
ImportInfo
>
libraryImports
()
const
;
Interpreter
::
ObjectValue
*
currentObjectValue
()
const
;
Interpreter
::
ObjectValue
*
idEnvironment
()
const
;
...
...
@@ -105,9 +111,9 @@ private:
QHash
<
AST
::
FunctionDeclaration
*
,
Interpreter
::
ObjectValue
*>
_functionScopes
;
QStringList
_includedScripts
;
Q
StringList
_fileImports
;
Q
StringList
_directoryImports
;
Q
StringList
_libraryImports
;
Q
List
<
ImportInfo
>
_fileImports
;
Q
List
<
ImportInfo
>
_directoryImports
;
Q
List
<
ImportInfo
>
_libraryImports
;
};
}
// end of namespace Qml
...
...
src/libs/qmljs/qmljslink.cpp
View file @
0d5d6344
...
...
@@ -65,8 +65,8 @@ void Link::initializeScopeChain()
}
else
{
// add scope chains for all components that import this file
foreach
(
Document
::
Ptr
otherDoc
,
_snapshot
)
{
foreach
(
const
QString
&
fileImport
,
otherDoc
->
bind
()
->
fileImports
())
{
if
(
_doc
->
fileName
()
==
fileImport
)
{
foreach
(
const
Bind
::
ImportInfo
&
fileImport
,
otherDoc
->
bind
()
->
fileImports
())
{
if
(
_doc
->
fileName
()
==
fileImport
.
name
)
{
ScopeChain
::
QmlComponentChain
*
component
=
new
ScopeChain
::
QmlComponentChain
;
componentScopes
.
insert
(
otherDoc
.
data
(),
component
);
scopeChain
.
qmlComponentScope
.
instantiatingComponents
+=
component
;
...
...
src/plugins/qmljseditor/qmljsmodelmanager.cpp
View file @
0d5d6344
...
...
@@ -236,15 +236,15 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho
QStringList
*
importedFiles
,
QSet
<
QString
>
*
scannedPaths
)
{
// scan files and directories that are explicitly imported
foreach
(
const
QString
&
fileImport
,
doc
->
bind
()
->
fileImports
())
{
if
(
!
snapshot
.
document
(
fileImport
))
*
importedFiles
+=
fileImport
;
foreach
(
const
Bind
::
ImportInfo
&
fileImport
,
doc
->
bind
()
->
fileImports
())
{
if
(
!
snapshot
.
document
(
fileImport
.
name
))
*
importedFiles
+=
fileImport
.
name
;
}
foreach
(
const
QString
&
directoryImport
,
doc
->
bind
()
->
directoryImports
())
{
if
(
snapshot
.
documentsInDirectory
(
directoryImport
).
isEmpty
())
{
if
(
!
scannedPaths
->
contains
(
directoryImport
))
{
*
importedFiles
+=
qmlFilesInDirectory
(
directoryImport
);
scannedPaths
->
insert
(
directoryImport
);
foreach
(
const
Bind
::
ImportInfo
&
directoryImport
,
doc
->
bind
()
->
directoryImports
())
{
if
(
snapshot
.
documentsInDirectory
(
directoryImport
.
name
).
isEmpty
())
{
if
(
!
scannedPaths
->
contains
(
directoryImport
.
name
))
{
*
importedFiles
+=
qmlFilesInDirectory
(
directoryImport
.
name
);
scannedPaths
->
insert
(
directoryImport
.
name
);
}
}
}
...
...
@@ -256,10 +256,10 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
{
// scan library imports
const
QStringList
importPaths
=
modelManager
->
importPaths
();
foreach
(
const
QString
&
libraryImport
,
doc
->
bind
()
->
libraryImports
())
{
foreach
(
const
Bind
::
ImportInfo
&
libraryImport
,
doc
->
bind
()
->
libraryImports
())
{
foreach
(
const
QString
&
importPath
,
importPaths
)
{
QDir
dir
(
importPath
);
dir
.
cd
(
libraryImport
);
dir
.
cd
(
libraryImport
.
name
);
const
QString
targetPath
=
dir
.
absolutePath
();
// if we know there is a library, done
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment