コード例 #1
0
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                var messageFormatter = new JsonMessageFormatter();
                // StreamJsonRpc v1.4 serializer defaults
                messageFormatter.JsonSerializer.NullValueHandling   = NullValueHandling.Ignore;
                messageFormatter.JsonSerializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
                messageFormatter.JsonSerializer.Converters.Add(new UriConverter());

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new Implementation.LanguageServer())
                            using (var rpc = new LanguageServerJsonRpc(cout, cin, messageFormatter, server)) {
                                rpc.TraceSource.Switch.Level = SourceLevels.Error;
                                rpc.SynchronizationContext   = new SingleThreadSynchronizationContext();

                                services.AddService(new UIService(rpc));
                                services.AddService(new ProgressService(rpc));
                                services.AddService(new TelemetryService(rpc));
                                services.AddService(messageFormatter.JsonSerializer);

                                var token = server.Start(services, rpc);
                                rpc.StartListening();

                                // Wait for the "exit" request, it will terminate the process.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: skeptycal/RTVS
        public static void Main(string[] args)
        {
            var debugMode = CheckDebugMode(args);

            using (CoreShell.Create()) {
                var connection = new VsCodeConnection(CoreShell.Current.ServiceManager);
                connection.Connect(debugMode);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates R session
        /// </summary>
        /// <param name="name">Session name</param>
        /// <param name="url">Path to local R interpreter (folder with R.dll) or URL to the remote machine</param>
        /// <returns>R session</returns>
        public static IRHostSession Create(string name)
        {
            var e = new WindowsRInstallation().GetCompatibleEngines().FirstOrDefault();

            if (e == null)
            {
                throw new InvalidOperationException("No R engines installed");
            }

            var ci = BrokerConnectionInfo.Create(e.Name, e.InstallPath, e.Architecture, string.Empty);
            var bc = new LocalBrokerClient(name, ci, CoreShell.Create());

            return(new RHostSession(new RSession(0, name, bc, new NullLock(), () => { })));
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: nevinhappy/PTVS
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new LanguageServer())
                            using (var rpc = JsonRpc.Attach(cout, cin, server)) {
                                services.AddService(new UIService(rpc));
                                services.AddService(new TelemetryService(rpc));
                                var token = server.Start(services, rpc);
                                // Wait for the "shutdown" request.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
コード例 #5
0
        public static void Main(string[] args)
        {
#if WAIT_FOR_DEBUGGER
            while (!System.Diagnostics.Debugger.IsAttached)
            {
                System.Threading.Thread.Sleep(1000);
            }
#endif
            var messageFormatter = new JsonMessageFormatter();
            // StreamJsonRpc v1.4 serializer defaults
            messageFormatter.JsonSerializer.NullValueHandling   = NullValueHandling.Ignore;
            messageFormatter.JsonSerializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
            messageFormatter.JsonSerializer.Converters.Add(new UriConverter());

            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var bcin = new BufferedStream(cin))
                        using (var cout = Console.OpenStandardOutput())
                            using (var server = new LanguageServer(services))
                                using (var rpc = new JsonRpc(cout, cin, server)) {
                                    rpc.SynchronizationContext = new SingleThreadSynchronizationContext();

                                    services
                                    .AddService(new UIService(rpc))
                                    .AddService(new Client(rpc))
                                    .AddService(new TelemetryService())
                                    .AddService(messageFormatter.JsonSerializer);

                                    var cts = new CancellationTokenSource();
                                    using (new RConnection(services, cts.Token)) {
                                        var token = server.Start();
                                        rpc.StartListening();
                                        // Wait for the "stop" request.
                                        token.WaitHandle.WaitOne();
                                        cts.Cancel();
                                    }
                                }
            }
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new LanguageServer())
                            using (var rpc = new JsonRpc(cout, cin, server)) {
                                var ui = new UIService(rpc);
                                rpc.SynchronizationContext = new SingleThreadSynchronizationContext(ui);

                                services.AddService(ui);
                                services.AddService(new TelemetryService(rpc));
                                var token = server.Start(services, rpc);
                                rpc.StartListening();

                                // Wait for the "shutdown" request.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: yepeiwen/PTVS
        public static void Main(string[] args)
        {
            CheckDebugMode();
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var cout = Console.OpenStandardOutput())
                        using (var server = new Implementation.LanguageServer())
                            using (var rpc = new JsonRpc(cout, cin, server)) {
                                rpc.SynchronizationContext = new SingleThreadSynchronizationContext();
                                rpc.JsonSerializer.Converters.Add(new UriConverter());

                                services.AddService(new UIService(rpc));
                                services.AddService(new ProgressService(rpc));
                                services.AddService(new TelemetryService(rpc));
                                var token = server.Start(services, rpc);
                                rpc.StartListening();

                                // Wait for the "exit" request, it will terminate the process.
                                token.WaitHandle.WaitOne();
                            }
            }
        }
コード例 #8
0
        static /* void */ async Task Main(string[] args)
        {
#if false
            Implementation.Server s = new Implementation.Server();
            // Console.WriteLine($"An analyzer for language {s.pa.PythonAnalysisSource}.");

            // Read JSON directly from a file
            JObject data         = JObject.Parse(File.ReadAllText(Path.Combine("..", "data.json")));
            JToken  processId    = (JToken)data.SelectToken("processId");
            JToken  capabilities = (JToken)data.SelectToken("capabilities");

            Console.WriteLine($"testing: {processId}, [{processId.GetType()}]");
            Console.WriteLine($"testing: {capabilities}, [{capabilities.GetType()}]");
            Test(processId);
            Test(capabilities);
#else
#if false
            using (CoreShell.Create()) {
                var services         = CoreShell.Current.ServiceManager;
                var messageFormatter = new JsonMessageFormatter();
                messageFormatter.JsonSerializer.NullValueHandling   = NullValueHandling.Ignore;
                messageFormatter.JsonSerializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
                messageFormatter.JsonSerializer.Converters.Add(new UriConverter());
            }
#endif
#endif
            IConfigurationRoot config = new ConfigurationBuilder()
                                        .AddJsonFile("config.json")         // the order the providers are added to the builder denotes priority of the config key-values (later takes precedence)
                                        .AddCommandLine(args)
                                        .Build();

            Console.WriteLine($"Should be setting backend to {config["preferredBackend"]}");

            Console.WriteLine("Done!");
            Environment.Exit(0);
        }
コード例 #9
0
        public static void Main(string[] args)
        {
#if WAIT_FOR_DEBUGGER
            while (!System.Diagnostics.Debugger.IsAttached)
            {
                System.Threading.Thread.Sleep(1000);
            }
#endif
            using (CoreShell.Create()) {
                var services = CoreShell.Current.ServiceManager;

                using (var cin = Console.OpenStandardInput())
                    using (var bcin = new BufferedStream(cin))
                        using (var cout = Console.OpenStandardOutput())
                            using (var server = new LanguageServer(services))
                                using (var rpc = new JsonRpc(cout, cin, server)) {
                                    services.AddService(new UIService(rpc));

                                    var token = server.Start();
                                    rpc.StartListening();
                                    token.WaitHandle.WaitOne();
                                }
            }
        }