Beispiel #1
0
        public NodesClassification Classify(IAnalyzableNode root)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            var syntaxNodes = root.DescendantNodesAndSelf();
            var results     = new Dictionary <IAnalyzableNode, AridCheckResult>();

            foreach (var node in syntaxNodes)
            {
                results[node] = Check(node, results);
            }

            return(new NodesClassification(results));
        }
Beispiel #2
0
        private static void WriteClassificationToConsole(
            IAnalyzableNode @class,
            NodesClassification classification,
            IChalk chalk)
        {
            foreach (var node in @class.DescendantNodesAndSelf())
            {
                var result = classification.GetResult(node);
                if (result.IsArid)
                {
                    chalk.Magenta($"ARID {node.Kind()}");
                }
                else
                {
                    chalk.Green($"NON-ARID {node.Kind()}");
                }

                chalk.Default(node.GetText());
                chalk.Default(Environment.NewLine + Environment.NewLine);
            }
        }