<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 { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IModel } from 'vs/editor/common/editorCommon';
import JSONContributionRegistry = require('vs/platform/jsonschemas/common/jsonContributionRegistry');
import { Registry } from 'vs/platform/platform';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ITextModelResolverService } from 'vs/platform/textmodelResolver/common/resolver';

let schemaRegistry = <JSONContributionRegistry.IJSONContributionRegistry>Registry.as(JSONContributionRegistry.Extensions.JSONContribution);

export class WorkbenchContentProvider implements IWorkbenchContribution {

	private modelService: IModelService;
	private modeService: IModeService;
	private textModelResolverService: ITextModelResolverService;

	constructor(
		@IModelService modelService: IModelService,
		@ITextModelResolverService textModelResolverService: ITextModelResolverService,
		@IModeService modeService: IModeService
	) {
		this.modelService = modelService;
		this.modeService = modeService;
		this.textModelResolverService = textModelResolverService;

		this.start();
	}

	public getId(): string {
		return 'vs.contentprovider';
	}

	private start(): void {
		this.textModelResolverService.registerTextModelContentProvider('vscode', {
			provideTextContent: (uri: URI): TPromise<IModel> => {
				if (uri.scheme !== 'vscode') {
					return null;
				}
				if (uri.authority === 'schemas') {
					let schemas = schemaRegistry.getSchemaContributions().schemas;
					let schema = schemas[uri.toString()];
					if (schema) {
						let modelContent = JSON.stringify(schema);
						let mode = this.modeService.getOrCreateMode('json');
						return TPromise.as(this.modelService.createModel(modelContent, mode, uri));
					}
				}
				return null;
			}
		});
	}
}

Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkbenchContentProvider);<commit_msg>:lipstick:<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 { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IModel } from 'vs/editor/common/editorCommon';
import JSONContributionRegistry = require('vs/platform/jsonschemas/common/jsonContributionRegistry');
import { Registry } from 'vs/platform/platform';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ITextModelResolverService } from 'vs/platform/textmodelResolver/common/resolver';

let schemaRegistry = <JSONContributionRegistry.IJSONContributionRegistry>Registry.as(JSONContributionRegistry.Extensions.JSONContribution);

export class WorkbenchContentProvider implements IWorkbenchContribution {

	constructor(
		@IModelService private modelService: IModelService,
		@ITextModelResolverService private textModelResolverService: ITextModelResolverService,
		@IModeService private modeService: IModeService
	) {
		this.start();
	}

	public getId(): string {
		return 'vs.contentprovider';
	}

	private start(): void {
		this.textModelResolverService.registerTextModelContentProvider('vscode', {
			provideTextContent: (uri: URI): TPromise<IModel> => {
				if (uri.scheme !== 'vscode') {
					return null;
				}
				if (uri.authority === 'schemas') {
					let schemas = schemaRegistry.getSchemaContributions().schemas;
					let schema = schemas[uri.toString()];
					if (schema) {
						let modelContent = JSON.stringify(schema);
						let mode = this.modeService.getOrCreateMode('json');
						return TPromise.as(this.modelService.createModel(modelContent, mode, uri));
					}
				}
				return null;
			}
		});
	}
}

Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkbenchContentProvider);
{'fraction_non_alphanumeric': 0.1723450886630803, 'fraction_numerical': 0.0, 'mean_word_length': 3.6395563770794825, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '3875549', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1289, 'n_words': 271}