Skip to content

Commit 5dcf359

Browse files
committed
add tracing to SemanticColoringProviderStyling
1 parent 2bde452 commit 5dcf359

8 files changed

Lines changed: 30 additions & 18 deletions

File tree

src/vs/editor/common/services/modelServiceImpl.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Range } from 'vs/editor/common/core/range';
1414
import { DefaultEndOfLine, EndOfLinePreference, EndOfLineSequence, IIdentifiedSingleEditOperation, ITextBuffer, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from 'vs/editor/common/model';
1515
import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel';
1616
import { 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';
1818
import { PLAINTEXT_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/modesRegistry';
1919
import { ILanguageSelection } from 'vs/editor/common/services/modeService';
2020
import { IModelService } from 'vs/editor/common/services/modelService';
@@ -24,6 +24,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
2424
import { CancellationTokenSource } from 'vs/base/common/cancellation';
2525
import { SparseEncodedTokens, MultilineTokens2 } from 'vs/editor/common/model/tokensStore';
2626
import { IThemeService } from 'vs/platform/theme/common/themeService';
27+
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
2728

2829
function 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;

src/vs/editor/contrib/smartSelect/test/smartSelect.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
1818
import { WordSelectionRangeProvider } from 'vs/editor/contrib/smartSelect/wordSelections';
1919
import { TestTextResourcePropertiesService } from 'vs/editor/test/common/services/modelService.test';
2020
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
21+
import { NullLogService } from 'vs/platform/log/common/log';
2122

2223
class MockJSMode extends MockMode {
2324

@@ -46,7 +47,7 @@ suite('SmartSelect', () => {
4647

4748
setup(() => {
4849
const configurationService = new TestConfigurationService();
49-
modelService = new ModelServiceImpl(configurationService, new TestTextResourcePropertiesService(configurationService), new TestThemeService());
50+
modelService = new ModelServiceImpl(configurationService, new TestTextResourcePropertiesService(configurationService), new TestThemeService(), new NullLogService());
5051
mode = new MockJSMode();
5152
});
5253

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ export module StaticServices {
146146

147147
export const standaloneThemeService = define(IStandaloneThemeService, () => new StandaloneThemeServiceImpl());
148148

149-
export const modelService = define(IModelService, (o) => new ModelServiceImpl(configurationService.get(o), resourcePropertiesService.get(o), standaloneThemeService.get(o)));
149+
export const logService = define(ILogService, () => new NullLogService());
150+
151+
export const modelService = define(IModelService, (o) => new ModelServiceImpl(configurationService.get(o), resourcePropertiesService.get(o), standaloneThemeService.get(o), logService.get(o)));
150152

151153
export const markerDecorationsService = define(IMarkerDecorationsService, (o) => new MarkerDecorationsService(modelService.get(o), markerService.get(o)));
152154

@@ -156,8 +158,6 @@ export module StaticServices {
156158

157159
export const storageService = define(IStorageService, () => new InMemoryStorageService());
158160

159-
export const logService = define(ILogService, () => new NullLogService());
160-
161161
export const editorWorkerService = define(IEditorWorkerService, (o) => new EditorWorkerServiceImpl(modelService.get(o), resourceConfigurationService.get(o), logService.get(o)));
162162
}
163163

src/vs/editor/test/common/services/modelService.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/resour
1717
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1818
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
1919
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
20+
import { NullLogService } from 'vs/platform/log/common/log';
2021

2122
const GENERATE_TESTS = false;
2223

@@ -28,7 +29,7 @@ suite('ModelService', () => {
2829
configService.setUserConfiguration('files', { 'eol': '\n' });
2930
configService.setUserConfiguration('files', { 'eol': '\r\n' }, URI.file(platform.isWindows ? 'c:\\myroot' : '/myroot'));
3031

31-
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService());
32+
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService());
3233
});
3334

3435
teardown(() => {

src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
2121
import { IFileService } from 'vs/platform/files/common/files';
2222
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
2323
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
24+
import { NullLogService } from 'vs/platform/log/common/log';
2425

2526
suite('MainThreadDocumentsAndEditors', () => {
2627

@@ -43,7 +44,7 @@ suite('MainThreadDocumentsAndEditors', () => {
4344
deltas.length = 0;
4445
const configService = new TestConfigurationService();
4546
configService.setUserConfiguration('editor', { 'detectIndentation': false });
46-
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService());
47+
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService());
4748
codeEditorService = new TestCodeEditorService();
4849
textFileService = new class extends mock<ITextFileService>() {
4950
isDirty() { return false; }

src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ suite('MainThreadEditors', () => {
4343

4444
setup(() => {
4545
const configService = new TestConfigurationService();
46-
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService());
46+
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService());
4747
const codeEditorService = new TestCodeEditorService();
4848

4949
movedResources.clear();

src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbe
3131
import { TestContextService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
3232
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
3333
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
34+
import { NullLogService } from 'vs/platform/log/common/log';
3435

3536
namespace Timer {
3637
export interface ITimerEvent {
@@ -74,7 +75,7 @@ suite.skip('QuickOpen performance (integration)', () => {
7475
[ITelemetryService, telemetryService],
7576
[IConfigurationService, configurationService],
7677
[ITextResourcePropertiesService, textResourcePropertiesService],
77-
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService, new TestThemeService())],
78+
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService, new TestThemeService(), new NullLogService())],
7879
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
7980
[IEditorService, new TestEditorService()],
8081
[IEditorGroupsService, new TestEditorGroupsService()],

src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,19 @@ suite.skip('TextSearch performance (integration)', () => {
6060
const telemetryService = new TestTelemetryService();
6161
const configurationService = new TestConfigurationService();
6262
const textResourcePropertiesService = new TestTextResourcePropertiesService(configurationService);
63+
const logService = new NullLogService();
6364
const instantiationService = new InstantiationService(new ServiceCollection(
6465
[ITelemetryService, telemetryService],
6566
[IConfigurationService, configurationService],
6667
[ITextResourcePropertiesService, textResourcePropertiesService],
67-
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService, new TestThemeService())],
68+
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService, new TestThemeService(), logService)],
6869
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
6970
[IEditorService, new TestEditorService()],
7071
[IEditorGroupsService, new TestEditorGroupsService()],
7172
[IEnvironmentService, TestEnvironmentService],
7273
[IUntitledTextEditorService, createSyncDescriptor(UntitledTextEditorService)],
7374
[ISearchService, createSyncDescriptor(LocalSearchService)],
74-
[ILogService, new NullLogService()]
75+
[ILogService, logService]
7576
));
7677

7778
const queryOptions: ITextQueryBuilderOptions = {

0 commit comments

Comments
 (0)