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


TypeScript uri.toString函數代碼示例

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


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

示例1: getMultiSelectedResources

export function getMultiSelectedResources(resource: URI | object, listService: IListService, editorService: IEditorService): URI[] {
	const list = listService.lastFocusedList;
	if (list && list.isDOMFocused()) {
		// Explorer
		if (list instanceof Tree) {
			const selection = list.getSelection().map((fs: ExplorerItem) => fs.resource);
			const focus = list.getFocus();
			const mainUriStr = URI.isUri(resource) ? resource.toString() : focus instanceof ExplorerItem ? focus.resource.toString() : undefined;
			// If the resource is passed it has to be a part of the returned context.
			// We only respect the selection if it contains the focused element.
			if (selection.some(s => URI.isUri(s) && s.toString() === mainUriStr)) {
				return selection;
			}
		}

		// Open editors view
		if (list instanceof List) {
			const selection = list.getSelectedElements().filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource());
			const focusedElements = list.getFocusedElements();
			const focus = focusedElements.length ? focusedElements[0] : undefined;
			const mainUriStr = URI.isUri(resource) ? resource.toString() : (focus instanceof OpenEditor) ? focus.getResource().toString() : undefined;
			// We only respect the selection if it contains the main element.
			if (selection.some(s => s.toString() === mainUriStr)) {
				return selection;
			}
		}
	}

	const result = getResourceForCommand(resource, listService, editorService);
	return !!result ? [result] : [];
}
開發者ID:liunian,項目名稱:vscode,代碼行數:31,代碼來源:files.ts

示例2: testWorkspace

export function testWorkspace(resource: URI): Workspace {
	return new Workspace(
		resource.toString(),
		resource.fsPath,
		toWorkspaceFolders([{ path: resource.fsPath }])
	);
}
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:7,代碼來源:testWorkspace.ts

示例3: isEqual

export function isEqual(first: uri, second: uri, ignoreCase?: boolean): boolean {
	const identityEquals = (first === second);
	if (identityEquals) {
		return true;
	}

	if (!first || !second) {
		return false;
	}

	if (ignoreCase) {
		return equalsIgnoreCase(first.toString(), second.toString());
	}

	return first.toString() === second.toString();
}
開發者ID:jinlongchen2018,項目名稱:vscode,代碼行數:16,代碼來源:resources.ts

示例4: getMultiSelectedResources

export function getMultiSelectedResources(resource: URI | {}, listService: IListService, editorService: IWorkbenchEditorService): URI[] {
	const list = listService.lastFocusedList;
	if (list && list.isDOMFocused()) {
		// Explorer
		if (list instanceof Tree) {
			const focus: IFileStat = list.getFocus();
			// If the resource is passed it has to be a part of the returned context.
			if (focus && (!URI.isUri(resource) || focus.resource.toString() === resource.toString())) {
				const selection = list.getSelection();
				// We only respect the selection if it contains the focused element.
				if (selection && selection.indexOf(focus) >= 0) {
					return selection.map(fs => fs.resource);
				}
			}
		}

		// Open editors view
		if (list instanceof List) {
			const focus = list.getFocusedElements();
			// If the resource is passed it has to be a part of the returned context.
			if (focus.length && (!URI.isUri(resource) || (focus[0] instanceof OpenEditor && focus[0].getResource().toString() === resource.toString()))) {
				const selection = list.getSelectedElements();
				// We only respect the selection if it contains the focused element.
				if (selection && selection.indexOf(focus[0]) >= 0) {
					return selection.filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource());
				}
			}
		}
	}

	const result = getResourceForCommand(resource, listService, editorService);
	return !!result ? [result] : [];
}
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:33,代碼來源:files.ts

示例5: testWorkspace

export function testWorkspace(resource: URI): Workspace {
	return new Workspace(
		resource.toString(),
		resource.fsPath,
		[resource]
	);
}
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:7,代碼來源:testWorkspace.ts

示例6: compute

