<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IFileDecorationsService } from 'vs/workbench/services/fileDecorations/browser/fileDecorations';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ISCMService, ISCMRepository } from 'vs/workbench/services/scm/common/scm';
import URI from 'vs/base/common/uri';
import Severity from 'vs/base/common/severity';
import { Color } from 'vs/base/common/color';

export class FileDecorations implements IWorkbenchContribution {

	private readonly _disposables: IDisposable[];
	// private readonly _type: DecorationType;
	private readonly _repositoryListeners = new Map<ISCMRepository, IDisposable>();

	constructor(
		@IFileDecorationsService private _decorationsService: IFileDecorationsService,
		@ISCMService private _scmService: ISCMService,
	) {
		this._scmService.repositories.forEach(this._onDidAddRepository, this);
		this._disposables = [
			this._scmService.onDidAddRepository(this._onDidAddRepository, this),
			this._scmService.onDidRemoveRepository(this._onDidRemoveRepository, this),
		];
	}

	dispose(): void {
		dispose(this._disposables);
	}

	private _onDidAddRepository(repo: ISCMRepository): void {
		const type = this._decorationsService.registerDecorationType(repo.provider.label);
		const { provider } = repo;

		let oldDecorations = new Map<string, URI>();
		const listener = provider.onDidChangeResources(() => {

			let newDecorations = new Map<string, URI>();
			let baseColor = Color.fromHex('#007acc');
			let factor = 0.0;
			for (const group of provider.resources) {

				factor += 0.1;
				let color = Color.getDarkerColor(baseColor, Color.black, factor);

				for (const resource of group.resourceCollection.resources) {

					this._decorationsService.setFileDecorations(type, resource.sourceUri, [{
						severity: Severity.Info,
						message: resource.decorations.tooltip,
						color
					}]);

					newDecorations.set(resource.sourceUri.toString(), resource.sourceUri);
				}
			}

			oldDecorations.forEach((value, key) => {
				if (!newDecorations.has(key)) {
					this._decorationsService.unsetFileDecorations(type, value);
				}
			});

			oldDecorations = newDecorations;
		});
<commit_msg>one scm color<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IFileDecorationsService } from 'vs/workbench/services/fileDecorations/browser/fileDecorations';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ISCMService, ISCMRepository } from 'vs/workbench/services/scm/common/scm';
import URI from 'vs/base/common/uri';
import Severity from 'vs/base/common/severity';
import { Color } from 'vs/base/common/color';

export class FileDecorations implements IWorkbenchContribution {

	private readonly _disposables: IDisposable[];
	// private readonly _type: DecorationType;
	private readonly _repositoryListeners = new Map<ISCMRepository, IDisposable>();

	constructor(
		@IFileDecorationsService private _decorationsService: IFileDecorationsService,
		@ISCMService private _scmService: ISCMService,
	) {
		this._scmService.repositories.forEach(this._onDidAddRepository, this);
		this._disposables = [
			this._scmService.onDidAddRepository(this._onDidAddRepository, this),
			this._scmService.onDidRemoveRepository(this._onDidRemoveRepository, this),
		];
	}

	dispose(): void {
		dispose(this._disposables);
	}

	private _onDidAddRepository(repo: ISCMRepository): void {
		const type = this._decorationsService.registerDecorationType(repo.provider.label);
		const { provider } = repo;

		let oldDecorations = new Map<string, URI>();
		const listener = provider.onDidChangeResources(() => {

			let newDecorations = new Map<string, URI>();
			let color = Color.fromHex('#007aCC');

			for (const group of provider.resources) {

				for (const resource of group.resourceCollection.resources) {
					// TODO@Joh have a better color and icon which is based
					// on the resource decoration
					this._decorationsService.setFileDecorations(type, resource.sourceUri, [{
						severity: Severity.Info,
						message: resource.decorations.tooltip,
						color
					}]);

					newDecorations.set(resource.sourceUri.toString(), resource.sourceUri);
				}
			}

			oldDecorations.forEach((value, key) => {
				if (!newDecorations.has(key)) {
					this._decorationsService.unsetFileDecorations(type, value);
				}
			});

			oldDecorations = newDecorations;
		});

{'fraction_non_alphanumeric': 0.17341262229042778, 'fraction_numerical': 0.0019182812200268559, 'mean_word_length': 3.2807881773399017, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4332989', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1454, 'n_words': 316}