public IList <AbstractSyntaxTreeAnalysisLevel> CreateLevels(ref AbstractSyntaxTreeNode expected) { var visitor = new AbstractSyntaxTreeAnalysisVisitor(); expected.PreOrder(visitor); return(visitor.Levels); }
public void Search_ShouldNotFindTwo() { var root = new AbstractSyntaxTreeNode("root"); root.Append(new AbstractSyntaxTreeNode("1 one")); var visitor = new AbstractSyntaxTreeWordSearchVisitor(Splitter, "two"); root.PreOrder(visitor); Assert.IsNull(visitor.Node); }
public void Search_ShouldFindTheNodeWithOne() { var root = new AbstractSyntaxTreeNode("root"); root.Append(new AbstractSyntaxTreeNode("1 one")); var visitor = new AbstractSyntaxTreeWordSearchVisitor(Splitter, "one"); root.PreOrder(visitor); Assert.IsTrue(visitor.Node.Value.Contains("1")); }
public AbstractSyntaxTreeNode Extract(AbstractSyntaxTreeNode root, string name) { var visitor = new ClassExtractorDeclVisitor(new ClassExtractorObj(), Splitter); root.PreOrder(visitor); var classNode = GatherDeclInformation(name, visitor.ExtractorObj, out var hashCode); var node = GatherMethodDeclaration(classNode, visitor.ExtractorObj, hashCode); return(node); }
public BagOfWordsMetric Create(AbstractSyntaxTreeNode expected, AbstractSyntaxTreeNode actual) { var expectedVisitor = new BagOfWordsMetricVisitor(Splitter); var actualVisitor = new BagOfWordsMetricVisitor(Splitter); expected.PreOrder(expectedVisitor); actual.PreOrder(actualVisitor); var lexicon = CreateJointLexicon(expectedVisitor.Lexicon, actualVisitor.Lexicon); var expectedVector = CreateWordVector(expectedVisitor.Content, lexicon); var actualVector = CreateWordVector(actualVisitor.Content, lexicon); return(new BagOfWordsMetric() { Difference = CalculateDifference(expectedVector, actualVector) }); }
public AbstractSyntaxTreeNode ExtractOrDefault(AbstractSyntaxTreeNode root, MethodDeclaration methodDeclaration) { var extractorObj = new MethodExtractorObj(); var methodExtractorVisitor = new MethodExtractorVisitor(extractorObj, Splitter, methodDeclaration.AstType); root.PreOrder(methodExtractorVisitor); var methodNode = GetMethodOrDefault(extractorObj, methodDeclaration, out var hashCode); if (methodNode == null) { return(null); } var callExpressionExtractorVisitor = new CallExpressionExtractorVisitor(extractorObj, Splitter); methodNode.PreOrder(callExpressionExtractorVisitor); var node = GatherCallExpressions(extractorObj, methodNode, root, hashCode); return(node); }