public void Analyse(Analysis.Context context)
 {
     context.AddProgramToAnalysis(this.program);
 }
示例#2
0
        // adapted from YarnSpinnerEditorWindow.CheckAllFiles(), converted into coroutine
        IEnumerator CheckAllFiles()
        {
            // The shared context for all script analysis.
            var analysisContext = new Yarn.Analysis.Context();

            // We shouldn't try to perform program analysis if
            // any of the files fails to compile, because that
            // analysis would be performed on incomplete data.
            bool shouldPerformAnalysis = true;

            // 9 Sept 2017, commented out from YarnSpinnerEditorWindow

            /*
             * // How many files have we finished checking?
             * int complete = 0;
             *
             * // Let's get started!
             *
             * // First, ensure that we're looking at all of the scripts.
             * UpdateYarnScriptList();
             */

            // Next, compile each one.
            foreach (var result in checkResults)
            {
                // Attempt to compile the file. Record any compiler messages.
                CheckerResult.State state;

                var messages = ValidateFile(result.script, analysisContext, out state);

                result.state    = state;
                result.messages = messages;

                // Don't perform whole-program analysis if any file failed to compile
                if (result.state != CheckerResult.State.Passed)
                {
                    shouldPerformAnalysis = false;
                }

                // 9 Sept 2017, commented out from YarnSpinnerEditorWindow

                /*
                 * // We're done with it; if we have a callback to call after
                 * // each file is validated, do so.
                 * complete++;
                 *
                 * if (callback != null)
                 *      callback(complete, checkResults.Count);
                 */

                yield return(0);
            }

            var results = new List <Yarn.Analysis.Diagnosis>();

            if (shouldPerformAnalysis)
            {
                var scriptAnalyses = analysisContext.FinishAnalysis();
                results.AddRange(scriptAnalyses);
            }

            var environmentAnalyses = AnalyseEnvironment();

            results.AddRange(environmentAnalyses);

            diagnoses = results;
        }