MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / activate

Function activate

Extension/src/main.ts:38–175  ·  view source on GitHub ↗
(context: vscode.ExtensionContext)

Source from the content-addressed store, hash-verified

36const disposables: vscode.Disposable[] = [];
37
38export 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,

Callers

nothing calls this directly

Calls 12

sendInstrumentationFunction · 0.90
instrumentFunction · 0.90
logFunction · 0.90
makeBinariesExecutableFunction · 0.85
checkVsixCompatibilityFunction · 0.85
showErrorMessageMethod · 0.80
pushMethod · 0.80
sendTelemetryFunction · 0.70
activateMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected