@@ -14,7 +14,7 @@ import { Range } from 'vs/editor/common/core/range';
1414import { DefaultEndOfLine , EndOfLinePreference , EndOfLineSequence , IIdentifiedSingleEditOperation , ITextBuffer , ITextBufferFactory , ITextModel , ITextModelCreationOptions } from 'vs/editor/common/model' ;
1515import { TextModel , createTextBuffer } from 'vs/editor/common/model/textModel' ;
1616import { IModelLanguageChangedEvent , IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents' ;
17- import { LanguageIdentifier , SemanticTokensProviderRegistry , SemanticTokensProvider , SemanticTokensLegend , SemanticTokens , SemanticTokensEdits } from 'vs/editor/common/modes' ;
17+ import { LanguageIdentifier , SemanticTokensProviderRegistry , SemanticTokensProvider , SemanticTokensLegend , SemanticTokens , SemanticTokensEdits , TokenMetadata } from 'vs/editor/common/modes' ;
1818import { PLAINTEXT_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/modesRegistry' ;
1919import { ILanguageSelection } from 'vs/editor/common/services/modeService' ;
2020import { IModelService } from 'vs/editor/common/services/modelService' ;
@@ -24,6 +24,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
2424import { CancellationTokenSource } from 'vs/base/common/cancellation' ;
2525import { SparseEncodedTokens , MultilineTokens2 } from 'vs/editor/common/model/tokensStore' ;
2626import { IThemeService } from 'vs/platform/theme/common/themeService' ;
27+ import { ILogService , LogLevel } from 'vs/platform/log/common/log' ;
2728
2829function MODEL_ID ( resource : URI ) : string {
2930 return resource . toString ( ) ;
@@ -120,7 +121,8 @@ export class ModelServiceImpl extends Disposable implements IModelService {
120121 constructor (
121122 @IConfigurationService configurationService : IConfigurationService ,
122123 @ITextResourcePropertiesService resourcePropertiesService : ITextResourcePropertiesService ,
123- @IThemeService themeService : IThemeService
124+ @IThemeService themeService : IThemeService ,
125+ @ILogService logService : ILogService
124126 ) {
125127 super ( ) ;
126128 this . _configurationService = configurationService ;
@@ -131,7 +133,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
131133 this . _configurationServiceSubscription = this . _configurationService . onDidChangeConfiguration ( e => this . _updateModelOptions ( ) ) ;
132134 this . _updateModelOptions ( ) ;
133135
134- this . _register ( new SemanticColoringFeature ( this , themeService ) ) ;
136+ this . _register ( new SemanticColoringFeature ( this , themeService , logService ) ) ;
135137 }
136138
137139 private static _readModelOptions ( config : IRawConfig , isForSimpleWidget : boolean ) : ITextModelCreationOptions {
@@ -443,10 +445,10 @@ class SemanticColoringFeature extends Disposable {
443445 private _watchers : Record < string , ModelSemanticColoring > ;
444446 private _semanticStyling : SemanticStyling ;
445447
446- constructor ( modelService : IModelService , themeService : IThemeService ) {
448+ constructor ( modelService : IModelService , themeService : IThemeService , logService : ILogService ) {
447449 super ( ) ;
448450 this . _watchers = Object . create ( null ) ;
449- this . _semanticStyling = this . _register ( new SemanticStyling ( themeService ) ) ;
451+ this . _semanticStyling = this . _register ( new SemanticStyling ( themeService , logService ) ) ;
450452 this . _register ( modelService . onModelAdded ( ( model ) => {
451453 this . _watchers [ model . uri . toString ( ) ] = new ModelSemanticColoring ( model , themeService , this . _semanticStyling ) ;
452454 } ) ) ;
@@ -462,7 +464,8 @@ class SemanticStyling extends Disposable {
462464 private _caches : WeakMap < SemanticTokensProvider , SemanticColoringProviderStyling > ;
463465
464466 constructor (
465- private readonly _themeService : IThemeService
467+ private readonly _themeService : IThemeService ,
468+ private readonly _logService : ILogService
466469 ) {
467470 super ( ) ;
468471 this . _caches = new WeakMap < SemanticTokensProvider , SemanticColoringProviderStyling > ( ) ;
@@ -476,7 +479,7 @@ class SemanticStyling extends Disposable {
476479
477480 public get ( provider : SemanticTokensProvider ) : SemanticColoringProviderStyling {
478481 if ( ! this . _caches . has ( provider ) ) {
479- this . _caches . set ( provider , new SemanticColoringProviderStyling ( provider . getLegend ( ) , this . _themeService ) ) ;
482+ this . _caches . set ( provider , new SemanticColoringProviderStyling ( provider . getLegend ( ) , this . _themeService , this . _logService ) ) ;
480483 }
481484 return this . _caches . get ( provider ) ! ;
482485 }
@@ -581,7 +584,8 @@ class SemanticColoringProviderStyling {
581584
582585 constructor (
583586 private readonly _legend : SemanticTokensLegend ,
584- private readonly _themeService : IThemeService
587+ private readonly _themeService : IThemeService ,
588+ private readonly _logService : ILogService
585589 ) {
586590 this . _hashTable = new HashTable ( ) ;
587591 }
@@ -605,6 +609,9 @@ class SemanticColoringProviderStyling {
605609 if ( typeof metadata === 'undefined' ) {
606610 metadata = Constants . NO_STYLING ;
607611 }
612+ if ( this . _logService . getLevel ( ) === LogLevel . Trace ) {
613+ this . _logService . trace ( `getTokenStyleMetadata(${ tokenType } ${ tokenModifiers . length ? ', ' + tokenModifiers . join ( ' ' ) : '' } ): foreground: ${ TokenMetadata . getForeground ( metadata ) } , fontStyle ${ TokenMetadata . getFontStyle ( metadata ) . toString ( 2 ) } ` ) ;
614+ }
608615
609616 this . _hashTable . add ( tokenTypeIndex , tokenModifierSet , metadata ) ;
610617 return metadata ;
0 commit comments