Ejemplo n.º 1
0
            private void AssociateToServiceGlobalType(string serviceName, string providerFunctionName, IExpressionOrSpread providerExpression)
            {
                var constructedFactoryType = providerExpression.GetJsType(context, new JsCyclicFlowAccumulator()).
                                             GetConstructedType(JsUnresolvedTypeArray.NoList);

                // The type of the service is the return type of the $get property, if it's a function.
                // If it's an array literal injectable, we need to add the association later, so create
                // a composite type that allows us to add it later
                var providerGetReturnType = constructedFactoryType.GetPropertyReferenceType("$get").GetReturnType();
                var providerGetGlobalType = GetProviderGetGlobalType(providerFunctionName);
                var serviceType           = JavaScriptType.CreateCompositeType(JsCombinedTypeKind.JsDynamic,
                                                                               providerGetReturnType, providerGetGlobalType);

                var offset = context.GetDocumentStartOffset(providerExpression);

                AssociateToServiceGlobalType(serviceName, serviceType, offset);
            }
Ejemplo n.º 2
0
            private void AssociateToProviderGlobalType(string serviceName, string providerFunctionName,
                                                       IJavaScriptTypedExpression providerExpression)
            {
                var providerGlobalType = GetHiddenGlobalPropertyType(serviceName + ProviderSuffix);

                // The type of the injected provider is the constructed type of the provider factory
                // function. But the referenced expression might not be a factory function, but an
                // injectable array literal. Create a composite type that we can populate later, when
                // we see a provider-like function (e.g. a function ending in Provider)
                var constructedFactoryType = providerExpression.GetJsType(context, new JsCyclicFlowAccumulator()).
                                             GetConstructedType(JsUnresolvedTypeArray.NoList);
                var providerFunctionGlobalType = GetProviderFunctionGlobalType(providerFunctionName);
                var providerType = JavaScriptType.CreateCompositeType(JsCombinedTypeKind.JsDynamic,
                                                                      constructedFactoryType, providerFunctionGlobalType);

                // We can't provide a decent offset here. But do we need to?
                CreateAssignmentAssociation(providerGlobalType, providerType, -1);
            }