public UnityEventFunction GetUnityEventFunction([NotNull] IMethod method, Version unityVersion, out MethodSignatureMatch match) { match = MethodSignatureMatch.NoMatch; var containingType = method.GetContainingType(); if (containingType == null) { return(null); } foreach (var type in GetBaseUnityTypes(containingType, unityVersion)) { foreach (var function in type.GetEventFunctions(unityVersion)) { match = function.Match(method); if (function.Match(method) != MethodSignatureMatch.NoMatch) { return(function); } } } return(null); }
private IncorrectMethodSignatureQuickFix(IMethodDeclaration methodDeclaration, MethodSignature expectedMethodSignature, MethodSignatureMatch match) { myMethodDeclaration = methodDeclaration; myExpectedMethodSignature = expectedMethodSignature; myMatch = match; }
public ChangeSignatureBulbAction(IMethodDeclaration methodDeclaration, MethodSignature expectedMethodSignature, MethodSignatureMatch match) { myMethodDeclaration = methodDeclaration; myExpectedMethodSignature = expectedMethodSignature; myMatch = match; Text = GetText(methodDeclaration, expectedMethodSignature); }
private IncorrectMethodSignatureQuickFix(IMethodDeclaration methodDeclaration, MethodSignature expectedMethodSignature, MethodSignatureMatch match) { myMethodDeclaration = methodDeclaration; myExpectedMethodSignatures = new FrugalLocalList <MethodSignature>(); myExpectedMethodSignatures.Add(expectedMethodSignature); myMatches = new FrugalLocalList <MethodSignatureMatch>(); myMatches.Add(match); }
public UnityEventFunction GetUnityEventFunction([NotNull] IMethod method, out MethodSignatureMatch match) { Assertion.Assert(method.IsValid(), "DeclaredElement is not valid"); match = MethodSignatureMatch.NoMatch; if (!(method.Module is IProjectPsiModule projectPsiModule)) { return(null); } var unityVersion = GetNormalisedActualVersion(projectPsiModule.Project); return(GetUnityEventFunction(method, unityVersion, out match)); }
private void AddMethodSignatureInspections(IHighlightingConsumer consumer, IMethod method, UnityEventFunction function, MethodSignatureMatch match) { if (match == MethodSignatureMatch.NoMatch || match == MethodSignatureMatch.ExactMatch) { return; } var methodSignature = function.AsMethodSignature(method.Module); foreach (var declaration in method.GetDeclarations()) { if (declaration is IMethodDeclaration methodDeclaration) { AddMethodSignatureInspections(consumer, methodDeclaration, methodSignature, match); } } }
public UnityEventFunction GetUnityEventFunction([NotNull] IMethod method, out MethodSignatureMatch match) { match = MethodSignatureMatch.NoMatch; var projectPsiModule = method.Module as IProjectPsiModule; var containingType = method.GetContainingType(); if (containingType != null && projectPsiModule != null) { var unityVersion = GetNormalisedActualVersion(projectPsiModule.Project); foreach (var type in GetBaseUnityTypes(containingType, unityVersion)) { foreach (var function in type.GetEventFunctions(unityVersion)) { match = function.Match(method); if (function.Match(method) != MethodSignatureMatch.NoMatch) { return(function); } } } } return(null); }
protected void AddMethodSignatureInspections(IHighlightingConsumer consumer, IMethodDeclaration methodDeclaration, MethodSignature expectedMethodSignature, MethodSignatureMatch match) { if (match == MethodSignatureMatch.NoMatch || match == MethodSignatureMatch.ExactMatch) { return; } // If the value is not a power of two, that means more than one flag has been set if (((int)match & ((int)match - 1)) != 0) { consumer.AddHighlighting(new IncorrectSignatureWarning(methodDeclaration, expectedMethodSignature, match)); } else { if ((match & MethodSignatureMatch.IncorrectStaticModifier) == MethodSignatureMatch.IncorrectStaticModifier) { consumer.AddHighlighting(new InvalidStaticModifierWarning(methodDeclaration, expectedMethodSignature)); } if ((match & MethodSignatureMatch.IncorrectReturnType) == MethodSignatureMatch.IncorrectReturnType) { consumer.AddHighlighting(new InvalidReturnTypeWarning(methodDeclaration, expectedMethodSignature)); } if ((match & MethodSignatureMatch.IncorrectParameters) == MethodSignatureMatch.IncorrectParameters) { consumer.AddHighlighting(new InvalidParametersWarning(methodDeclaration, expectedMethodSignature)); } if ((match & MethodSignatureMatch.IncorrectTypeParameters) == MethodSignatureMatch.IncorrectTypeParameters) { consumer.AddHighlighting(new InvalidTypeParametersWarning(methodDeclaration, expectedMethodSignature)); } } }
public Candidate(IMethod method, MethodSignatureMatch match) { Method = method; Match = match; }