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
b548ab16
Commit
b548ab16
authored
14 years ago
by
Christian Kamm
Browse files
Options
Downloads
Patches
Plain Diff
QmlJS: Mark invalid urls and files in url properties as an error.
Reviewed-by: Erik Verbruggen
parent
34093064
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/qmljs/qmljscheck.cpp
+25
-2
25 additions, 2 deletions
src/libs/qmljs/qmljscheck.cpp
with
25 additions
and
2 deletions
src/libs/qmljs/qmljscheck.cpp
+
25
−
2
View file @
b548ab16
...
...
@@ -34,6 +34,7 @@
#include
"parser/qmljsast_p.h"
#include
<QtCore/QDebug>
#include
<QtCore/QDir>
#include
<QtGui/QColor>
#include
<QtGui/QApplication>
...
...
@@ -82,11 +83,13 @@ class AssignmentCheck : public ValueVisitor
{
public:
DiagnosticMessage
operator
()(
const
Document
::
Ptr
&
document
,
const
SourceLocation
&
location
,
const
Interpreter
::
Value
*
lhsValue
,
const
Interpreter
::
Value
*
rhsValue
,
ExpressionNode
*
ast
)
{
_doc
=
document
;
_message
=
DiagnosticMessage
(
DiagnosticMessage
::
Error
,
location
,
QString
());
_rhsValue
=
rhsValue
;
_ast
=
ast
;
...
...
@@ -132,7 +135,7 @@ public:
}
}
virtual
void
visit
(
const
StringValue
*
)
virtual
void
visit
(
const
StringValue
*
value
)
{
UnaryMinusExpression
*
unaryMinus
=
cast
<
UnaryMinusExpression
*>
(
_ast
);
...
...
@@ -142,6 +145,25 @@ public:
||
_ast
->
kind
==
Node
::
Kind_FalseLiteral
)
{
_message
.
message
=
Check
::
tr
(
"string value expected"
);
}
if
(
value
&&
value
->
asUrlValue
())
{
if
(
StringLiteral
*
literal
=
cast
<
StringLiteral
*>
(
_ast
))
{
QUrl
url
(
literal
->
value
->
asString
());
if
(
!
url
.
isValid
()
&&
!
url
.
isEmpty
())
{
_message
.
message
=
Check
::
tr
(
"not a valid url"
);
}
else
{
QString
fileName
=
url
.
toLocalFile
();
if
(
!
fileName
.
isEmpty
())
{
if
(
url
.
isRelative
())
{
fileName
.
prepend
(
QDir
::
separator
());
fileName
.
prepend
(
_doc
->
path
());
}
if
(
!
QFileInfo
(
fileName
).
exists
())
_message
.
message
=
Check
::
tr
(
"file or directory does not exist"
);
}
}
}
}
}
virtual
void
visit
(
const
ColorValue
*
)
...
...
@@ -160,6 +182,7 @@ public:
_message
.
message
=
Check
::
tr
(
"expected anchor line"
);
}
Document
::
Ptr
_doc
;
DiagnosticMessage
_message
;
const
Value
*
_rhsValue
;
ExpressionNode
*
_ast
;
...
...
@@ -281,7 +304,7 @@ bool Check::visit(UiScriptBinding *ast)
const
SourceLocation
loc
=
locationFromRange
(
expStmt
->
firstSourceLocation
(),
expStmt
->
lastSourceLocation
());
AssignmentCheck
assignmentCheck
;
DiagnosticMessage
message
=
assignmentCheck
(
loc
,
lhsValue
,
rhsValue
,
expr
);
DiagnosticMessage
message
=
assignmentCheck
(
_doc
,
loc
,
lhsValue
,
rhsValue
,
expr
);
if
(
!
message
.
message
.
isEmpty
())
_messages
+=
message
;
}
...
...
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