當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript wordHelper.getWordAtText函數代碼示例

本文整理匯總了TypeScript中vs/editor/common/model/wordHelper.getWordAtText函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getWordAtText函數的具體用法?TypeScript getWordAtText怎麽用?TypeScript getWordAtText使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getWordAtText函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: _getWordAtColumn

	private static _getWordAtColumn(txt:string, column:number, modeIndex: number, modeTransitions:ModeTransition[]): IWordAtPosition {
		let modeStartIndex = modeTransitions[modeIndex].startIndex;
		let modeEndIndex = (modeIndex + 1 < modeTransitions.length ? modeTransitions[modeIndex + 1].startIndex : txt.length);
		let modeId = modeTransitions[modeIndex].modeId;

		return getWordAtText(
			column, WordHelper.massageWordDefinitionOf(modeId),
			txt.substring(modeStartIndex, modeEndIndex), modeStartIndex
		);
	}
開發者ID:GYGit,項目名稱:vscode,代碼行數:10,代碼來源:textModelWithTokensHelpers.ts

示例2: getWordAtPosition

	public static getWordAtPosition(lineContent: string, column: number, topModeId: string, modeTransitions: ModeTransition[]): IWordAtPosition {

		if (!modeTransitions || modeTransitions.length === 0) {
			return getWordAtText(column, WordHelper.massageWordDefinitionOf(topModeId), lineContent, 0);
		}

		let result: IWordAtPosition = null;
		let columnIndex = column - 1;
		let modeIndex = ModeTransition.findIndexInSegmentsArray(modeTransitions, columnIndex);

		result = WordHelper._getWordAtColumn(lineContent, column, modeIndex, modeTransitions);

		if (!result && modeIndex > 0 && modeTransitions[modeIndex].startIndex === columnIndex) {
			// The position is right at the beginning of `modeIndex`, so try looking at `modeIndex` - 1 too
			result = WordHelper._getWordAtColumn(lineContent, column, modeIndex - 1, modeTransitions);
		}

		return result;
	}
開發者ID:elemongw,項目名稱:vscode,代碼行數:19,代碼來源:textModelWithTokensHelpers.ts

示例3: getWordAtPosition

	public static getWordAtPosition(textSource:ITextSource, position:IPosition): IWordAtPosition {

		if (!textSource._lineIsTokenized(position.lineNumber)) {
			return getWordAtText(position.column, WordHelper.massageWordDefinitionOf(textSource.getModeId()), textSource.getLineContent(position.lineNumber), 0);
		}

		let result: IWordAtPosition = null;
		let txt = textSource.getLineContent(position.lineNumber);
		let modeTransitions = textSource._getLineModeTransitions(position.lineNumber);
		let columnIndex = position.column - 1;
		let modeIndex = ModeTransition.findIndexInSegmentsArray(modeTransitions, columnIndex);

		result = WordHelper._getWordAtColumn(txt, position.column, modeIndex, modeTransitions);

		if (!result && modeIndex > 0 && modeTransitions[modeIndex].startIndex === columnIndex) {
			// The position is right at the beginning of `modeIndex`, so try looking at `modeIndex` - 1 too
			result = WordHelper._getWordAtColumn(txt, position.column, modeIndex - 1, modeTransitions);
		}

		return result;
	}
開發者ID:GYGit,項目名稱:vscode,代碼行數:21,代碼來源:textModelWithTokensHelpers.ts


注:本文中的vs/editor/common/model/wordHelper.getWordAtText函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。