Repository navigation
Allow loading of custom data - #142
Conversation
| export * from './cssLanguageTypes'; | ||
| export * from 'vscode-languageserver-types'; | ||
|
|
||
| export interface LanguageServiceOptions { |
There was a problem hiding this comment.
move to 'types'...
|
|
||
| export function getCSSLanguageService(): LanguageService { | ||
| export function getCSSLanguageService(options?: LanguageServiceOptions): LanguageService { | ||
| handleCustomData(options); |
There was a problem hiding this comment.
If we choose this API, we must store the properies/directives per LanguageService, not in global arrays. Users can create any number of language services, each with a different set of data.
I would suggest to make a new type CSSPropertySet (name to be debated) containing properties/directives/..., that is registered globaly with the vscode-css-languageservice (exported const propertySets : CSSPropertySet[]) Our built-in properties (generated from MDN) should also be represented in one (or multiple) CSSPropertySets.
In a first step, all language services just use that global list of propertySets. In a later step we allow to create a language service with a custom list of Sets. That language service would then only use that set. It would be good to already prepare our code to avoid accessing CSSPropertySet globaly.
There was a problem hiding this comment.
Yeah I was about to check with you. The same problem with HTML now. Do we make the language services stateful? I'll go with stateful then.
|
|
||
| public getCompletionForTopLevel(result: CompletionList): CompletionList { | ||
| for (let entry of languageFacts.getAtDirectives()) { | ||
| const atDirectives = languageFacts.getAtDirectives(); |
There was a problem hiding this comment.
I find the original code more readable.
There was a problem hiding this comment.
We need atDirectives[entryName] for accessing the each entry. It previously returns an array, so let...of works, now it's an object.
| import { addPseudoClasses } from './pseudoClasses'; | ||
| import { addPseudoElements } from './pseudoElements'; | ||
|
|
||
| let { properties, atdirectives, pseudoclasses, pseudoelements } = browsers.data.css; |
There was a problem hiding this comment.
Let's avoid globals at more than one place.
| } | ||
| } | ||
|
|
||
| const propertySet: { [key: string]: IEntry } = {}; |
There was a problem hiding this comment.
Let's avoid globals at more than one point...
| return getCSSLanguageService(customData); | ||
| } | ||
|
|
||
| function assertCompletion(completions: CompletionList, expected: ItemDescription, document: TextDocument) { |
There was a problem hiding this comment.
I'd rather not copy, but just add new tests to completions.tests
For microsoft/vscode#64164.
languageFacts