protected override void RemoveFieldDeclaration(ICSharpCode.TextEditor.Document.IDocument document, IField field)
        {
            // In VB, the field region begins at the start of the declaration
            // and ends on the first column of the line following the declaration.
            int startOffset = document.PositionToOffset(new TextLocation(0, field.Region.BeginLine - 1));
            int endOffset   = document.PositionToOffset(new TextLocation(0, field.Region.EndLine - 1));

            document.Remove(startOffset, endOffset - startOffset);
        }
        protected override void ReplaceFieldDeclaration(ICSharpCode.TextEditor.Document.IDocument document, IField oldField, string newFieldDeclaration)
        {
            // In VB, the field region begins at the start of the declaration
            // and ends on the first column of the line following the declaration.
            int startOffset = document.PositionToOffset(new TextLocation(0, oldField.Region.BeginLine - 1));
            int endOffset   = document.PositionToOffset(new TextLocation(0, oldField.Region.EndLine - 1));

            document.Replace(startOffset, endOffset - startOffset, tabs + newFieldDeclaration + Environment.NewLine);
        }
        static TextLocation FindMethodStart(ICSharpCode.TextEditor.Document.IDocument document, DomRegion bodyRegion)
        {
            if (bodyRegion.IsEmpty)
            {
                return(TextLocation.Empty);
            }
            int offset = document.PositionToOffset(new TextLocation(bodyRegion.BeginColumn - 1, bodyRegion.BeginLine - 1));

            while (offset < document.TextLength)
            {
                if (document.GetCharAt(offset) == '{')
                {
                    return(document.OffsetToPosition(offset + 1));
                }
                offset++;
            }
            return(TextLocation.Empty);
        }