public static IDocumentIndentEngine CreateEngine(string text) { var sb = new StringBuilder(); int offset = 0; for (int i = 0; i < text.Length; i++) { var ch = text [i]; if (ch == '$') { offset = i; continue; } sb.Append(ch); } var data = new TextEditorData(); data.Text = sb.ToString(); var csi = new JSonIndentEngine(data); var result = new CacheIndentEngine(csi); result.Update(offset); return(result); }
public static IDocumentIndentEngine CreateEngine(string text) { var sb = new StringBuilder(); int offset = 0; for (int i = 0; i < text.Length; i++) { var ch = text [i]; if (ch == '$') { offset = i; continue; } sb.Append(ch); } var tww = new TestWorkbenchWindow(); var content = new TestViewContent(); tww.ViewContent = content; content.ContentName = "/a.json"; content.Data.MimeType = "application/json"; content.Data.Text = sb.ToString(); var doc = new MonoDevelop.Ide.Gui.Document(tww); var csi = new JSonIndentEngine(content.Data, doc); var result = new CacheIndentEngine(csi); result.Update(content.Data, offset); return(result); }
public static async Task <TestCase> Create(string text, bool tabsToSpaces = false) { var test = new TestCase(); var sb = new StringBuilder(); int offset = 0; for (int i = 0; i < text.Length; i++) { var ch = text [i]; if (ch == '$') { offset = i; continue; } sb.Append(ch); } var content = new TestViewContent(); await content.Initialize(new FileDescriptor ("/a.json", null, null)); content.Editor.MimeType = "application/json"; content.Editor.Text = sb.ToString(); test.testCase = await TextEditorExtensionTestCase.Create(content, null, false); test.testCase.Document.Editor.Options = new CustomEditorOptions { TabsToSpaces = tabsToSpaces, TabSize = 4 }; var csi = new JSonIndentEngine(content.Editor); var result = new CacheIndentEngine(csi); result.Update(content.Editor, offset); test.Engine = result; return(test); }