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
dab558d4
Commit
dab558d4
authored
15 years ago
by
Christian Kamm
Browse files
Options
Downloads
Patches
Plain Diff
Add errors for incorrect imports in Qml.
Task-number: QTCREATORBUG-874 Reviewed-by: Erik Verbruggen
parent
0423169b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/qmljs/qmljscheck.cpp
+1
-0
1 addition, 0 deletions
src/libs/qmljs/qmljscheck.cpp
src/libs/qmljs/qmljslink.cpp
+35
-5
35 additions, 5 deletions
src/libs/qmljs/qmljslink.cpp
src/libs/qmljs/qmljslink.h
+4
-0
4 additions, 0 deletions
src/libs/qmljs/qmljslink.h
with
40 additions
and
5 deletions
src/libs/qmljs/qmljscheck.cpp
+
1
−
0
View file @
dab558d4
...
...
@@ -187,6 +187,7 @@ QList<DiagnosticMessage> Check::operator()()
{
_messages
.
clear
();
Node
::
accept
(
_doc
->
ast
(),
this
);
_messages
.
append
(
_link
.
diagnosticMessages
());
return
_messages
;
}
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljslink.cpp
+
35
−
5
View file @
dab558d4
...
...
@@ -8,6 +8,7 @@
#include
<QtCore/QFileInfo>
#include
<QtCore/QDir>
#include
<QtCore/QDebug>
#include
<QtCore/QCoreApplication>
using
namespace
QmlJS
;
using
namespace
QmlJS
::
Interpreter
;
...
...
@@ -33,6 +34,11 @@ Interpreter::Engine *Link::engine()
return
_context
->
engine
();
}
QList
<
DiagnosticMessage
>
Link
::
diagnosticMessages
()
const
{
return
_diagnosticMessages
;
}
void
Link
::
scopeChainAt
(
Document
::
Ptr
doc
,
const
QList
<
Node
*>
&
astPath
)
{
ScopeChain
&
scopeChain
=
_context
->
scopeChain
();
...
...
@@ -234,10 +240,21 @@ void Link::importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
importNamespace
->
setProperty
(
targetName
,
importedDoc
->
bind
()
->
rootObjectValue
());
}
else
{
// error!
_diagnosticMessages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
import
->
fileNameToken
,
QCoreApplication
::
translate
(
"QmlJS::Link"
,
"could not find file or directory"
)));
}
}
static
SourceLocation
locationFromRange
(
const
SourceLocation
&
start
,
const
SourceLocation
&
end
)
{
return
SourceLocation
(
start
.
offset
,
end
.
end
()
-
start
.
begin
(),
start
.
startLine
,
start
.
startColumn
);
}
/*
import Qt 4.6
import Qt 4.6 as Xxx
...
...
@@ -266,13 +283,20 @@ void Link::importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, A
const
QString
versionString
=
doc
->
source
().
mid
(
import
->
versionToken
.
offset
,
import
->
versionToken
.
length
);
const
int
dotIdx
=
versionString
.
indexOf
(
QLatin1Char
(
'.'
));
if
(
dotIdx
==
-
1
)
{
// only major (which is probably invalid, but let's handle it anyway)
majorVersion
=
versionString
.
toInt
();
minorVersion
=
0
;
// ### TODO: Check with magic version numbers above
_diagnosticMessages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
import
->
versionToken
,
QCoreApplication
::
translate
(
"QmlJS::Link"
,
"expected two numbers separated by a dot"
)));
return
;
}
else
{
majorVersion
=
versionString
.
left
(
dotIdx
).
toInt
();
minorVersion
=
versionString
.
mid
(
dotIdx
+
1
).
toInt
();
}
}
else
{
_diagnosticMessages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
locationFromRange
(
import
->
firstSourceLocation
(),
import
->
lastSourceLocation
()),
QCoreApplication
::
translate
(
"QmlJS::Link"
,
"package import requires a version number"
)));
return
;
}
// if the package is in the meta type system, use it
...
...
@@ -280,6 +304,7 @@ void Link::importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, A
foreach
(
QmlObjectValue
*
object
,
engine
()
->
metaTypeSystem
().
staticTypesForImport
(
package
,
majorVersion
,
minorVersion
))
{
namespaceObject
->
setProperty
(
object
->
className
(),
object
);
}
return
;
}
else
{
// check the filesystem
QStringList
localImportPaths
=
_importPaths
;
...
...
@@ -309,9 +334,14 @@ void Link::importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, A
}
}
b
re
ak
;
re
turn
;
}
}
_diagnosticMessages
.
append
(
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
locationFromRange
(
import
->
firstSourceLocation
(),
import
->
lastSourceLocation
()),
QCoreApplication
::
translate
(
"QmlJS::Link"
,
"package not found"
)));
}
UiQualifiedId
*
Link
::
qualifiedTypeNameId
(
Node
*
node
)
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljslink.h
+
4
−
0
View file @
dab558d4
...
...
@@ -26,6 +26,8 @@ public:
// Get the scope chain for the currentObject inside doc.
void
scopeChainAt
(
Document
::
Ptr
doc
,
const
QList
<
AST
::
Node
*>
&
astPath
=
QList
<
AST
::
Node
*>
());
QList
<
DiagnosticMessage
>
diagnosticMessages
()
const
;
private:
Interpreter
::
Engine
*
engine
();
...
...
@@ -52,6 +54,8 @@ private:
Interpreter
::
Context
*
_context
;
QMultiHash
<
QString
,
Document
::
Ptr
>
_documentByPath
;
const
QStringList
_importPaths
;
QList
<
DiagnosticMessage
>
_diagnosticMessages
;
};
}
// namespace QmlJS
...
...
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