function getCppToolsTestApi()

in out/testApi.js [32:79]


function getCppToolsTestApi(version) {
    return __awaiter(this, void 0, void 0, function* () {
        let cpptools = vscode.extensions.getExtension("ms-vscode.cpptools");
        let extension;
        let api;
        if (cpptools) {
            if (!cpptools.isActive) {
                extension = yield cpptools.activate();
            }
            else {
                extension = cpptools.exports;
            }
            if (isCppToolsTestExtension(extension)) {
                // ms-vscode.cpptools > 0.17.5
                try {
                    api = extension.getTestApi(version);
                }
                catch (err) {
                    // Unfortunately, ms-vscode.cpptools [0.17.6, 0.18.1] throws a RangeError if you specify a version greater than v1.
                    // These versions of the extension will not be able to act on the newer interface and v2 is a superset of v1, so we can safely fall back to v1.
                    let e = err;
                    if (e.message && e.message.startsWith("Invalid version")) {
                        api = extension.getTestApi(api_1.Version.v1);
                    }
                }
                if (version !== api_1.Version.v1) {
                    if (!api.getVersion) {
                        console.warn(`vscode-cpptools-api version ${version} requested, but is not available in the current version of the cpptools extension. Using version 1 instead.`);
                    }
                    else if (version !== api.getVersion()) {
                        console.warn(`vscode-cpptools-api version ${version} requested, but is not available in the current version of the cpptools extension. Using version ${api.getVersion()} instead.`);
                    }
                }
            }
            else {
                // ms-vscode.cpptools version 0.17.5
                api = extension;
                if (version !== api_1.Version.v0) {
                    console.warn(`vscode-cpptools-api version ${version} requested, but is not available in version 0.17.5 of the cpptools extension. Using version 0 instead.`);
                }
            }
        }
        else {
            console.warn("C/C++ extension is not installed");
        }
        return api;
    });
}