Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public create(info: ts.server.PluginCreateInfo): ts.LanguageService {
if ((info.languageService as any)[litHtmlPluginMarker]) {
// Already decorated
return info.languageService;
}
const logger = new LanguageServiceLogger(info);
this._config.update(info.config);
logger.log('config: ' + JSON.stringify(this._config));
const styledLanguageService = new StyledTemplateLanguageService(
this._typescript, {} as any,
new CssDocumentProvider(this.htmlLanguageService),
logger);
const htmlTemplateLanguageService = new HtmlTemplateLanguageService(
this._typescript,
this._config,
this._virtualDocumentProvider,
this.htmlLanguageService,
styledLanguageService,
logger);
const languageService = decorateWithTemplateLanguageService(
this._typescript,
info.languageService,
info.project,
export function getSubstitutions(
typescript: typeof ts,
languageService: LanguageService,
documentProvider: VirtualDocumentProvider,
templateString: string,
spans: ReadonlyArray<{ start: number, end: number }>
): string {
const virtualDoc = documentProvider.createVirtualDocument(new NoopTemplateContext(typescript, templateString));
const regions = getDocumentRegions(languageService, virtualDoc);
const cssSpans = spans
.map(span => ({ language: regions.getLanguageAtPosition(virtualDoc.positionAt(span.start)), span }))
.filter(x => x.language === 'css')
.map(x => x.span);
const settings = getTemplateSettings({} as any);
return settings.getSubstitutions!(templateString, cssSpans);
}