Ejemplo n.º 1
0
        private static void SetLaunchDebugOptions(DebugLaunchInfo debugLaunchInfo, JObject adapterLaunchInfoJson)
        {
            string[] options = SplitDebugOptions(adapterLaunchInfoJson.Value <string>("options"));

            string djangoOption = options.FirstOrDefault(x => x.StartsWith("DJANGO_DEBUG"));

            if (djangoOption != null)
            {
                string[] parsedOption = djangoOption.Split('=');
                if (parsedOption.Length == 2)
                {
                    debugLaunchInfo.DebugDjango = parsedOption[1].Trim().ToLower().Equals("true");
                }
            }

            string webPageUrlOption = options.FirstOrDefault(x => x.StartsWith("WEB_BROWSER_URL"));

            if (webPageUrlOption != null)
            {
                string[] parsedOption = webPageUrlOption.Split('=');
                if (parsedOption.Length == 2)
                {
                    debugLaunchInfo.LaunchWebPageUrl = HttpUtility.UrlDecode(parsedOption[1]);
                }
            }
        }
Ejemplo n.º 2
0
        private static void SetEnvVariables(DebugLaunchInfo debugLaunchInfo, JObject adapterLaunchInfoJson)
        {
            var env = new Dictionary <string, string>();

            foreach (var envVariable in adapterLaunchInfoJson.Value <JArray>("env"))
            {
                env[envVariable.Value <string>("name")] = envVariable.Value <string>("value");
            }

            debugLaunchInfo.Env = env.Count == 0 ? null : env;
        }
Ejemplo n.º 3
0
        private static void SetScriptPathAndArguments(DebugLaunchInfo debugLaunchInfo, JObject adapterLaunchInfoJson)
        {
            debugLaunchInfo.Script          = adapterLaunchInfoJson.Value <string>("scriptName");
            debugLaunchInfo.ScriptArguments = new List <string>();

            string scriptArgs = adapterLaunchInfoJson.Value <string>("scriptArgs");

            try {
                debugLaunchInfo.ScriptArguments.AddRange(GetParsedCommandLineArguments(scriptArgs));
            } catch (Exception) {
                MessageBox.Show(Strings.UnableToParseScriptArgs.FormatUI(scriptArgs), Strings.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 4
0
        private static void SetInterpreterPathAndArguments(DebugLaunchInfo debugLaunchInfo, JObject adapterLaunchInfoJson)
        {
            debugLaunchInfo.InterpreterPathAndArguments = new List <string>()
            {
                adapterLaunchInfoJson.Value <string>("exe").Replace("\"", "")
            };

            string interpreterArgs = adapterLaunchInfoJson.Value <string>("interpreterArgs");

            try {
                debugLaunchInfo.InterpreterPathAndArguments.AddRange(GetParsedCommandLineArguments(interpreterArgs));
            } catch (Exception) {
                MessageBox.Show(Strings.UnableToParseInterpreterArgs.FormatUI(interpreterArgs), Strings.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                debugLaunchInfo.ScriptArguments = new List <string> {
                    adapterLaunchInfoJson.Value <string>("exe")
                };
            }
        }
Ejemplo n.º 5
0
        private static DebugLaunchInfo GetLaunchDebugInfo(string adapterLaunchJson)
        {
            var adapterLaunchInfoJson = JObject.Parse(adapterLaunchJson);

            adapterLaunchInfoJson = adapterLaunchInfoJson.Value <JObject>("ConfigurationProperties") ?? adapterLaunchInfoJson;//Based on the VS version, the JSON could be nested in ConfigurationProperties

            var debugLaunchInfo = new DebugLaunchInfo()
            {
                CurrentWorkingDirectory = adapterLaunchInfoJson.Value <string>("cwd"),
                Console = "externalTerminal",
            };

            SetInterpreterPathAndArguments(debugLaunchInfo, adapterLaunchInfoJson);
            SetScriptPathAndArguments(debugLaunchInfo, adapterLaunchInfoJson);
            SetEnvVariables(debugLaunchInfo, adapterLaunchInfoJson);
            SetLaunchDebugOptions(debugLaunchInfo, adapterLaunchInfoJson);

            return(debugLaunchInfo);
        }