ShaderTools.Hlsl.Formatting.Formatter.GetEditsAfterKeystroke C# (CSharp) Method

GetEditsAfterKeystroke() public static method

public static GetEditsAfterKeystroke ( SyntaxTree syntaxTree, int position, char character, FormattingOptions options ) : IList
syntaxTree ShaderTools.Hlsl.Syntax.SyntaxTree
position int
character char
options FormattingOptions
return IList
        public static IList<Edit> GetEditsAfterKeystroke(SyntaxTree syntaxTree, int position, char character, FormattingOptions options)
        {
            var location = syntaxTree.MapRootFilePosition(position);

            // Find span of block / statement terminated by the character just typed.
            var token = syntaxTree.Root.FindTokenOnLeft(location);
            if (token.Text != character.ToString())
                return new List<Edit>();

            // Get span of node containing this token.
            var span = token.Parent.GetTextSpanRoot();
            if (span == TextSpan.None)
                return new List<Edit>();

            return GetEdits(syntaxTree, span, options);
        }