export function compute(languageService:ts.LanguageService, resource:URI, position:EditorCommon.IPosition):Modes.ILogicalSelectionEntry[] {

	var sourceFile = languageService.getSourceFile(resource.toString()),
		offset = converter.getOffset(sourceFile, position);

	var token = ts.getTokenAtPosition(sourceFile, offset),
		lastStart = -1,
		lastEnd = -1,
		result:Modes.ILogicalSelectionEntry[] = [];

	while(token) {

		var start = token.getStart(),
			end = token.getEnd();

		if(start !== lastStart || end !== lastEnd) {
			result.unshift({
				type: 'node',
				range: converter.getRange(sourceFile, start, end)
			});
		}

		lastStart = start;
		lastEnd = end;
		token = token.parent;
	}

	return result;
}
開發者ID:578723746,項目名稱:vscode,代碼行數:29,代碼來源:logicalSelection.ts

示例7: find

export function find(project: projectService.IProject, resource: URI, position: EditorCommon.IPosition, includeDecl: boolean, insideFileOnly: boolean = false): Modes.IReference[] {

	var filename = resource.toString(),
		offset = project.host.getScriptLineMap(filename).getOffset(position),
		entries: ts.ReferenceEntry[];

	entries = insideFileOnly
		? project.languageService.getOccurrencesAtPosition(filename, offset)
		: project.languageService.getReferencesAtPosition(filename, offset);

	if(!entries) {
		return [];
	}

	return entries.filter(info => {
		var targetFile = project.languageService.getSourceFile(info.fileName);
		return (includeDecl || !isDeclaration(targetFile, info.textSpan.start));
	}).map(info => {
		var r:Modes.IReference = {
			resource: URI.parse(info.fileName),
			range: project.host.getScriptLineMap(info.fileName).getRangeFromSpan(info.textSpan)
		};
		return r;
	});
}
開發者ID:578723746,項目名稱:vscode,代碼行數:25,代碼來源:references.ts

示例8: compute

export function compute(languageService: ts.LanguageService, resource:URI, position:EditorCommon.IPosition):Modes.IComputeExtraInfoResult {

	var filename = resource.toString(),
		sourceFile = languageService.getSourceFile(filename),
		offset = converter.getOffset(sourceFile, position),
		info = languageService.getQuickInfoAtPosition(filename, offset),
		result:Modes.IComputeExtraInfoResult;

	if(info) {

		var htmlContent = [
			previewer.html(info.displayParts),
			previewer.html(info.documentation, 'documentation')
		];

		result = {
			value: '',
			htmlContent: htmlContent,
			className: 'typeInfo ts',
			range: converter.getRange(sourceFile, info.textSpan)
		};
	}

	return result;
}
開發者ID:gaoxiaojun,項目名稱:vscode,代碼行數:25,代碼來源:extraInfo.ts

示例9: insert

	public insert(uri:URI, element:IMirrorModel): void {
		let key = uri.toString();

		if (this._map.contains(key)) {
			// There already exists a model with this id => this is a programmer error
			throw new Error('ResourceService: Cannot add model ' + ResourceService._anonymousModelId(key) + ' because it already exists!');
		}
		this._map.set(key, element);
	}
開發者ID:douglaseccker,項目名稱:vscode,代碼行數:9,代碼來源:resourceServiceImpl.ts

示例10: saveViewState

	protected saveViewState(resource: URI | string, editorViewState: HtmlPreviewEditorViewState): void {
		const memento = this.getMemento(this.storageService, Scope.WORKSPACE);
		let editorViewStateMemento: { [key: string]: { [position: number]: HtmlPreviewEditorViewState } } = memento[this.viewStateStorageKey];
		if (!editorViewStateMemento) {
			editorViewStateMemento = Object.create(null);
			memento[this.viewStateStorageKey] = editorViewStateMemento;
		}

		let fileViewState = editorViewStateMemento[resource.toString()];
		if (!fileViewState) {
			fileViewState = Object.create(null);
			editorViewStateMemento[resource.toString()] = fileViewState;
		}

		if (typeof this.position === 'number') {
			fileViewState[this.position] = editorViewState;
		}
	}
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:18,代碼來源:webviewEditor.ts


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