eclipselabs/eclipse-language-service

Remove dependency to WTP (for content type)

Closed this issue · 9 comments

If you have not Eclipse WTP which defines content types org.eclipse.wst.jsdt.core.jsonSource and org.eclipse.wst.css.core.csssource, the JSON/CSS Editor with Generic Editor doesn't work because thoses content type are not defined.

Perhaps a solution is to define again org.eclipse.wst.jsdt.core.jsonSource

<content-type
        base-type="org.eclipse.core.runtime.text"
        file-extensions="json"
        id="org.eclipse.wst.jsdt.core.jsonSource"
        name="JSON"
        priority="normal">            
  </content-type>

Or working with a new content type org.eclipse.languageserver.languages.json which extends org.eclipse.wst.jsdt.core.jsonSource

<content-type
        base-type="org.eclipse.wst.jsdt.core.jsonSource"
        file-extensions="json"
        id="org.eclipse.languageserver.languages.json"
        name="JSON"
        priority="normal">            
  </content-type>

I don't what is the better clean mean. I post just some ideas without testing.

Redefining the same content-type isn't recommended as id are supposed to be really unique. Having another content-type seems cleaner.

I agree with you.

I think we should:

  • define a new org.eclipse.languageserver.languages.json
  • support both org.eclipse.languageserver.languages.json and org.eclipse.wst.jsdt.core.jsonSource for completion, hover, etc

No need to define support for both, see https://github.com/eclipselabs/eclipse-language-service/blob/master/org.eclipse.languageserver/src/org/eclipse/languageserver/LanguageServiceAccessor.java#L172 . The Language Server Eclipse integration will attach the language server for any content-type that matches this file.
So if we have an org.eclipse.languageserver.languages.json associated to .json files and have the language server associated to this content-type, then all .json file can receive extensions from language server, with or without org.eclipse.wdt.jsdt.core.jsonSource available.

Buf if we have WTP, the JSON file will have org.eclipse.wst.jsdt.core.jsonSource content type and not org.eclipse.languageserver.languages.json, no?

A file can have several content-types and can simultaneously be org.eclipse.wst.jsdt.core.jsonSource and org.eclipse.languageserver.languages.json. The LanguageServerAccessor is supposed to find association for any of those. If it doesn't, then it's a bug.

A file can have several content-types

Thank's for this info! I dodn't know that.

Should be fixed with 5f64040