当前位置: 首页>>代码示例>>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;未经允许,请勿转载。