private void CheckMethodDeclaration(IMethodDeclaration methodDeclaration, IAttribute element, IHighlightingConsumer consumer) { if (methodDeclaration == null) { return; } var predefinedType = myPredefinedTypeCache.GetOrCreatePredefinedType(element.GetPsiModule()); var gizmoType = TypeFactory.CreateTypeByCLRName(KnownTypes.GizmoType, predefinedType.Module); var componentType = TypeFactory.CreateTypeByCLRName(KnownTypes.Component, predefinedType.Module); IType derivedType = componentType; var derivedName = "component"; var gizmoName = "gizmoType"; var firstParamCorrect = false; var secondParamCorrect = false; for (var i = 0; i < methodDeclaration.Params.ParameterDeclarations.Count; i++) { var param = methodDeclaration.Params.ParameterDeclarations[i]; if (param.Type.GetTypeElement() ?.IsDescendantOf(componentType.GetTypeElement()) == true) { if (i == 0) { firstParamCorrect = true; } derivedType = param.Type; derivedName = param.DeclaredName; } if (param.Type.GetTypeElement() ?.Equals(gizmoType?.GetTypeElement()) == true) { if (i == 1) { secondParamCorrect = true; } gizmoName = param.DeclaredName; } } var expectedDeclaration = new MethodSignature(predefinedType.Void, true, new[] { derivedType, gizmoType }, new[] { derivedName, gizmoName }); var match = expectedDeclaration.Match(methodDeclaration); if (methodDeclaration.Params.ParameterDeclarations.Count == 2) { if (firstParamCorrect && secondParamCorrect) { match &= ~MethodSignatureMatch.IncorrectParameters; } else if (!firstParamCorrect && secondParamCorrect && match == MethodSignatureMatch.IncorrectParameters) { // TODO: Should this be ExpectedComponentWarning? consumer.AddHighlighting(new ParameterNotDerivedFromComponentWarning(methodDeclaration.Params.ParameterDeclarations.First())); return; } } AddMethodSignatureInspections(consumer, methodDeclaration, expectedDeclaration, match); }