func New()

in src/ulsp/controller/scip/scip.go [98:136]


func New(p Params) (Controller, error) {
	configs := entity.MonorepoConfigs{}
	if err := p.Config.Get(entity.MonorepoConfigKey).Populate(&configs); err != nil {
		panic(fmt.Sprintf("getting configuration for %q: %v", entity.MonorepoConfigKey, err))
	}

	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		return nil, fmt.Errorf("failed to create fs watcher for scip: %w", err)
	}

	notificationManagerParams := notifier.NotificationManagerParams{
		Sessions:   p.Sessions,
		IdeGateway: p.IdeGateway,
		Logger:     p.Logger,
	}

	return &controller{
		configs:        configs,
		sessions:       p.Sessions,
		ideGateway:     p.IdeGateway,
		logger:         p.Logger.With("plugin", _nameKey),
		stats:          p.Stats.SubScope("scip"),
		documents:      p.PluginDocSync,
		diagnostics:    p.PluginDiagnostics,
		registries:     make(map[string]registry.Registry),
		watcher:        watcher,
		fs:             p.FS,
		initialLoad:    make(chan bool, 1),
		watchCloser:    make(chan bool, 1),
		loadedIndices:  make(map[string]string),
		debounceTimers: make(map[string]*time.Timer),
		indexNotifier:  NewIndexNotifier(notifier.NewNotificationManager(notificationManagerParams)),
		newScipRegistry: func(workspaceRoot, indexFolder string) registry.Registry {
			p.Logger.Infof("Creating new SCIP registry for %q, index folder %q", workspaceRoot, indexFolder)
			return registry.NewPartialScipRegistry(workspaceRoot, indexFolder, p.Logger.Named("fast-loader"))
		},
	}, nil
}