public async Task <IMethodEntityWithPropagator> GetMethodEntityAsync(MethodDescriptor methodDescriptor)
        {
            IMethodEntityWithPropagator methodEntity = null;

            if (!methodEntitiesMap.TryGetValue(methodDescriptor, out methodEntity))
            {
                methodEntity = await solutionGrain.GetMethodEntityAsync(methodDescriptor);

                methodEntitiesMap.TryAdd(methodDescriptor, methodEntity);
            }

            return(methodEntity);
        }
        public override async Task <IEnumerable <MethodModification> > GetModificationsAsync(IEnumerable <string> modifiedDocuments)
        {
            var modifications = await base.GetModificationsAsync(modifiedDocuments);

            this.newMethodEntities = new ConcurrentDictionary <MethodDescriptor, IMethodEntityWithPropagator>(methodEntities);

            foreach (var modification in modifications)
            {
                if (modification.ModificationKind == ModificationKind.MethodRemoved ||
                    modification.ModificationKind == ModificationKind.MethodUpdated)
                {
                    IMethodEntityWithPropagator previousValue = null;
                    newMethodEntities.TryRemove(modification.MethodDescriptor, out previousValue);
                }
            }

            return(modifications);
        }
        private async Task CreateMethodEntityAsync(MethodDescriptor methodDescriptor)
        {
            // This is a private method. We must not register this as a grain callee
            // await StatsHelper.RegisterMsg("MethodEntityGrain::CreateMethodEntity", this.GrainFactory);

            this.solutionGrain = OrleansSolutionManager.GetSolutionGrain(this.GrainFactory);

            this.State.MethodDescriptor = methodDescriptor;
            var methodDescriptorToSearch = methodDescriptor.BaseDescriptor;

            var codeProviderGrain = await solutionGrain.GetProjectCodeProviderAsync(methodDescriptorToSearch);

            // This wrapper caches some of the queries to codeProvider
            //this.codeProvider = new ProjectCodeProviderWithCache(codeProviderGrain);
            this.codeProvider = codeProviderGrain;

            //Logger.LogWarning(this.GetLogger(), "MethodEntityGrain", "CreateMethodEntity", "{0} calls to proivder {1}", methodDescriptor, this.codeProvider);
            var sw = new Stopwatch();

            sw.Start();

            this.methodEntity = (MethodEntity)await codeProvider.CreateMethodEntityAsync(methodDescriptorToSearch);

            sw.Stop();

            Logger.LogInfo(this.GetLogger(), "MethodEntityGrain", "CreateMethodEntity", "{0};call to provider;{1};ms;{2};ticks", methodDescriptor, sw.ElapsedMilliseconds, sw.ElapsedTicks);

            if (methodDescriptor.IsAnonymousDescriptor)
            {
                this.methodEntity = this.methodEntity.GetAnonymousMethodEntity((AnonymousMethodDescriptor)methodDescriptor);
            }

            //// this is for RTA analysis
            //await solutionGrain.AddInstantiatedTypesAsync(this.methodEntity.InstantiatedTypes);

            // This take cares of doing the progation of types
            this.methodEntityPropagator = new MethodEntityWithPropagator(methodEntity, codeProvider);

            await this.WriteStateAsync();

            //Logger.LogWarning(this.GetLogger(), "MethodEntityGrain", "CreateMethodEntity", "Exit {0}", methodDescriptor);
        }
        private async Task PropagateEffectsAsync(PropagationEffects propagationEffects, PropagationKind propKind, IMethodEntityWithPropagator methodEntityProp = null)
        {
            //var hasMoreEffects = true;

            //do
            //{
            //Logger.LogS("AnalysisOrchestator", "DoPropagationOfEffects", "");

            if (GrainClient.IsInitialized)
            {
                Logger.LogInfo(GrainClient.Logger, "Orchestrator", "PropagatEffFects", "Propagating effets computed in {0}", propagationEffects.SiloAddress);
            }

            await this.ProcessCalleesAsync(propagationEffects.CalleesInfo, propKind);

            if (propagationEffects.ResultChanged)
            {
                await this.ProcessReturnAsync(propagationEffects.CallersInfo, propKind);
            }

            //hasMoreEffects = propagationEffects.MoreEffectsToFetch;

            //if (hasMoreEffects && methodEntityProp != null)
            //{
            //	propagationEffects = await methodEntityProp.GetMoreEffects();
            //}
            //}
            //while (hasMoreEffects);
        }
示例#5
0
        internal async Task PropagateEffectsAsync(PropagationEffects propagationEffects, PropagationKind propKind, IMethodEntityWithPropagator methodEntityProp = null)
        {
            Logger.LogInfo(Logger.OrleansLogger, "SiloOrchestrator", "PropagatEffFects", "Propagating effets computed in {0}", propagationEffects.SiloAddress);

            await this.ProcessCalleesAsync(propagationEffects.CalleesInfo, propKind);

            if (propagationEffects.ResultChanged)
            {
                await this.ProcessReturnAsync(propagationEffects.CallersInfo, propKind);
            }

            await ProcessMessages();
        }