Introduce JSON validation

Support basic validation for JSON files according to the
draft http://tools.ietf.org/html/draft-zyp-json-schema-03.

This is not a complete implementation yet, but it should
already be useful, since "type" verification along with
many of the attributes is done.

Change-Id: I364bc98dd92937c5e2ea9cba7e15ed8e03eb9beb
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
Leandro Melo
2012-02-07 15:30:33 +01:00
parent 454e2c3928
commit 26b783ff02
11 changed files with 1738 additions and 11 deletions

View File

@@ -31,14 +31,20 @@
**************************************************************************/
#include "qmljssemanticinfoupdater.h"
#include "qmljseditorplugin.h"
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljscheck.h>
#include <qmljs/jsoncheck.h>
#include <qmljs/qmljscontext.h>
#include <qmljs/qmljslink.h>
#include <qmljstools/qmljsmodelmanager.h>
#include <coreplugin/icore.h>
#include <utils/json.h>
namespace QmlJSEditor {
namespace Internal {
@@ -125,7 +131,14 @@ SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::Document::Ptr
ScopeChain *scopeChain = new ScopeChain(doc, semanticInfo.context);
semanticInfo.m_rootScopeChain = QSharedPointer<const ScopeChain>(scopeChain);
if (doc->language() != Document::JsonLanguage) {
if (doc->language() == Document::JsonLanguage) {
Utils::JsonSchema *schema =
QmlJSEditorPlugin::instance()->jsonManager()->schemaForFile(doc->fileName());
if (schema) {
JsonCheck jsonChecker(doc);
semanticInfo.staticAnalysisMessages = jsonChecker(schema);
}
} else {
Check checker(doc, semanticInfo.context);
semanticInfo.staticAnalysisMessages = checker();
}