Пример #1
0
        private IType CreateParameterType(UnityEventFunctionParameter parameter)
        {
            var type = TypeFactory.CreateTypeByCLRName(parameter.ClrTypeName, myMethodDeclaration.GetPsiModule());

            if (parameter.IsArray)
            {
                return(TypeFactory.CreateArrayType(type, 1));
            }
            return(type);
        }
Пример #2
0
        private bool DoTypesMatch(IType parameterType, UnityEventFunctionParameter requiredParameter)
        {
            if (requiredParameter.IsArray && parameterType is IArrayType)
            {
                var arrayType = (IArrayType)parameterType;
                parameterType = arrayType.ElementType;
            }

            var typeElement = parameterType.GetTypeElement();

            if (typeElement == null)
            {
                return(false);
            }
            return(Equals(typeElement.GetClrName(), requiredParameter.ClrTypeName));
        }
Пример #3
0
        private ChangeSignatureParameter FindBestMatch(UnityEventFunctionParameter requiredParameter, ChangeSignatureModel model, int i)
        {
            // Try and match type and name first
            for (var j = i; j < model.ChangeSignatureParameters.Length; j++)
            {
                if (model.ChangeSignatureParameters[j].ParameterName == requiredParameter.Name &&
                    DoTypesMatch(model.ChangeSignatureParameters[j].ParameterType, requiredParameter))
                {
                    return(model.ChangeSignatureParameters[j]);
                }
            }

            // Now just match type - we'll update name after
            for (var j = i; j < model.ChangeSignatureParameters.Length; j++)
            {
                if (DoTypesMatch(model.ChangeSignatureParameters[j].ParameterType, requiredParameter))
                {
                    return(model.ChangeSignatureParameters[j]);
                }
            }

            return(null);
        }