forked from qt-creator/qt-creator
QmlJs: Make "qbs" an implicit import for qbs files
We want to have qbs syntax highlighting, even if the import qbs statement is missing, because we want to remove the reqirement for it. Change-Id: I569be825440bc733c3c0fa8e146e785060e08384 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include "qmljsdocument.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
using namespace LanguageUtils;
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJS::AST;
|
||||
@@ -178,6 +180,17 @@ bool Bind::visit(AST::Program *)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Bind::endVisit(UiProgram *)
|
||||
{
|
||||
if (_doc->language() == Dialect::QmlQbs) {
|
||||
static const QString qbsBaseImport = QStringLiteral("qbs");
|
||||
static auto isQbsBaseImport = [] (const ImportInfo &ii) {
|
||||
return ii.name() == qbsBaseImport; };
|
||||
if (!Utils::anyOf(_imports, isQbsBaseImport))
|
||||
_imports += ImportInfo::moduleImport(qbsBaseImport, ComponentVersion(), QString());
|
||||
}
|
||||
}
|
||||
|
||||
bool Bind::visit(UiImport *ast)
|
||||
{
|
||||
ComponentVersion version;
|
||||
|
Reference in New Issue
Block a user