forked from qt-creator/qt-creator
Json: Use the javascript editor for json files.
Task-number: QTCREATORBUG-4639 Change-Id: Icd0fda434d5ca66056d784dd87240db76e8a442c Reviewed-on: http://codereview.qt-project.org/6035 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
@@ -17,4 +17,9 @@
|
||||
<glob pattern="*.qs"/>
|
||||
<glob pattern="*.qtt"/>
|
||||
</mime-type>
|
||||
<mime-type type="application/json">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>JSON file</comment>
|
||||
<glob pattern="*.json"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
|
||||
@@ -30,9 +30,10 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmljseditorconstants.h"
|
||||
#include "jsfilewizard.h"
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
|
||||
#include <utils/filewizarddialog.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/filewizarddialog.h>
|
||||
@@ -104,7 +105,7 @@ Core::GeneratedFiles JsFileWizard::generateFiles(const QWizard *w,
|
||||
const QString path = wizardDialog->path();
|
||||
const QString name = wizardDialog->fileName();
|
||||
|
||||
const QString mimeType = QLatin1String(Constants::JS_MIMETYPE);
|
||||
const QString mimeType = QLatin1String(QmlJSTools::Constants::JS_MIMETYPE);
|
||||
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, preferredSuffix(mimeType));
|
||||
|
||||
Core::GeneratedFile file(fileName);
|
||||
|
||||
@@ -30,9 +30,10 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmljseditorconstants.h"
|
||||
#include "qmlfilewizard.h"
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
@@ -49,7 +50,7 @@ Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path,
|
||||
QString * /*errorMessage*/) const
|
||||
|
||||
{
|
||||
const QString mimeType = QLatin1String(Constants::QML_MIMETYPE);
|
||||
const QString mimeType = QLatin1String(QmlJSTools::Constants::QML_MIMETYPE);
|
||||
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, preferredSuffix(mimeType));
|
||||
|
||||
Core::GeneratedFile file(fileName);
|
||||
|
||||
@@ -58,9 +58,6 @@ const char * const RENAME_USAGES = "QmlJSEditor.RenameUsages";
|
||||
const char * const RUN_SEMANTIC_SCAN = "QmlJSEditor.RunSemanticScan";
|
||||
const char * const SHOW_QT_QUICK_HELPER = "QmlJSEditor.ShowQtQuickHelper";
|
||||
|
||||
const char * const QML_MIMETYPE = "application/x-qml";
|
||||
const char * const JS_MIMETYPE = "application/javascript";
|
||||
|
||||
const char *const TASK_CATEGORY_QML = "Task.Category.Qml";
|
||||
const char *const TASK_CATEGORY_QML_ANALYSIS = "Task.Category.QmlAnalysis";
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "qmljseditor.h"
|
||||
#include "qmljseditorconstants.h"
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <qmldesigner/qmldesignerconstants.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -64,7 +65,7 @@ static bool openInDesignMode()
|
||||
if (!bauhausDetected) {
|
||||
if (const Core::IMode *dm = Core::ModeManager::instance()->mode(QLatin1String(Core::Constants::MODE_DESIGN)))
|
||||
if (const Core::DesignMode *designMode = qobject_cast<const Core::DesignMode *>(dm))
|
||||
bauhausPresent = designMode->registeredMimeTypes().contains(QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE));
|
||||
bauhausPresent = designMode->registeredMimeTypes().contains(QLatin1String(QmlJSTools::Constants::QML_MIMETYPE));
|
||||
bauhausDetected = true;
|
||||
}
|
||||
if (!bauhausPresent)
|
||||
@@ -86,7 +87,7 @@ QString QmlJSEditorEditable::preferredModeType() const
|
||||
// if we are in other mode than edit or design, use the hard-coded default.
|
||||
// because the editor opening decision is modal, it would be confusing to
|
||||
// have the user also access to this failsafe setting.
|
||||
if (editorWidget()->mimeType() == QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE)
|
||||
if (editorWidget()->mimeType() == QLatin1String(QmlJSTools::Constants::QML_MIMETYPE)
|
||||
&& openInDesignMode())
|
||||
return QLatin1String(Core::Constants::MODE_DESIGN_TYPE);
|
||||
return QString();
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "qmljseditorconstants.h"
|
||||
#include "qmljseditorplugin.h"
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
|
||||
@@ -90,8 +92,9 @@ QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
|
||||
: Core::IEditorFactory(parent)
|
||||
{
|
||||
m_mimeTypes
|
||||
<< QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE)
|
||||
<< QLatin1String(QmlJSEditor::Constants::JS_MIMETYPE)
|
||||
<< QLatin1String(QmlJSTools::Constants::QML_MIMETYPE)
|
||||
<< QLatin1String(QmlJSTools::Constants::JS_MIMETYPE)
|
||||
<< QLatin1String(QmlJSTools::Constants::JSON_MIMETYPE)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,9 +146,10 @@ SemanticInfo SemanticInfoUpdater::semanticInfo(const SemanticInfoUpdaterSource &
|
||||
QmlJS::ScopeChain *scopeChain = new QmlJS::ScopeChain(doc, semanticInfo.context);
|
||||
semanticInfo.m_rootScopeChain = QSharedPointer<const QmlJS::ScopeChain>(scopeChain);
|
||||
|
||||
QmlJS::Check checker(doc, semanticInfo.context);
|
||||
foreach (const QmlJS::StaticAnalysis::Message &msg, checker()) {
|
||||
semanticInfo.semanticMessages += msg.toDiagnosticMessage();
|
||||
if (doc->language() != QmlJS::Document::JsonLanguage) {
|
||||
QmlJS::Check checker(doc, semanticInfo.context);
|
||||
foreach (const QmlJS::StaticAnalysis::Message &msg, checker()) {
|
||||
semanticInfo.semanticMessages += msg.toDiagnosticMessage();
|
||||
}
|
||||
|
||||
return semanticInfo;
|
||||
|
||||
Reference in New Issue
Block a user