Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
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
Environments
Packages & Registries
Packages & Registries
Container Registry
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
Marco Bubke
flatpak-qt-creator
Commits
e6d9d9e3
Commit
e6d9d9e3
authored
Feb 16, 2010
by
Christian Kamm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix incorrect 'invalid property' errors for PropertyChanges.
Reviewed-by: Roberto Raggi
parent
866b8fa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
9 deletions
+61
-9
src/libs/qmljs/qmljscheck.cpp
src/libs/qmljs/qmljscheck.cpp
+57
-9
src/libs/qmljs/qmljscheck.h
src/libs/qmljs/qmljscheck.h
+4
-0
No files found.
src/libs/qmljs/qmljscheck.cpp
View file @
e6d9d9e3
...
...
@@ -30,6 +30,7 @@
#include "qmljscheck.h"
#include "qmljsbind.h"
#include "qmljsinterpreter.h"
#include "qmljsevaluate.h"
#include "parser/qmljsast_p.h"
#include <QtCore/QDebug>
...
...
@@ -43,6 +44,8 @@ Check::Check(Document::Ptr doc, const Snapshot &snapshot)
,
_snapshot
(
snapshot
)
,
_context
(
&
_engine
)
,
_link
(
&
_context
,
doc
,
snapshot
)
,
_extraScope
(
0
)
,
_allowAnyProperty
(
false
)
{
}
...
...
@@ -68,12 +71,7 @@ bool Check::visit(UiProgram *ast)
bool
Check
::
visit
(
UiObjectDefinition
*
ast
)
{
const
ObjectValue
*
oldScopeObject
=
_context
.
qmlScopeObject
();
_context
.
setQmlScopeObject
(
_doc
->
bind
()
->
findQmlObject
(
ast
));
Node
::
accept
(
ast
->
initializer
,
this
);
_context
.
setQmlScopeObject
(
oldScopeObject
);
visitQmlObject
(
ast
,
ast
->
initializer
);
return
false
;
}
...
...
@@ -81,13 +79,58 @@ bool Check::visit(UiObjectBinding *ast)
{
checkScopeObjectMember
(
ast
->
qualifiedId
);
visitQmlObject
(
ast
,
ast
->
initializer
);
return
false
;
}
void
Check
::
visitQmlObject
(
AST
::
Node
*
ast
,
AST
::
UiObjectInitializer
*
initializer
)
{
const
ObjectValue
*
oldScopeObject
=
_context
.
qmlScopeObject
();
_context
.
setQmlScopeObject
(
_doc
->
bind
()
->
findQmlObject
(
ast
));
const
ObjectValue
*
oldExtraScope
=
_extraScope
;
const
bool
oldAllowAnyProperty
=
_allowAnyProperty
;
const
ObjectValue
*
scopeObject
=
_doc
->
bind
()
->
findQmlObject
(
ast
);
_context
.
setQmlScopeObject
(
scopeObject
);
#ifndef NO_DECLARATIVE_BACKEND
// check if the object has a Qt.PropertyChanges ancestor
const
ObjectValue
*
prototype
=
scopeObject
->
prototype
(
&
_context
);
while
(
prototype
)
{
if
(
const
QmlObjectValue
*
qmlMetaObject
=
dynamic_cast
<
const
QmlObjectValue
*>
(
prototype
))
{
// ### Also check for Qt package. Involves changes in QmlObjectValue.
if
(
qmlMetaObject
->
qmlTypeName
()
==
QLatin1String
(
"PropertyChanges"
))
break
;
}
prototype
=
prototype
->
prototype
(
&
_context
);
}
// find the target script binding
if
(
prototype
&&
initializer
)
{
for
(
UiObjectMemberList
*
m
=
initializer
->
members
;
m
;
m
=
m
->
next
)
{
if
(
UiScriptBinding
*
scriptBinding
=
cast
<
UiScriptBinding
*>
(
m
->
member
))
{
if
(
scriptBinding
->
qualifiedId
&&
scriptBinding
->
qualifiedId
->
name
->
asString
()
==
QLatin1String
(
"target"
)
&&
!
scriptBinding
->
qualifiedId
->
next
)
{
if
(
ExpressionStatement
*
expStmt
=
cast
<
ExpressionStatement
*>
(
scriptBinding
->
statement
))
{
Evaluate
evaluator
(
&
_context
);
const
Value
*
targetValue
=
evaluator
(
expStmt
->
expression
);
if
(
const
ObjectValue
*
target
=
value_cast
<
const
ObjectValue
*>
(
targetValue
))
{
_extraScope
=
target
;
}
else
{
_allowAnyProperty
=
true
;
}
}
}
}
}
}
#endif
Node
::
accept
(
ast
->
initializer
,
this
);
Node
::
accept
(
initializer
,
this
);
_context
.
setQmlScopeObject
(
oldScopeObject
);
return
false
;
_extraScope
=
oldExtraScope
;
_allowAnyProperty
=
oldAllowAnyProperty
;
}
bool
Check
::
visit
(
UiScriptBinding
*
ast
)
...
...
@@ -106,6 +149,9 @@ bool Check::visit(UiArrayBinding *ast)
void
Check
::
checkScopeObjectMember
(
const
AST
::
UiQualifiedId
*
id
)
{
if
(
_allowAnyProperty
)
return
;
const
ObjectValue
*
scopeObject
=
_context
.
qmlScopeObject
();
if
(
!
id
)
...
...
@@ -121,6 +167,8 @@ void Check::checkScopeObjectMember(const AST::UiQualifiedId *id)
scopeObject
=
_context
.
typeEnvironment
(
_doc
.
data
());
const
Value
*
value
=
scopeObject
->
lookupMember
(
propertyName
,
&
_context
);
if
(
_extraScope
&&
!
value
)
value
=
_extraScope
->
lookupMember
(
propertyName
,
&
_context
);
if
(
!
value
)
{
error
(
id
->
identifierToken
,
QString
(
"'%1' is not a valid property name"
).
arg
(
propertyName
));
...
...
src/libs/qmljs/qmljscheck.h
View file @
e6d9d9e3
...
...
@@ -53,6 +53,7 @@ protected:
virtual
bool
visit
(
AST
::
UiArrayBinding
*
ast
);
private:
void
visitQmlObject
(
AST
::
Node
*
ast
,
AST
::
UiObjectInitializer
*
initializer
);
void
checkScopeObjectMember
(
const
AST
::
UiQualifiedId
*
id
);
void
warning
(
const
AST
::
SourceLocation
&
loc
,
const
QString
&
message
);
...
...
@@ -66,6 +67,9 @@ private:
Link
_link
;
QList
<
DiagnosticMessage
>
_messages
;
const
Interpreter
::
ObjectValue
*
_extraScope
;
bool
_allowAnyProperty
;
};
}
// namespace QmlJS
...
...
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