当前位置: 首页>>代码示例>>C#>>正文


C# Refactoring.RefactoringOptions类代码示例

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


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


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