public IntellisenseIcon Resolve(IBooParseTreeNode node)
        {
            Type nodeType = node.GetType();

            if (treeNodeIconMap.ContainsKey(nodeType))
                return treeNodeIconMap[nodeType];

            return 0;
        }
        public BooParseTreeNodeList FlattenFrom(IBooParseTreeNode node)
        {
            BooParseTreeNodeList flattened = new IntellisenseNodeList();

            // add anything "below" the scope (e.g. locals in a method, methods in a class)
            flattened.AddRange(FlattenDown(node.Children));

            // add anything "above" the scope (e.g. classes in a method)
            // also walks sideways (e.g. other methods in same class if scope is a method)
            flattened.AddRange(FlattenUp(node));

            return flattened;
        }
        private IList<IBooParseTreeNode> FlattenUp(IBooParseTreeNode node)
        {
            IList<IBooParseTreeNode> flattened = new IntellisenseNodeList();
            IBooParseTreeNode parent = node;

            while ((parent = parent.Parent) != null)
            {
                foreach (IBooParseTreeNode sibling in parent.Children)
                {
                    flattened.Add(sibling);
                }

                flattened.Add(parent);
            }

            return flattened;
        }
        private IBooParseTreeNode GetScopeByLine(IBooParseTreeNode node, int line)
        {
            foreach (IBooParseTreeNode child in node.Children)
            {
                IBooParseTreeNode foundNode = GetScopeByLine(child, line);

                if (foundNode != null)
                    return foundNode;
            }

            bool isScopable = AttributeHelper.Has<ScopableAttribute>(node.GetType());

            if (isScopable && node.ContainsLine(line))
                return node;

            return null;
        }
        private static string Output(IBooParseTreeNode node, int indentLevel)
        {
            string indent = "";

            for (int i = 0; i < indentLevel; i++)
            {
                indent += "  ";
            }

            string output = indent +
                            node.GetType().Name + ": " +
                            node.Name +
                            "(" + node.StartLine + "," + node.EndLine + ")" +
                            Environment.NewLine;

            foreach (IBooParseTreeNode child in node.Children)
            {
                output += Output(child, indentLevel + 1);
            }

            return output;
        }
Exemple #6
0
        public void InjectIntoScope(IBooParseTreeNode scope)
        {
            if (scope == null) return;

            TypeKeywordResolver keywords = new TypeKeywordResolver();

            string[] words = keywords.GetForScope(scope);

            foreach (IBooParseTreeNode child in scope.Children)
            {
                keywords.GetForScope(child);
            }

            foreach (string word in words)
            {
                KeywordTreeNode treeNode = new KeywordTreeNode();

                treeNode.Name = word;

                scope.Children.Add(treeNode);
            }
        }
        private void Push(IBooParseTreeNode node, int line)
        {
            node.Parent = currentScope;
            node.StartLine = line;

            currentScope.Children.Add(node);
            currentScope = node;
        }
 private void Pop(int endLine)
 {
     currentScope.EndLine = endLine;
     currentScope = currentScope.Parent;
 }
        public override void Run()
        {
            currentScope = project;

            Visit(CompileUnit);

            VisitReferences();
        }
 public override void Add(IBooParseTreeNode member)
 {
     // allow only other namespaces to be displayed
     if (member is NamespaceTreeNode)
         base.Add(member);
 }
 public static string Output(IBooParseTreeNode node)
 {
     return Output(node, 0);
 }
        private DocumentTreeNode GetDocument(IBooParseTreeNode node)
        {
            var currentNode = node;

            while (!(currentNode is DocumentTreeNode))
            {
                currentNode = currentNode.Parent;
            }

            return currentNode as DocumentTreeNode;
        }
        /// <summary>
        /// Adds members from the current scope (flattened, so all containing scopes are included) to
        /// the declarations.
        /// </summary>
        private void AddMembersFromScopeTree(IntellisenseDeclarations declarations, IBooParseTreeNode scopedParseTree)
        {
            var parseTreeFlattener = new BooParseTreeNodeFlatterner();

            declarations.AddRange(parseTreeFlattener.FlattenFrom(scopedParseTree));
        }
        /// <summary>
        /// Adds keywords based on the current scope to the declarations.
        /// </summary>
        private void AddKeywords(IntellisenseDeclarations declarations, IBooParseTreeNode scopedParseTree)
        {
            var keywords = new TypeKeywordResolver();

            declarations.Add(keywords.GetForScope(scopedParseTree));
        }
 public override void Add(IBooParseTreeNode item)
 {
     if (item.IntellisenseVisible)
         base.Add(item);
 }
 public CompiledDocument(IBooParseTreeNode root)
 {
     this.root = root;
 }