QmlJS: Make variables in imported JS documents show up in completion.

Filtering them out has long since become unnecessary. It was used back
when JS files were sourced from Script elements - there they'd only
make the functions available. Now functions and variables are imported.

Task-number: QTCREATORBUG-1735
Reviewed-by: Erik Verbruggen
This commit is contained in:
Christian Kamm
2010-06-25 13:01:55 +02:00
parent 11a08a250a
commit 123607ad70
4 changed files with 2 additions and 29 deletions

View File

@@ -1385,7 +1385,6 @@ QList<const ObjectValue *> ScopeChain::all() const
Context::Context(Engine *engine) Context::Context(Engine *engine)
: _engine(engine), : _engine(engine),
_lookupMode(JSLookup),
_qmlScopeObjectIndex(-1), _qmlScopeObjectIndex(-1),
_qmlScopeObjectSet(false) _qmlScopeObjectSet(false)
{ {
@@ -1410,16 +1409,6 @@ ScopeChain &Context::scopeChain()
return _scopeChain; return _scopeChain;
} }
Context::LookupMode Context::lookupMode() const
{
return _lookupMode;
}
void Context::setLookupMode(LookupMode lookupMode)
{
_lookupMode = lookupMode;
}
const ObjectValue *Context::typeEnvironment(const QmlJS::Document *doc) const const ObjectValue *Context::typeEnvironment(const QmlJS::Document *doc) const
{ {
return _typeEnvironments.value(doc->fileName(), 0); return _typeEnvironments.value(doc->fileName(), 0);
@@ -1437,9 +1426,7 @@ const Value *Context::lookup(const QString &name)
const ObjectValue *scope = scopes.at(index); const ObjectValue *scope = scopes.at(index);
if (const Value *member = scope->lookupMember(name, this)) { if (const Value *member = scope->lookupMember(name, this)) {
if (_lookupMode == JSLookup || ! dynamic_cast<const ASTVariableReference *>(member)) { return member;
return member;
}
} }
} }

View File

@@ -270,12 +270,6 @@ private:
class QMLJS_EXPORT Context class QMLJS_EXPORT Context
{ {
public:
enum LookupMode {
JSLookup,
QmlLookup
};
public: public:
Context(Engine *engine); Context(Engine *engine);
~Context(); ~Context();
@@ -284,9 +278,6 @@ public:
const ScopeChain &scopeChain() const; const ScopeChain &scopeChain() const;
ScopeChain &scopeChain(); ScopeChain &scopeChain();
LookupMode lookupMode() const;
void setLookupMode(LookupMode lookupMode);
const ObjectValue *typeEnvironment(const Document *doc) const; const ObjectValue *typeEnvironment(const Document *doc) const;
void setTypeEnvironment(const Document *doc, const ObjectValue *typeEnvironment); void setTypeEnvironment(const Document *doc, const ObjectValue *typeEnvironment);
@@ -307,7 +298,6 @@ private:
typedef QHash<QString, const Value *> Properties; typedef QHash<QString, const Value *> Properties;
Engine *_engine; Engine *_engine;
LookupMode _lookupMode;
QHash<const ObjectValue *, Properties> _properties; QHash<const ObjectValue *, Properties> _properties;
QHash<QString, const ObjectValue *> _typeEnvironments; QHash<QString, const ObjectValue *> _typeEnvironments;
QSet<QString> _documentsImportingPlugins; QSet<QString> _documentsImportingPlugins;

View File

@@ -54,8 +54,6 @@ void Link::initializeScopeChain()
QHash<Document *, ScopeChain::QmlComponentChain *> componentScopes; QHash<Document *, ScopeChain::QmlComponentChain *> componentScopes;
if (_doc->qmlProgram()) { if (_doc->qmlProgram()) {
_context->setLookupMode(Context::QmlLookup);
scopeChain.qmlComponentScope.clear(); scopeChain.qmlComponentScope.clear();
componentScopes.insert(_doc.data(), &scopeChain.qmlComponentScope); componentScopes.insert(_doc.data(), &scopeChain.qmlComponentScope);
makeComponentChain(_doc, &scopeChain.qmlComponentScope, &componentScopes); makeComponentChain(_doc, &scopeChain.qmlComponentScope, &componentScopes);

View File

@@ -208,9 +208,7 @@ public:
private: private:
void insertProperty(const QString &name, const Interpreter::Value *value) void insertProperty(const QString &name, const Interpreter::Value *value)
{ {
if (_context->lookupMode() == Interpreter::Context::JSLookup || _properties.insert(name, value);
! dynamic_cast<const Interpreter::ASTVariableReference *>(value))
_properties.insert(name, value);
} }
virtual bool processProperty(const QString &name, const Interpreter::Value *value) virtual bool processProperty(const QString &name, const Interpreter::Value *value)