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


TypeScript vscode-uri.parse函數代碼示例

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


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

示例1: getFilePath

export function getFilePath(documentUri: string): string {
  const IS_WINDOWS = platform() === 'win32';
  if (IS_WINDOWS) {
    // Windows have a leading slash like /C:/Users/pine
    return Uri.parse(documentUri).path.slice(1);
  } else {
    return Uri.parse(documentUri).path;
  }
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:9,代碼來源:paths.ts

示例2: getUri

export function getUri(fullpath: string, id: number, buftype: string): string {
  if (!fullpath) return `untitled:${id}`
  if (path.isAbsolute(fullpath)) return Uri.file(fullpath).toString()
  if (isuri.isValid(fullpath)) return Uri.parse(fullpath).toString()
  if (buftype != '') return `${buftype}:${id}`
  return `unknown:${id}`
}
開發者ID:illarionvk,項目名稱:dotfiles,代碼行數:7,代碼來源:index.ts

示例3: resolveWorkspaceRoot

function resolveWorkspaceRoot(activeDoc: TextDocument, workspaceFolders: WorkspaceFolder[]): string | undefined {
	for (let i = 0; i < workspaceFolders.length; i++) {
		if (startsWith(activeDoc.uri, workspaceFolders[i].uri)) {
			return path.resolve(URI.parse(workspaceFolders[i].uri).fsPath);
		}
	}
}
開發者ID:developers23,項目名稱:vscode,代碼行數:7,代碼來源:pathCompletion.ts

示例4:

export function ensureLeadingDot<T extends string>(href: T): T {
  if (!Uri.parse(href).scheme &&
      !(href.startsWith('./') || href.startsWith('../'))) {
    return './' + href as T;
  }
  return href;
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:7,代碼來源:url-utils.ts

示例5: it

 it('should fire onWillSaveUntil', async () => {
   let doc = await helper.createDocument()
   let filepath = Uri.parse(doc.uri).fsPath
   let fn = jest.fn()
   let disposable = workspace.onWillSaveUntil(event => {
     let promise = new Promise<TextEdit[]>(resolve => {
       fn()
       let edit: TextEdit = {
         newText: 'foo',
         range: Range.create(0, 0, 0, 0)
       }
       resolve([edit])
     })
     event.waitUntil(promise)
   }, null, 'test')
   await helper.wait(100)
   await nvim.setLine('bar')
   await helper.wait(30)
   await events.fire('BufWritePre', [doc.bufnr])
   await helper.wait(30)
   let content = doc.getDocumentContent()
   expect(content.startsWith('foobar')).toBe(true)
   disposable.dispose()
   expect(fn).toBeCalledTimes(1)
   if (fs.existsSync(filepath)) {
     fs.unlinkSync(filepath)
   }
 })
開發者ID:illarionvk,項目名稱:dotfiles,代碼行數:28,代碼來源:workspace.test.ts

示例6: getFormatter

function getFormatter(
	document: TextDocument,
	env: IEnvironment,
	config: RubyConfiguration,
	range?: Range
): IFormatter {
	if (typeof config.format === 'string') {
		const formatterConfig: FormatterConfig = {
			env,
			executionRoot: URI.parse(config.workspaceFolderUri).fsPath,
			config: {
				command: config.format,
				useBundler: config.useBundler,
			},
		};

		if (range) {
			formatterConfig.range = range;
		}

		return new FORMATTER_MAP[config.format](document, formatterConfig);
	} else {
		return new NullFormatter();
	}
}
開發者ID:rubyide,項目名稱:vscode-ruby,代碼行數:25,代碼來源:Formatter.ts

示例7: providePathSuggestions

function providePathSuggestions(pathValue: string, position: Position, range: Range, document: TextDocument, workspaceFolders: WorkspaceFolder[]) {
	const fullValue = stripQuotes(pathValue);
	const isValueQuoted = startsWith(pathValue, `'`) || startsWith(pathValue, `"`);
	const valueBeforeCursor = isValueQuoted
		? fullValue.slice(0, position.character - (range.start.character + 1))
		: fullValue.slice(0, position.character - range.start.character);
	const workspaceRoot = resolveWorkspaceRoot(document, workspaceFolders);
	const currentDocFsPath = URI.parse(document.uri).fsPath;

	const paths = providePaths(valueBeforeCursor, currentDocFsPath, workspaceRoot)
		.filter(p => {
			// Exclude current doc's path
			return path.resolve(currentDocFsPath, '../', p) !== currentDocFsPath;
		})
		.filter(p => {
			// Exclude paths that start with `.`
			return p[0] !== '.';
		});

	const fullValueRange = isValueQuoted ? shiftRange(range, 1, -1) : range;
	const replaceRange = pathToReplaceRange(valueBeforeCursor, fullValue, fullValueRange);

	const suggestions = paths.map(p => pathToSuggestion(p, replaceRange));
	return suggestions;
}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:25,代碼來源:pathCompletion.ts

示例8: createLink

function createLink(
  document: TextDocument,
  documentContext: DocumentContext,
  attributeValue: string,
  startOffset: number,
  endOffset: number,
  base: string
): DocumentLink | null {
  const documentUri = Uri.parse(document.uri);
  const tokenContent = stripQuotes(attributeValue);
  if (tokenContent.length === 0) {
    return null;
  }
  if (tokenContent.length < attributeValue.length) {
    startOffset++;
    endOffset--;
  }
  const workspaceUrl = getWorkspaceUrl(documentUri, tokenContent, documentContext, base);
  if (!workspaceUrl || !isValidURI(workspaceUrl)) {
    return null;
  }
  return {
    range: Range.create(document.positionAt(startOffset), document.positionAt(endOffset)),
    target: workspaceUrl
  };
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:26,代碼來源:htmlLinks.ts

示例9:

export function ensureLeadingDot<T>(href: T): T {
  const hrefString = href as any as string;
  if (!Uri.parse(hrefString).scheme &&
      !(hrefString.startsWith('./') || hrefString.startsWith('../'))) {
    return './' + href as any as T;
  }
  return href;
}
開發者ID:Polymer,項目名稱:vulcanize,代碼行數:8,代碼來源:url-utils.ts


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