import { injectable , inject } from 'inversify' ; import { Workspace , Languages , LanguageClientFactory , BaseLanguageClientContribution } from '@theia/languages/lib/browser' ; @ injectable ( ) export class DslClientContribution extends BaseLanguageClientContribution { readonly id = "dsl" ; readonly name = "DSL" ; constructor ( @ inject ( Workspace ) protected readonly workspace , @ inject ( Languages ) protected readonly languages , @ inject ( LanguageClientFactory ) protected readonly languageClientFactory ) { super ( workspace , languages , languageClientFactory ) ; } protected get globPatterns ( ) { return [ '**/*.dsl' ] ; } } registerDSL ( ) ; export function registerDSL ( ) { monaco . languages . register ( { id : 'dsl' , aliases : [ 'DSL' , 'dsl' ] , extensions : [ '.dsl' ] , mimetypes : [ 'text/dsl' ] } ) ; monaco . languages . setLanguageConfiguration ( 'dsl' , { comments : { lineComment : "//" , blockComment : [ '/*' , '*/' ] } , brackets : [ [ '{' , '}' ] , [ '(' , ')' ] ] , autoClosingPairs : [ { open : '{' , close : '}' } , { open : '(' , close : ')' } ] } ) ; monaco . languages . setMonarchTokensProvider ( 'dsl' , < any > { keywords : [ 'protocol' , 'type' , 'request' , 'notification' , 'extends' ] , typeKeywords : [ 'boolean' , 'number' , 'string' ] , operators : [ ':' ] , symbols : /[=><!~?:&|+\-*\/\^%]+/ , escapes : /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/ , tokenizer : { root : [ [ /[a-z_$][\w$]*/ , { cases : { '@typeKeywords' : 'keyword' , '@keywords' : 'keyword' , '@default' : 'identifier' } } ] , [ /[A-Z][\w\$]*/ , 'type.identifier' ] , { include : '@whitespace' } , [ /[{}()\[\]]/ , '@brackets' ] , [ /[<>](?!@symbols)/ , '@brackets' ] , [ /@symbols/ , { cases : { '@operators' : 'operator' , '@default' : '' } } ] ] , whitespace : [ [ /[ \t\r\n]+/ , 'white' ] , [ /\/\*/ , 'comment' , '@comment' ] , [ /\/\/.*$/ , 'comment' ] , ] , comment : [ [ /[^\/*]+/ , 'comment' ] , [ /\/\*/ , 'comment.invalid' ] , [ "\\*/" , 'comment' , '@pop' ] , [ /[\/*]/ , 'comment' ] ] , string : [ [ /[^\\"]+/ , 'string' ] , [ /@escapes/ , 'string.escape' ] , [ /\\./ , 'string.escape.invalid' ] , [ /"/ , 'string' , '@pop' ] ] , } , } ) ; }