forked from qt-creator/qt-creator
QmlJS: Fix enum completion with 'as' imports.
Change-Id: Ifc229c23c14a6395c9d3e5f7ec76b9b04678787d Reviewed-on: http://codereview.qt-project.org/5134 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -2118,6 +2118,33 @@ ImportInfo Imports::info(const QString &name, const Context *context) const
|
||||
return ImportInfo();
|
||||
}
|
||||
|
||||
QString Imports::nameForImportedObject(const ObjectValue *value, const Context *context) const
|
||||
{
|
||||
QListIterator<Import> it(_imports);
|
||||
it.toBack();
|
||||
while (it.hasPrevious()) {
|
||||
const Import &i = it.previous();
|
||||
const ObjectValue *import = i.object;
|
||||
const ImportInfo &info = i.info;
|
||||
|
||||
if (info.type() == ImportInfo::FileImport) {
|
||||
if (import == value)
|
||||
return import->className();
|
||||
} else {
|
||||
const Value *v = import->lookupMember(value->className(), context);
|
||||
if (v == value) {
|
||||
QString result = value->className();
|
||||
if (!info.id().isEmpty()) {
|
||||
result.prepend(QLatin1Char('.'));
|
||||
result.prepend(info.id());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QList<Import> Imports::all() const
|
||||
{
|
||||
return _imports;
|
||||
|
@@ -896,6 +896,7 @@ public:
|
||||
void append(const Import &import);
|
||||
|
||||
ImportInfo info(const QString &name, const Context *context) const;
|
||||
QString nameForImportedObject(const ObjectValue *value, const Context *context) const;
|
||||
QList<Import> all() const;
|
||||
|
||||
const TypeScope *typeScope() const;
|
||||
|
Reference in New Issue
Block a user