• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript modes.TokenizationRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/editor/common/modes.TokenizationRegistry的典型用法代码示例。如果您正苦于以下问题:TypeScript TokenizationRegistry类的具体用法?TypeScript TokenizationRegistry怎么用?TypeScript TokenizationRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TokenizationRegistry类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('Microsoft/monaco-editor#122: Unhandled Exception: TypeError: Unable to get property \'replace\' of undefined or null reference', () => {
		function assertViewLineTokens(model: Model, lineNumber: number, forceTokenization: boolean, expected: ViewLineToken[]): void {
			let actual = model.getLineTokens(lineNumber, !forceTokenization).inflate();
			assert.deepEqual(actual, expected);
		}

		let _tokenId = 10;
		const LANG_ID1 = 'indicisiveMode1';
		const LANG_ID2 = 'indicisiveMode2';
		const languageIdentifier1 = new LanguageIdentifier(LANG_ID1, 3);
		const languageIdentifier2 = new LanguageIdentifier(LANG_ID2, 4);

		const tokenizationSupport: ITokenizationSupport = {
			getInitialState: () => NULL_STATE,
			tokenize: undefined,
			tokenize2: (line, state) => {
				let myId = ++_tokenId;
				let tokens = new Uint32Array(2);
				tokens[0] = 0;
				tokens[1] = (
					myId << MetadataConsts.FOREGROUND_OFFSET
				) >>> 0;
				return new TokenizationResult2(tokens, state);
			}
		};

		let registration1 = TokenizationRegistry.register(LANG_ID1, tokenizationSupport);
		let registration2 = TokenizationRegistry.register(LANG_ID2, tokenizationSupport);

		let model = Model.createFromString('A model with\ntwo lines');

		assertViewLineTokens(model, 1, true, [new ViewLineToken(12, 'mtk1')]);
		assertViewLineTokens(model, 2, true, [new ViewLineToken(9, 'mtk1')]);

		model.setMode(languageIdentifier1);

		assertViewLineTokens(model, 1, true, [new ViewLineToken(12, 'mtk11')]);
		assertViewLineTokens(model, 2, true, [new ViewLineToken(9, 'mtk12')]);

		model.setMode(languageIdentifier2);

		assertViewLineTokens(model, 1, false, [new ViewLineToken(12, 'mtk1')]);
		assertViewLineTokens(model, 2, false, [new ViewLineToken(9, 'mtk1')]);

		model.dispose();
		registration1.dispose();
		registration2.dispose();
	});
开发者ID:diarmaidm,项目名称:vscode,代码行数:48,代码来源:textModelWithTokens.test.ts


示例2: timeout

		return TPromise.any([this._tokenizationSupportChangedPromise(language), timeout(500)]).then(_ => {
			let tokenizationSupport = TokenizationRegistry.get(language);
			if (tokenizationSupport) {
				return _colorize(lines, options.tabSize, tokenizationSupport);
			}
			return _fakeColorize(lines, options.tabSize);
		});
开发者ID:developers23,项目名称:vscode,代码行数:7,代码来源:colorizer.ts


示例3: constructor

		constructor() {
			super(OUTER_LANGUAGE_ID);
			this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), {}));

			this._register(TokenizationRegistry.register(this.getLanguageIdentifier().language, {
				getInitialState: (): IState => NULL_STATE,
				tokenize: undefined,
				tokenize2: (line: string, state: IState): TokenizationResult2 => {
					const tokensArr: number[] = [];
					let prevLanguageId: LanguageIdentifier | undefined = undefined;
					for (let i = 0; i < line.length; i++) {
						const languageId = (line.charAt(i) === 'x' ? INNER_LANGUAGE_ID : OUTER_LANGUAGE_ID);
						if (prevLanguageId !== languageId) {
							tokensArr.push(i);
							tokensArr.push((languageId.id << MetadataConsts.LANGUAGEID_OFFSET));
						}
						prevLanguageId = languageId;
					}

					const tokens = new Uint32Array(tokensArr.length);
					for (let i = 0; i < tokens.length; i++) {
						tokens[i] = tokensArr[i];
					}
					return new TokenizationResult2(tokens, state);
				}
			}));
		}
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:27,代码来源:model.test.ts


示例4: _colorize

		return new Promise<string>((resolve, reject) => {
			let listener: IDisposable | null = null;
			let timeout: TimeoutTimer | null = null;

			const execute = () => {
				if (listener) {
					listener.dispose();
					listener = null;
				}
				if (timeout) {
					timeout.dispose();
					timeout = null;
				}
				const tokenizationSupport = TokenizationRegistry.get(language!);
				if (tokenizationSupport) {
					_colorize(lines, tabSize, tokenizationSupport).then(resolve, reject);
					return;
				}
				resolve(_fakeColorize(lines, tabSize));
			};

			// wait 500ms for mode to load, then give up
			timeout = new TimeoutTimer();
			timeout.cancelAndSet(execute, 500);
			listener = TokenizationRegistry.onDidChange((e) => {
				if (e.changedLanguages.indexOf(language!) >= 0) {
					execute();
				}
			});
		});
开发者ID:PKRoma,项目名称:vscode,代码行数:30,代码来源:colorizer.ts


示例5: constructor

	constructor(tokenType:string) {
		super();

		TokenizationRegistry.register(this.getId(), new TokenizationSupport(null, this.getId(), {
			getInitialState: () => new StateForMockTokenizingMode(this.getId(), tokenType)
		}, false));
	}
