/******************************************************************************
 * Copyright 2021 TypeFox GmbH
 * This program and the accompanying materials are made available under the
 * terms of the MIT License, which is available in the project root.
 ******************************************************************************/ import { createDefaultModule , createDefaultSharedModule , createLangiumParser , Grammar , inject , IParserConfig , LangiumGeneratedServices , LangiumGeneratedSharedServices , LangiumServices , LangiumSharedServices , Module } from 'langium' ; import { LangiumConfig } from './package' ; export function validateParser ( grammar , config ) { const parserConfig = { ... config . chevrotainParserConfig , skipValidations : false } ; const unavailable = ( ) => ( { } ) ; const generatedSharedModule = { AstReflection : unavailable , } ; const generatedModule = { Grammar : ( ) => grammar , LanguageMetaData : unavailable , parser : { ParserConfig : ( ) => parserConfig } } ; const shared = inject ( createDefaultSharedModule ( ) , generatedSharedModule ) ; const services = inject ( createDefaultModule ( { shared } ) , generatedModule ) ; try { createLangiumParser ( services ) ; return undefined ; } catch ( err ) { if ( err instanceof Error ) { return err ; } throw err ; } }