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

Method init

Extension/src/LanguageServer/client.ts:1401–1503  ·  view source on GitHub ↗
(rootUri: vscode.Uri | undefined, isFirstClient: boolean)

Source from the content-addressed store, hash-verified

1399 }
1400
1401 private async init(rootUri: vscode.Uri | undefined, isFirstClient: boolean) {
1402 ui = getUI();
1403 ui.bind(this);
1404 if ((await firstClientStarted).wasShutdown) {
1405 this.isSupported = false;
1406 DefaultClient.isStarted.resolve();
1407 return;
1408 }
1409
1410 try {
1411 const workspaceFolder: vscode.WorkspaceFolder | undefined = this.rootFolder;
1412 this.innerConfiguration = new configs.CppProperties(this, rootUri, workspaceFolder);
1413 this.innerConfiguration.ConfigurationsChanged((e) => this.onConfigurationsChanged(e));
1414 this.innerConfiguration.SelectionChanged((e) => this.onSelectedConfigurationChanged(e));
1415 this.innerConfiguration.CompileCommandsChanged((e) => this.onCompileCommandsChanged(e));
1416 this.disposables.push(this.innerConfiguration);
1417
1418 this.innerLanguageClient = languageClient;
1419 telemetry.logLanguageServerEvent("NonDefaultInitialCppSettings", this.settingsTracker.getUserModifiedSettings());
1420 failureMessageShown = false;
1421
1422 if (isFirstClient) {
1423 workspaceReferences = new refs.ReferencesManager(this);
1424 // Only register file watchers and providers after the extension has finished initializing,
1425 // e.g. prevents empty c_cpp_properties.json from generation.
1426 this.registerFileWatcher();
1427 initializedClientCount = 0;
1428 this.inlayHintsProvider = new InlayHintsProvider();
1429 this.hoverProvider = new HoverProvider(this);
1430 this.copilotHoverProvider = new CopilotHoverProvider(this);
1431
1432 this.disposables.push(vscode.languages.registerHoverProvider(util.documentSelector, instrument(this.copilotHoverProvider)));
1433 this.disposables.push(vscode.languages.registerHoverProvider(util.documentSelector, instrument(this.hoverProvider)));
1434 this.disposables.push(vscode.languages.registerInlayHintsProvider(util.documentSelector, instrument(this.inlayHintsProvider)));
1435 this.disposables.push(vscode.languages.registerRenameProvider(util.documentSelector, instrument(new RenameProvider(this))));
1436 this.disposables.push(vscode.languages.registerReferenceProvider(util.documentSelector, instrument(new FindAllReferencesProvider(this))));
1437 this.disposables.push(vscode.languages.registerWorkspaceSymbolProvider(instrument(new WorkspaceSymbolProvider(this))));
1438 this.disposables.push(vscode.languages.registerDocumentSymbolProvider(util.documentSelector, instrument(new DocumentSymbolProvider()), undefined));
1439 this.disposables.push(vscode.languages.registerCodeActionsProvider(util.documentSelector, instrument(new CodeActionProvider(this)), undefined));
1440 this.disposables.push(vscode.languages.registerCallHierarchyProvider(util.documentSelector, instrument(new CallHierarchyProvider(this))));
1441
1442 // Because formatting and codeFolding can vary per folder, we need to register these providers once
1443 // and leave them registered. The decision of whether to provide results needs to be made on a per folder basis,
1444 // within the providers themselves.
1445 this.documentFormattingProviderDisposable = vscode.languages.registerDocumentFormattingEditProvider(util.documentSelector, instrument(new DocumentFormattingEditProvider(this)));
1446 this.formattingRangeProviderDisposable = vscode.languages.registerDocumentRangeFormattingEditProvider(util.documentSelector, instrument(new DocumentRangeFormattingEditProvider(this)));
1447 this.onTypeFormattingProviderDisposable = vscode.languages.registerOnTypeFormattingEditProvider(util.documentSelector, instrument(new OnTypeFormattingEditProvider(this)), ";", "}", "\n");
1448
1449 this.codeFoldingProvider = new FoldingRangeProvider(this);
1450 this.codeFoldingProviderDisposable = vscode.languages.registerFoldingRangeProvider(util.documentSelector, instrument(this.codeFoldingProvider));
1451
1452 const settings: CppSettings = new CppSettings();
1453 if (settings.isEnhancedColorizationEnabled && semanticTokensLegend) {
1454 this.semanticTokensProvider = instrument(new SemanticTokensProvider());
1455 this.semanticTokensProviderDisposable = vscode.languages.registerDocumentSemanticTokensProvider(util.documentSelector, this.semanticTokensProvider, semanticTokensLegend);
1456 }
1457
1458 this.copilotCompletionProvider = CopilotCompletionContextProvider.Create();

Callers 4

constructorMethod · 0.95
instrumentation.tsFile · 0.45
initializeFunction · 0.45
constructorMethod · 0.45

Calls 15

registerFileWatcherMethod · 0.95
registerNotificationsMethod · 0.95
requestCompilerMethod · 0.95
getUIFunction · 0.90
instrumentFunction · 0.90
initializeIntervalTimerFunction · 0.90
bindMethod · 0.80
ConfigurationsChangedMethod · 0.80
SelectionChangedMethod · 0.80

Tested by

no test coverage detected