开发者ID:aminroosta,项目名称:vscode,代码行数:7,代码来源:mockMode.ts


示例6: setTheme

	public setTheme(themeName: string): string {
		let theme: StandaloneTheme;
		if (this._knownThemes.has(themeName)) {
			theme = this._knownThemes.get(themeName);
		} else {
			theme = this._knownThemes.get(VS_THEME_NAME);
		}
		this._theme = theme;

		let cssRules: string[] = [];
		let hasRule: { [rule: string]: boolean; } = {};
		let ruleCollector: ICssStyleCollector = {
			addRule: (rule: string) => {
				if (!hasRule[rule]) {
					cssRules.push(rule);
					hasRule[rule] = true;
				}
			}
		};
		themingRegistry.getThemingParticipants().forEach(p => p(theme, ruleCollector));

		let tokenTheme = theme.tokenTheme;
		let colorMap = tokenTheme.getColorMap();
		ruleCollector.addRule(generateTokensCSSForColorMap(colorMap));

		this._styleElement.innerHTML = cssRules.join('\n');

		TokenizationRegistry.setColorMap(colorMap);
		this._onThemeChange.fire(theme);

		return theme.id;
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:32,代码来源:standaloneThemeServiceImpl.ts


示例7: colorize

	public static colorize(modeService: IModeService, text: string, mimeType: string, options: IColorizerOptions): TPromise<string> {
		if (strings.startsWithUTF8BOM(text)) {
			text = text.substr(1);
		}
		let lines = text.split(/\r\n|\r|\n/);
		let language = modeService.getModeId(mimeType);

		options = options || {};
		if (typeof options.tabSize === 'undefined') {
			options.tabSize = 4;
		}

		// Send out the event to create the mode
		modeService.getOrCreateMode(language);

		let tokenizationSupport = TokenizationRegistry.get(language);
		if (tokenizationSupport) {
			return TPromise.as(_colorize(lines, options.tabSize, tokenizationSupport));
		}

		// wait 500ms for mode to load, then give up
		return TPromise.any([this._tokenizationSupportChangedPromise(language), timeout(500)]).then(_ => {
			let tokenizationSupport = TokenizationRegistry.get(language);
			if (tokenizationSupport) {
				return _colorize(lines, options.tabSize, tokenizationSupport);
			}
			return _fakeColorize(lines, options.tabSize);
		});
	}
开发者ID:developers23,项目名称:vscode,代码行数:29,代码来源:colorizer.ts


示例8: constructor

	constructor(config: editorCommon.IConfiguration, theme: ITheme) {
		this.lineHeight = config.editor.lineHeight;
		this.pixelRatio = config.editor.pixelRatio;
		this.overviewRulerLanes = config.editor.viewInfo.overviewRulerLanes;

		this.renderBorder = config.editor.viewInfo.overviewRulerBorder;
		const borderColor = theme.getColor(editorOverviewRulerBorder);
		this.borderColor = borderColor ? borderColor.toString() : null;

		this.hideCursor = config.editor.viewInfo.hideCursorInOverviewRuler;
		const cursorColor = theme.getColor(editorCursorForeground);
		this.cursorColor = cursorColor ? cursorColor.transparent(0.7).toString() : null;

		this.themeType = theme.type;

		const minimapEnabled = config.editor.viewInfo.minimap.enabled;
		const backgroundColor = (minimapEnabled ? TokenizationRegistry.getDefaultBackground() : null);
		this.backgroundColor = (backgroundColor ? Color.Format.CSS.formatHex(backgroundColor) : null);

		const position = config.editor.layoutInfo.overviewRuler;
		this.top = position.top;
		this.right = position.right;
		this.domWidth = position.width;
		this.domHeight = position.height;
		this.canvasWidth = (this.domWidth * this.pixelRatio) | 0;
		this.canvasHeight = (this.domHeight * this.pixelRatio) | 0;

		const [x, w] = this._initLanes(1, this.canvasWidth, this.overviewRulerLanes);
		this.x = x;
		this.w = w;
	}
开发者ID:gokulakrishna9,项目名称:vscode,代码行数:31,代码来源:decorationsOverviewRuler.ts


示例9: _actualColorize

function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
	let html: string[] = [];
	let state = tokenizationSupport.getInitialState();
	let colorMap = TokenizationRegistry.getColorMap();

	for (let i = 0, length = lines.length; i < length; i++) {
		let line = lines[i];
		let tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
		let lineTokens = new LineTokens(colorMap, tokenizeResult.tokens, line);
		let renderResult = renderLine(new RenderLineInput(
			line,
			tabSize,
			0,
			-1,
			'none',
			false,
			new LineParts(lineTokens.inflate(), line.length + 1)
		));

		html = html.concat(renderResult.output);
		html.push('<br/>');

		state = tokenizeResult.endState;
	}

	return html.join('');
}
开发者ID:fs814,项目名称:vscode,代码行数:27,代码来源:colorizer.ts


示例10:

		return new TPromise<void>((c, e, p) => {
			listener = TokenizationRegistry.onDidChange((e) => {
				if (e.languageId === languageId) {
					stopListening();
					c(void 0);
				}
			});
		}, stopListening);
开发者ID:StateFarmIns,项目名称:vscode,代码行数:8,代码来源:colorizer.ts



注:本文中的vs/editor/common/modes.TokenizationRegistry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript modes.TypeDefinitionProviderRegistry类代码示例发布时间:2022-05-25
下一篇:
TypeScript modes.TokenMetadata类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap