MakeTree() public static method

public static MakeTree ( ICoreShell coreShell, string expression ) : EditorTree
coreShell ICoreShell
expression string
return Microsoft.R.Editor.Tree.EditorTree
Exemplo n.º 1
0
        public void EditorTree_InvalidateAll()
        {
            EditorTree tree = EditorTreeTest.MakeTree("if(true) x <- a + b");

            tree.Invalidate();
            tree.AstRoot.Children.Should().BeEmpty();
        }
Exemplo n.º 2
0
 public void InvalidateAll()
 {
     using (var tree = EditorTreeTest.MakeTree(_coreShell, "if(true) x <- a + b")) {
         tree.Invalidate();
         tree.AstRoot.Children.Should().ContainSingle();
         tree.AstRoot.Children[0].Children.Should().BeEmpty();
     }
 }
Exemplo n.º 3
0
        public void EditorTree_InvalidateInRangeTest()
        {
            EditorTree tree = EditorTreeTest.MakeTree("if(true) x <- a + b");

            bool nodesChanged = false;
            bool result       = tree.InvalidateInRange(tree.AstRoot, new TextRange(4, 1), out nodesChanged);

            result.Should().BeTrue();
            nodesChanged.Should().BeTrue();
        }
Exemplo n.º 4
0
        public void InvalidateAllInRange(string content, int start, int length)
        {
            using (var tree = EditorTreeTest.MakeTree(_coreShell, content)) {
                bool nodesChanged = tree.InvalidateInRange(new TextRange(start, length));
                nodesChanged.Should().BeTrue();

                tree.AstRoot.Children.Should().ContainSingle();
                tree.AstRoot.Children[0].Should().BeOfType <GlobalScope>();
                tree.AstRoot.Children[0].Children.Should().BeEmpty();
            }
        }
Exemplo n.º 5
0
        public void InvalidatePartsInRange01(string content, int start, int length)
        {
            using (var tree = EditorTreeTest.MakeTree(_coreShell, content)) {
                bool nodesChanged = tree.InvalidateInRange(new TextRange(start, length));
                nodesChanged.Should().BeTrue();

                tree.AstRoot.Children.Should().ContainSingle();
                tree.AstRoot.Children[0].Should().BeOfType <GlobalScope>();

                tree.AstRoot.Children[0].Children.Should().NotBeEmpty();
                tree.AstRoot.Children[0].Children[0].Should().BeOfType <If>();

                var ifStatement = tree.AstRoot.Children[0].Children[0] as If;
                ifStatement.Should().NotBeNull();
                ifStatement.Scope.Should().NotBeNull();
                ifStatement.Scope.Children.Count.Should().Be(2);
                ifStatement.Scope.OpenCurlyBrace.Should().NotBeNull();
                ifStatement.Scope.CloseCurlyBrace.Should().NotBeNull();
            }
        }