public override bool IsValid (RefactoringOptions options) { // if (options.SelectedItem != null) // return false; var buffer = options.Document.Editor; if (buffer.IsSomethingSelected) { ParsedDocument doc = options.ParseDocument (); if (doc != null && doc.CompilationUnit != null) { if (doc.CompilationUnit.GetMemberAt (buffer.Caret.Line, buffer.Caret.Column) == null) return false; return true; } } return false; }
public override bool IsValid (RefactoringOptions options) { // if (options.SelectedItem != null) // return false; var buffer = options.Document.Editor; if (buffer.Document.MimeType != CSharpFormatter.MimeType) return false; if (buffer.IsSomethingSelected) { ParsedDocument doc = options.ParseDocument (); if (doc != null && doc.CompilationUnit != null) { var member = doc.CompilationUnit.GetMemberAt (buffer.Caret.Line, buffer.Caret.Column); if (member == null) return false; if (!member.BodyRegion.Contains (buffer.Caret.Line, buffer.Caret.Column)) return false; return true; } } return false; }
public ExtractMethodParameters CreateParameters (RefactoringOptions options) { var buffer = options.Document.Editor; if (!buffer.IsSomethingSelected) return null; ParsedDocument doc = options.ParseDocument (); if (doc == null || doc.CompilationUnit == null) return null; IMember member = doc.CompilationUnit.GetMemberAt (buffer.Caret.Line, buffer.Caret.Column); if (member == null) return null; ExtractMethodParameters param = new ExtractMethodParameters () { DeclaringMember = member, Location = new DomLocation (buffer.Caret.Line, buffer.Caret.Column) }; Analyze (options, param, true); return param; }