@@ -6,9 +6,9 @@ import * as fm from 'file-matcher';
66import * as fs from 'fs-extra' ;
77import { inject , injectable } from 'inversify' ;
88import * as path from 'path' ;
9-
109import { IWorkspaceService } from '../common/application/types' ;
1110import { ICurrentProcess , ILogger } from '../common/types' ;
11+ import { EXTENSION_ROOT_DIR } from '../constants' ;
1212import { ICodeCssGenerator } from './types' ;
1313
1414// This class generates css using the current theme in order to colorize code.
@@ -20,12 +20,12 @@ import { ICodeCssGenerator } from './types';
2020@injectable ( )
2121export class CodeCssGenerator implements ICodeCssGenerator {
2222 constructor (
23- @inject ( IWorkspaceService ) private workspaceService : IWorkspaceService ,
24- @inject ( ICurrentProcess ) private currentProcess : ICurrentProcess ,
25- @inject ( ILogger ) private logger : ILogger ) {
23+ @inject ( IWorkspaceService ) private workspaceService : IWorkspaceService ,
24+ @inject ( ICurrentProcess ) private currentProcess : ICurrentProcess ,
25+ @inject ( ILogger ) private logger : ILogger ) {
2626 }
2727
28- public generateThemeCss = async ( ) : Promise < string > => {
28+ public generateThemeCss = async ( ) : Promise < string > => {
2929 try {
3030 // First compute our current theme.
3131 const workbench = this . workspaceService . getConfiguration ( 'workbench' ) ;
@@ -51,7 +51,7 @@ export class CodeCssGenerator implements ICodeCssGenerator {
5151 return '' ;
5252 }
5353
54- private getScopeColor = ( tokenColors : JSONArray , scope : string ) : string => {
54+ private getScopeColor = ( tokenColors : JSONArray , scope : string ) : string => {
5555 // Search through the scopes on the json object
5656 const match = tokenColors . findIndex ( entry => {
5757 if ( entry ) {
@@ -81,7 +81,7 @@ export class CodeCssGenerator implements ICodeCssGenerator {
8181 }
8282
8383 // tslint:disable-next-line:max-func-body-length
84- private generateCss = ( tokenColors : JSONArray , fontFamily : string , fontSize : number ) : string => {
84+ private generateCss = ( tokenColors : JSONArray , fontFamily : string , fontSize : number ) : string => {
8585
8686 // There's a set of values that need to be found
8787 const comment = this . getScopeColor ( tokenColors , 'comment' ) ;
@@ -233,11 +233,11 @@ export class CodeCssGenerator implements ICodeCssGenerator {
233233
234234 }
235235
236- private mergeColors = ( colors1 : JSONArray , colors2 : JSONArray ) : JSONArray => {
236+ private mergeColors = ( colors1 : JSONArray , colors2 : JSONArray ) : JSONArray => {
237237 return [ ...colors1 , ...colors2 ] ;
238238 }
239239
240- private readTokenColors = async ( themeFile : string ) : Promise < JSONArray > => {
240+ private readTokenColors = async ( themeFile : string ) : Promise < JSONArray > => {
241241 const tokenContent = await fs . readFile ( themeFile , 'utf8' ) ;
242242 const theme = JSON . parse ( tokenContent ) as JSONObject ;
243243 const tokenColors = theme [ 'tokenColors' ] as JSONArray ;
@@ -257,7 +257,7 @@ export class CodeCssGenerator implements ICodeCssGenerator {
257257 return [ ] ;
258258 }
259259
260- private findTokenColors = async ( theme : string ) : Promise < JSONArray > => {
260+ private findTokenColors = async ( theme : string ) : Promise < JSONArray > => {
261261 const currentExe = this . currentProcess . execPath ;
262262 let currentPath = path . dirname ( currentExe ) ;
263263
@@ -271,11 +271,11 @@ export class CodeCssGenerator implements ICodeCssGenerator {
271271
272272 // Search through all of the json files for the theme name
273273 const escapedThemeName = theme . replace ( / [ - \/ \\ ^ $ * + ? . ( ) | [ \] { } ] / g, '\\$&' ) ;
274- const searchOptions : fm . FindOptions = {
274+ const searchOptions : fm . FindOptions = {
275275 path : extensionsPath ,
276276 recursiveSearch : true ,
277- fileFilter : {
278- fileNamePattern : '**/*.json' ,
277+ fileFilter : {
278+ fileNamePattern : '**/*.json' ,
279279 content : new RegExp ( `id[',"]:\\s*[',"]${ escapedThemeName } [',"]` )
280280 }
281281 } ;
@@ -316,7 +316,7 @@ export class CodeCssGenerator implements ICodeCssGenerator {
316316 }
317317
318318 // We should return a default. The vscode-light theme
319- const defaultThemeFile = path . join ( __dirname , 'defaultTheme.json' ) ;
319+ const defaultThemeFile = path . join ( EXTENSION_ROOT_DIR , 'resources' , 'defaultTheme.json' ) ;
320320 return this . readTokenColors ( defaultThemeFile ) ;
321321 }
322322}
0 commit comments