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


TypeScript Range.compareRangesUsingStarts方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/core/range.Range.compareRangesUsingStarts方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Range.compareRangesUsingStarts方法的具體用法?TypeScript Range.compareRangesUsingStarts怎麽用?TypeScript Range.compareRangesUsingStarts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/core/range.Range的用法示例。


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

示例1:

		return symbols.sort((a, b) => {
			// sort by range and provider rank
			let ret = Range.compareRangesUsingStarts(a.symbol.range, b.symbol.range);
			if (ret === 0) {
				ret = provider.indexOf(a.provider) - provider.indexOf(b.provider);
			}
			return ret;
		});
開發者ID:asotog,項目名稱:vscode,代碼行數:8,代碼來源:codelens.ts

示例2:

		decorations = decorations.sort((a, b) => {
			let aClassName = a.options.className;
			let bClassName = b.options.className;

			if (aClassName < bClassName) {
				return -1;
			}
			if (aClassName > bClassName) {
				return 1;
			}

			return Range.compareRangesUsingStarts(a.range, b.range);
		});
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:13,代碼來源:decorations.ts

示例3:

		decorations = decorations.sort((a, b) => {
			if (a.options.zIndex! < b.options.zIndex!) {
				return -1;
			}
			if (a.options.zIndex! > b.options.zIndex!) {
				return 1;
			}
			const aClassName = a.options.className!;
			const bClassName = b.options.className!;

			if (aClassName < bClassName) {
				return -1;
			}
			if (aClassName > bClassName) {
				return 1;
			}

			return Range.compareRangesUsingStarts(a.range, b.range);
		});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:19,代碼來源:decorations.ts

示例4: union

function union(oldLinks: Link[], newLinks: Link[]): Link[] {
	// reunite oldLinks with newLinks and remove duplicates
	var result: Link[] = [],
		oldIndex: number,
		oldLen: number,
		newIndex: number,
		newLen: number,
		oldLink: Link,
		newLink: Link,
		comparisonResult: number;

	for (oldIndex = 0, newIndex = 0, oldLen = oldLinks.length, newLen = newLinks.length; oldIndex < oldLen && newIndex < newLen;) {
		oldLink = oldLinks[oldIndex];
		newLink = newLinks[newIndex];

		if (Range.areIntersectingOrTouching(oldLink.range, newLink.range)) {
			// Remove the oldLink
			oldIndex++;
			continue;
		}

		comparisonResult = Range.compareRangesUsingStarts(oldLink.range, newLink.range);

		if (comparisonResult < 0) {
			// oldLink is before
			result.push(oldLink);
			oldIndex++;
		} else {
			// newLink is before
			result.push(newLink);
			newIndex++;
		}
	}

	for (; oldIndex < oldLen; oldIndex++) {
		result.push(oldLinks[oldIndex]);
	}
	for (; newIndex < newLen; newIndex++) {
		result.push(newLinks[newIndex]);
	}

	return result;
}
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:43,代碼來源:getLinks.ts

示例5: compareEntriesUsingStart

function compareEntriesUsingStart(a: DocumentSymbol, b: DocumentSymbol): number {
	return Range.compareRangesUsingStarts(a.range, b.range);
}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:3,代碼來源:quickOpen.ts

示例6:

		newDecorations.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
開發者ID:aminroosta,項目名稱:vscode,代碼行數:1,代碼來源:textModelWithDecorations.ts

示例7: _deltaDecorationsImpl

	private _deltaDecorationsImpl(eventBuilder:DeferredEventsBuilder, ownerId:number, oldDecorationsIds:string[], newDecorations: ModelDeltaDecoration[]): string[] {

		if (oldDecorationsIds.length === 0) {
			// Nothing to remove
			return this._addDecorationsImpl(eventBuilder, ownerId, newDecorations);
		}

		if (newDecorations.length === 0) {
			// Nothing to add
			this._removeDecorationsImpl(eventBuilder, oldDecorationsIds);
			return [];
		}

		let oldDecorations = this._resolveOldDecorations(oldDecorationsIds);

		oldDecorations.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
		newDecorations.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));

		let result:string[] = [],
			oldDecorationsIndex = 0,
			oldDecorationsLength = oldDecorations.length,
			newDecorationsIndex = 0,
			newDecorationsLength = newDecorations.length,
			decorationsToAdd: ModelDeltaDecoration[] = [],
			decorationsToRemove: string[] = [];

		while (oldDecorationsIndex < oldDecorationsLength && newDecorationsIndex < newDecorationsLength) {
			let oldDecoration = oldDecorations[oldDecorationsIndex];
			let newDecoration = newDecorations[newDecorationsIndex];
			let comparison = Range.compareRangesUsingStarts(oldDecoration.range, newDecoration.range);

			if (comparison < 0) {
				// `oldDecoration` is before `newDecoration` => remove `oldDecoration`
				decorationsToRemove.push(oldDecoration.id);
				oldDecorationsIndex++;
				continue;
			}

			if (comparison > 0) {
				// `newDecoration` is before `oldDecoration` => add `newDecoration`
				decorationsToAdd.push(newDecoration);
				newDecorationsIndex++;
				continue;
			}

			// The ranges of `oldDecoration` and `newDecoration` are equal

			if (!oldDecoration.options.equals(newDecoration.options)) {
				// The options do not match => remove `oldDecoration`
				decorationsToRemove.push(oldDecoration.id);
				oldDecorationsIndex++;
				continue;
			}

			// Bingo! We can reuse `oldDecoration` for `newDecoration`
			result[newDecoration.index] = oldDecoration.id;
			oldDecorationsIndex++;
			newDecorationsIndex++;
		}

		while (oldDecorationsIndex < oldDecorationsLength) {
			// No more new decorations => remove decoration at `oldDecorationsIndex`
			decorationsToRemove.push(oldDecorations[oldDecorationsIndex].id);
			oldDecorationsIndex++;
		}

		while (newDecorationsIndex < newDecorationsLength) {
			// No more old decorations => add decoration at `newDecorationsIndex`
			decorationsToAdd.push(newDecorations[newDecorationsIndex]);
			newDecorationsIndex++;
		}

		// Remove `decorationsToRemove`
		if (decorationsToRemove.length > 0) {
			this._removeDecorationsImpl(eventBuilder, decorationsToRemove);
		}

		// Add `decorationsToAdd`
		if (decorationsToAdd.length > 0) {
			let newIds = this._addDecorationsImpl(eventBuilder, ownerId, decorationsToAdd);
			for (let i = 0, len = decorationsToAdd.length; i < len; i++) {
				result[decorationsToAdd[i].index] = newIds[i];
			}
		}

		return result;
	}
開發者ID:aminroosta,項目名稱:vscode,代碼行數:87,代碼來源:textModelWithDecorations.ts

示例8:

			ops.sort((o1, o2) => {
				return Range.compareRangesUsingStarts(o1.range, o2.range);
			});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:3,代碼來源:replaceAllCommand.ts

示例9: compareDecorations

	public static compareDecorations(a:EditorCommon.IModelDecoration, b:EditorCommon.IModelDecoration): number {
		return Range.compareRangesUsingStarts(a.range, b.range);
	}
開發者ID:ErickWendel,項目名稱:vscode,代碼行數:3,代碼來源:viewModelDecorations.ts

示例10: compareEntriesUsingStart

function compareEntriesUsingStart(a: SymbolInformation, b: SymbolInformation): number {
	return Range.compareRangesUsingStarts(Range.lift(a.location.range), Range.lift(b.location.range));
}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:3,代碼來源:quickOpen.ts


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