302
340
if ((cls.Kind == TypeKind.Class && !cls.IsSealed) || cls.Kind == TypeKind.Interface) {
303
341
ainfo.Add (cls.Kind != TypeKind.Interface ? GettextCatalog.GetString ("Find _derived classes") : GettextCatalog.GetString ("Find _implementor classes"), new System.Action (new FindDerivedClasses (cls).Run));
305
// if (baseConstructor != null) {
306
// Refactorer refactorer2 = new Refactorer (ctx, pinfo, baseConstructor.DeclaringType, baseConstructor, null);
307
// ainfo.Add (GettextCatalog.GetString ("Go to _base"), new RefactoryOperation (refactorer2.GoToBase));
315
if (resolveResult != null) {
316
// List<string> namespaces = QuickFixHandler.GetResolveableNamespaces (options, out resolveDirect);
318
// if (item == null || namespaces.Count > 1) {
319
// if (item == null) {
320
// foreach (string ns in namespaces) {
321
// // remove used namespaces for conflict resolving.
322
// if (options.Document.CompilationUnit.IsNamespaceUsedAt (ns, options.ResolveResult.ResolvedExpression.Region.Start))
324
// CommandInfo info = resolveMenu.CommandInfos.Add ("using " + ns + ";", new RefactoryOperation (new ResolveNameOperation (ctx, doc, resolveResult, ns).AddImport));
325
// info.Icon = MonoDevelop.Ide.Gui.Stock.AddNamespace;
327
// // remove all unused namespaces (for resolving conflicts)
328
// namespaces.RemoveAll (ns => !doc.CompilationUnit.IsNamespaceUsedAt (ns, resolveResult.ResolvedExpression.Region.Start));
331
// if (namespaces.Count > (item == null ? 0 : 1))
332
// ainfo.Add (resolveMenu, null);
338
// if (cls.GetSourceProject () != null && includeModifyCommands && ((cls.ClassType == ClassType.Class) || (cls.ClassType == ClassType.Struct))) {
339
// ciset.CommandInfos.Add (GettextCatalog.GetString ("_Encapsulate Fields..."), new RefactoryOperation (refactorer.EncapsulateField));
340
// ciset.CommandInfos.Add (GettextCatalog.GetString ("Override/Implement members..."), new RefactoryOperation (refactorer.OverrideOrImplementMembers));
343
// ainfo.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindReferences), new RefactoryOperation (refactorer.FindReferences));
345
// if (canRename && cls.ClassType == ClassType.Interface && eclass != null) {
346
// // is now provided by the refactoring command infrastructure:
347
//// ciset.CommandInfos.Add (GettextCatalog.GetString ("Implement Interface (explicit)"), new RefactoryOperation (refactorer.ImplementExplicitInterface));
348
//// ciset.CommandInfos.Add (GettextCatalog.GetString ("Implement Interface (implicit)"), new RefactoryOperation (refactorer.ImplementImplicitInterface));
349
// } else if (canRename && includeModifyCommands && cls.BaseType != null && cls.ClassType != ClassType.Interface && cls == eclass) {
350
// // Class might have interfaces... offer to implement them
351
// CommandInfoSet impset = new CommandInfoSet ();
352
// CommandInfoSet expset = new CommandInfoSet ();
353
// CommandInfoSet abstactset = new CommandInfoSet ();
354
// bool ifaceAdded = false;
355
// bool abstractAdded = false;
357
// foreach (IReturnType rt in cls.BaseTypes) {
358
// IType iface = ctx.GetType (rt);
359
// if (iface == null)
361
// if (iface.ClassType == ClassType.Interface) {
362
// Refactorer ifaceRefactorer = new Refactorer (ctx, pinfo, cls, iface, rt);
363
// impset.CommandInfos.Add (ambience.GetString (rt, OutputFlags.IncludeGenerics), new RefactoryOperation (ifaceRefactorer.ImplementImplicitInterface));
364
// expset.CommandInfos.Add (ambience.GetString (rt, OutputFlags.IncludeGenerics), new RefactoryOperation (ifaceRefactorer.ImplementExplicitInterface));
365
// ifaceAdded = true;
366
// } else if (ContainsAbstractMembers (iface)) {
367
// Refactorer ifaceRefactorer = new Refactorer (ctx, pinfo, cls, iface, rt);
368
// abstactset.CommandInfos.Add (ambience.GetString (rt, OutputFlags.IncludeGenerics), new RefactoryOperation (ifaceRefactorer.ImplementAbstractMembers));
369
// abstractAdded = true;
374
// impset.Text = GettextCatalog.GetString ("Implement Interface (implicit)");
375
// ciset.CommandInfos.Add (impset, null);
377
// expset.Text = GettextCatalog.GetString ("Implement Interface (explicit)");
378
// ciset.CommandInfos.Add (expset, null);
380
// if (abstractAdded) {
381
// abstactset.Text = GettextCatalog.GetString ("Implement abstract members");
382
// ciset.CommandInfos.Add (abstactset, null);
388
// IMember eitem = resolveResult != null ? (resolveResult.CallingMember ?? resolveResult.CallingType) : null;
390
// string itemName = null;
391
// if (item is IMember)
392
// itemName = ((IMember)item).Name;
394
// if (item != null && eitem != null && (eitem.Equals (item) || (eitem.Name == itemName && !(eitem is IProperty) && !(eitem is IMethod)))) {
395
// // If this occurs, then @item is either its own enclosing item, in
396
// // which case, we don't want to show it twice, or it is the base-class
397
// // version of @eitem, in which case we don't want to show the base-class
398
// // @item, we'd rather show the item the user /actually/ requested, @eitem.
403
// IType eclass = null;
405
// if (item is IType) {
406
// if (((IType)item).ClassType == ClassType.Interface)
407
// eclass = FindEnclosingClass (ctx, editor.Name, line, column); else
408
// eclass = (IType)item;
409
// if (eitem is IMethod && ((IMethod)eitem).IsConstructor && eitem.DeclaringType.Equals (item)) {
415
// INode realItem = item;
416
// if (item is InstantiatedType)
417
// realItem = ((InstantiatedType)item).UninstantiatedType;
418
// if (realItem is CompoundType) {
419
// editor.GetLineColumnFromPosition (editor.CursorPosition, out line, out column);
420
// ((CompoundType)realItem).SetMainPart (doc.FileName, line, column);
426
// var unit = doc.CompilationUnit;
427
// if (unit != null && unit.Usings != null && unit.Usings.Any (u => !u.IsFromNamespace && u.Region.Contains (line, column))) {
428
// CommandInfoSet organizeUsingsMenu = new CommandInfoSet ();
429
// organizeUsingsMenu.Text = GettextCatalog.GetString ("_Organize Usings");
430
// organizeUsingsMenu.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.RemoveUnusedImports), new RefactoryOperation (delegate {
431
// new RemoveUnusedImportsHandler ().Start (options);
433
// organizeUsingsMenu.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (MonoDevelop.Refactoring.RefactoryCommands.SortImports), new RefactoryOperation (delegate {
434
// new SortImportsHandler ().Start (options);
436
// organizeUsingsMenu.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (MonoDevelop.Refactoring.RefactoryCommands.RemoveSortImports), new RefactoryOperation (delegate {
437
// new RemoveSortImportsHandler ().Start (options);
439
// ainfo.Add (organizeUsingsMenu, null);
443
// IParsedFile pinfo = doc.CompilationUnit;
444
// if (pinfo == null)
448
// Refactorer refactorer = new Refactorer (ctx, pinfo, eclass, realItem, null);
449
// Ambience ambience = AmbienceService.GetAmbienceForFile (pinfo.FileName);
450
// bool includeModifyCommands = this.IsModifiable (item);
453
// // case: clicked on base in "constructor" - so pointing to the base constructor using argument count
454
// // not 100% correct, but it's the fastest thing to do.
455
// if (resolveResult is BaseResolveResult && eitem is IMethod && ((IMethod)eitem).IsConstructor) {
456
// IType type = item as IType;
457
// IMethod baseConstructor = null;
458
// int idx1 = resolveResult.ResolvedExpression.Expression.IndexOf ('(');
459
// int idx2 = resolveResult.ResolvedExpression.Expression.IndexOf (')');
460
// int paramCount = 0;
461
// if (idx1 > 0 && idx2 > 0) {
462
// if (idx2 - idx1 > 1)
464
// for (int i=idx1; i < idx2; i++) {
465
// if (resolveResult.ResolvedExpression.Expression[i] == ',')
469
// foreach (IMethod m in type.Methods) {
470
// if (m.IsConstructor && m.Parameters.Count == paramCount)
471
// baseConstructor = m;
473
// Refactorer refactorer2 = new Refactorer (ctx, pinfo, baseConstructor.DeclaringType, baseConstructor, null);
474
// ainfo.Add (GettextCatalog.GetString ("Go to _base"), new RefactoryOperation (refactorer2.GoToBase));
477
// else if (item is IField) {
478
// if (includeModifyCommands) {
480
// ciset.CommandInfos.Add (GettextCatalog.GetString ("_Encapsulate Field..."), new RefactoryOperation (refactorer.EncapsulateField));
485
346
ainfo.AddSeparator ();
487
while (item != null) {
490
// case: clicked on base in "constructor" - so pointing to the base constructor using argument count
491
// not 100% correct, but it's the fastest thing to do.
492
if (resolveResult is BaseResolveResult && eitem is IMethod && ((IMethod)eitem).IsConstructor) {
493
IType type = item as IType;
494
IMethod baseConstructor = null;
495
int idx1 = resolveResult.ResolvedExpression.Expression.IndexOf ('(');
496
int idx2 = resolveResult.ResolvedExpression.Expression.IndexOf (')');
498
if (idx1 > 0 && idx2 > 0) {
501
for (int i=idx1; i < idx2; i++) {
502
if (resolveResult.ResolvedExpression.Expression[i] == ',')
506
foreach (IMethod m in type.Methods) {
507
if (m.IsConstructor && m.Parameters.Count == paramCount)
510
if (baseConstructor != null && (ci = BuildRefactoryMenuForItem (ctx, doc.CompilationUnit, null, baseConstructor, true)) != null) {
511
ainfo.Add (ci, null);
516
// Add the selected item
517
if ((ci = BuildRefactoryMenuForItem (ctx, doc.CompilationUnit, eclass, item, IsModifiable (item))) != null) {
518
ainfo.Add (ci, null);
521
if (item is IParameter) {
522
// Add the encompasing method for the previous item in the menu
523
item = ((IParameter) item).DeclaringMember;
524
if (item != null && (ci = BuildRefactoryMenuForItem (ctx, doc.CompilationUnit, null, item, true)) != null) {
525
ainfo.Add (ci, null);
531
if (item is IMember && !(eitem != null && eitem is IMember)) {
532
// Add the encompasing class for the previous item in the menu
533
item = ((IMember) item).DeclaringType;
534
if (item != null && (ci = BuildRefactoryMenuForItem (ctx, doc.CompilationUnit, null, item, IsModifiable (item))) != null) {
535
ainfo.Add (ci, null);
546
ainfo.AddSeparator ();*/
660
386
return "..." + fileName.Substring (idx);
664
CommandInfo BuildRefactoryMenuForItem (ITypeResolveContext ctx, IParsedFile pinfo, IType eclass, INode item, bool includeModifyCommands)
666
INode realItem = item;
667
if (item is InstantiatedType)
668
realItem = ((InstantiatedType)item).UninstantiatedType;
669
Document doc = IdeApp.Workbench.ActiveDocument;
670
ITextBuffer editor = doc.GetContent<ITextBuffer> ();
672
if (realItem is CompoundType) {
674
editor.GetLineColumnFromPosition (editor.CursorPosition, out line, out column);
675
((CompoundType)realItem).SetMainPart (doc.FileName, line, column);
679
Refactorer refactorer = new Refactorer (ctx, pinfo, eclass, realItem, null);
680
CommandInfoSet ciset = new CommandInfoSet ();
681
Ambience ambience = AmbienceService.GetAmbienceForFile (pinfo.FileName);
682
OutputFlags flags = OutputFlags.IncludeMarkup;
683
if (item is IParameter) {
684
flags |= OutputFlags.IncludeParameterName;
686
flags |= OutputFlags.IncludeParameters;
689
string itemName = EscapeName (ambience.GetString (item, flags));
690
bool canRename = false;
692
if (IdeApp.ProjectOperations.CanJumpToDeclaration (item)) {
693
if (item is CompoundType) {
694
CommandInfoSet declSet = new CommandInfoSet ();
695
declSet.Text = GettextCatalog.GetString ("_Go to declaration");
696
CompoundType ct = (CompoundType)item;
697
foreach (IType part in ct.Parts) {
698
Refactorer partRefactorer = new Refactorer (ctx, pinfo, eclass, part, null);
699
declSet.CommandInfos.Add (string.Format (GettextCatalog.GetString ("{0}, Line {1}"), FormatFileName (part.GetDefinition ().Region.FileName), part.Location.Line), new RefactoryOperation (partRefactorer.GoToDeclaration));
701
ciset.CommandInfos.Add (declSet);
703
ciset.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.GotoDeclaration), new RefactoryOperation (refactorer.GoToDeclaration));
708
if ((item is IMember || item is LocalVariable || item is IParameter) && !(item is IType))
709
ciset.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindReferences), new RefactoryOperation (refactorer.FindReferences));
711
// We can rename local variables (always), method params (always),
712
// or class/members (if they belong to a project)
713
if ((item is LocalVariable) || (item is IParameter)) {
715
} else if (item is IType) {
716
canRename = ((IType)item).GetSourceProject () != null;
717
} else if (item is IMember) {
718
IType cls = ((IMember)item).DeclaringType;
719
canRename = cls != null && cls.GetSourceProject () != null;
722
RefactoringOptions options = new RefactoringOptions () {
725
ResolveResult = null,
726
SelectedItem = item is InstantiatedType ? ((InstantiatedType)item).UninstantiatedType : item
728
foreach (var refactoring in RefactoringService.Refactorings) {
729
if (refactoring.IsValid (options)) {
730
CommandInfo info = new CommandInfo (refactoring.GetMenuDescription (options));
731
info.AccelKey = refactoring.AccelKey;
732
ciset.CommandInfos.Add (info, new RefactoryOperation (new RefactoringOperationWrapper (refactoring, options).Operation));
736
// if (canRename && !(item is IType)) {
737
// // Defer adding this item for Classes until later
738
// ciset.CommandInfos.Add (GettextCatalog.GetString ("_Rename"), new RefactoryOperation (refactorer.Rename));
741
IType cls = (IType) item;
743
if (cls.ClassType == ClassType.Enum)
744
txt = GettextCatalog.GetString ("Enum <b>{0}</b>", itemName);
745
else if (cls.ClassType == ClassType.Struct)
746
txt = GettextCatalog.GetString ("Struct <b>{0}</b>", itemName);
747
else if (cls.ClassType == ClassType.Interface)
748
txt = GettextCatalog.GetString ("Interface <b>{0}</b>", itemName);
749
else if (cls.ClassType == ClassType.Delegate)
750
txt = GettextCatalog.GetString ("Delegate <b>{0}</b>", itemName);
752
txt = GettextCatalog.GetString ("Class <b>{0}</b>", itemName);
754
if (cls.BaseType != null && cls.ClassType == ClassType.Class) {
755
foreach (IReturnType rt in cls.BaseTypes) {
756
IType bc = ctx.GetType (rt);
757
if (bc != null && bc.ClassType != ClassType.Interface) {
758
ciset.CommandInfos.Add (GettextCatalog.GetString ("Go to _base"), new RefactoryOperation (refactorer.GoToBase));
764
if ((cls.ClassType == ClassType.Class && !cls.IsSealed) || cls.ClassType == ClassType.Interface) {
765
ciset.CommandInfos.Add (cls.ClassType != ClassType.Interface ? GettextCatalog.GetString ("Find _derived classes") : GettextCatalog.GetString ("Find _implementor classes"), new RefactoryOperation (refactorer.FindDerivedClasses));
768
if (cls.GetSourceProject () != null && includeModifyCommands && ((cls.ClassType == ClassType.Class) || (cls.ClassType == ClassType.Struct))) {
769
ciset.CommandInfos.Add (GettextCatalog.GetString ("_Encapsulate Fields..."), new RefactoryOperation (refactorer.EncapsulateField));
770
ciset.CommandInfos.Add (GettextCatalog.GetString ("Override/Implement members..."), new RefactoryOperation (refactorer.OverrideOrImplementMembers));
773
ciset.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindReferences), new RefactoryOperation (refactorer.FindReferences));
776
// ciset.CommandInfos.Add (GettextCatalog.GetString ("_Rename"), new RefactoryOperation (refactorer.Rename));
778
if (canRename && cls.ClassType == ClassType.Interface && eclass != null) {
779
// An interface is selected, so just need to provide these 2 submenu items
780
ciset.CommandInfos.Add (GettextCatalog.GetString ("Implement Interface (implicit)"), new RefactoryOperation (refactorer.ImplementImplicitInterface));
781
ciset.CommandInfos.Add (GettextCatalog.GetString ("Implement Interface (explicit)"), new RefactoryOperation (refactorer.ImplementExplicitInterface));
782
} else if (canRename && includeModifyCommands && cls.BaseType != null && cls.ClassType != ClassType.Interface && cls == eclass) {
783
// Class might have interfaces... offer to implement them
784
CommandInfoSet impset = new CommandInfoSet ();
785
CommandInfoSet expset = new CommandInfoSet ();
786
CommandInfoSet abstactset = new CommandInfoSet ();
787
bool ifaceAdded = false;
788
bool abstractAdded = false;
790
foreach (IReturnType rt in cls.BaseTypes) {
791
IType iface = ctx.GetType (rt);
794
if (iface.ClassType == ClassType.Interface) {
795
Refactorer ifaceRefactorer = new Refactorer (ctx, pinfo, cls, iface, rt);
796
impset.CommandInfos.Add (ambience.GetString (rt, OutputFlags.IncludeGenerics), new RefactoryOperation (ifaceRefactorer.ImplementImplicitInterface));
797
expset.CommandInfos.Add (ambience.GetString (rt, OutputFlags.IncludeGenerics), new RefactoryOperation (ifaceRefactorer.ImplementExplicitInterface));
799
} else if (ContainsAbstractMembers (iface)) {
800
Refactorer ifaceRefactorer = new Refactorer (ctx, pinfo, cls, iface, rt);
801
abstactset.CommandInfos.Add (ambience.GetString (rt, OutputFlags.IncludeGenerics), new RefactoryOperation (ifaceRefactorer.ImplementAbstractMembers));
802
abstractAdded = true;
807
impset.Text = GettextCatalog.GetString ("Implement Interface (implicit)");
808
ciset.CommandInfos.Add (impset, null);
810
expset.Text = GettextCatalog.GetString ("Implement Interface (explicit)");
811
ciset.CommandInfos.Add (expset, null);
814
abstactset.Text = GettextCatalog.GetString ("Implement abstract members");
815
ciset.CommandInfos.Add (abstactset, null);
818
} else if (item is IField) {
819
txt = GettextCatalog.GetString ("Field <b>{0}</b>", itemName);
820
if (includeModifyCommands) {
822
ciset.CommandInfos.Add (GettextCatalog.GetString ("_Encapsulate Field..."), new RefactoryOperation (refactorer.EncapsulateField));
823
AddRefactoryMenuForClass (ctx, pinfo, ciset, ((IField) item).ReturnType.FullName);
825
} else if (item is IProperty) {
826
if (((IProperty)item).IsIndexer) {
827
txt = GettextCatalog.GetString ("Indexer <b>{0}</b>", itemName);
829
txt = GettextCatalog.GetString ("Property <b>{0}</b>", itemName);
831
AddRefactoryMenuForClass (ctx, pinfo, ciset, ((IProperty) item).ReturnType.FullName);
832
} else if (item is IEvent) {
833
txt = GettextCatalog.GetString ("Event <b>{0}</b>", itemName);
834
} else if (item is IMethod) {
835
IMethod method = item as IMethod;
837
if (method.IsConstructor) {
838
txt = GettextCatalog.GetString ("Constructor <b>{0}</b>", EscapeName (method.DeclaringType.Name));
840
txt = GettextCatalog.GetString ("Method <b>{0}</b>", itemName);
841
if (method.IsOverride)
842
ciset.CommandInfos.Add (GettextCatalog.GetString ("Go to _base"), new RefactoryOperation (refactorer.GoToBase));
844
} else if (item is IParameter) {
845
txt = GettextCatalog.GetString ("Parameter <b>{0}</b>", itemName);
846
AddRefactoryMenuForClass (ctx, pinfo, ciset, ((IParameter) item).ReturnType.FullName);
847
} else if (item is LocalVariable) {
848
LocalVariable var = (LocalVariable) item;
849
AddRefactoryMenuForClass (ctx, pinfo, ciset, var.ReturnType.FullName);
850
txt = GettextCatalog.GetString ("Variable <b>{0}</b>", itemName);
856
ciset.UseMarkup = true;
861
390
public static bool ContainsAbstractMembers (IType cls)
865
394
return cls.GetMembers ().Any (m => m.IsAbstract);
868
/* void AddRefactoryMenuForClass (ITypeResolveContext ctx, IParsedFile pinfo, CommandInfoSet ciset, string className)
870
IType cls = ctx.GetType (className, null, true, true);
872
CommandInfo ci = BuildRefactoryMenuForItem (ctx, pinfo, null, cls, false);
874
ciset.CommandInfos.Add (ci, null);
880
public class Refactorer
882
ISearchProgressMonitor monitor;
883
ICompilationUnit pinfo;
887
IReturnType hintReturnType;
889
public Refactorer (ProjectDom ctx, ICompilationUnit pinfo, IType klass, INode item, IReturnType hintReturnType)
895
this.hintReturnType = hintReturnType;
898
public void GoToDeclaration ()
900
IdeApp.ProjectOperations.JumpToDeclaration (item, true);
903
public void FindReferences ()
905
monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true, true);
906
ThreadPool.QueueUserWorkItem (FindReferencesThread);
909
void FindReferencesThread (object state)
912
foreach (MemberReference mref in ReferenceFinder.FindReferences (IdeApp.ProjectOperations.CurrentSelectedSolution, item, monitor)) {
913
monitor.ReportResult (new MonoDevelop.Ide.FindInFiles.SearchResult (new FileProvider (mref.FileName), mref.Position, mref.Name.Length));
915
} catch (Exception ex) {
917
monitor.ReportError ("Error finding references", ex);
919
LoggingService.LogError ("Error finding references", ex);
926
public void GoToBase ()
928
IType cls = item as IType;
929
if (cls != null && cls.BaseTypes != null) {
930
foreach (IReturnType bc in cls.BaseTypes) {
931
IType bcls = ctx.GetType (bc);
932
if (bcls != null && bcls.ClassType != ClassType.Interface && !bcls.Location.IsEmpty) {
933
IdeApp.Workbench.OpenDocument (bcls.CompilationUnit.FileName, bcls.Location.Line, bcls.Location.Column);
939
IMethod method = item as IMethod;
940
if (method != null) {
941
foreach (IReturnType bc in method.DeclaringType.BaseTypes) {
942
IType bcls = ctx.GetType (bc);
943
if (bcls != null && bcls.ClassType != ClassType.Interface && !bcls.Location.IsEmpty) {
944
IMethod baseMethod = null;
945
foreach (IMethod m in bcls.Methods) {
946
if (m.Name == method.Name && m.Parameters.Count == m.Parameters.Count) {
951
if (baseMethod != null)
952
IdeApp.Workbench.OpenDocument (bcls.CompilationUnit.FileName, baseMethod.Location.Line, baseMethod.Location.Column);
960
public void FindDerivedClasses ()
962
ThreadPool.QueueUserWorkItem (FindDerivedThread);
965
void FindDerivedThread (object state)
967
monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor (true, true);
969
IType cls = (IType) item;
970
if (cls == null) return;
972
CodeRefactorer cr = IdeApp.Workspace.GetCodeRefactorer (IdeApp.ProjectOperations.CurrentSelectedSolution);
973
foreach (IType sub in cr.FindDerivedClasses (cls)) {
974
if (!sub.Location.IsEmpty) {
975
IEditableTextFile textFile = cr.TextFileProvider.GetEditableTextFile (sub.CompilationUnit.FileName);
976
if (textFile == null)
977
textFile = new TextFile (sub.CompilationUnit.FileName);
978
int position = textFile.GetPositionFromLineColumn (sub.Location.Line, sub.Location.Column);
979
monitor.ReportResult (new MonoDevelop.Ide.FindInFiles.SearchResult (new FileProvider (sub.CompilationUnit.FileName, sub.SourceProject as Project), position, 0));
985
void ImplementInterface (bool explicitly)
987
var doc = IdeApp.Workbench.ActiveDocument;
988
var editor = doc.Editor.Parent;
989
IType interfaceType = item as IType;
990
IType declaringType = klass;
992
var mode = new Mono.TextEditor.InsertionCursorEditMode (editor, CodeGenerationService.GetInsertionPoints (doc, declaringType));
993
var helpWindow = new Mono.TextEditor.PopupWindow.ModeHelpWindow ();
994
helpWindow.TransientFor = IdeApp.Workbench.RootWindow;
995
helpWindow.TitleText = GettextCatalog.GetString ("<b>Implement Interface -- Targeting</b>");
996
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Key</b>"), GettextCatalog.GetString ("<b>Behavior</b>")));
997
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Up</b>"), GettextCatalog.GetString ("Move to <b>previous</b> target point.")));
998
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Down</b>"), GettextCatalog.GetString ("Move to <b>next</b> target point.")));
999
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Enter</b>"), GettextCatalog.GetString ("<b>Declare interface implementation</b> at target point.")));
1000
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Esc</b>"), GettextCatalog.GetString ("<b>Cancel</b> this refactoring.")));
1001
mode.HelpWindow = helpWindow;
1002
mode.CurIndex = mode.InsertionPoints.Count - 1;
1004
mode.Exited += delegate(object s, Mono.TextEditor.InsertionCursorEventArgs args) {
1006
var generator = doc.CreateCodeGenerator ();
1007
args.InsertionPoint.Insert (doc.Editor, generator.CreateInterfaceImplementation (declaringType, interfaceType, explicitly));
1012
public void ImplementImplicitInterface ()
1014
ImplementInterface (false);
1017
public void ImplementExplicitInterface ()
1019
ImplementInterface (true);
1022
public void ImplementAbstractMembers ()
1024
var doc = IdeApp.Workbench.ActiveDocument;
1025
IType interfaceType = item as IType;
1026
MonoDevelop.Refactoring.ImplementInterface.ImplementAbstractMembers.Implement (doc, interfaceType);
1029
public void EncapsulateField ()
1031
EncapsulateFieldDialog dialog;
1032
if (item is IField) {
1033
dialog = new EncapsulateFieldDialog (IdeApp.Workbench.ActiveDocument, ctx, (IField) item);
1035
dialog = new EncapsulateFieldDialog (IdeApp.Workbench.ActiveDocument, ctx, (IType) item);
1037
MessageService.ShowCustomDialog (dialog);
1040
public void OverrideOrImplementMembers ()
1042
MessageService.ShowCustomDialog (new OverridesImplementsDialog (IdeApp.Workbench.ActiveDocument, (IType)item));
1045
public void Rename ()
1047
// RenameItemDialog dialog = new RenameItemDialog (ctx, item);