(context: vscode.ExtensionContext)
| 36 | const disposables: vscode.Disposable[] = []; |
| 37 | |
| 38 | export async function activate(context: vscode.ExtensionContext): Promise<CppToolsApi & CppToolsExtension> { |
| 39 | sendInstrumentation({ |
| 40 | name: "activate", |
| 41 | context: { cpptools: '', start: '' } |
| 42 | }); |
| 43 | |
| 44 | util.setExtensionContext(context); |
| 45 | util.setProgress(0); |
| 46 | Telemetry.activate(); |
| 47 | |
| 48 | // Register a protocol handler to serve localized versions of the schema for c_cpp_properties.json |
| 49 | class SchemaProvider implements vscode.TextDocumentContentProvider { |
| 50 | public async provideTextDocumentContent(uri: vscode.Uri): Promise<string> { |
| 51 | console.assert(uri.path[0] === '/', "A preceding slash is expected on schema uri path"); |
| 52 | const fileName: string = uri.path.substring(1); |
| 53 | const locale: string = getLocaleId(); |
| 54 | let localizedFilePath: string = util.getExtensionFilePath(path.join("dist/schema/", locale, fileName)); |
| 55 | const fileExists: boolean = await util.checkFileExists(localizedFilePath); |
| 56 | if (!fileExists) { |
| 57 | localizedFilePath = util.getExtensionFilePath(fileName); |
| 58 | } |
| 59 | return util.readFileText(localizedFilePath); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | vscode.workspace.registerTextDocumentContentProvider('cpptools-schema', instrument(new SchemaProvider())); |
| 64 | |
| 65 | // Initialize the DebuggerExtension and register the related commands and providers. |
| 66 | util.setProgress(util.getProgressDebuggerStarted()); |
| 67 | await DebuggerExtension.initialize(context); |
| 68 | util.setProgress(util.getProgressDebuggerSuccess()); |
| 69 | |
| 70 | const info: PlatformInformation = await PlatformInformation.GetPlatformInformation(); |
| 71 | sendTelemetry(info); |
| 72 | |
| 73 | // Always attempt to make the binaries executable, not just when installedVersion changes. |
| 74 | // The user may have uninstalled and reinstalled the same version. |
| 75 | await makeBinariesExecutable(); |
| 76 | |
| 77 | // Notify users if debugging may not be supported on their OS. |
| 78 | util.checkDistro(info); |
| 79 | await checkVsixCompatibility(); |
| 80 | |
| 81 | const ignoreRecommendations: boolean | undefined = vscode.workspace.getConfiguration("extensions", null).get<boolean>("ignoreRecommendations"); |
| 82 | if (ignoreRecommendations !== true) { |
| 83 | await LanguageServer.preReleaseCheck(); |
| 84 | } |
| 85 | |
| 86 | const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined); |
| 87 | let isOldMacOs: boolean = false; |
| 88 | if (info.platform === 'darwin') { |
| 89 | const releaseParts: string[] = os.release().split("."); |
| 90 | if (releaseParts.length >= 1) { |
| 91 | isOldMacOs = parseInt(releaseParts[0]) < 16; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Read the setting and determine whether we should activate the language server prior to installing callbacks, |
nothing calls this directly
no test coverage detected