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


C# BaseRefactoringContext.TranslateString方法代码示例

本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Refactoring.BaseRefactoringContext.TranslateString方法的典型用法代码示例。如果您正苦于以下问题:C# BaseRefactoringContext.TranslateString方法的具体用法?C# BaseRefactoringContext.TranslateString怎么用?C# BaseRefactoringContext.TranslateString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.NRefactory.CSharp.Refactoring.BaseRefactoringContext的用法示例。


在下文中一共展示了BaseRefactoringContext.TranslateString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GatherVisitor

			public GatherVisitor (BaseRefactoringContext context, SyntaxTree unit,
								  AccessToClosureIssue issueProvider)
				: base (context)
			{
				this.title = context.TranslateString (issueProvider.Title);
				this.unit = unit;
				this.issueProvider = issueProvider;
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:8,代码来源:AccessToClosureIssue.cs

示例2: GetAction

            CodeAction GetAction(BaseRefactoringContext context, Expression targetExpression,
			                                   IMember member)
            {
                var builder = context.CreateTypeSytemAstBuilder(targetExpression);
                var newType = builder.ConvertType(member.DeclaringType);
                string description = string.Format("{0} '{1}'", context.TranslateString("Use base class"), newType.GetText());
                return new CodeAction(description, script => {
                    script.Replace(targetExpression, newType);
                });
            }
开发者ID:artifexor,项目名称:NRefactory,代码行数:10,代码来源:ReferenceToStaticMemberViaDerivedTypeIssue.cs

示例3: GetFixes

        protected override IEnumerable<CodeAction> GetFixes(BaseRefactoringContext context, Node env,
															 string variableName)
        {
            var containingStatement = env.ContainingStatement;

            // we don't give a fix for these cases since the general fix may not work
            // lambda in while/do-while/for condition
            if (containingStatement is WhileStatement || containingStatement is DoWhileStatement ||
                containingStatement is ForStatement)
                yield break;
            // lambda in for initializer/iterator
            if (containingStatement.Parent is ForStatement &&
                ((ForStatement)containingStatement.Parent).EmbeddedStatement != containingStatement)
                yield break;

            Action<Script> action = script =>
            {
                var newName = LocalVariableNamePicker.PickSafeName (
                    containingStatement.GetParent<EntityDeclaration> (),
                    Enumerable.Range (1, 100).Select (i => variableName + i));

                var variableDecl = new VariableDeclarationStatement (new SimpleType("var"), newName,
                                                                     new IdentifierExpression (variableName));

                if (containingStatement.Parent is BlockStatement || containingStatement.Parent is SwitchSection) {
                    script.InsertBefore (containingStatement, variableDecl);
                } else {
                    var offset = script.GetCurrentOffset (containingStatement.StartLocation);
                    script.InsertBefore (containingStatement, variableDecl);
                    script.InsertText (offset, "{");
                    script.InsertText (script.GetCurrentOffset (containingStatement.EndLocation), "}");
                    script.FormatText (containingStatement.Parent);
                }

                var textNodes = new List<AstNode> ();
                textNodes.Add (variableDecl.Variables.First ().NameToken);

                foreach (var reference in env.GetAllReferences ()) {
                    var identifier = new IdentifierExpression (newName);
                    script.Replace (reference.AstNode, identifier);
                    textNodes.Add (identifier);
                }
                script.Link (textNodes.ToArray ());
            };
            yield return new CodeAction (context.TranslateString ("Copy to local variable"), action, env.AstNode);
        }
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:46,代码来源:AccessToModifiedClosureIssue.cs

示例4: GetActions

			IEnumerable<CodeAction> GetActions(BaseRefactoringContext context, Expression targetExpression,
			                                   IMember member)
			{
				var csResolver = context.Resolver.GetResolverStateBefore(targetExpression);
				var builder = new TypeSystemAstBuilder(csResolver);
				var newType = builder.ConvertType(member.DeclaringType);
				string description = string.Format("{0} '{1}'", context.TranslateString("Use base class"), newType.GetText());
				yield return new CodeAction(description, script => {
					script.Replace(targetExpression, newType);
				});
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:11,代码来源:ReferenceToStaticMemberViaDerivedTypeIssue.cs


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