Commit 9a601374 authored by Fawzi Mohamed's avatar Fawzi Mohamed

qmljs: add explicit typeName to exports

Change-Id: If777f312c6532db9a37214f173c10b5542c02e60
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent ef54a29c
......@@ -38,6 +38,7 @@
#include <QCryptographicHash>
#include <QDir>
#include <QFileInfo>
#include <algorithm>
......@@ -525,7 +526,7 @@ void Snapshot::insert(const Document::Ptr &document, bool allowInvalid)
cImport.importId = document->importId();
cImport.language = document->language();
cImport.possibleExports << Export(ImportKey(ImportType::File, fileName),
QString(), true);
QString(), true, QFileInfo(fileName).baseName());
cImport.fingerprint = document->fingerprint();
_dependencies.addCoreImport(cImport);
}
......@@ -606,8 +607,7 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info)
}
foreach (const QmlDirParser::Component &component, info.components()) {
foreach (const Export &e, cImport.possibleExports)
// renaming of type name not really represented here... fix?
_dependencies.addExport(component.fileName, e.exportName, e.pathRequired);
_dependencies.addExport(component.fileName, e.exportName, e.pathRequired, e.typeName);
}
cImport.fingerprint = info.fingerprint();
_dependencies.addCoreImport(cImport);
......
......@@ -471,12 +471,14 @@ bool operator <(const ImportKey &i1, const ImportKey &i2)
return i1.compare(i2) < 0;
}
const QString Export::LibraryTypeName = QLatin1String("%Library%");
Export::Export()
: intrinsic(false)
{ }
Export::Export(ImportKey exportName, QString pathRequired, bool intrinsic)
: exportName(exportName), pathRequired(pathRequired), intrinsic(intrinsic)
Export::Export(ImportKey exportName, QString pathRequired, bool intrinsic, const QString &typeName)
: exportName(exportName), pathRequired(pathRequired), typeName(typeName), intrinsic(intrinsic)
{ }
bool Export::visibleInVContext(const ViewerContext &vContext) const
......@@ -488,7 +490,8 @@ bool operator ==(const Export &i1, const Export &i2)
{
return i1.exportName == i2.exportName
&& i1.pathRequired == i2.pathRequired
&& i1.intrinsic == i2.intrinsic;
&& i1.intrinsic == i2.intrinsic
&& i1.typeName == i2.typeName;
}
bool operator !=(const Export &i1, const Export &i2)
......@@ -770,32 +773,32 @@ void ImportDependencies::removeImportCacheEntry(const ImportKey &importKey, cons
}
void ImportDependencies::addExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath)
const QString &requiredPath, const QString &typeName)
{
if (!m_coreImports.contains(importId)) {
CoreImport newImport(importId);
newImport.language = Language::AnyLanguage;
newImport.possibleExports.append(Export(importKey, requiredPath, false));
newImport.possibleExports.append(Export(importKey, requiredPath, false, typeName));
m_coreImports.insert(newImport.importId, newImport);
m_importCache[importKey].append(importId);
return;
}
CoreImport &importValue = m_coreImports[importId];
importValue.possibleExports.append(Export(importKey, requiredPath, false));
importValue.possibleExports.append(Export(importKey, requiredPath, false, typeName));
m_importCache[importKey].append(importId);
qCDebug(importsLog) << "added export "<< importKey.toString() << " for id " <<importId
<< " (" << requiredPath << ")";
}
void ImportDependencies::removeExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath)
const QString &requiredPath, const QString &typeName)
{
if (!m_coreImports.contains(importId)) {
qCWarning(importsLog) << "non existing core import for removeExport(" << importId << ", "
<< importKey.toString() << ")";
} else {
CoreImport &importValue = m_coreImports[importId];
if (!importValue.possibleExports.removeOne(Export(importKey, requiredPath, false))) {
if (!importValue.possibleExports.removeOne(Export(importKey, requiredPath, false, typeName))) {
qCWarning(importsLog) << "non existing export for removeExport(" << importId << ", "
<< importKey.toString() << ")";
}
......
......@@ -128,10 +128,13 @@ bool operator <(const ImportKey &i1, const ImportKey &i2);
class QMLJS_EXPORT Export
{
public:
static const QString LibraryTypeName;
Export();
Export(ImportKey exportName, QString pathRequired, bool intrinsic = false);
Export(ImportKey exportName, QString pathRequired, bool intrinsic = false,
const QString &typeName = LibraryTypeName);
ImportKey exportName;
QString pathRequired;
QString typeName;
bool intrinsic;
bool visibleInVContext(const ViewerContext &vContext) const;
};
......@@ -205,9 +208,9 @@ public:
void removeCoreImport(const QString &importId);
void addExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath);
const QString &requiredPath, const QString &typeName = Export::LibraryTypeName);
void removeExport(const QString &importId, const ImportKey &importKey,
const QString &requiredPath);
const QString &requiredPath, const QString &typeName = Export::LibraryTypeName);
void iterateOnCoreImports(const ViewerContext &vContext,
std::function<bool(const CoreImport &)> const &iterF) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment