/// <summary> /// Report a warning for the position of current expression. /// </summary> /// <param name="flow">Flow controller of program point providing data for evaluation.</param> /// <param name="message">Message of the warning.</param> /// <param name="cause">Cause of the warning.</param> private static void SetWarning(FlowController flow, string message, AnalysisWarningCause cause) { var warning = new AnalysisWarning(flow.CurrentScript.FullName, message, flow.CurrentPartial, flow.CurrentProgramPoint, cause); AnalysisWarningHandler.SetWarning(flow.OutSet, warning); }
/// <summary> /// Report a warning for the position of current expression. /// </summary> /// <param name="message">Message of the warning.</param> /// <param name="cause">Cause of the warning.</param> protected void SetWarning(string message, AnalysisWarningCause cause) { var warning = new AnalysisWarning(flow.CurrentScript.FullName, message, flow.CurrentPartial, flow.CurrentProgramPoint, cause); AnalysisWarningHandler.SetWarning(OutSet, warning); }
/// <summary> /// Construct new instance of AnalysisWarning /// </summary> /// <param name="fullFileName">Full name of source code file</param> /// <param name="message">Warning message</param> /// <param name="element">Element, where the warning was produced</param> /// <param name="programPoint">The program point, where the warning was produced</param> /// <param name="cause">Warning cause</param> public AnalysisWarning(string fullFileName, string message, LangElement element, ProgramPointBase programPoint, AnalysisWarningCause cause) { Message = message; LangElement = element; ProgramPoint = programPoint; Cause = cause; FullFileName = fullFileName; }
/// <summary> /// Determines when the FlowOutputSet contains analysis warning, /// which has the same cause as the second parameter /// </summary> /// <param name="outset">Output set, which possibly contains warnings.</param> /// <param name="cause">Cause, to match</param> /// <returns>True, if FlowOutputSet contains warning with given cause</returns> public static bool ContainsWarning(FlowOutputSet outset, AnalysisWarningCause cause) { var warnings = AnalysisWarningHandler.ReadWarnings <AnalysisWarning>(outset); foreach (var value in warnings) { var infoValue = (InfoValue <AnalysisWarning>)value; if (infoValue.Data.Cause == cause) { return(true); } } return(false); }
/// <summary> /// Generates a warning of the proper type and with the given message /// </summary> /// <param name="message">Text of warning</param> /// <param name="cause">More specific warning type</param> public void SetWarning(string message, AnalysisWarningCause cause) { AnalysisWarningHandler.SetWarning(Context, new AnalysisWarning(Point.OwningScriptFullName, message, Point.Partial, Point, cause)); }
/// <summary> /// Runs the analysis of the code. /// </summary> /// <param name="code">The source code without <?php</param> /// <param name="cause">Cause, to match</param> /// <returns> /// <c>true</c>, if the FlowOutputSet of the analysis end contains warning with specified cause /// </returns> public static bool ArgumentWarningTest(string code, AnalysisWarningCause cause) { return(ContainsWarning(Analyze(code), cause)); }