本文整理汇总了TypeScript中jsonc-parser.findNodeAtLocation函数的典型用法代码示例。如果您正苦于以下问题:TypeScript findNodeAtLocation函数的具体用法?TypeScript findNodeAtLocation怎么用?TypeScript findNodeAtLocation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findNodeAtLocation函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
child => {
const pathNode = jsonc.findNodeAtLocation(child, ['path']);
if (!this.isPathValue(pathNode)) {
return undefined;
}
return new vscode.DocumentLink(this.getRange(document, pathNode),
basename(pathNode.value).match('.json$')
? this.getFileTarget(document, pathNode)
: this.getFolderTarget(document, pathNode));
});
示例2: getExendsLink
private getExendsLink(document: vscode.TextDocument, root: jsonc.Node): vscode.DocumentLink | undefined {
const extendsNode = jsonc.findNodeAtLocation(root, ['extends']);
if (!this.isPathValue(extendsNode)) {
return undefined;
}
return new vscode.DocumentLink(
this.getRange(document, extendsNode),
basename(extendsNode.value).match('.json$')
? this.getFileTarget(document, extendsNode)
: vscode.Uri.file(join(dirname(document.uri.fsPath), extendsNode!.value + '.json')));
}
示例3: getReferencesLinks
private getReferencesLinks(document: vscode.TextDocument, root: jsonc.Node) {
return mapChildren(
jsonc.findNodeAtLocation(root, ['references']),
child => {
const pathNode = jsonc.findNodeAtLocation(child, ['path']);
if (!this.isPathValue(pathNode)) {
return undefined;
}
return new vscode.DocumentLink(this.getRange(document, pathNode),
basename(pathNode.value).match('.json$')
? this.getFileTarget(document, pathNode)
: this.getFolderTarget(document, pathNode));
});
}
示例4: getExtendsLink
private getExtendsLink(document: vscode.TextDocument, root: jsonc.Node): vscode.DocumentLink | undefined {
const extendsNode = jsonc.findNodeAtLocation(root, ['extends']);
if (!this.isPathValue(extendsNode)) {
return undefined;
}
if (extendsNode.value.startsWith('.')) {
return new vscode.DocumentLink(
this.getRange(document, extendsNode),
vscode.Uri.file(join(dirname(document.uri.fsPath), extendsNode.value + (extendsNode.value.endsWith('.json') ? '' : '.json')))
);
}
const workspaceFolderPath = vscode.workspace.getWorkspaceFolder(document.uri)!.uri.fsPath;
return new vscode.DocumentLink(
this.getRange(document, extendsNode),
vscode.Uri.file(join(workspaceFolderPath, 'node_modules', extendsNode.value + (extendsNode.value.endsWith('.json') ? '' : '.json')))
);
}
示例5: getFilesLinks
private getFilesLinks(document: vscode.TextDocument, root: jsonc.Node) {
return mapChildren(
jsonc.findNodeAtLocation(root, ['files']),
child => this.pathNodeToLink(document, child));
}