Add QmlJS semantic checker.

* Add SemanticHighlighter to QmlJSTextEditor to update the semantic info
  in a background thread.
* Add QmlJS::Check to run semantic checks on qml and js documents.
* Add a check for incorrect property names.
* Fix hoverhandler to show tool tips from extra selections over help
  tooltips.
This commit is contained in:
Christian Kamm
2010-02-16 10:36:09 +01:00
parent 98a0757916
commit da3679066e
11 changed files with 571 additions and 62 deletions

View File

@@ -686,7 +686,9 @@ void StringValue::accept(ValueVisitor *visitor) const
Context::Context(Engine *engine)
: _engine(engine),
_lookupMode(JSLookup)
_lookupMode(JSLookup),
_qmlScopeObjectIndex(-1),
_qmlScopeObjectSet(false)
{
}
@@ -739,6 +741,39 @@ void Context::pushScope(const ObjectValue *object)
void Context::popScope()
{
_scopeChain.removeLast();
if (_scopeChain.length() <= _qmlScopeObjectIndex)
_qmlScopeObjectSet = false;
}
// Marks this to be the location where a scope object can be inserted.
void Context::markQmlScopeObject()
{
_qmlScopeObjectIndex = _scopeChain.length();
}
// Sets or inserts the scope object if scopeObject != 0, removes it otherwise.
void Context::setQmlScopeObject(const ObjectValue *scopeObject)
{
if (_qmlScopeObjectSet) {
if (scopeObject == 0) {
_scopeChain.removeAt(_qmlScopeObjectIndex);
_qmlScopeObjectSet = false;
} else {
_scopeChain[_qmlScopeObjectIndex] = scopeObject;
}
} else if (scopeObject != 0 && _scopeChain.length() >= _qmlScopeObjectIndex) {
_scopeChain.insert(_qmlScopeObjectIndex, scopeObject);
_qmlScopeObjectSet = true;
}
}
// Gets the scope object, if set. Returns 0 otherwise.
const ObjectValue *Context::qmlScopeObject() const
{
if (!_qmlScopeObjectSet)
return 0;
else
return _scopeChain[_qmlScopeObjectIndex];
}
const Value *Context::lookup(const QString &name)