private List <IMethod> ScanHierarchyConflicts(IEnumerable <HierarchyMember> hierarchyMembers) { var members = new List <IMethod>(); var provider = new MakeGenericHierarchyConflictTextProvider(); var conflictConsumer = new HierarchyConflictConsumer(); foreach (HierarchyMember hierarchyMember in hierarchyMembers) { // paranoiac check var member = hierarchyMember.Member as IMethod; if (member != null) { members.Add(member); conflictConsumer.AddConflictsForHierarhyMember(hierarchyMember); } } foreach (HierarchyConflict hierarchyConflict in conflictConsumer.MyHierarchyConflicts) { IConflict conflict = hierarchyConflict.CreateConflict(provider); if (conflict != null) { Driver.AddConflict(conflict); } } return(members); }
public override MethodInvocation ProcessUsage(IReference reference) { var referenceExpression = reference.GetTreeNode() as IReferenceExpression; if (referenceExpression == null) { Driver.AddConflict(ReferenceConflict.CreateError(reference, "{0} can not be updated correctly.", "Usage")); return(null); } bool isExtensionMethod = referenceExpression.IsExtensionMethod(); IInvocationExpression invocation = InvocationExpressionNavigator.GetByInvokedExpression(referenceExpression); if (invocation == null) { Driver.AddConflict(ReferenceConflict.CreateError(reference, "{0} can not be updated correctly.", "Usage")); return(null); } ITreeNode element = GetArgument(invocation, isExtensionMethod); var argument = element as ICSharpArgument; IType type = argument != null?GetTypeOfValue(argument.Value) : GetTypeOfValue(element); if (type == null || !type.CanUseExplicitly(invocation)) { Driver.AddConflict(ReferenceConflict.CreateError( reference, "Argument of {0} is not valid 'typeof' expression.", "usage")); return(null); } // we can rely on resolve result since method declaration is not yet changed. ResolveResultWithInfo resolveResult = reference.Resolve(); ISubstitution substitution = resolveResult.Result.Substitution; var method = resolveResult.DeclaredElement as IMethod; if (method == null) { return(null); } if (argument != null) { invocation.RemoveArgument(argument); return(new MethodInvocation(reference, type, method, substitution)); } CSharpElementFactory factory = CSharpElementFactory.GetInstance(invocation.GetPsiModule()); IReferenceExpression newInvokedExpression = invocation.InvokedExpression.ReplaceBy(factory.CreateReferenceExpression("$0", Executer.Method)); return(new MethodInvocation(newInvokedExpression.Reference, type, method, substitution)); }
public override void ProcessParameterReference(IReference reference) { Driver.AddConflict(new UnsupportedLanguageConflict(reference.GetTreeNode(), "parameter usage", ConflictSeverity.Error)); }
public override ITypeParameter AddTypeParameter(IDeclaration declaration) { Driver.AddConflict(new UnsupportedLanguageConflict(declaration, "method declaration", ConflictSeverity.Error)); return(null); }
public override void RemoveParameter(IDeclaration declaration, int index) { Driver.AddConflict(new UnsupportedLanguageConflict(declaration, "method declaration", ConflictSeverity.Error)); }
public override MethodInvocation ProcessUsage(IReference reference) { // when something goes wrong just add conflict Driver.AddConflict(new UnsupportedLanguageConflict(reference.GetTreeNode(), "usage", ConflictSeverity.Error)); return(null); }