public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements) { // build the new method handler var view = _pythonFileNode.GetTextView(); var textBuffer = _pythonFileNode.GetTextBuffer(); PythonAst ast; var classDef = GetClassForEvents(out ast); if (classDef != null) { int end = classDef.Body.EndIndex; // insert after the newline at the end of the last statement of the class def if (textBuffer.CurrentSnapshot[end] == '\r') { if (end + 1 < textBuffer.CurrentSnapshot.Length && textBuffer.CurrentSnapshot[end + 1] == '\n') { end += 2; } else { end++; } } else if (textBuffer.CurrentSnapshot[end] == '\n') { end++; } using (var edit = textBuffer.CreateEdit()) { var text = BuildMethod( eventDescription, methodName, new string(' ', classDef.Body.GetStart(ast).Column - 1), view.Options.IsConvertTabsToSpacesEnabled() ? view.Options.GetIndentSize() : -1); edit.Insert(end, text); edit.Apply(); return(true); } } return(false); }
public override bool CreateMethod(EventDescription eventDescription, string methodName, string initialStatements) { // build the new method handler var view = _pythonFileNode.GetTextView(); var textBuffer = _pythonFileNode.GetTextBuffer(); var classDef = GetClassForEvents(); if (classDef != null) { int end = classDef.Body.EndIndex; using (var edit = textBuffer.CreateEdit()) { var text = BuildMethod( eventDescription, methodName, new string(' ', classDef.Body.Start.Column - 1), view.Options.IsConvertTabsToSpacesEnabled() ? view.Options.GetIndentSize() : -1); edit.Insert(end, text); edit.Apply(); return(true); } } return(false); }