简体   繁体   中英

How to use xtext language services from Angular

I'm working on a DSL developed using xtext. I am using autocomplete using orion editor. It works great with the auto generated web editor. But, we want to integrate it with another web app developed using Angular 4. I got to configure the editor, but somehow all calls to language services (eg Occurrences, hover, etc) fails with 404 . While same calls work fine with the auto generated embedded editor. What I'm missing here?

Here is how my code to create editor looks like in typescript:

xtext.createEditor({
    'serviceUrl': 'http://localhost:8080/xtext-service',
    'syntaxDefinition': 'http://localhost:8080/xtext-resources/generated/dsl-syntax.js',
    'parentClass': 'xtext-editor',
    'enableCors': true,
    'loadFromServer': false
  })

If I compare AJAX calls made by angular app and web editor, significant difference I see is, the web editor sends few cookies, which angular app doesn't. Can that be a reason? If so, how can I fix angular app accordingly?

In case anyone else is stuck with the same situation, I resolved it by adding

sendFullText: true

to the config object passed to the createEditor method. This property configures the editor to use language services in stateless mode and doesn't expect cookie/session to be passed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM