コード例 #1
0
        /// <summary>
        /// Initializes the Language Service instance
        /// </summary>
        /// <param name="serviceHost"></param>
        /// <param name="context"></param>
        public void InitializeService(LanguageServiceHost serviceHost)
        {
            // Register the requests that this service will handle
            //serviceHost.SetRequestHandler(SignatureHelpRequest.Type, HandleSignatureHelpRequest);
            //serviceHost.SetRequestHandler(CompletionResolveRequest.Type, HandleCompletionResolveRequest);
            //serviceHost.SetRequestHandler(HoverRequest.Type, HandleHoverRequest);
            serviceHost.SetRequestHandler(CompletionRequest.Type, HandleCompletionRequest);
            serviceHost.SetRequestHandler(DefinitionRequest.Type, HandleDefinitionRequest);


            serviceHost.RegisterInitializeTask(this.InitializeCallback);


            // Register the file change update handler
            WorkspaceService.Instance.RegisterTextDocChangeCallback(HandleDidChangeTextDocumentNotification);

            // Register the file open update handler
            WorkspaceService.Instance.RegisterTextDocOpenCallback(HandleDidOpenTextDocumentNotification);


            // Register a no-op shutdown task for validation of the shutdown logic

            /*serviceHost.RegisterShutdownTask(async (shutdownParams, shutdownRequestContext) =>
             * {
             *  Logger.Write(LogLevel.Verbose, "Shutting down language service");
             *  DeletePeekDefinitionScripts();
             *  await Task.FromResult(0);
             * });
             *
             * // Register the configuration update handler
             * WorkspaceService<SqlToolsSettings>.Instance.RegisterConfigChangeCallback(HandleDidChangeConfigurationNotification);
             *
             * // Register the file change update handler
             * WorkspaceService<SqlToolsSettings>.Instance.RegisterTextDocChangeCallback(HandleDidChangeTextDocumentNotification);
             *
             * // Register the file open update handler
             * WorkspaceService<SqlToolsSettings>.Instance.RegisterTextDocOpenCallback(HandleDidOpenTextDocumentNotification);
             *
             * // Register a callback for when a connection is created
             * ConnectionServiceInstance.RegisterOnConnectionTask(UpdateLanguageServiceOnConnection);
             *
             * // Register a callback for when a connection is closed
             * ConnectionServiceInstance.RegisterOnDisconnectTask(RemoveAutoCompleteCacheUriReference);
             *
             * // Store the SqlToolsContext for future use
             * Context = context;*/
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //if debug helps to attach debugger when debugging vscode
#if DEBUG
            while (!System.Diagnostics.Debugger.IsAttached)
            {
                System.Threading.Thread.Sleep(100);
            }
#endif

            try
            {
                Logger.Initialize("xmllanguageserver", minimumLogLevel: LogLevel.Verbose, isEnabled: true);
                Logger.Write(LogLevel.Normal, "Starting Xml Language Service Host");


                // Grab the instance of the service host
                LanguageServiceHost languageServiceHost = LanguageServiceHost.Instance;

                // Start the service
                languageServiceHost.Start().Wait();

                // Initialize the services that will be hosted here
                WorkspaceService.Instance.InitializeService(languageServiceHost);
                XmlLanguageService.Instance.InitializeService(languageServiceHost);

                languageServiceHost.Initialize();
                languageServiceHost.WaitForExit();
            }
            catch (AggregateException e)
            {
                LogAggregateException(e);
                throw;
            }
            catch (Exception e)
            {
                Logger.Write(LogLevel.Error, e.Message + " - " + e.StackTrace);
                throw;
            }
        }
コード例 #3
0
        public void InitializeService(LanguageServiceHost serviceHost)
        {
            Logger.Write(LogLevel.Normal, "InitializeService");

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

            // Register the handlers for when changes to the workspace occur
            serviceHost.SetEventHandler(DidChangeTextDocumentNotification.Type, HandleDidChangeTextDocumentNotification);
            serviceHost.SetEventHandler(DidOpenTextDocumentNotification.Type, HandleDidOpenTextDocumentNotification);
            serviceHost.SetEventHandler(DidCloseTextDocumentNotification.Type, HandleDidCloseTextDocumentNotification);

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

                if (Workspace != null)
                {
                    Workspace.WorkspacePath = parameters.RootPath;
                }
                await Task.FromResult(0);
            });

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

                if (Workspace != null)
                {
                    Workspace.Dispose();
                    Workspace = null;
                }
                await Task.FromResult(0);
            });
        }
コード例 #4
0
 public TypeScriptContext(CompilerOptions options)
 {
     _jsEngine = new JSEngine(x => { x.AllowClr(typeof(TypeScriptContext).GetTypeInfo().Assembly); });
     Host      = new LanguageServiceHost(options, new NullLogger());
 }