// CorrectIndenting is completely unused in the entire MonoDevelopment code environment - doesn't have to be implemented /// <summary> /// Used for formatting selected code /// </summary> public override void OnTheFlyFormat(Ide.Gui.Document _doc, int startOffset, int endOffset) { var doc = _doc.Editor.Document; DFormattingPolicy policy = null; TextStylePolicy textStyle = null; if (_doc.HasProject) { policy = _doc.Project.Policies.Get <DFormattingPolicy>(Indentation.DTextEditorIndentation.mimeTypes); textStyle = _doc.Project.Policies.Get <TextStylePolicy>(Indentation.DTextEditorIndentation.mimeTypes); } else { policy = PolicyService.GetDefaultPolicy <DFormattingPolicy> (Indentation.DTextEditorIndentation.mimeTypes); textStyle = PolicyService.GetDefaultPolicy <TextStylePolicy> (Indentation.DTextEditorIndentation.mimeTypes); } if (IndentCorrectionOnly) { using (doc.OpenUndoGroup()) using (var r = doc.CreateReader()) D_Parser.Formatting.Indent.IndentEngineWrapper.CorrectIndent(r, startOffset, endOffset, doc.Replace, policy.Options, new TextStyleAdapter(textStyle) { KeepAlignmentSpaces = policy.KeepAlignmentSpaces }); return; } var dpd = _doc.ParsedDocument as ParsedDModule; if (dpd == null) { return; } var formattingVisitor = new DFormattingVisitor(policy.Options, new DocAdapt(doc), dpd.DDom, new TextStyleAdapter(textStyle)); formattingVisitor.CheckFormattingBoundaries = true; var dl = doc.OffsetToLocation(startOffset); formattingVisitor.FormattingStartLocation = new CodeLocation(dl.Column, dl.Line); dl = doc.OffsetToLocation(endOffset); formattingVisitor.FormattingEndLocation = new CodeLocation(dl.Column, dl.Line); formattingVisitor.WalkThroughAst(); using (doc.OpenUndoGroup()) formattingVisitor.ApplyChanges(doc.Replace); }
public void Save(DFormattingPolicy p) { if (p == null) { throw new ArgumentNullException("p"); } p.CommentOutStandardHeaders = chk_CommentOutStdHeaders.Active; p.InsertStarAtCommentNewLine = chk_InsertStarAtCommentNewLine.Active; p.KeepAlignmentSpaces = check_KeepAlignmentSpaces.Active; p.IndentPastedCodeLines = check_IndentPastedCodeLines.Active; }