static bool TryGetDiagnostic(SyntaxNodeAnalysisContext nodeContext, out Diagnostic diagnostic) { diagnostic = default(Diagnostic); var node = nodeContext.Node as BinaryExpressionSyntax; var flowAnalzyer = new FlowAnalyzer<NullFlowState>(nodeContext.SemanticModel, new NullFlowState(nodeContext.SemanticModel)); var analyzer = flowAnalzyer.Analyze(nodeContext.Node); var state = analyzer.GetFlowState(node.Left); var leftState = state.GetReferenceState(node.Left); if (leftState == NullState.NotNull) { diagnostic = Diagnostic.Create (descriptor, node.Right.GetLocation (), "Remove redundant right side"); return true; } if (leftState == NullState.Null) { diagnostic = Diagnostic.Create (descriptor, node.Left.GetLocation (), "Remove redundant left side"); return true; } if (state.GetReferenceState(node.Right) == NullState.Null) { diagnostic = Diagnostic.Create (descriptor, node.Right.GetLocation (), "Remove redundant left side"); } return false; }
public CodeContext() { resolver = new SymbolResolver(); analyzer = new SemanticAnalyzer(); flow_analyzer = new FlowAnalyzer(); used_attr = new UsedAttr(); }
static bool TryGetDiagnostic(SyntaxNodeAnalysisContext nodeContext, out Diagnostic diagnostic) { diagnostic = default(Diagnostic); if (nodeContext.IsFromGeneratedCode()) { return(false); } var node = nodeContext.Node as BinaryExpressionSyntax; var flowAnalzyer = new FlowAnalyzer <NullFlowState>(nodeContext.SemanticModel, new NullFlowState(nodeContext.SemanticModel)); var analyzer = flowAnalzyer.Analyze(nodeContext.Node); var state = analyzer.GetFlowState(node.Left); var leftState = state.GetReferenceState(node.Left); if (leftState == NullState.NotNull) { diagnostic = Diagnostic.Create(descriptor, node.Right.GetLocation(), "Remove redundant right side"); return(true); } if (leftState == NullState.Null) { diagnostic = Diagnostic.Create(descriptor, node.Left.GetLocation(), "Remove redundant left side"); return(true); } if (state.GetReferenceState(node.Right) == NullState.Null) { diagnostic = Diagnostic.Create(descriptor, node.Right.GetLocation(), "Remove redundant left side"); } return(false); }
private void Button1_Click(object sender, EventArgs e) { generalFlow = new FlowAnalyzer(); generalFlow.Calculate(); richTextBox1.Text = generalFlow.PrintDistributionOfIntervals().ToString(); richTextBox1.AppendText($"\n\nLambda = {generalFlow.lambda};\n" + $"Modelled Lambda = {generalFlow.modelledLambda}"); richTextBox1.AppendText(generalFlow.PrintProbabilities().ToString()); richTextBox4.Text = generalFlow.PrintPrimaryCalculation().ToString(); richTextBox5.Text = generalFlow.PrintCallsPerInterval().ToString(); button2.Enabled = true; }
private void Button3_Click(object sender, EventArgs e) { flow1 = new FlowAnalyzer(lambda1); flow2 = new FlowAnalyzer(lambda2); richTextBox2.Text = flow1.PrintDivisionOfCalls("Flow 1").ToString(); richTextBox2.AppendText(flow2.PrintDivisionOfCalls("Flow 2", false).ToString()); int len1 = flow1.intervalsArray.Length; int len2 = flow2.intervalsArray.Length; summary = new Interval[ Math.Max(len1, len2)]; for (int i = 0; i < summary.Length; i++) { summary[i] = new Interval(); summary[i].SetPoints(i, i + 1); } for (int i = 0; i < Math.Min(len1, len2); i++) { summary[i].Calls = flow1.intervalsArray[i].Calls + flow2.intervalsArray[i].Calls; } if (flow1.intervalsArray.Length >= flow2.intervalsArray.Length) { Array.Copy(flow1.intervalsArray, len2, summary, len2, len1 - len2); } else { Array.Copy(flow2.intervalsArray, len1, summary, len1, len2 - len1); } lambdaSum = (double)(FlowAnalyzer.SIZE) / summary.Last().EndPoint; PlotLambdas(); richTextBox2.Text += "\n"; richTextBox2.Text += string.Format("Summary |"); foreach (var item in summary) { richTextBox2.Text += $"{item.Calls,3}|"; } button4.Enabled = true; }
private int ExecuteCommand(IIgnite ignite, IEnumerable <string> sourceFrameCacheNames, string flowCacheName) { var compute = ignite.GetCompute(); var flowCache = CacheFactory.GetOrCreateFlowCache(ignite, flowCacheName); foreach (var cacheName in sourceFrameCacheNames) { var frameCache = ignite.GetOrCreateCache <object, object>(cacheName); m_logger.Info($"Tracking flows in frame cache:{cacheName}..."); var flowAnalyzer = new FlowAnalyzer() { FrameCacheName = cacheName, FlowCacheName = flowCacheName, }; compute.Broadcast(flowAnalyzer); m_logger.Info($"Tracking flows in frame cache:{cacheName} done, frames={frameCache.GetSize()}, flows={flowCache.GetSize()}."); } return(0); }
public void Analyze(SyntaxNode node) { // do null flow analysis var flowAnalzyer = new FlowAnalyzer<NullFlowState>(this.context.SemanticModel, new NullFlowState(this.context.SemanticModel)); this.flowAnalysis = flowAnalzyer.Analyze(node); // check assignments and dereferences and report diagnostics this.Visit(node); }