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;
		}
		protected override void Initialize ()
		{
			base.Initialize ();
			IStateMachineIndentEngine indentEngine;
			indentEngine = new JSonIndentEngine (Editor, DocumentContext);
			stateTracker = new CacheIndentEngine (indentEngine);
			Editor.SetIndentationTracker (new JSonIndentationTracker (Editor, stateTracker));
		}
예제 #3
0
        protected override void Initialize()
        {
            base.Initialize();
            IStateMachineIndentEngine indentEngine;

            indentEngine = new JSonIndentEngine(Editor, DocumentContext);
            stateTracker = new CacheIndentEngine(indentEngine);
            Editor.SetIndentationTracker(new JSonIndentationTracker(Editor, stateTracker));
        }
예제 #4
0
 JSonIndentEngine(JSonIndentEngine jSonIndentEngine)
 {
     this.editor         = jSonIndentEngine.editor;
     this.offset         = jSonIndentEngine.offset;
     this.line           = jSonIndentEngine.line;
     this.column         = jSonIndentEngine.column;
     this.thisLineIndent = jSonIndentEngine.thisLineIndent;
     this.nextLineIndent = jSonIndentEngine.nextLineIndent;
     this.currentIndent  = jSonIndentEngine.currentIndent != null ? new StringBuilder(jSonIndentEngine.currentIndent.ToString()) : null;
     this.previousChar   = jSonIndentEngine.previousChar;
     this.isLineStart    = jSonIndentEngine.isLineStart;
     this.isInString     = jSonIndentEngine.isInString;
 }
예제 #5
0
		JSonIndentEngine (JSonIndentEngine jSonIndentEngine)
		{
			this.editor = jSonIndentEngine.editor;
			this.ctx = jSonIndentEngine.ctx;
			this.offset = jSonIndentEngine.offset;
			this.line = jSonIndentEngine.line;
			this.column = jSonIndentEngine.column;
			this.thisLineIndent = jSonIndentEngine.thisLineIndent.Clone ();
			this.nextLineIndent = jSonIndentEngine.nextLineIndent.Clone ();
			this.currentIndent = jSonIndentEngine.currentIndent != null ? new StringBuilder (jSonIndentEngine.currentIndent.ToString ()) : null;
			this.previousChar = jSonIndentEngine.previousChar;
			this.isLineStart = jSonIndentEngine.isLineStart;
			this.isInString = jSonIndentEngine.isInString;
		}
예제 #6
0
        protected override void Initialize()
        {
            base.Initialize();

            // This extension needs to be turned off if the webtooling addin json extension is present.
            //   That addin defines a "text/x-json" mimeType that has multiple levels of inheritance.
            var mimeChain = IdeServices.DesktopService.GetMimeTypeInheritanceChain("text/x-json").ToList();

            jsonExtensionInstalled = (mimeChain.Count > 2);

            if (!jsonExtensionInstalled)
            {
                IStateMachineIndentEngine indentEngine;
                indentEngine = new JSonIndentEngine(Editor);
                stateTracker = new CacheIndentEngine(indentEngine);
                Editor.IndentationTracker = new JSonIndentationTracker(Editor, stateTracker);
            }
        }