當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。