forked from qt-creator/qt-creator
qmljs: added qmljsconstants.h
Moved Document::Language, Import::Type and StaticAnalysis::Severity enums to qmljsconstants.h and renamed values removing the redundant part. Thus the effective length changed little or improved (Document::QmlLanguage => Language::Qml). The separate file allows better reuse of enum values without introducing circular dependencies. Change-Id: I5186d7c04f5d3f6c289068b919be5ff1ff118326 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "qmljsglobal_p.h"
|
||||
#include "qmljsastfwd_p.h"
|
||||
#include "qmljsmemorypool_p.h"
|
||||
#include <qmljs/qmljsconstants.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QSet>
|
||||
@@ -59,21 +60,19 @@ class MemoryPool;
|
||||
class QML_PARSER_EXPORT DiagnosticMessage
|
||||
{
|
||||
public:
|
||||
enum Kind { Warning, Error };
|
||||
|
||||
DiagnosticMessage()
|
||||
: kind(Error) {}
|
||||
: kind(Severity::Error) {}
|
||||
|
||||
DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
|
||||
DiagnosticMessage(Severity::Enum kind, const AST::SourceLocation &loc, const QString &message)
|
||||
: kind(kind), loc(loc), message(message) {}
|
||||
|
||||
bool isWarning() const
|
||||
{ return kind == Warning; }
|
||||
{ return kind == Severity::Warning; }
|
||||
|
||||
bool isError() const
|
||||
{ return kind == Error; }
|
||||
{ return kind == Severity::Error; }
|
||||
|
||||
Kind kind;
|
||||
Severity::Enum kind;
|
||||
AST::SourceLocation loc;
|
||||
QString message;
|
||||
};
|
||||
|
||||
@@ -289,7 +289,7 @@ case 20: {
|
||||
if (node) {
|
||||
node->importToken = loc(1);
|
||||
} else {
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, loc(1),
|
||||
QLatin1String("Expected a qualified name id or a string literal")));
|
||||
|
||||
return false; // ### remove me
|
||||
@@ -583,7 +583,7 @@ case 78: {
|
||||
case 79: {
|
||||
bool rx = lexer->scanRegExp(Lexer::NoPrefix);
|
||||
if (!rx) {
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, location(lexer), lexer->errorMessage()));
|
||||
return false; // ### remove me
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ case 79: {
|
||||
case 80: {
|
||||
bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
|
||||
if (!rx) {
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, location(lexer), lexer->errorMessage()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ case 88: {
|
||||
|
||||
case 89: {
|
||||
if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Warning, mem->lbracketToken,
|
||||
QLatin1String("Ignored annotation")));
|
||||
|
||||
sym(1).Expression = mem->base;
|
||||
@@ -691,7 +691,7 @@ case 89: {
|
||||
} else {
|
||||
sym(1).UiQualifiedId = 0;
|
||||
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, loc(1),
|
||||
QLatin1String("Expected a qualified name id")));
|
||||
|
||||
return false; // ### recover
|
||||
@@ -1747,7 +1747,7 @@ case 347: {
|
||||
msg = qApp->translate("QmlParser", "Syntax error");
|
||||
else
|
||||
msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token]));
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, token_buffer[0].loc, msg));
|
||||
|
||||
action = errorState;
|
||||
goto _Lcheck_token;
|
||||
@@ -1775,7 +1775,7 @@ case 347: {
|
||||
int a = t_action(errorState, *tk);
|
||||
if (a > 0 && t_action(a, yytoken)) {
|
||||
const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk]));
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, token_buffer[0].loc, msg));
|
||||
|
||||
yytoken = *tk;
|
||||
yylval = 0;
|
||||
@@ -1799,7 +1799,7 @@ case 347: {
|
||||
int a = t_action(errorState, tk);
|
||||
if (a > 0 && t_action(a, yytoken)) {
|
||||
const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk]));
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, token_buffer[0].loc, msg));
|
||||
|
||||
yytoken = tk;
|
||||
yylval = 0;
|
||||
@@ -1812,7 +1812,7 @@ case 347: {
|
||||
}
|
||||
|
||||
const QString msg = qApp->translate("QmlParser", "Syntax error");
|
||||
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg));
|
||||
diagnostic_messages.append(DiagnosticMessage(Severity::Error, token_buffer[0].loc, msg));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
inline DiagnosticMessage diagnosticMessage() const
|
||||
{
|
||||
foreach (const DiagnosticMessage &d, diagnostic_messages) {
|
||||
if (d.kind != DiagnosticMessage::Warning)
|
||||
if (d.kind != Severity::Warning)
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ HEADERS += \
|
||||
$$PWD/iscriptevaluator.h \
|
||||
$$PWD/qmljssimplereader.h \
|
||||
$$PWD/persistenttrie.h \
|
||||
$$PWD/qmljsqrcparser.h
|
||||
$$PWD/qmljsqrcparser.h \
|
||||
$$PWD/qmljsconstants.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/qmljsbind.cpp \
|
||||
|
||||
@@ -28,6 +28,7 @@ QtcLibrary {
|
||||
"qmljscheck.cpp", "qmljscheck.h",
|
||||
"qmljscodeformatter.cpp", "qmljscodeformatter.h",
|
||||
"qmljscompletioncontextfinder.cpp", "qmljscompletioncontextfinder.h",
|
||||
"qmljsconstants.h",
|
||||
"qmljscontext.cpp", "qmljscontext.h",
|
||||
"qmljsdelta.cpp", "qmljsdelta.h",
|
||||
"qmljsdocument.cpp", "qmljsdocument.h",
|
||||
|
||||
@@ -204,17 +204,17 @@ bool Bind::visit(UiImport *ast)
|
||||
const QString importId = ast->importId.toString();
|
||||
ImportInfo import = ImportInfo::moduleImport(toString(ast->importUri), version,
|
||||
importId, ast);
|
||||
if (_doc->language() == Document::QmlLanguage) {
|
||||
if (_doc->language() == Language::Qml) {
|
||||
const QString importStr = import.name() + importId;
|
||||
QmlLanguageBundles langBundles = ModelManagerInterface::instance()->extendedBundles();
|
||||
QmlBundle qq1 = langBundles.bundleForLanguage(Document::QmlQtQuick1Language);
|
||||
QmlBundle qq2 = langBundles.bundleForLanguage(Document::QmlQtQuick2Language);
|
||||
QmlBundle qq1 = langBundles.bundleForLanguage(Language::QmlQtQuick1);
|
||||
QmlBundle qq2 = langBundles.bundleForLanguage(Language::QmlQtQuick2);
|
||||
bool isQQ1 = qq1.supportedImports().contains(importStr);
|
||||
bool isQQ2 = qq2.supportedImports().contains(importStr);
|
||||
if (isQQ1 && ! isQQ2)
|
||||
_doc->setLanguage(Document::QmlQtQuick1Language);
|
||||
_doc->setLanguage(Language::QmlQtQuick1);
|
||||
if (isQQ2 && ! isQQ1)
|
||||
_doc->setLanguage(Document::QmlQtQuick2Language);
|
||||
_doc->setLanguage(Language::QmlQtQuick2);
|
||||
}
|
||||
_imports += import;
|
||||
} else if (!ast->fileName.isEmpty()) {
|
||||
|
||||
@@ -288,14 +288,14 @@ bool QmlBundle::readFrom(QString path, QStringList *errors)
|
||||
return errs.isEmpty();
|
||||
}
|
||||
|
||||
QmlBundle QmlLanguageBundles::bundleForLanguage(Document::Language l) const
|
||||
QmlBundle QmlLanguageBundles::bundleForLanguage(Language::Enum l) const
|
||||
{
|
||||
if (m_bundles.contains(l))
|
||||
return m_bundles.value(l);
|
||||
return QmlBundle();
|
||||
}
|
||||
|
||||
void QmlLanguageBundles::mergeBundleForLanguage(Document::Language l, const QmlBundle &bundle)
|
||||
void QmlLanguageBundles::mergeBundleForLanguage(Language::Enum l, const QmlBundle &bundle)
|
||||
{
|
||||
if (bundle.isEmpty())
|
||||
return;
|
||||
@@ -305,14 +305,14 @@ void QmlLanguageBundles::mergeBundleForLanguage(Document::Language l, const QmlB
|
||||
m_bundles.insert(l,bundle);
|
||||
}
|
||||
|
||||
QList<Document::Language> QmlLanguageBundles::languages() const
|
||||
QList<Language::Enum> QmlLanguageBundles::languages() const
|
||||
{
|
||||
return m_bundles.keys();
|
||||
}
|
||||
|
||||
void QmlLanguageBundles::mergeLanguageBundles(const QmlLanguageBundles &o)
|
||||
{
|
||||
foreach (Document::Language l, o.languages())
|
||||
foreach (Language::Enum l, o.languages())
|
||||
mergeBundleForLanguage(l, o.bundleForLanguage(l));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,12 +102,12 @@ private:
|
||||
class QMLJS_EXPORT QmlLanguageBundles
|
||||
{
|
||||
public:
|
||||
QmlBundle bundleForLanguage(Document::Language l) const;
|
||||
void mergeBundleForLanguage(Document::Language l, const QmlBundle &bundle);
|
||||
QList<Document::Language> languages() const;
|
||||
QmlBundle bundleForLanguage(Language::Enum l) const;
|
||||
void mergeBundleForLanguage(Language::Enum l, const QmlBundle &bundle);
|
||||
QList<Language::Enum> languages() const;
|
||||
void mergeLanguageBundles(const QmlLanguageBundles &);
|
||||
private:
|
||||
QHash<Document::Language,QmlBundle> m_bundles;
|
||||
QHash<Language::Enum,QmlBundle> m_bundles;
|
||||
};
|
||||
} // namespace QmlJS
|
||||
|
||||
|
||||
76
src/libs/qmljs/qmljsconstants.h
Normal file
76
src/libs/qmljs/qmljsconstants.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLJSCONSTANTS_H
|
||||
#define QMLJSCONSTANTS_H
|
||||
|
||||
namespace QmlJS {
|
||||
|
||||
namespace ImportType {
|
||||
enum Enum {
|
||||
Invalid,
|
||||
ImplicitDirectory,
|
||||
Library,
|
||||
File,
|
||||
Directory,
|
||||
QrcFile,
|
||||
QrcDirectory,
|
||||
ImplicitQrcDirectory,
|
||||
UnknownFile // refers a file/directory that wasn't found
|
||||
};
|
||||
}
|
||||
|
||||
namespace Severity {
|
||||
enum Enum
|
||||
{
|
||||
Hint, // cosmetic or convention
|
||||
MaybeWarning, // possibly a warning, insufficient information
|
||||
Warning, // could cause unintended behavior
|
||||
MaybeError, // possibly an error, insufficient information
|
||||
Error // definitely an error
|
||||
};
|
||||
}
|
||||
|
||||
namespace Language {
|
||||
enum Enum
|
||||
{
|
||||
Unknown = 0,
|
||||
JavaScript = 1,
|
||||
Json = 2,
|
||||
Qml = 3,
|
||||
QmlQtQuick1 = 4,
|
||||
QmlQtQuick2 = 5,
|
||||
QmlQbs = 6,
|
||||
QmlProject = 7,
|
||||
QmlTypeInfo = 8
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace QmlJS
|
||||
#endif // QMLJSCONSTANTS_H
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "qmljsdocument.h"
|
||||
#include "qmljsbind.h"
|
||||
#include "qmljsconstants.h"
|
||||
#include <qmljs/parser/qmljslexer_p.h>
|
||||
#include <qmljs/parser/qmljsparser_p.h>
|
||||
|
||||
@@ -81,56 +82,56 @@ using namespace QmlJS::AST;
|
||||
*/
|
||||
|
||||
|
||||
bool Document::isQmlLikeLanguage(Document::Language language)
|
||||
bool Document::isQmlLikeLanguage(Language::Enum language)
|
||||
{
|
||||
switch (language) {
|
||||
case QmlLanguage:
|
||||
case QmlQtQuick1Language:
|
||||
case QmlQtQuick2Language:
|
||||
case QmlQbsLanguage:
|
||||
case QmlProjectLanguage:
|
||||
case QmlTypeInfoLanguage:
|
||||
case Language::Qml:
|
||||
case Language::QmlQtQuick1:
|
||||
case Language::QmlQtQuick2:
|
||||
case Language::QmlQbs:
|
||||
case Language::QmlProject:
|
||||
case Language::QmlTypeInfo:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Document::isFullySupportedLanguage(Document::Language language)
|
||||
bool Document::isFullySupportedLanguage(Language::Enum language)
|
||||
{
|
||||
switch (language) {
|
||||
case JavaScriptLanguage:
|
||||
case JsonLanguage:
|
||||
case QmlLanguage:
|
||||
case QmlQtQuick1Language:
|
||||
case QmlQtQuick2Language:
|
||||
case Language::JavaScript:
|
||||
case Language::Json:
|
||||
case Language::Qml:
|
||||
case Language::QmlQtQuick1:
|
||||
case Language::QmlQtQuick2:
|
||||
return true;
|
||||
case UnknownLanguage:
|
||||
case QmlQbsLanguage:
|
||||
case QmlProjectLanguage:
|
||||
case QmlTypeInfoLanguage:
|
||||
case Language::Unknown:
|
||||
case Language::QmlQbs:
|
||||
case Language::QmlProject:
|
||||
case Language::QmlTypeInfo:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Document::isQmlLikeOrJsLanguage(Document::Language language)
|
||||
bool Document::isQmlLikeOrJsLanguage(Language::Enum language)
|
||||
{
|
||||
switch (language) {
|
||||
case QmlLanguage:
|
||||
case QmlQtQuick1Language:
|
||||
case QmlQtQuick2Language:
|
||||
case QmlQbsLanguage:
|
||||
case QmlProjectLanguage:
|
||||
case QmlTypeInfoLanguage:
|
||||
case JavaScriptLanguage:
|
||||
case Language::Qml:
|
||||
case Language::QmlQtQuick1:
|
||||
case Language::QmlQtQuick2:
|
||||
case Language::QmlQbs:
|
||||
case Language::QmlProject:
|
||||
case Language::QmlTypeInfo:
|
||||
case Language::JavaScript:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Document::Document(const QString &fileName, Language language)
|
||||
Document::Document(const QString &fileName, Language::Enum language)
|
||||
: _engine(0)
|
||||
, _ast(0)
|
||||
, _bind(0)
|
||||
@@ -163,24 +164,24 @@ Document::~Document()
|
||||
delete _engine;
|
||||
}
|
||||
|
||||
Document::MutablePtr Document::create(const QString &fileName, Language language)
|
||||
Document::MutablePtr Document::create(const QString &fileName, Language::Enum language)
|
||||
{
|
||||
Document::MutablePtr doc(new Document(fileName, language));
|
||||
doc->_ptr = doc;
|
||||
return doc;
|
||||
}
|
||||
|
||||
Document::Language Document::guessLanguageFromSuffix(const QString &fileName)
|
||||
Language::Enum Document::guessLanguageFromSuffix(const QString &fileName)
|
||||
{
|
||||
if (fileName.endsWith(QLatin1String(".qml"), Qt::CaseInsensitive))
|
||||
return QmlLanguage;
|
||||
return Language::Qml;
|
||||
if (fileName.endsWith(QLatin1String(".qbs"), Qt::CaseInsensitive))
|
||||
return QmlQbsLanguage;
|
||||
return Language::QmlQbs;
|
||||
if (fileName.endsWith(QLatin1String(".js"), Qt::CaseInsensitive))
|
||||
return JavaScriptLanguage;
|
||||
return Language::JavaScript;
|
||||
if (fileName.endsWith(QLatin1String(".json"), Qt::CaseInsensitive))
|
||||
return JsonLanguage;
|
||||
return UnknownLanguage;
|
||||
return Language::Json;
|
||||
return Language::Unknown;
|
||||
}
|
||||
|
||||
Document::Ptr Document::ptr() const
|
||||
@@ -193,12 +194,12 @@ bool Document::isQmlDocument() const
|
||||
return isQmlLikeLanguage(_language);
|
||||
}
|
||||
|
||||
Document::Language Document::language() const
|
||||
Language::Enum Document::language() const
|
||||
{
|
||||
return _language;
|
||||
}
|
||||
|
||||
void Document::setLanguage(Document::Language l)
|
||||
void Document::setLanguage(Language::Enum l)
|
||||
{
|
||||
_language = l;
|
||||
}
|
||||
@@ -428,7 +429,7 @@ void Snapshot::remove(const QString &fileName)
|
||||
|
||||
Document::MutablePtr Snapshot::documentFromSource(
|
||||
const QString &code, const QString &fileName,
|
||||
Document::Language language) const
|
||||
Language::Enum language) const
|
||||
{
|
||||
Document::MutablePtr newDoc = Document::create(fileName, language);
|
||||
|
||||
|
||||
@@ -50,36 +50,23 @@ public:
|
||||
typedef QSharedPointer<const Document> Ptr;
|
||||
typedef QSharedPointer<Document> MutablePtr;
|
||||
|
||||
enum Language
|
||||
{
|
||||
UnknownLanguage = 0,
|
||||
JavaScriptLanguage = 1,
|
||||
JsonLanguage = 2,
|
||||
QmlLanguage = 3,
|
||||
QmlQtQuick1Language = 4,
|
||||
QmlQtQuick2Language = 5,
|
||||
QmlQbsLanguage = 6,
|
||||
QmlProjectLanguage = 7,
|
||||
QmlTypeInfoLanguage = 8
|
||||
};
|
||||
|
||||
static bool isQmlLikeLanguage(Language languge);
|
||||
static bool isFullySupportedLanguage(Language language);
|
||||
static bool isQmlLikeOrJsLanguage(Language language);
|
||||
static bool isQmlLikeLanguage(Language::Enum languge);
|
||||
static bool isFullySupportedLanguage(Language::Enum language);
|
||||
static bool isQmlLikeOrJsLanguage(Language::Enum language);
|
||||
protected:
|
||||
Document(const QString &fileName, Language language);
|
||||
Document(const QString &fileName, Language::Enum language);
|
||||
|
||||
public:
|
||||
~Document();
|
||||
|
||||
static MutablePtr create(const QString &fileName, Language language);
|
||||
static Language guessLanguageFromSuffix(const QString &fileName);
|
||||
static MutablePtr create(const QString &fileName, Language::Enum language);
|
||||
static Language::Enum guessLanguageFromSuffix(const QString &fileName);
|
||||
|
||||
Document::Ptr ptr() const;
|
||||
|
||||
bool isQmlDocument() const;
|
||||
Language language() const;
|
||||
void setLanguage(Language l);
|
||||
Language::Enum language() const;
|
||||
void setLanguage(Language::Enum l);
|
||||
|
||||
AST::UiProgram *qmlProgram() const;
|
||||
AST::Program *jsProgram() const;
|
||||
@@ -124,7 +111,7 @@ private:
|
||||
QString _source;
|
||||
QWeakPointer<Document> _ptr;
|
||||
int _editorRevision;
|
||||
Language _language;
|
||||
Language::Enum _language;
|
||||
bool _parsedCorrectly;
|
||||
|
||||
// for documentFromSource
|
||||
@@ -237,7 +224,7 @@ public:
|
||||
|
||||
Document::MutablePtr documentFromSource(const QString &code,
|
||||
const QString &fileName,
|
||||
Document::Language language) const;
|
||||
Language::Enum language) const;
|
||||
};
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
@@ -2074,7 +2074,7 @@ bool ASTSignal::getSourceLocation(QString *fileName, int *line, int *column) con
|
||||
|
||||
|
||||
ImportInfo::ImportInfo()
|
||||
: _type(InvalidImport)
|
||||
: _type(ImportType::Invalid)
|
||||
, _ast(0)
|
||||
{
|
||||
}
|
||||
@@ -2089,7 +2089,7 @@ ImportInfo ImportInfo::moduleImport(QString uri, ComponentVersion version,
|
||||
}
|
||||
|
||||
ImportInfo info;
|
||||
info._type = LibraryImport;
|
||||
info._type = ImportType::Library;
|
||||
info._name = uri;
|
||||
info._path = uri;
|
||||
info._path.replace(QLatin1Char('.'), QDir::separator());
|
||||
@@ -2111,17 +2111,17 @@ ImportInfo ImportInfo::pathImport(const QString &docPath, const QString &path,
|
||||
info._path = importFileInfo.absoluteFilePath();
|
||||
|
||||
if (importFileInfo.isFile()) {
|
||||
info._type = FileImport;
|
||||
info._type = ImportType::File;
|
||||
} else if (importFileInfo.isDir()) {
|
||||
info._type = DirectoryImport;
|
||||
info._type = ImportType::Directory;
|
||||
} else if (path.startsWith(QLatin1String("qrc:"))) {
|
||||
info._path = path;
|
||||
if (ModelManagerInterface::instance()->filesAtQrcPath(info.path()).isEmpty())
|
||||
info._type = QrcDirectoryImport;
|
||||
info._type = ImportType::QrcDirectory;
|
||||
else
|
||||
info._type = QrcFileImport;
|
||||
info._type = ImportType::QrcFile;
|
||||
} else {
|
||||
info._type = UnknownFileImport;
|
||||
info._type = ImportType::UnknownFile;
|
||||
}
|
||||
info._version = version;
|
||||
info._as = as;
|
||||
@@ -2132,7 +2132,7 @@ ImportInfo ImportInfo::pathImport(const QString &docPath, const QString &path,
|
||||
ImportInfo ImportInfo::invalidImport(UiImport *ast)
|
||||
{
|
||||
ImportInfo info;
|
||||
info._type = InvalidImport;
|
||||
info._type = ImportType::Invalid;
|
||||
info._ast = ast;
|
||||
return info;
|
||||
}
|
||||
@@ -2140,17 +2140,17 @@ ImportInfo ImportInfo::invalidImport(UiImport *ast)
|
||||
ImportInfo ImportInfo::implicitDirectoryImport(const QString &directory)
|
||||
{
|
||||
ImportInfo info;
|
||||
info._type = ImplicitDirectoryImport;
|
||||
info._type = ImportType::ImplicitDirectory;
|
||||
info._path = directory;
|
||||
return info;
|
||||
}
|
||||
|
||||
bool ImportInfo::isValid() const
|
||||
{
|
||||
return _type != InvalidImport;
|
||||
return _type != ImportType::Invalid;
|
||||
}
|
||||
|
||||
ImportInfo::Type ImportInfo::type() const
|
||||
ImportType::Enum ImportInfo::type() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
@@ -2201,7 +2201,7 @@ const Value *TypeScope::lookupMember(const QString &name, const Context *context
|
||||
const ImportInfo &info = i.info;
|
||||
|
||||
// JS import has no types
|
||||
if (info.type() == ImportInfo::FileImport || info.type() == ImportInfo::QrcFileImport)
|
||||
if (info.type() == ImportType::File || info.type() == ImportType::QrcFile)
|
||||
continue;
|
||||
|
||||
if (!info.as().isEmpty()) {
|
||||
@@ -2231,7 +2231,7 @@ void TypeScope::processMembers(MemberProcessor *processor) const
|
||||
const ImportInfo &info = i.info;
|
||||
|
||||
// JS import has no types
|
||||
if (info.type() == ImportInfo::FileImport || info.type() == ImportInfo::QrcFileImport)
|
||||
if (info.type() == ImportType::File || info.type() == ImportType::QrcFile)
|
||||
continue;
|
||||
|
||||
if (!info.as().isEmpty())
|
||||
@@ -2258,7 +2258,7 @@ const Value *JSImportScope::lookupMember(const QString &name, const Context *,
|
||||
const ImportInfo &info = i.info;
|
||||
|
||||
// JS imports are always: import "somefile.js" as Foo
|
||||
if (info.type() != ImportInfo::FileImport && info.type() != ImportInfo::QrcFileImport)
|
||||
if (info.type() != ImportType::File && info.type() != ImportType::QrcFile)
|
||||
continue;
|
||||
|
||||
if (info.as() == name) {
|
||||
@@ -2281,7 +2281,7 @@ void JSImportScope::processMembers(MemberProcessor *processor) const
|
||||
const ObjectValue *import = i.object;
|
||||
const ImportInfo &info = i.info;
|
||||
|
||||
if (info.type() == ImportInfo::FileImport || info.type() == ImportInfo::QrcFileImport)
|
||||
if (info.type() == ImportType::File || info.type() == ImportType::QrcFile)
|
||||
processor->processProperty(info.as(), import);
|
||||
}
|
||||
}
|
||||
@@ -2338,7 +2338,7 @@ ImportInfo Imports::info(const QString &name, const Context *context) const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (info.type() == ImportInfo::FileImport || info.type() == ImportInfo::QrcFileImport) {
|
||||
if (info.type() == ImportType::File || info.type() == ImportType::QrcFile) {
|
||||
if (import->className() == firstId)
|
||||
return info;
|
||||
} else {
|
||||
@@ -2358,7 +2358,7 @@ QString Imports::nameForImportedObject(const ObjectValue *value, const Context *
|
||||
const ObjectValue *import = i.object;
|
||||
const ImportInfo &info = i.info;
|
||||
|
||||
if (info.type() == ImportInfo::FileImport || info.type() == ImportInfo::QrcFileImport) {
|
||||
if (info.type() == ImportType::File || info.type() == ImportType::QrcFile) {
|
||||
if (import == value)
|
||||
return import->className();
|
||||
} else {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljs_global.h>
|
||||
#include <qmljs/qmljsconstants.h>
|
||||
|
||||
#include <QFileInfoList>
|
||||
#include <QList>
|
||||
@@ -866,17 +867,6 @@ public:
|
||||
class QMLJS_EXPORT ImportInfo
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
InvalidImport,
|
||||
ImplicitDirectoryImport,
|
||||
LibraryImport,
|
||||
FileImport,
|
||||
DirectoryImport,
|
||||
QrcFileImport,
|
||||
QrcDirectoryImport,
|
||||
UnknownFileImport // refers a file/directory that wasn't found
|
||||
};
|
||||
|
||||
ImportInfo();
|
||||
|
||||
static ImportInfo moduleImport(QString uri, LanguageUtils::ComponentVersion version,
|
||||
@@ -888,7 +878,7 @@ public:
|
||||
static ImportInfo implicitDirectoryImport(const QString &directory);
|
||||
|
||||
bool isValid() const;
|
||||
Type type() const;
|
||||
ImportType::Enum type() const;
|
||||
|
||||
// LibraryImport: uri with ',' separator
|
||||
// Other: non-absolute path
|
||||
@@ -905,7 +895,7 @@ public:
|
||||
AST::UiImport *ast() const;
|
||||
|
||||
private:
|
||||
Type _type;
|
||||
ImportType::Enum _type;
|
||||
LanguageUtils::ComponentVersion _version;
|
||||
QString _name;
|
||||
QString _path;
|
||||
|
||||
@@ -244,16 +244,16 @@ void LinkPrivate::populateImportedTypes(Imports *imports, Document::Ptr doc)
|
||||
|
||||
if (!import.object) {
|
||||
switch (info.type()) {
|
||||
case ImportInfo::FileImport:
|
||||
case ImportInfo::DirectoryImport:
|
||||
case ImportInfo::QrcFileImport:
|
||||
case ImportInfo::QrcDirectoryImport:
|
||||
case ImportType::File:
|
||||
case ImportType::Directory:
|
||||
case ImportType::QrcFile:
|
||||
case ImportType::QrcDirectory:
|
||||
import = importFileOrDirectory(doc, info);
|
||||
break;
|
||||
case ImportInfo::LibraryImport:
|
||||
case ImportType::Library:
|
||||
import = importNonFile(doc, info);
|
||||
break;
|
||||
case ImportInfo::UnknownFileImport:
|
||||
case ImportType::UnknownFile:
|
||||
imports->setImportFailed();
|
||||
if (info.ast()) {
|
||||
error(doc, info.ast()->fileNameToken,
|
||||
@@ -290,8 +290,8 @@ Import LinkPrivate::importFileOrDirectory(Document::Ptr doc, const ImportInfo &i
|
||||
|
||||
QString path = importInfo.path();
|
||||
|
||||
if (importInfo.type() == ImportInfo::DirectoryImport
|
||||
|| importInfo.type() == ImportInfo::ImplicitDirectoryImport) {
|
||||
if (importInfo.type() == ImportType::Directory
|
||||
|| importInfo.type() == ImportType::ImplicitDirectory) {
|
||||
import.object = new ObjectValue(valueOwner);
|
||||
|
||||
importLibrary(doc, path, &import);
|
||||
@@ -303,11 +303,11 @@ Import LinkPrivate::importFileOrDirectory(Document::Ptr doc, const ImportInfo &i
|
||||
import.object->setMember(targetName, importedDoc->bind()->rootObjectValue());
|
||||
}
|
||||
}
|
||||
} else if (importInfo.type() == ImportInfo::FileImport) {
|
||||
} else if (importInfo.type() == ImportType::File) {
|
||||
Document::Ptr importedDoc = snapshot.document(path);
|
||||
if (importedDoc)
|
||||
import.object = importedDoc->bind()->rootObjectValue();
|
||||
} else if (importInfo.type() == ImportInfo::QrcFileImport) {
|
||||
} else if (importInfo.type() == ImportType::QrcFile) {
|
||||
QLocale locale;
|
||||
QStringList filePaths = ModelManagerInterface::instance()
|
||||
->filesAtQrcPath(path, &locale, 0, ModelManagerInterface::ActiveQrcResources);
|
||||
@@ -319,7 +319,7 @@ Import LinkPrivate::importFileOrDirectory(Document::Ptr doc, const ImportInfo &i
|
||||
if (importedDoc)
|
||||
import.object = importedDoc->bind()->rootObjectValue();
|
||||
}
|
||||
} else if (importInfo.type() == ImportInfo::QrcDirectoryImport){
|
||||
} else if (importInfo.type() == ImportType::QrcDirectory){
|
||||
import.object = new ObjectValue(valueOwner);
|
||||
|
||||
importLibrary(doc, path, &import);
|
||||
@@ -454,7 +454,7 @@ bool LinkPrivate::importLibrary(Document::Ptr doc,
|
||||
if (libraryInfo.pluginTypeInfoStatus() == LibraryInfo::NoTypeInfo) {
|
||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||
if (modelManager) {
|
||||
if (importInfo.type() == ImportInfo::LibraryImport) {
|
||||
if (importInfo.type() == ImportType::Library) {
|
||||
if (version.isValid()) {
|
||||
const QString uri = importInfo.name();
|
||||
modelManager->loadPluginTypes(
|
||||
@@ -510,12 +510,12 @@ bool LinkPrivate::importLibrary(Document::Ptr doc,
|
||||
|
||||
void LinkPrivate::error(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message)
|
||||
{
|
||||
appendDiagnostic(doc, DiagnosticMessage(DiagnosticMessage::Error, loc, message));
|
||||
appendDiagnostic(doc, DiagnosticMessage(Severity::Error, loc, message));
|
||||
}
|
||||
|
||||
void LinkPrivate::warning(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message)
|
||||
{
|
||||
appendDiagnostic(doc, DiagnosticMessage(DiagnosticMessage::Warning, loc, message));
|
||||
appendDiagnostic(doc, DiagnosticMessage(Severity::Warning, loc, message));
|
||||
}
|
||||
|
||||
void LinkPrivate::appendDiagnostic(const Document::Ptr &doc, const DiagnosticMessage &message)
|
||||
|
||||
@@ -258,7 +258,7 @@ void ScopeChain::update() const
|
||||
m_all += m_cppContextProperties;
|
||||
|
||||
// the root scope in js files doesn't see instantiating components
|
||||
if (m_document->language() != Document::JavaScriptLanguage || m_jsScopes.count() != 1) {
|
||||
if (m_document->language() != Language::JavaScript || m_jsScopes.count() != 1) {
|
||||
if (m_qmlComponentScope) {
|
||||
foreach (const QmlComponentChain *parent, m_qmlComponentScope->instantiatingComponents())
|
||||
collectScopes(parent, &m_all);
|
||||
@@ -312,8 +312,8 @@ void ScopeChain::initializeRootScope()
|
||||
if (!m_document->bind()->isJsLibrary()) {
|
||||
foreach (Document::Ptr otherDoc, snapshot) {
|
||||
foreach (const ImportInfo &import, otherDoc->bind()->imports()) {
|
||||
if ((import.type() == ImportInfo::FileImport && m_document->fileName() == import.path())
|
||||
|| (import.type() == ImportInfo::QrcFileImport
|
||||
if ((import.type() == ImportType::File && m_document->fileName() == import.path())
|
||||
|| (import.type() == ImportType::QrcFile
|
||||
&& ModelManagerInterface::instance()->filesAtQrcPath(import.path())
|
||||
.contains(m_document->fileName()))) {
|
||||
QmlComponentChain *component = new QmlComponentChain(otherDoc);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmljsstaticanalysismessage.h"
|
||||
#include "qmljsconstants.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -35,6 +36,7 @@
|
||||
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJS::StaticAnalysis;
|
||||
using namespace QmlJS::Severity;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -43,7 +45,7 @@ class StaticAnalysisMessages
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::StaticAnalysisMessages)
|
||||
|
||||
public:
|
||||
void newMsg(Type type, Severity severity, const QString &message, int placeholders = 0)
|
||||
void newMsg(Type type, Enum severity, const QString &message, int placeholders = 0)
|
||||
{
|
||||
PrototypeMessageData prototype;
|
||||
prototype.type = type;
|
||||
@@ -152,7 +154,7 @@ StaticAnalysisMessages::StaticAnalysisMessages()
|
||||
tr("Unnecessary parentheses."));
|
||||
newMsg(MaybeWarnEqualityTypeCoercion, MaybeWarning,
|
||||
tr("== and != may perform type coercion, use === or !== to avoid it."));
|
||||
newMsg(WarnConfusingExpressionStatement, Warning,
|
||||
newMsg(WarnConfusingExpressionStatement, Error,
|
||||
tr("Expression statements should be assignments, calls or delete expressions only."));
|
||||
newMsg(HintDeclarationsShouldBeAtStartOfFunction, Hint,
|
||||
tr("Place var declarations at the start of a function."));
|
||||
@@ -168,17 +170,17 @@ StaticAnalysisMessages::StaticAnalysisMessages()
|
||||
tr("Prototype cycle, the last non-repeated component is '%1'."), 1);
|
||||
newMsg(ErrInvalidPropertyType, Error,
|
||||
tr("Invalid property type '%1'."), 1);
|
||||
newMsg(WarnEqualityTypeCoercion, Warning,
|
||||
newMsg(WarnEqualityTypeCoercion, Error,
|
||||
tr("== and != perform type coercion, use === or !== to avoid it."));
|
||||
newMsg(WarnExpectedNewWithUppercaseFunction, Warning,
|
||||
newMsg(WarnExpectedNewWithUppercaseFunction, Error,
|
||||
tr("Calls of functions that start with an uppercase letter should use 'new'."));
|
||||
newMsg(WarnNewWithLowercaseFunction, Warning,
|
||||
newMsg(WarnNewWithLowercaseFunction, Error,
|
||||
tr("Use 'new' only with functions that start with an uppercase letter."));
|
||||
newMsg(WarnNumberConstructor, Warning,
|
||||
newMsg(WarnNumberConstructor, Error,
|
||||
msgInvalidConstructor("Function"));
|
||||
newMsg(HintBinaryOperatorSpacing, Hint,
|
||||
tr("Use spaces around binary operators."));
|
||||
newMsg(WarnUnintentinalEmptyBlock, Warning,
|
||||
newMsg(WarnUnintentinalEmptyBlock, Error,
|
||||
tr("Unintentional empty block, use ({}) for empty object literal."));
|
||||
newMsg(HintPreferNonVarPropertyType, Hint,
|
||||
tr("Use %1 instead of 'var' or 'variant' to improve performance."), 1);
|
||||
@@ -206,16 +208,16 @@ StaticAnalysisMessages::StaticAnalysisMessages()
|
||||
tr("Maximum string value length is %1."), 1);
|
||||
newMsg(ErrInvalidArrayValueLength, Error,
|
||||
tr("%1 elements expected in array value."), 1);
|
||||
newMsg(WarnImperativeCodeNotEditableInVisualDesigner, Warning,
|
||||
newMsg(WarnImperativeCodeNotEditableInVisualDesigner, Error,
|
||||
tr("Imperative code is not supported in the Qt Quick Designer."));
|
||||
newMsg(WarnUnsupportedTypeInVisualDesigner, Warning,
|
||||
newMsg(WarnUnsupportedTypeInVisualDesigner, Error,
|
||||
tr("This type is not supported in the Qt Quick Designer."));
|
||||
newMsg(WarnReferenceToParentItemNotSupportedByVisualDesigner, Warning,
|
||||
newMsg(WarnReferenceToParentItemNotSupportedByVisualDesigner, Error,
|
||||
tr("Reference to parent item cannot be resolved correctly by the Qt Quick Designer."));
|
||||
newMsg(WarnUndefinedValueForVisualDesigner, Warning,
|
||||
newMsg(WarnUndefinedValueForVisualDesigner, Error,
|
||||
tr("This visual property binding cannot be evaluated in the local context "
|
||||
"and might not show up in Qt Quick Designer as expected."));
|
||||
newMsg(WarnStatesOnlyInRootItemForVisualDesigner, Warning,
|
||||
newMsg(WarnStatesOnlyInRootItemForVisualDesigner, Error,
|
||||
tr("Qt Quick Designer only supports states in the root item."));
|
||||
}
|
||||
|
||||
@@ -271,10 +273,10 @@ DiagnosticMessage Message::toDiagnosticMessage() const
|
||||
case Hint:
|
||||
case MaybeWarning:
|
||||
case Warning:
|
||||
diagnostic.kind = DiagnosticMessage::Warning;
|
||||
diagnostic.kind = Warning;
|
||||
break;
|
||||
default:
|
||||
diagnostic.kind = DiagnosticMessage::Error;
|
||||
diagnostic.kind = Error;
|
||||
break;
|
||||
}
|
||||
diagnostic.loc = location;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define QMLJS_STATICANALYSIS_QMLJSSTATICANALYSISMESSAGE_H
|
||||
|
||||
#include "qmljs_global.h"
|
||||
#include "qmljsconstants.h"
|
||||
#include "parser/qmljsengine_p.h"
|
||||
|
||||
#include <QRegExp>
|
||||
@@ -40,15 +41,6 @@
|
||||
namespace QmlJS {
|
||||
namespace StaticAnalysis {
|
||||
|
||||
enum Severity
|
||||
{
|
||||
Hint, // cosmetic or convention
|
||||
MaybeWarning, // possibly a warning, insufficient information
|
||||
Warning, // could cause unintended behavior
|
||||
MaybeError, // possibly an error, insufficient information
|
||||
Error // definitely an error
|
||||
};
|
||||
|
||||
enum Type
|
||||
{
|
||||
// Changing the numbers can break user code.
|
||||
@@ -134,7 +126,7 @@ enum Type
|
||||
class QMLJS_EXPORT PrototypeMessageData {
|
||||
public:
|
||||
Type type;
|
||||
Severity severity;
|
||||
Severity::Enum severity;
|
||||
QString message;
|
||||
int placeholders;
|
||||
};
|
||||
@@ -159,7 +151,7 @@ public:
|
||||
AST::SourceLocation location;
|
||||
QString message;
|
||||
Type type;
|
||||
Severity severity;
|
||||
Severity::Enum severity;
|
||||
|
||||
static const PrototypeMessageData prototypeForMessageType(Type type);
|
||||
};
|
||||
|
||||
@@ -194,7 +194,7 @@ UiQualifiedId *QmlJS::qualifiedTypeNameId(Node *node)
|
||||
|
||||
DiagnosticMessage QmlJS::errorMessage(const AST::SourceLocation &loc, const QString &message)
|
||||
{
|
||||
return DiagnosticMessage(DiagnosticMessage::Error, loc, message);
|
||||
return DiagnosticMessage(Severity::Error, loc, message);
|
||||
}
|
||||
|
||||
bool QmlJS::isValidBuiltinPropertyType(const QString &name)
|
||||
|
||||
@@ -67,7 +67,7 @@ AST::SourceLocation locationFromRange(const T *node)
|
||||
template <class T>
|
||||
DiagnosticMessage errorMessage(const T *node, const QString &message)
|
||||
{
|
||||
return DiagnosticMessage(DiagnosticMessage::Error,
|
||||
return DiagnosticMessage(Severity::Error,
|
||||
locationFromRange(node),
|
||||
message);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ using namespace QmlDesigner;
|
||||
using namespace QmlJS::AST;
|
||||
|
||||
ASTObjectTextExtractor::ASTObjectTextExtractor(const QString &text):
|
||||
m_document(Document::create("<ASTObjectTextExtractor>", Document::QmlLanguage))
|
||||
m_document(Document::create("<ASTObjectTextExtractor>", Language::Qml))
|
||||
{
|
||||
m_document->setSource(text);
|
||||
m_document->parseQml();
|
||||
|
||||
@@ -38,7 +38,7 @@ using namespace QmlDesigner;
|
||||
using namespace QmlJS::AST;
|
||||
|
||||
FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
|
||||
m_doc(Document::create("<internal>", Document::QmlLanguage))
|
||||
m_doc(Document::create("<internal>", Language::Qml))
|
||||
{
|
||||
m_doc->setSource(text);
|
||||
bool ok = m_doc->parseQml();
|
||||
|
||||
@@ -36,7 +36,7 @@ using namespace QmlDesigner;
|
||||
using namespace QmlJS::AST;
|
||||
|
||||
ObjectLengthCalculator::ObjectLengthCalculator():
|
||||
m_doc(Document::create("<internal>", Document::QmlLanguage))
|
||||
m_doc(Document::create("<internal>", Language::Qml))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ bool QmlRefactoring::reparseDocument()
|
||||
|
||||
// qDebug() << "QmlRefactoring::reparseDocument() new QML source:" << newSource;
|
||||
|
||||
Document::MutablePtr tmpDocument(Document::create("<ModelToTextMerger>", Document::QmlLanguage));
|
||||
Document::MutablePtr tmpDocument(Document::create("<ModelToTextMerger>", Language::Qml));
|
||||
tmpDocument->setSource(newSource);
|
||||
|
||||
if (tmpDocument->parseQml()) {
|
||||
|
||||
@@ -545,7 +545,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
|
||||
m_isFileComponent = true;
|
||||
const Imports *imports = context()->imports(document());
|
||||
ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
|
||||
if (importInfo.isValid() && importInfo.type() == ImportInfo::LibraryImport) {
|
||||
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
|
||||
m_majorVersion = importInfo.version().majorVersion();
|
||||
m_minorVersion = importInfo.version().minorVersion();
|
||||
}
|
||||
@@ -950,9 +950,9 @@ QString NodeMetaInfoPrivate::importDirectoryPath() const
|
||||
const Imports *imports = context()->imports(document());
|
||||
ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
|
||||
|
||||
if (importInfo.type() == ImportInfo::DirectoryImport) {
|
||||
if (importInfo.type() == ImportType::Directory) {
|
||||
return importInfo.path();
|
||||
} else if (importInfo.type() == ImportInfo::LibraryImport) {
|
||||
} else if (importInfo.type() == ImportType::Library) {
|
||||
if (modelManager) {
|
||||
foreach (const QString &importPath, modelManager->importPaths()) {
|
||||
const QString targetPath = QDir(importPath).filePath(importInfo.path());
|
||||
|
||||
@@ -91,7 +91,7 @@ static inline bool checkIfDerivedFromItem(const QString &fileName)
|
||||
|
||||
QmlJS::Document::MutablePtr document =
|
||||
QmlJS::Document::create(fileName.isEmpty() ?
|
||||
QLatin1String("<internal>") : fileName, QmlJS::Document::QmlLanguage);
|
||||
QLatin1String("<internal>") : fileName, QmlJS::Language::Qml);
|
||||
document->setSource(source);
|
||||
document->parseQml();
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ void ModelToTextMerger::applyChanges()
|
||||
if (m_rewriteActions.isEmpty())
|
||||
return;
|
||||
|
||||
Document::MutablePtr tmpDocument(Document::create(QLatin1String("<ModelToTextMerger>"), Document::QmlLanguage));
|
||||
Document::MutablePtr tmpDocument(Document::create(QLatin1String("<ModelToTextMerger>"), Language::Qml));
|
||||
tmpDocument->setSource(m_rewriterView->textModifier()->text());
|
||||
if (!tmpDocument->parseQml()) {
|
||||
qDebug() << "*** Possible problem: QML file wasn't parsed correctly.";
|
||||
|
||||
@@ -359,12 +359,12 @@ public:
|
||||
|
||||
const Imports *imports = m_context->imports(m_doc.data());
|
||||
ImportInfo importInfo = imports->info(fullTypeName, m_context.data());
|
||||
if (importInfo.isValid() && importInfo.type() == ImportInfo::LibraryImport) {
|
||||
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
|
||||
QString name = importInfo.name();
|
||||
majorVersion = importInfo.version().majorVersion();
|
||||
minorVersion = importInfo.version().minorVersion();
|
||||
typeName.prepend(name + QLatin1Char('.'));
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportInfo::DirectoryImport) {
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::Directory) {
|
||||
QString path = importInfo.path();
|
||||
QDir dir(m_doc->path());
|
||||
// should probably try to make it relatve to some import path, not to the document path
|
||||
@@ -372,7 +372,7 @@ public:
|
||||
QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
if (!name.isEmpty())
|
||||
typeName.prepend(name + QLatin1Char('.'));
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportInfo::QrcDirectoryImport) {
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
|
||||
QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
||||
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
@@ -738,7 +738,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
try {
|
||||
Snapshot snapshot = m_rewriterView->textModifier()->getSnapshot();
|
||||
const QString fileName = url.toLocalFile();
|
||||
Document::MutablePtr doc = Document::create(fileName.isEmpty() ? QLatin1String("<internal>") : fileName, Document::QmlLanguage);
|
||||
Document::MutablePtr doc = Document::create(fileName.isEmpty() ? QLatin1String("<internal>") : fileName, Language::Qml);
|
||||
doc->setSource(data);
|
||||
doc->parseQml();
|
||||
|
||||
@@ -766,13 +766,13 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
setupImports(doc, differenceHandler);
|
||||
|
||||
if (m_rewriterView->model()->imports().isEmpty()) {
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::DiagnosticMessage::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found"));
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found"));
|
||||
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
|
||||
}
|
||||
|
||||
foreach (const QmlDesigner::Import &import, m_rewriterView->model()->imports()) {
|
||||
if (import.isLibraryImport() && import.url() == QLatin1String("QtQuick") && !supportedQtQuickVersion(import.version())) {
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::DiagnosticMessage::Error, AST::SourceLocation(0, 0, 0, 0),
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0),
|
||||
QCoreApplication::translate("QmlDesigner::TextToModelMerger", "Unsupported QtQuick version"));
|
||||
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
|
||||
}
|
||||
@@ -787,8 +787,8 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
|
||||
foreach (StaticAnalysis::Type type, StaticAnalysis::Message::allMessageTypes()) {
|
||||
StaticAnalysis::PrototypeMessageData prototypeMessageData = StaticAnalysis::Message::prototypeForMessageType(type);
|
||||
if (prototypeMessageData.severity == StaticAnalysis::MaybeWarning
|
||||
|| prototypeMessageData.severity == StaticAnalysis::Warning) {
|
||||
if (prototypeMessageData.severity == Severity::MaybeWarning
|
||||
|| prototypeMessageData.severity == Severity::Warning) {
|
||||
check.disableMessage(type);
|
||||
}
|
||||
}
|
||||
@@ -800,9 +800,9 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
check.enableMessage(StaticAnalysis::WarnStatesOnlyInRootItemForVisualDesigner);
|
||||
|
||||
foreach (const StaticAnalysis::Message &message, check()) {
|
||||
if (message.severity == StaticAnalysis::Error)
|
||||
if (message.severity == Severity::Error)
|
||||
errors.append(RewriterView::Error(message.toDiagnosticMessage(), QUrl::fromLocalFile(doc->fileName())));
|
||||
if (message.severity == StaticAnalysis::Warning)
|
||||
if (message.severity == Severity::Warning)
|
||||
warnings.append(RewriterView::Error(message.toDiagnosticMessage(), QUrl::fromLocalFile(doc->fileName())));
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ QmlJS::AST::ExpressionNode *QmlExpressionUnderCursor::operator()(const QTextCurs
|
||||
_text = expressionUnderCursor(cursor);
|
||||
|
||||
Document::MutablePtr newDoc = Document::create(
|
||||
QLatin1String("<expression>"), Document::JavaScriptLanguage);
|
||||
QLatin1String("<expression>"), Language::JavaScript);
|
||||
newDoc->setSource(_text);
|
||||
newDoc->parseExpression();
|
||||
exprDoc = newDoc;
|
||||
|
||||
@@ -1079,7 +1079,7 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
||||
if (AST::UiImport *importAst = cast<AST::UiImport *>(node)) {
|
||||
// if it's a file import, link to the file
|
||||
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
||||
if (import.ast() == importAst && import.type() == ImportInfo::FileImport) {
|
||||
if (import.ast() == importAst && import.type() == ImportType::File) {
|
||||
BaseTextEditorWidget::Link link(import.path());
|
||||
link.linkTextStart = importAst->firstSourceLocation().begin();
|
||||
link.linkTextEnd = importAst->lastSourceLocation().end();
|
||||
|
||||
@@ -812,7 +812,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
if (oldDoc && oldDoc->editorRevision() == it.value().second)
|
||||
continue;
|
||||
|
||||
Document::Language language;
|
||||
Language::Enum language;
|
||||
if (oldDoc)
|
||||
language = oldDoc->language();
|
||||
else
|
||||
|
||||
@@ -115,7 +115,7 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
|
||||
const QString moduleName = qmlValue->moduleName();
|
||||
const Imports *imports = scopeChain.context()->imports(qmlDocument.data());
|
||||
const ImportInfo importInfo = imports->info(qmlValue->className(), scopeChain.context().data());
|
||||
if (importInfo.isValid() && importInfo.type() == ImportInfo::LibraryImport) {
|
||||
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
|
||||
const int majorVersion = importInfo.version().majorVersion();
|
||||
const int minorVersion = importInfo.version().minorVersion();
|
||||
return moduleName + QString::number(majorVersion) + QLatin1Char('.')
|
||||
@@ -127,20 +127,20 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
|
||||
|
||||
const Imports *imports = scopeChain.context()->imports(qmlDocument.data());
|
||||
const ImportInfo importInfo = imports->info(typeName, scopeChain.context().data());
|
||||
if (importInfo.isValid() && importInfo.type() == ImportInfo::LibraryImport) {
|
||||
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
|
||||
const QString moduleName = importInfo.name();
|
||||
const int majorVersion = importInfo.version().majorVersion();
|
||||
const int minorVersion = importInfo.version().minorVersion();
|
||||
return moduleName + QString::number(majorVersion) + QLatin1Char('.')
|
||||
+ QString::number(minorVersion) ;
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportInfo::DirectoryImport) {
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::Directory) {
|
||||
const QString path = importInfo.path();
|
||||
const QDir dir(qmlDocument->path());
|
||||
// should probably try to make it relatve to some import path, not to the document path
|
||||
QString relativeDir = dir.relativeFilePath(path);
|
||||
const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
return name;
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportInfo::QrcDirectoryImport) {
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
|
||||
QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
||||
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
@@ -350,7 +350,7 @@ void HoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *nod
|
||||
|
||||
foreach (const Import &import, imports->all()) {
|
||||
if (import.info.ast() == node) {
|
||||
if (import.info.type() == ImportInfo::LibraryImport
|
||||
if (import.info.type() == ImportType::Library
|
||||
&& !import.libraryPath.isEmpty()) {
|
||||
QString msg = tr("Library at %1").arg(import.libraryPath);
|
||||
const LibraryInfo &libraryInfo = scopeChain.context()->snapshot().libraryInfo(import.libraryPath);
|
||||
|
||||
@@ -413,11 +413,11 @@ protected:
|
||||
length = end-begin;
|
||||
}
|
||||
QTextCharFormat format;
|
||||
if (d.severity == StaticAnalysis::Warning || d.severity == StaticAnalysis::MaybeWarning)
|
||||
if (d.severity == Severity::Warning || d.severity == Severity::MaybeWarning)
|
||||
format.setUnderlineColor(Qt::darkYellow);
|
||||
else if (d.severity == StaticAnalysis::Error || d.severity == StaticAnalysis::MaybeError)
|
||||
else if (d.severity == Severity::Error || d.severity == Severity::MaybeError)
|
||||
format.setUnderlineColor(Qt::red);
|
||||
else if (d.severity == StaticAnalysis::Hint)
|
||||
else if (d.severity == Severity::Hint)
|
||||
format.setUnderlineColor(Qt::darkGreen);
|
||||
|
||||
format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
|
||||
|
||||
@@ -128,7 +128,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
|
||||
ScopeChain *scopeChain = new ScopeChain(doc, semanticInfo.context);
|
||||
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
|
||||
|
||||
if (doc->language() == Document::JsonLanguage) {
|
||||
if (doc->language() == Language::Json) {
|
||||
Utils::JsonSchema *schema =
|
||||
QmlJSEditorPlugin::instance()->jsonManager()->schemaForFile(doc->fileName());
|
||||
if (schema) {
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <qmljs/qmljsbundle.h>
|
||||
#include <qmljs/qmljsconstants.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
@@ -39,10 +40,10 @@
|
||||
namespace QmlJSTools {
|
||||
|
||||
namespace {
|
||||
typedef QmlJS::Document::Language Language;
|
||||
typedef QmlJS::QmlBundle QmlBundle;
|
||||
typedef QmlJS::QmlLanguageBundles QmlLanguageBundles;
|
||||
}
|
||||
using namespace QmlJS;
|
||||
|
||||
/*!
|
||||
\class QmlJSEditor::BasicBundleProvider
|
||||
@@ -106,27 +107,26 @@ QmlBundle BasicBundleProvider::defaultQmlprojectBundle()
|
||||
}
|
||||
|
||||
void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
, QmlJS::QmlLanguageBundles &bundles
|
||||
, QmlLanguageBundles &bundles
|
||||
, const QHash<QString,QString> &replacements)
|
||||
{
|
||||
typedef QmlJS::Document Doc;
|
||||
QHash<QString,QString> myReplacements = replacements;
|
||||
|
||||
bundles.mergeBundleForLanguage(Doc::QmlQbsLanguage, defaultQbsBundle());
|
||||
bundles.mergeBundleForLanguage(Doc::QmlTypeInfoLanguage, defaultQmltypesBundle());
|
||||
bundles.mergeBundleForLanguage(Doc::QmlProjectLanguage, defaultQmlprojectBundle());
|
||||
bundles.mergeBundleForLanguage(Language::QmlQbs, defaultQbsBundle());
|
||||
bundles.mergeBundleForLanguage(Language::QmlTypeInfo, defaultQmltypesBundle());
|
||||
bundles.mergeBundleForLanguage(Language::QmlProject, defaultQmlprojectBundle());
|
||||
|
||||
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit);
|
||||
if (!qtVersion) {
|
||||
QmlBundle b1(defaultQt4QtQuick1Bundle());
|
||||
bundles.mergeBundleForLanguage(Doc::QmlLanguage, b1);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlQtQuick1Language, b1);
|
||||
bundles.mergeBundleForLanguage(Language::Qml, b1);
|
||||
bundles.mergeBundleForLanguage(Language::QmlQtQuick1, b1);
|
||||
QmlBundle b11(defaultQt5QtQuick1Bundle());
|
||||
bundles.mergeBundleForLanguage(Doc::QmlLanguage, b11);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlQtQuick1Language, b11);
|
||||
bundles.mergeBundleForLanguage(Language::Qml, b11);
|
||||
bundles.mergeBundleForLanguage(Language::QmlQtQuick1, b11);
|
||||
QmlBundle b2(defaultQt5QtQuick2Bundle());
|
||||
bundles.mergeBundleForLanguage(Doc::QmlLanguage, b2);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlQtQuick2Language, b2);
|
||||
bundles.mergeBundleForLanguage(Language::Qml, b2);
|
||||
bundles.mergeBundleForLanguage(Language::QmlQtQuick2, b2);
|
||||
return;
|
||||
}
|
||||
QString qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
|
||||
@@ -150,15 +150,15 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
qtQuick1Bundle.merge(bAtt);
|
||||
}
|
||||
if (!qtQuick1Bundle.supportedImports().contains(QLatin1String("QtQuick 1."),
|
||||
QmlJS::PersistentTrie::Partial)) {
|
||||
PersistentTrie::Partial)) {
|
||||
if (qtVersion->qtVersion().majorVersion == 4)
|
||||
qtQuick1Bundle.merge(defaultQt4QtQuick1Bundle());
|
||||
else if (qtVersion->qtVersion().majorVersion > 4)
|
||||
qtQuick1Bundle.merge(defaultQt5QtQuick1Bundle());
|
||||
}
|
||||
qtQuick1Bundle.replaceVars(myReplacements);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlLanguage, qtQuick1Bundle);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlQtQuick1Language, qtQuick1Bundle);
|
||||
bundles.mergeBundleForLanguage(Language::Qml, qtQuick1Bundle);
|
||||
bundles.mergeBundleForLanguage(Language::QmlQtQuick1, qtQuick1Bundle);
|
||||
}
|
||||
if (features.contains(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_2))) {
|
||||
myReplacements.insert(QLatin1String("$(CURRENT_DIRECTORY)"), qtQmlPath);
|
||||
@@ -175,12 +175,12 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
qtQuick2Bundle.merge(bAtt);
|
||||
}
|
||||
if (!qtQuick2Bundle.supportedImports().contains(QLatin1String("QtQuick 2."),
|
||||
QmlJS::PersistentTrie::Partial)) {
|
||||
PersistentTrie::Partial)) {
|
||||
qtQuick2Bundle.merge(defaultQt5QtQuick2Bundle());
|
||||
}
|
||||
qtQuick2Bundle.replaceVars(myReplacements);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlLanguage, qtQuick2Bundle);
|
||||
bundles.mergeBundleForLanguage(Doc::QmlQtQuick2Language, qtQuick2Bundle);
|
||||
bundles.mergeBundleForLanguage(Language::Qml, qtQuick2Bundle);
|
||||
bundles.mergeBundleForLanguage(Language::QmlQtQuick2, qtQuick2Bundle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ static void mergeSuffixes(QStringList &l1, const QStringList &l2)
|
||||
l1 = l2;
|
||||
}
|
||||
|
||||
QmlJS::Document::Language QmlJSTools::languageOfFile(const QString &fileName)
|
||||
QmlJS::Language::Enum QmlJSTools::languageOfFile(const QString &fileName)
|
||||
{
|
||||
QStringList jsSuffixes(QLatin1String("js"));
|
||||
QStringList qmlSuffixes(QLatin1String("qml"));
|
||||
@@ -202,14 +202,14 @@ QmlJS::Document::Language QmlJSTools::languageOfFile(const QString &fileName)
|
||||
const QFileInfo info(fileName);
|
||||
const QString fileSuffix = info.suffix();
|
||||
if (jsSuffixes.contains(fileSuffix))
|
||||
return QmlJS::Document::JavaScriptLanguage;
|
||||
return QmlJS::Language::JavaScript;
|
||||
if (qbsSuffixes.contains(fileSuffix))
|
||||
return QmlJS::Document::QmlQbsLanguage;
|
||||
return QmlJS::Language::QmlQbs;
|
||||
if (qmlSuffixes.contains(fileSuffix) || qmlProjectSuffixes.contains(fileSuffix))
|
||||
return QmlJS::Document::QmlLanguage;
|
||||
return QmlJS::Language::Qml;
|
||||
if (jsonSuffixes.contains(fileSuffix))
|
||||
return QmlJS::Document::JsonLanguage;
|
||||
return QmlJS::Document::UnknownLanguage;
|
||||
return QmlJS::Language::Json;
|
||||
return QmlJS::Language::Unknown;
|
||||
}
|
||||
|
||||
QStringList QmlJSTools::qmlAndJsGlobPatterns()
|
||||
@@ -666,23 +666,23 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho
|
||||
// scan files and directories that are explicitly imported
|
||||
foreach (const ImportInfo &import, doc->bind()->imports()) {
|
||||
const QString &importName = import.path();
|
||||
if (import.type() == ImportInfo::FileImport) {
|
||||
if (import.type() == ImportType::File) {
|
||||
if (! snapshot.document(importName))
|
||||
*importedFiles += importName;
|
||||
} else if (import.type() == ImportInfo::DirectoryImport) {
|
||||
} else if (import.type() == ImportType::Directory) {
|
||||
if (snapshot.documentsInDirectory(importName).isEmpty()) {
|
||||
if (! scannedPaths->contains(importName)) {
|
||||
*importedFiles += qmlFilesInDirectory(importName);
|
||||
scannedPaths->insert(importName);
|
||||
}
|
||||
}
|
||||
} else if (import.type() == ImportInfo::QrcFileImport) {
|
||||
} else if (import.type() == ImportType::QrcFile) {
|
||||
QStringList importPaths = ModelManagerInterface::instance()->filesAtQrcPath(importName);
|
||||
foreach (const QString &importPath, importPaths) {
|
||||
if (! snapshot.document(importPath))
|
||||
*importedFiles += importPath;
|
||||
}
|
||||
} else if (import.type() == ImportInfo::QrcDirectoryImport) {
|
||||
} else if (import.type() == ImportType::QrcDirectory) {
|
||||
QMapIterator<QString,QStringList> dirContents(ModelManagerInterface::instance()->filesInQrcPath(importName));
|
||||
while (dirContents.hasNext()) {
|
||||
dirContents.next();
|
||||
@@ -792,13 +792,13 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
|
||||
// scan dir and lib imports
|
||||
const QStringList importPaths = modelManager->importPaths();
|
||||
foreach (const ImportInfo &import, doc->bind()->imports()) {
|
||||
if (import.type() == ImportInfo::DirectoryImport) {
|
||||
if (import.type() == ImportType::Directory) {
|
||||
const QString targetPath = import.path();
|
||||
findNewQmlLibraryInPath(targetPath, snapshot, modelManager,
|
||||
importedFiles, scannedPaths, newLibraries);
|
||||
}
|
||||
|
||||
if (import.type() == ImportInfo::LibraryImport) {
|
||||
if (import.type() == ImportType::Library) {
|
||||
if (!import.version().isValid())
|
||||
continue;
|
||||
foreach (const QString &importPath, importPaths) {
|
||||
@@ -829,8 +829,8 @@ void ModelManager::parse(QFutureInterface<void> &future,
|
||||
|
||||
const QString fileName = files.at(i);
|
||||
|
||||
Document::Language language = languageOfFile(fileName);
|
||||
if (language == Document::UnknownLanguage) {
|
||||
Language::Enum language = languageOfFile(fileName);
|
||||
if (language == Language::Unknown) {
|
||||
if (fileName.endsWith(QLatin1String(".qrc")))
|
||||
modelManager->updateQrcFile(fileName);
|
||||
continue;
|
||||
@@ -951,7 +951,7 @@ void ModelManager::updateImportPaths()
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
activeBundles.mergeLanguageBundles(it.value().activeBundle);
|
||||
foreach (Document::Language l, it.value().activeBundle.languages()) {
|
||||
foreach (Language::Enum l, it.value().activeBundle.languages()) {
|
||||
foreach (const QString &path, it.value().activeBundle.bundleForLanguage(l)
|
||||
.searchPaths().stringList()) {
|
||||
const QString canonicalPath = QFileInfo(path).canonicalFilePath();
|
||||
@@ -964,7 +964,7 @@ void ModelManager::updateImportPaths()
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
extendedBundles.mergeLanguageBundles(it.value().extendedBundle);
|
||||
foreach (Document::Language l, it.value().extendedBundle.languages()) {
|
||||
foreach (Language::Enum l, it.value().extendedBundle.languages()) {
|
||||
foreach (const QString &path, it.value().extendedBundle.bundleForLanguage(l)
|
||||
.searchPaths().stringList()) {
|
||||
const QString canonicalPath = QFileInfo(path).canonicalFilePath();
|
||||
|
||||
@@ -58,7 +58,7 @@ class QrcParser;
|
||||
|
||||
namespace QmlJSTools {
|
||||
|
||||
QMLJSTOOLS_EXPORT QmlJS::Document::Language languageOfFile(const QString &fileName);
|
||||
QMLJSTOOLS_EXPORT QmlJS::Language::Enum languageOfFile(const QString &fileName);
|
||||
QMLJSTOOLS_EXPORT QStringList qmlAndJsGlobPatterns();
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -123,7 +123,7 @@ QmlJSRefactoringFile::QmlJSRefactoringFile(const QString &fileName, const QShare
|
||||
: RefactoringFile(fileName, data)
|
||||
{
|
||||
// the RefactoringFile is invalid if its not for a file with qml or js code
|
||||
if (languageOfFile(fileName) == Document::UnknownLanguage)
|
||||
if (languageOfFile(fileName) == Language::Unknown)
|
||||
m_fileName.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user