Beispiel #1
0
        /// <summary>
        /// Analyzes the specified script path.
        /// </summary>
        /// <param name="path">The path to the script to analyze.</param>
        /// <param name="settings">The script analyzer settings.</param>
        /// <returns>The script analysis result.</returns>
        public ScriptAnalyzerResult Analyze(FilePath path, ScriptAnalyzerSettings settings)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            // Make the script path absolute.
            path = path.MakeAbsolute(_environment);

            // Get the correct callback.
            var callback = settings.Mode == ScriptAnalyzerMode.Modules
                ? ModuleAnalyzeCallback
                : (Action <IScriptAnalyzerContext>)AnalyzeCallback;

            // Create a new context.
            var context = new ScriptAnalyzerContext(
                _fileSystem, _environment,
                _log, callback, path);

            // Analyze the script.
            context.Analyze(path);

            // Create and return the results.
            return(new ScriptAnalyzerResult(
                       context.Current,
                       context.Lines,
                       context.Errors));
        }
Beispiel #2
0
        /// <summary>
        /// Analyzes the specified script path.
        /// </summary>
        /// <param name="path">The path to the script to analyze.</param>
        /// <returns>The script analysis result.</returns>
        public ScriptAnalyzerResult Analyze(FilePath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            // Make the script path absolute.
            path = path.MakeAbsolute(_environment);

            // Create a new context.
            var context = new ScriptAnalyzerContext(
                _fileSystem, _environment, _log, AnalyzeCallback, path);

            // Analyze the script.
            context.Analyze(path);

            // Create and return the results.
            return(new ScriptAnalyzerResult(
                       context.Current,
                       context.Lines));
        }