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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user