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

C# Refactoring.BaseRefactoringContext类代码示例

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

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



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

示例1: GetIssues

		public IEnumerable<CodeIssue> GetIssues (BaseRefactoringContext context)
		{
			var unit = context.RootNode as SyntaxTree;
			if (unit == null)
				return Enumerable.Empty<CodeIssue> ();
			return GetGatherVisitor (context, unit).GetIssues ();
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:7,代码来源:VariableOnlyAssignedIssue.cs


示例2: GetIssues

		public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
		{
			var visitor = new GatherVisitor (context, this);
			context.RootNode.AcceptVisitor (visitor);
			visitor.Collect ();
			return visitor.FoundIssues;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:7,代码来源:RedundantUsingIssue.cs


示例3: GetIssues

        public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
        {
            var delegateVisitor = new GetDelgateUsagesVisitor (context);
            context.RootNode.AcceptVisitor (delegateVisitor);

            return new GatherVisitor (context, delegateVisitor).GetIssues ();
        }
开发者ID:Xiaoqing,项目名称:NRefactory,代码行数:7,代码来源:ParameterNotUsedIssue.cs


示例4: GetIssues

			public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
			{
				// use a separate instance for every call, this is necessary
				// for thread-safety
				var provider = (CodeIssueProvider)Activator.CreateInstance(ProviderType);
				return provider.GetIssues(context);
			}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:7,代码来源:IssueManager.cs


示例5: GetIssues

		public IEnumerable<CodeIssue> GetIssues (BaseRefactoringContext context)
		{
			var unit = context.RootNode as CompilationUnit;
			if (unit == null)
				return Enumerable.Empty<CodeIssue> ();
			return new GatherVisitor (context, unit).GetIssues ();
		}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:7,代码来源:TypeParameterNotUsedIssue.cs


示例6: GatherVisitor

			public GatherVisitor (BaseRefactoringContext context, CompilationUnit unit,
								  AccessToClosureIssue issueProvider)
				: base (context)
			{
				this.title = context.TranslateString (issueProvider.Title);
				this.unit = unit;
				this.issueProvider = issueProvider;
			}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:8,代码来源:AccessToClosureIssue.cs


示例7: GatherVisitor

			public GatherVisitor(BaseRefactoringContext context) : base (context)
			{
				this.context = context;
				rules = new Dictionary<string, Func<int, int, bool>>();
				rules [typeof(ArgumentException).FullName] = (left, right) => left > right;
				rules [typeof(ArgumentNullException).FullName] = (left, right) => left < right;
				rules [typeof(ArgumentOutOfRangeException).FullName] = (left, right) => left < right;
				rules [typeof(DuplicateWaitObjectException).FullName] = (left, right) => left < right;
			}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:9,代码来源:IncorrectExceptionParameterOrderingIssue.cs


示例8: GetIssues

		public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
		{
			var sw = new Stopwatch();
			sw.Start();
			var gatherer = new GatherVisitor(context, tryResolve);
			var issues = gatherer.GetIssues();
			sw.Stop();
			Console.WriteLine("Elapsed time in ParameterCanBeDemotedIssue: {0} (Checked types: {3, 4} Qualified for resolution check: {5, 4} Members with issues: {4, 4} Method bodies resolved: {2, 4} File: '{1}')",
			                  sw.Elapsed, context.UnresolvedFile.FileName, gatherer.MethodResolveCount, gatherer.TypesChecked, gatherer.MembersWithIssues, gatherer.TypeResolveCount);
			return issues;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:11,代码来源:ParameterCanBeDemotedIssue.cs


示例9: FindUsage

		protected static bool FindUsage (BaseRefactoringContext context, CompilationUnit unit, IVariable variable,
										 AstNode declaration)
		{
			var found = false;
			refFinder.FindLocalReferences (variable, context.ParsedFile, unit, context.Compilation,
				(node, resolveResult) =>
				{
					found = found || node != declaration;
				}, context.CancellationToken);
			return found;
		}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:11,代码来源:VariableNotUsedIssue.cs


示例10: FindUsage

		protected static bool FindUsage (BaseRefactoringContext context, SyntaxTree unit,
										 ITypeParameter typaParameter, AstNode declaration)
		{
			var found = false;
			refFinder.FindTypeParameterReferences (typaParameter, context.UnresolvedFile, unit, context.Compilation,
				(node, resolveResult) =>
				{
					found = found || node != declaration;
				}, context.CancellationToken);
			return found;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:11,代码来源:TypeParameterNotUsedIssue.cs


示例11: GetIssues

		public override IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context, string subIssue = null)
		{
			var refactoringContext = context as SDRefactoringContext;
			if (refactoringContext == null)
				return Enumerable.Empty<CodeIssue>();
			
			var syntaxTree = context.RootNode as SyntaxTree;
			if (syntaxTree == null)
				return Enumerable.Empty<CodeIssue>();

			return syntaxTree.Errors.Select(error => CreateCodeIssue(error, refactoringContext));
		}
开发者ID:nataviva,项目名称:SharpDevelop-1,代码行数:12,代码来源:CSharpSyntaxIssue.cs


示例12: GetElementType

        static IType GetElementType(ResolveResult rr, BaseRefactoringContext context)
        {
            if (rr.IsError || rr.Type.Kind == TypeKind.Unknown)
                return null;
            var type = GetCollectionType(rr.Type);
            if (type == null)
                return null;

            var parameterizedType = type as ParameterizedType;
            if (parameterizedType != null)
                return parameterizedType.TypeArguments.First();
            return context.Compilation.FindType(KnownTypeCode.Object);
        }
开发者ID:riviti,项目名称:NRefactory,代码行数:13,代码来源:IterateViaForeachAction.cs


示例13: HidesMember

		protected static bool HidesMember(BaseRefactoringContext ctx, AstNode node, string variableName)
		{
			var typeDecl = node.GetParent<TypeDeclaration> ();
			if (typeDecl == null)
				return false;
			var typeResolveResult = ctx.Resolve (typeDecl) as TypeResolveResult;
			if (typeResolveResult == null)
				return false;

			var entityDecl = node.GetParent<EntityDeclaration> ();
			var isStatic = (entityDecl.Modifiers & Modifiers.Static) == Modifiers.Static;

			return typeResolveResult.Type.GetMembers (m => m.Name == variableName && m.IsStatic	== isStatic).Any ();
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:14,代码来源:VariableHidesMemberIssue.cs


示例14: TestOnlyAssigned

		protected static bool TestOnlyAssigned(BaseRefactoringContext ctx, AstNode rootNode, IVariable variable)
		{
			var assignment = false;
			var nonAssignment = false;
			foreach (var result in ctx.FindReferences(rootNode, variable)) {
				var node = result.Node;
				if (node is ParameterDeclaration)
					continue;

				if (node is VariableInitializer) {
					if (!(node as VariableInitializer).Initializer.IsNull)
						assignment = true;
					continue;
				}

				if (node is IdentifierExpression) {
					var parent = node.Parent;
					if (parent is AssignmentExpression) {
						if (((AssignmentExpression)parent).Left == node) {
							assignment = true;
							continue;
						}
					} else if (parent is UnaryOperatorExpression) {
						var op = ((UnaryOperatorExpression)parent).Operator;
						switch (op) {
							case UnaryOperatorType.Increment:
							case UnaryOperatorType.PostIncrement:
							case UnaryOperatorType.Decrement:
							case UnaryOperatorType.PostDecrement:
								assignment = true;
								if (!(parent.Parent is ExpressionStatement))
									nonAssignment = true;
								continue;
						}
					} else if (parent is DirectionExpression) {
						if (((DirectionExpression)parent).FieldDirection == FieldDirection.Out) {
							assignment = true;
							// Using dummy variables is necessary for ignoring
							// out-arguments, so we don't want to warn for those.
							nonAssignment = true;
							continue;
						}
					}
				}
				nonAssignment = true;
			}
			return assignment && !nonAssignment;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:48,代码来源:VariableOnlyAssignedIssue.cs


示例15: HidesMember

        protected static bool HidesMember(BaseRefactoringContext ctx, AstNode node, string variableName)
        {
            var typeDecl = node.GetParent<TypeDeclaration>();
            if (typeDecl == null)
                return false;
            var entityDecl = node.GetParent<EntityDeclaration>();
            var memberResolveResult = ctx.Resolve(entityDecl) as MemberResolveResult;
            if (memberResolveResult == null)
                return false;
            var typeResolveResult = ctx.Resolve(typeDecl) as TypeResolveResult;
            if (typeResolveResult == null)
                return false;

            var sourceMember = memberResolveResult.Member;

            return typeResolveResult.Type.GetMembers(m => m.Name == variableName).Any(m2 => IsAccessible(sourceMember, m2));
        }
开发者ID:segaman,项目名称:NRefactory,代码行数:17,代码来源:VariableHidesMemberIssue.cs


示例16: 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


示例17: GetBackingField

		internal static IField GetBackingField (BaseRefactoringContext context, PropertyDeclaration propertyDeclaration)
		{
			// automatic properties always need getter & setter
			if (propertyDeclaration == null || propertyDeclaration.Getter.IsNull || propertyDeclaration.Setter.IsNull || propertyDeclaration.Getter.Body.IsNull || propertyDeclaration.Setter.Body.IsNull)
				return null;
			if (!context.Supports(csharp3) || propertyDeclaration.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Abstract) || ((TypeDeclaration)propertyDeclaration.Parent).ClassType == ClassType.Interface)
				return null;
			var getterField = ScanGetter (context, propertyDeclaration);
			if (getterField == null)
				return null;
			var setterField = ScanSetter (context, propertyDeclaration);
			if (setterField == null)
				return null;
			if (!getterField.Equals(setterField))
				return null;
			return getterField;
		}
开发者ID:asiazhang,项目名称:SharpDevelop,代码行数:17,代码来源:RemoveBackingStoreAction.cs


示例18: TestOnlyAssigned

		protected static bool TestOnlyAssigned (BaseRefactoringContext ctx, SyntaxTree unit, IVariable variable)
		{
			var assignment = false;
			var nonAssignment = false;
			refFinder.FindLocalReferences (variable, ctx.UnresolvedFile, unit, ctx.Compilation,
				(node, resolveResult) =>
				{
					if (node is ParameterDeclaration)
						return;

					if (node is VariableInitializer) {
						if (!(node as VariableInitializer).Initializer.IsNull)
							assignment = true;
						return;
					}

					if (node is IdentifierExpression) {
						var parent = node.Parent;
						if (parent is AssignmentExpression) {
							if (((AssignmentExpression)parent).Left == node) {
								assignment = true;
								return;
							}
						} else if (parent is UnaryOperatorExpression) {
							var op = ((UnaryOperatorExpression)parent).Operator;
							switch (op) {
							case UnaryOperatorType.Increment:
							case UnaryOperatorType.PostIncrement:
							case UnaryOperatorType.Decrement:
							case UnaryOperatorType.PostDecrement:
								assignment = true;
								return;
							}
						} else if (parent is DirectionExpression) {
							if (((DirectionExpression)parent).FieldDirection == FieldDirection.Out) {
								assignment = true;
								return;
							}
						}
					}
					nonAssignment = true;
				}, ctx.CancellationToken);
			return assignment && !nonAssignment;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:44,代码来源:VariableOnlyAssignedIssue.cs


示例19: GetIssues

		public override IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context, string subIssue = null)
		{
			var refactoringContext = context as SDRefactoringContext;
			if (refactoringContext == null)
				yield break;
			
			var syntaxTree = context.RootNode as SyntaxTree;
			if (syntaxTree == null)
				yield break;
			
			int prevLine = 0;
			foreach (var error in syntaxTree.Errors) {
				if (error.Region.BeginLine == prevLine)
					continue; // show at most one error per line
				prevLine = error.Region.BeginLine;
				var issue = CreateCodeIssue(error, refactoringContext);
				if (issue != null)
					yield return issue;
			}
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:20,代码来源:CSharpSyntaxIssue.cs


示例20: GetIssues

 public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
 {
     return new ReplaceWithSingleCallToAnyIssue.GatherVisitor<ReplaceWithSingleCallToSingleOrDefaultIssue>(context, "SingleOrDefault").GetIssues();
 }
开发者ID:jijamw,项目名称:NRefactory,代码行数:4,代码来源:ReplaceWithSingleCallToSingleOrDefaultIssue.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Refactoring.TypeSystemAstBuilder类代码示例发布时间:2022-05-26
下一篇:
C# Completion.CompletionDataWrapper类代码示例发布时间: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