private static void AddDebuggerOptions(IAdapterLaunchInfo adapterLaunchInfo, DebugInfo launchJson) { var debugService = (IPythonDebugOptionsService)Package.GetGlobalService(typeof(IPythonDebugOptionsService)); // Stop on entry should always be true for VS Debug Adapter Host. // If stop on entry is disabled then VS will automatically issue // continue when it sees "stopped" event with "reason=entry". launchJson.StopOnEntry = true; // Force this to false to prevent subprocess debugging, which we do not support yet in PTVS launchJson.SubProcess = false; launchJson.PromptBeforeRunningWithBuildError = debugService.PromptBeforeRunningWithBuildError; launchJson.RedirectOutput = debugService.TeeStandardOutput; launchJson.WaitOnAbnormalExit = debugService.WaitOnAbnormalExit; launchJson.WaitOnNormalExit = debugService.WaitOnNormalExit; launchJson.BreakOnSystemExitZero = debugService.BreakOnSystemExitZero; launchJson.DebugStdLib = debugService.DebugStdLib; launchJson.ShowReturnValue = debugService.ShowFunctionReturnValue; var variablePresentation = new VariablePresentation(); variablePresentation.Class = debugService.VariablePresentationForClasses; variablePresentation.Function = debugService.VariablePresentationForFunctions; variablePresentation.Protected = debugService.VariablePresentationForProtected; variablePresentation.Special = debugService.VariablePresentationForSpecial; launchJson.VariablePresentation = variablePresentation; var excludePTVSInstallDirectory = new PathRule() { Path = PathUtils.GetParent(typeof(DebugAdapterLauncher).Assembly.Location), Include = false, }; launchJson.Rules = new List <PathRule>() { excludePTVSInstallDirectory }; }
/// <summary> /// Adds variable presentation options to the json that will be passed to the debugger when launched. /// </summary> /// <param name="adapterLaunchInfoJson">Launch info json that comes from the interpreter and/or the user</param> /// <param name="launchJson">The json that will be passed to the debugger</param> private static void AddVariablePresentationOptions(JObject adapterLaunchInfoJson, DebugInfo launchJson) { if (adapterLaunchInfoJson == null) { throw new ArgumentNullException(nameof(adapterLaunchInfoJson)); } if (launchJson == null) { throw new ArgumentNullException(nameof(launchJson)); } // create a default variable presentation and add it to the launchJson var variablePresentation = new VariablePresentation(); launchJson.VariablePresentation = variablePresentation; // if no variable presentation is provided, we're done var varPresJson = adapterLaunchInfoJson.Value <JObject>("variablePresentation"); if (varPresJson == null) { return; } // otherwise, update the launchJson with the provided presentation values var classModeStr = varPresJson.Value <string>("class"); if (classModeStr != null) { if (Enum.TryParse(classModeStr, ignoreCase: true, out PresentationMode classMode)) { variablePresentation.Class = classMode; } } var functionModeStr = varPresJson.Value <string>("function"); if (functionModeStr != null) { if (Enum.TryParse(functionModeStr, ignoreCase: true, out PresentationMode functionMode)) { variablePresentation.Function = functionMode; } } var protectedModeStr = varPresJson.Value <string>("protected"); if (protectedModeStr != null) { if (Enum.TryParse(protectedModeStr, ignoreCase: true, out PresentationMode protectedMode)) { variablePresentation.Protected = protectedMode; } } var specialModeStr = varPresJson.Value <string>("special"); if (specialModeStr != null) { if (Enum.TryParse(specialModeStr, ignoreCase: true, out PresentationMode specialMode)) { variablePresentation.Special = specialMode; } } }