public int Format(TextDocument textDocument, uint offset, uint length, int cursor)
        {
            var replacements = ClangFormat.FormatXml(textDocument.Text, offset, length, (uint)cursor,
                                                     ClangFormatSettings.Default);

            return(ApplyReplacements(textDocument, cursor, replacements));
        }
Ejemplo n.º 2
0
        public int Format(TextDocument textDocument, uint offset, uint length, int cursor)
        {
            bool replaceCursor = cursor >= 0 ? true : false;

            if (!replaceCursor)
            {
                cursor = 0;
            }

            var replacements = ClangFormat.FormatXml(textDocument.Text, offset, length, (uint)cursor,
                                                     ClangFormatSettings.Default);

            return(ApplyReplacements(textDocument, cursor, replacements, replaceCursor));
        }
        public int Format(IEditor editor, uint offset, uint length, int cursor)
        {
            bool replaceCursor = cursor >= 0 ? true : false;

            if (!replaceCursor)
            {
                cursor = 0;
            }

            var replacements = ClangFormat.FormatXml(editor.SourceFile.Location, editor.Document.Text, offset, length, (uint)cursor);

            if (replacements != null)
            {
                return(ApplyReplacements(editor.Document, cursor, replacements, replaceCursor));
            }

            return(cursor);
        }