Beispiel #1
0
        public static CodeAction WrapResolvableCSharpCodeAction(
            this CodeAction razorCodeAction,
            RazorCodeActionContext context,
            string action = LanguageServerConstants.CodeActions.Default)
        {
            if (razorCodeAction is null)
            {
                throw new ArgumentNullException(nameof(razorCodeAction));
            }

            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var csharpParams = new CSharpCodeActionParams()
            {
                Data         = razorCodeAction.Data,
                RazorFileUri = context.Request.TextDocument.Uri
            };

            var resolutionParams = new RazorCodeActionResolutionParams()
            {
                Action   = action,
                Language = LanguageServerConstants.CodeActions.Languages.CSharp,
                Data     = csharpParams
            };

            razorCodeAction.Data = JToken.FromObject(resolutionParams);

            return(razorCodeAction);
        }
        public static RazorCodeAction WrapResolvableCSharpCodeAction(
            this RazorCodeAction razorCodeAction,
            RazorCodeActionContext context,
            string action = LanguageServerConstants.CodeActions.Default)
        {
            if (razorCodeAction is null)
            {
                throw new ArgumentNullException(nameof(razorCodeAction));
            }

            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var csharpParams = new CSharpCodeActionParams()
            {
                Data         = razorCodeAction.Data,
                RazorFileUri = context.Request.TextDocument.Uri
            };

            var resolutionParams = new RazorCodeActionResolutionParams()
            {
                Action   = action,
                Language = LanguageServerConstants.CodeActions.Languages.CSharp,
                Data     = csharpParams
            };

            razorCodeAction = razorCodeAction with {
                Data = JToken.FromObject(resolutionParams)
            };

            if (razorCodeAction.Children != null)
            {
                for (var i = 0; i < razorCodeAction.Children.Length; i++)
                {
                    razorCodeAction.Children[i] = razorCodeAction.Children[i].WrapResolvableCSharpCodeAction(context, action);
                }
            }

            return(razorCodeAction);
        }
    }