• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Refactoring.RefactoringOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MonoDevelop.Refactoring.RefactoringOptions的典型用法代码示例。如果您正苦于以下问题:C# RefactoringOptions类的具体用法?C# RefactoringOptions怎么用?C# RefactoringOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RefactoringOptions类属于MonoDevelop.Refactoring命名空间,在下文中一共展示了RefactoringOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AnalyzeTargetExpression

		bool AnalyzeTargetExpression (RefactoringOptions options, MonoDevelop.CSharp.Ast.CompilationUnit unit)
		{
			var data = options.GetTextEditorData ();
			var target = unit.GetNodeAt (data.Caret.Line, data.Caret.Column);
			if (target == null)
				return false;
			if (target.Parent is MemberReferenceExpression && ((MemberReferenceExpression)target.Parent).GetChildByRole (MemberReferenceExpression.Roles.Identifier) == target) {
				var memberReference = (MemberReferenceExpression)target.Parent;
				target = memberReference.Target;
				var targetResult = options.GetResolver ().Resolve (new ExpressionResult (data.GetTextBetween (target.StartLocation.Line, target.StartLocation.Column, target.EndLocation.Line, target.EndLocation.Column)), resolvePosition);
				if (targetResult.StaticResolve)
					modifiers = MonoDevelop.Projects.Dom.Modifiers.Static;
				declaringType = options.Dom.GetType (targetResult.ResolvedType);
				methodName = memberReference.MemberName;
			} else if (target is Identifier) {
				declaringType = options.ResolveResult.CallingType;
				methodName = data.GetTextBetween (target.StartLocation.Line, target.StartLocation.Column, target.EndLocation.Line, target.EndLocation.Column);
			}
			
			if (declaringType != null && !HasCompatibleMethod (declaringType, methodName, invocation)) {
				if (declaringType.HasParts)
					declaringType = declaringType.Parts.FirstOrDefault (t => t.CompilationUnit.FileName == options.Document.FileName) ?? declaringType;
				var doc = ProjectDomService.GetParsedDocument (declaringType.SourceProjectDom, declaringType.CompilationUnit.FileName);
				declaringType = doc.CompilationUnit.GetTypeAt (declaringType.Location) ?? declaringType;
				return true;
			}
			return false;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:28,代码来源:CreateMethodCodeGenerator.cs


示例2: GetFixes

		//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded?
		//maybe the item's type's SourceProject is null?
		public IEnumerable<IAnalysisFixAction> GetFixes (MonoDevelop.Ide.Gui.Document doc, object fix)
		{
			var renameFix = (RenameMemberFix) fix;
			var refactoring = new RenameRefactoring ();
			var options = new RefactoringOptions () {
				Document = doc,
				Dom = doc.Dom,
				SelectedItem = renameFix.Item,
			};
			if (!refactoring.IsValid (options))
				yield break;
			
			var prop = new RenameRefactoring.RenameProperties () {
				NewName = renameFix.NewName,
			};
			
			yield return new RenameFixAction () {
				Label = GettextCatalog.GetString ("Rename '{0}' to '{1}'", renameFix.Item.Name, renameFix.NewName),
				Refactoring = refactoring,
				Options = options,
				Properties = prop,
				Preview = false,
			};
				
			yield return new RenameFixAction () {
				Label = GettextCatalog.GetString ("Rename '{0}' to '{1}' with preview",
					renameFix.Item.Name, renameFix.NewName),
				Refactoring = refactoring,
				Options = options,
				Properties = prop,
				Preview = true,
			};
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:35,代码来源:RenameMemberFix.cs


示例3: PerformChanges

        public override List<Change> PerformChanges(RefactoringOptions options, object properties)
        {
            List<Change> changes = new List<Change>();
            var resolveResult = options.ResolveResult;
            if (resolveResult == null) throw new InvalidOperationException("Cannot generate class here");
            var resType = resolveResult.ResolvedType;

            var doc = options.Document;
            var editor = doc.Editor;
            var currentDir = doc.FileName.ParentDirectory;
            var nspace = resType.Namespace;
            string typeName = resolveResult.ResolvedExpression.Expression;
            var body = resType.Type.BodyRegion;
            var content = editor.GetTextBetween(body.Start.Line, 1, body.End.Line, body.End.Column);
            var contentLength = content.Length;
            content = fileFormatResolver.GetNewTypeFileContent(content, nspace, editor.EolMarker);
            CreateFileChange createFileChange = new CreateFileChange(@"{0}\{1}.cs".ToFormat(currentDir, typeName), content);
            changes.Add(createFileChange);

            TextReplaceChange textReplaceChange = new TextReplaceChange();
            textReplaceChange.FileName = context.GetCurrentFilePath();
            textReplaceChange.RemovedChars = contentLength + 1;
            int num = editor.Document.LocationToOffset(body.Start.Line, 1);
            textReplaceChange.Offset = num - 1;
            textReplaceChange.InsertedText = string.Empty;
            changes.Add (textReplaceChange);

            return changes;
        }
开发者ID:felbus,项目名称:Stereo,代码行数:29,代码来源:MoveToAnotherFileRefactoring.cs


示例4: Run

 protected override void Run(RefactoringOptions options)
 {
     RefactoringOperation operation = new CreateIVarOperation ();
     if (operation.IsValid (options)) {
         operation.Run (options);
     }
 }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:7,代码来源:CreateIVarHandler.cs


示例5: DRenameNameDialog

        public DRenameNameDialog(RefactoringOptions options,DRenameRefactoring rename)
        {
            this.rename = rename;
            this.options = options;

            this.Build ();
            var ds = (INode)options.SelectedItem;

            #region Adjust dialog title
            var app = "Renaming ";

            if (ds is DClassLike)
            {
                var dc = (DClassLike)ds;
                app+=dc.ClassType.ToString();
            }
            else if (ds is DMethod)
                app += "method";
            else if (ds is DVariable)
                app += ((DVariable)ds).IsAlias ? "alias" : "variable";
            else
                app += "item";

            Title = app;
            #endregion

            text_NewId.Text = ds.Name;

            buttonPreview.Sensitive = buttonOk.Sensitive = false;

            buttonOk.Clicked += OnOKClicked;
            buttonPreview.Clicked += OnPreviewClicked;
            text_NewId.Changed += delegate { setNotifyIcon(buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName()); };
            ValidateName();
        }
开发者ID:robik,项目名称:Mono-D,代码行数:35,代码来源:DRenameNameDialog.cs


示例6: Run

 protected override void Run(RefactoringOptions options)
 {
     if (renameRefactoring.IsValid (options))
     {
         renameRefactoring.Run (options);
     }
 }
开发者ID:felbus,项目名称:Stereo,代码行数:7,代码来源:RenameNamespaceHandler.cs


示例7: PerformChanges

        public override List<Change> PerformChanges(RefactoringOptions options, object prop)
        {
            #region Init
            var renameProperties = prop as RenameProperties;
            if (renameProperties == null) return null;

            var changes = new List<Change>();

            var doc = options.Document;
            if (doc == null)	return null;

            var ddoc = doc.ParsedDocument as ParsedDModule;
            if (ddoc == null)	return null;

            var n = options.SelectedItem as INode;
            if (n == null) return null;

            var project = doc.HasProject ? doc.Project as DProject : null;

            var parseCache = project != null ?
                project.ParseCache :
                ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache);

            var modules = project == null ?
                (IEnumerable<DModule>)new[] { (Ide.IdeApp.Workbench.ActiveDocument.ParsedDocument as ParsedDModule).DDom } :
                project.LocalFileCache;

            var ctxt = ResolutionContext.Create(parseCache, null,null);
            #endregion

            // Enumerate references
            foreach (var mod in modules)
            {
                if (mod == null)
                    continue;

                var references = D_Parser.Refactoring.ReferencesFinder.Scan(mod, n, ctxt).ToList();

                if (((DModule)n.NodeRoot).FileName == mod.FileName)
                    references.Insert(0, new IdentifierDeclaration(n.Name) { Location = n.NameLocation });

                if (references.Count < 1)
                    continue;

                var txt = TextFileProvider.Instance.GetEditableTextFile(new FilePath(mod.FileName));
                foreach (ISyntaxRegion reference in references)
                {
                    changes.Add(new TextReplaceChange {
                        FileName = mod.FileName,
                        InsertedText = renameProperties.NewName,
                        RemovedChars = n.Name.Length,
                        Description = string.Format (GettextCatalog.GetString ("Replace '{0}' with '{1}'"), n.Name, renameProperties.NewName),
                        Offset = txt.GetPositionFromLineColumn(reference.Location.Line, reference.Location.Column)
                    });
                }
            }

            return changes;
        }
开发者ID:rikkimax,项目名称:Mono-D,代码行数:59,代码来源:DRenameRefactoring.cs


示例8: ProcessSelection

 public void ProcessSelection(IEnumerable<IRefactorTask> tasks, RefactoringOptions options)
 {
     Options = options;
     var displayableTasks = tasks.ToList();
     displayableTasks.Add(new CancelRefactoring());
     displayableTasks.Reverse ();
     selectionDisplay.GetSelectedFix(displayableTasks);
 }
开发者ID:nieve,项目名称:Stereo,代码行数:8,代码来源:QuickFixesController.cs


示例9: IsValid

		public override bool IsValid (RefactoringOptions options)
		{
			try {
				return Analyze (options);
			} catch (Exception e) {
				LoggingService.LogError ("Exception while create method analyzation", e);
				return false;
			}
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:9,代码来源:CreateMethodCodeGenerator.cs


示例10: Run

		protected override void Run (RefactoringOptions options)
		{
			RemoveUnusedImportsRefactoring removeUnusedImportsRefactoring = new RemoveUnusedImportsRefactoring ();
			SortImportsRefactoring sortImportsRefactoring = new SortImportsRefactoring ();
			if (removeUnusedImportsRefactoring.IsValid (options) && sortImportsRefactoring.IsValid (options)) {
				sortImportsRefactoring.Run (options);
				removeUnusedImportsRefactoring.Run (options);
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:9,代码来源:RefactorImportsHandler.cs


示例11: IsValid

        public override bool IsValid(RefactoringOptions options)
        {
            if (options == null)
                return false;

            var n = options.SelectedItem as INode;
            //TODO: Any further node types that cannot be renamed?
            return n != null && CanRenameNode(n);
        }
开发者ID:Geod24,项目名称:Mono-D,代码行数:9,代码来源:DRenameRefactoring.cs


示例12: QuickFixDialog

 public QuickFixDialog(RefactoringOptions options, RefactoringOperation refactoring)
 {
     this.refactoring = refactoring;
     this.options = options;
     this.Build ();
     buttonOk.Clicked += OnOKClicked;
     this.Title = "Quick Fix";
     this.label1.Text = "Are you sure you want to move this type to a new file?";
     this.GdkWindow.Opacity = 0.75;
 }
开发者ID:felbus,项目名称:Stereo,代码行数:10,代码来源:QuickFixDialog.cs


示例13: IsValid

 public override bool IsValid(RefactoringOptions options)
 {
     if (context.IsCurrentPositionTypeDeclarationUnmatchingFileName()) {
         var types = context.GetTypes ();
         if (types == null)
             return false;
         return types.Count () > 1;
     }
     return false;
 }
开发者ID:felbus,项目名称:Stereo,代码行数:10,代码来源:MoveToAnotherFileRefactoring.cs


示例14: Run

		public override void Run (RefactoringOptions options)
		{
			ExtractMethodParameters param = CreateParameters (options);
			if (param == null)
				return;
			if (!Analyze (options, param, false)) {
				MessageService.ShowError (GettextCatalog.GetString ("Invalid selection for method extraction."));
				return;
			}
			MessageService.ShowCustomDialog (new ExtractMethodDialog (options, this, param));
		}
开发者ID:silk,项目名称:monodevelop,代码行数:11,代码来源:ExtractMethodRefactoring.cs


示例15: CreateIVarDialog

        public CreateIVarDialog(RefactoringOperation refactoring, RefactoringOptions options, MonobjcProject project)
            : base(refactoring, options, project)
        {
            this.Build ();

            this.buttonOk.Sensitive = false;
            this.entryName.Changed += delegate { this.buttonOk.Sensitive = this.Validate (); };
            this.entryType.Changed += delegate { this.buttonOk.Sensitive = this.Validate (); };
            this.Validate ();

            this.buttonOk.Clicked += OnOKClicked;
        }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:12,代码来源:CreateIVarDialog.cs


示例16: HandleVisitorUsingDeclarationVisited

		void HandleVisitorUsingDeclarationVisited (UsingDeclaration node, InspectionData data)
		{
			if (!data.Graph.UsedUsings.Contains (node.Namespace)) {
				AddResult (data,
					new DomRegion (node.StartLocation.Line, node.StartLocation.Column, node.EndLocation.Line, node.EndLocation.Column),
					GettextCatalog.GetString ("Remove unused usings"),
					delegate {
						RefactoringOptions options = new RefactoringOptions () { Document = data.Document, Dom = data.Document.Dom};
						new RemoveUnusedImportsRefactoring ().Run (options);
					}
				);
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:UnusedUsingInspector.cs


示例17: GetFixes

		//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded?
		//maybe the item's type's SourceProject is null?
		public IEnumerable<IAnalysisFixAction> GetFixes (MonoDevelop.Ide.Gui.Document doc, object fix)
		{
			var renameFix = (RenameMemberFix)fix;
			var refactoring = new RenameRefactoring ();
			var options = new RefactoringOptions () {
				Document = doc,
				Dom = doc.Dom,
				SelectedItem = renameFix.Item,
			};
			
			if (renameFix.Item == null) {
				INode item;
				ResolveResult resolveResult;
				var editor = options.Document.GetContent<MonoDevelop.Ide.Gui.Content.ITextBuffer> ();
				CurrentRefactoryOperationsHandler.GetItem (options.Dom, options.Document, editor, out resolveResult, out item);
				options.SelectedItem = item;
			}
			
			if (!refactoring.IsValid (options))
				yield break;
			
			var prop = new RenameRefactoring.RenameProperties () {
				NewName = renameFix.NewName,
			};
			if (string.IsNullOrEmpty (renameFix.NewName)) {
				yield return new RenameFixAction () {
					Label = GettextCatalog.GetString ("Rename '{0}'...", renameFix.OldName),
					Refactoring = refactoring,
					Options = options,
					Properties = prop,
					Preview = false,
				};
				yield break;
			}
			yield return new RenameFixAction () {
				Label = GettextCatalog.GetString ("Rename '{0}' to '{1}'", renameFix.OldName, renameFix.NewName),
				Refactoring = refactoring,
				Options = options,
				Properties = prop,
				Preview = false,
			};
			
			yield return new RenameFixAction () {
				Label = GettextCatalog.GetString ("Rename '{0}' to '{1}' with preview",
					renameFix.OldName, renameFix.NewName),
				Refactoring = refactoring,
				Options = options,
				Properties = prop,
				Preview = true,
			};
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:53,代码来源:RenameMemberFix.cs


示例18: IsValid

		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;
		}
开发者ID:silk,项目名称:monodevelop,代码行数:15,代码来源:ExtractMethodRefactoring.cs


示例19: IsValid

        public override bool IsValid(RefactoringOptions options)
        {
            if (options.ResolveResult == null) {
                return false;
            }

            if (!IsProjectValid(options)) {
                return false;
            }

            if (!IsClass(options)) {
                return false;
            }

            return true;
        }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:16,代码来源:CreateIVarOperation.cs


示例20: GetFixes

		//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded?
		//maybe the item's type's SourceProject is null?
		public IEnumerable<IAnalysisFixAction> GetFixes (TextEditor editor, DocumentContext doc, object fix)
		{
			var renameFix = (RenameMemberFix)fix;
			var refactoring = new RenameRefactoring ();
			var options = new RefactoringOptions (editor, doc) {
			//	SelectedItem = renameFix.Item,
			};
			
//			if (renameFix.Item == null) {
//				ResolveResult resolveResult;
//				options.SelectedItem = CurrentRefactoryOperationsHandler.GetItem (options.Editor, options.DocumentContext, out resolveResult);
//			}
//			
//			if (!refactoring.IsValid (options))
//				yield break;
//			
			var prop = new RenameRefactoring.RenameProperties () {
				NewName = renameFix.NewName,
			};
			if (string.IsNullOrEmpty (renameFix.NewName)) {
				yield return new RenameFixAction () {
					Label = GettextCatalog.GetString ("Rename '{0}'...", renameFix.OldName),
					Refactoring = refactoring,
					Options = options,
					Properties = prop,
					Preview = false,
				};
				yield break;
			}
			yield return new RenameFixAction () {
				Label = GettextCatalog.GetString ("Rename '{0}' to '{1}'", renameFix.OldName, renameFix.NewName),
				Refactoring = refactoring,
				Options = options,
				Properties = prop,
				Preview = false,
			};
			
			yield return new RenameFixAction () {
				Label = GettextCatalog.GetString ("Rename '{0}' to '{1}' with preview",
					renameFix.OldName, renameFix.NewName),
				Refactoring = refactoring,
				Options = options,
				Properties = prop,
				Preview = true,
			};
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:48,代码来源:RenameMemberFix.cs



注:本文中的MonoDevelop.Refactoring.RefactoringOptions类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SourceEditor.ExtensibleTextEditor类代码示例发布时间:2022-05-26
下一篇:
C# MSBuild.MSBuildProject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap