Ejemplo n.º 1
0
        /// <summary>
        /// Logs the given text in the editor.
        /// </summary>
        internal static void LogToWindow(this QsLanguageServer server, string text, MessageType severity)
        {
            var message = AsMessageParams(text, severity);

            QsCompilerError.Verify(server != null && message != null, "cannot log message - given server or text was null");
            _ = server.NotifyClientAsync(Methods.WindowLogMessageName, message);
        }
Ejemplo n.º 2
0
        int OnExecute()
        {
            MSBuildLocator.RegisterDefaults(); // needed to "configure" the design time build

            QsLanguageServer server = null;

            switch (Validate())
            {
            case ConnectionMode.NamedPipe:
                server = ConnectNamedPipe(WriterPipeName, ReaderPipeName);
                break;

            case ConnectionMode.Socket:
                server = ConnectSocket(port: Port.Value);
                break;
            }

            Log("Waiting for shutdown...");
            server.WaitForShutdown();

            if (server.ReadyForExit)
            {
                Log("Exiting normally.");
                return(0);
            }
            else
            {
                Log("Exiting abnormally.");
                return(1);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows a dialog window with options (actions) to the user, and returns the selected option (action).
        /// </summary>
        internal static async Task <MessageActionItem> ShowDialogInWindowAsync(this QsLanguageServer server, string text, MessageType severity, MessageActionItem[] actionItems)
        {
            var message =
                new ShowMessageRequestParams()
            {
                Message     = text,
                MessageType = severity,
                Actions     = actionItems
            };

            return(await server.InvokeAsync <MessageActionItem>(Methods.WindowShowMessageRequestName, message));
        }
Ejemplo n.º 4
0
        static int Main(string[] args)
        {
            MSBuildLocator.RegisterDefaults(); // needed to "configure" the design time build

            Log("Called with command line arguments: " + String.Join(" ", args));
            var options = new OptionSet
            {
                { "l|log=", "file to write log messages to.", l => logFile = l },
                { "p|port=", "TCP port to connect to", (int p) => port = p },
                { "w|writer=", "Named pipe to write to", w => writerPipeName = w },
                { "r|reader=", "Named pipe to read from", r => readerPipeName = r }
            };

            List <String> extra = null;

            try { extra = options.Parse(args); }
            catch (OptionException e)
            { Log(e.Message); }

            QsLanguageServer server = null;

            switch (Validate())
            {
            case ConnectionMode.NamedPipe:
                server = ConnectNamedPipe(writerPipeName, readerPipeName);
                break;

            case ConnectionMode.Socket:
                server = ConnectSocket(port: port.Value);
                break;
            }

            Log("Waiting for shutdown...");
            server.WaitForShutdown();

            if (server.ReadyForExit)
            {
                Log("Exiting normally.");
                return(0);
            }
            else
            {
                Log("Exiting abnormally.");
                return(1);
            }
        }
Ejemplo n.º 5
0
        private static QsLanguageServer ConnectSocket(string hostname = "localhost", int port = 8008)
        {
            try
            {
                Log($"Connecting via socket.");
                var client = new TcpClient(hostname, port);
                var stream = client.GetStream();

                Log($"Connected to {hostname} at port {port}.");
                var lsp = new QsLanguageServer(stream, stream);
                return(lsp);
            }
            catch (Exception ex)
            {
                Log($"[ERROR] {ex.Message}");
                Environment.Exit(-2);
                return(null);
            }
        }