Example #1
0
        public override void InitializeService(IServiceHost serviceHost)
        {
            serviceHost.SetAsyncEventHandler(DidChangeTextDocumentNotification.Type, HandleDidChangeTextDocumentNotification);
            serviceHost.SetAsyncEventHandler(DidOpenTextDocumentNotification.Type, HandleDidOpenTextDocumentNotification);
            serviceHost.SetAsyncEventHandler(DidCloseTextDocumentNotification.Type, HandleDidCloseTextDocumentNotification);

            // Register an initialization handler that sets the workspace path
            serviceHost.RegisterInitializeTask(async(parameters, context) =>
            {
                Logger.Instance.Write(LogLevel.Verbose, "Initializing workspace service");

                // Create a workspace that will handle state for the session
                Workspace = new Workspace(parameters.Capabilities);

                // we only support a single workspace path
                if (parameters.WorkspaceFolders != null)
                {
                    Workspace.WorkspacePath = parameters.WorkspaceFolders.First().Uri;
                }
                else
                {
                    Workspace.WorkspacePath = parameters.RootUri;
                }

                await Task.FromResult(0);
            });

            // Register a shutdown request that disposes the workspace
            serviceHost.RegisterShutdownTask(async(parameters, context) =>
            {
                Logger.Instance.Write(LogLevel.Verbose, "Shutting down workspace service");

                if (Workspace != null)
                {
                    Workspace.Dispose();
                    Workspace = null;
                }

                await Task.FromResult(0);
            });
        }
Example #2
0
 public void InitializeService(IServiceHost serviceHost)
 {
     // Register the handlers for when changes to the workspae occur
     serviceHost.SetAsyncEventHandler(DidChangeConfigurationNotification <TConfig> .Type, HandleDidChangeConfigurationNotification);
 }