MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / initVcpkgDatabase

Function initVcpkgDatabase

Extension/src/LanguageServer/extension.ts:66–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64type VcpkgDatabase = Record<string, string[]>; // Stored as <header file entry> -> [<port name>]
65let vcpkgDbPromise: Promise<VcpkgDatabase>;
66async function initVcpkgDatabase(): Promise<VcpkgDatabase> {
67 const database: VcpkgDatabase = {};
68 try {
69 const zip = new StreamZip.async({ file: util.getExtensionFilePath('VCPkgHeadersDatabase.zip') });
70 try {
71 const data = await zip.entryData('VCPkgHeadersDatabase.txt');
72 const lines = data.toString().split('\n');
73 lines.forEach(line => {
74 const portFilePair: string[] = line.split(':');
75 if (portFilePair.length !== 2) {
76 return;
77 }
78
79 const portName: string = portFilePair[0];
80 const relativeHeader: string = portFilePair[1].trimEnd();
81
82 if (!database[relativeHeader]) {
83 database[relativeHeader] = [];
84 }
85
86 database[relativeHeader].push(portName);
87 });
88 } catch {
89 console.log("Unable to parse vcpkg database file.");
90 }
91 await zip.close();
92 } catch {
93 console.log("Unable to open vcpkg database file.");
94 }
95 return database;
96}
97
98function getVcpkgHelpAction(): vscode.CodeAction {
99 const dummy: any[] = [{}]; // To distinguish between entry from CodeActions and the command palette

Callers 1

activateFunction · 0.85

Calls 4

toStringMethod · 0.80
pushMethod · 0.80
forEachMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected