本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Refactoring.BaseRefactoringContext类的典型用法代码示例。如果您正苦于以下问题:C# BaseRefactoringContext类的具体用法?C# BaseRefactoringContext怎么用?C# BaseRefactoringContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseRefactoringContext类属于ICSharpCode.NRefactory.CSharp.Refactoring命名空间,在下文中一共展示了BaseRefactoringContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ();
}
示例2: GetIssues
public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
{
var visitor = new GatherVisitor (context, this);
context.RootNode.AcceptVisitor (visitor);
visitor.Collect ();
return visitor.FoundIssues;
}
示例3: GetIssues
public IEnumerable<CodeIssue> GetIssues(BaseRefactoringContext context)
{
var delegateVisitor = new GetDelgateUsagesVisitor (context);
context.RootNode.AcceptVisitor (delegateVisitor);
return new GatherVisitor (context, delegateVisitor).GetIssues ();
}
示例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);
}
示例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 ();
}
示例6: GatherVisitor
public GatherVisitor (BaseRefactoringContext context, CompilationUnit unit,
AccessToClosureIssue issueProvider)
: base (context)
{
this.title = context.TranslateString (issueProvider.Title);
this.unit = unit;
this.issueProvider = issueProvider;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
示例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 ();
}
示例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;
}
示例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));
}