public static Edit[] GetEditsAfterKeystroke(string code, int position, char ch, FormattingOptions options = null) {
     using (new DebugTimer("FormatKeyStroke")) {
         if (ch == ';' || ch == '}') {
             var ast = new JSParser(code).Parse(new CodeSettings() { AllowShebangLine = true });
             var visitor = new RangeVisitor(ch, position, ast);
             ast.Walk(visitor);
             if (visitor.Span != default(IndexSpan)) {
                 return FilterRange(
                     visitor.Span.Start,
                     visitor.Span.End,
                     GetEdits(code, options, ast)
                 );
             }
         }
         return new Edit[0];
     }
 }
示例#2
0
 public static Edit[] GetEditsAfterKeystroke(string code, int position, char ch, FormattingOptions options = null)
 {
     using (new DebugTimer("FormatKeyStroke")) {
         if (ch == ';' || ch == '}')
         {
             var ast = new JSParser(code).Parse(new CodeSettings()
             {
                 AllowShebangLine = true
             });
             var visitor = new RangeVisitor(ch, position, ast);
             ast.Walk(visitor);
             if (visitor.Span != default(IndexSpan))
             {
                 return(FilterRange(
                            visitor.Span.Start,
                            visitor.Span.End,
                            GetEdits(code, options, ast)
                            ));
             }
         }
         return(new Edit[0]);
     }
 }