Beispiel #1
0
        bool Visit(MetaProperty mp, Node n, int offset)
        {
            n.MetaProperty = mp;
            // Check if we are not inside the right node
            if (!(n.StartOffset < offset && n.EndOffset >= offset))
            {
                return(false);
            }

            NodePath.Add(n);
            if (n.Children != null)
            {
                foreach (var c in n.Children)
                {
                    if (Visit(mp, c, offset))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #2
0
        bool Visit(Member m, Node n, int offset)
        {
            n.Member = m;
            // Check if we are not inside the right node
            if (!(n.StartOffset < offset && n.EndOffset >= offset))
            {
                return(false);
            }

            NodePath.Add(n);

            if (n.Children != null)
            {
                foreach (var c in n.Children)
                {
                    if (m is Method)
                    {
                        var method = m as Method;

                        foreach (var db in method.DrawBlocks)
                        {
                            if (Visit(db, c, offset))
                            {
                                return(true);
                            }
                        }
                    }

                    if (Visit(m, c, offset))
                    {
                        return(true);
                    }
                }
            }

            return(true);
        }
Beispiel #3
0
        bool Visit(Namescope scope, Node n, int offset)
        {
            n.TypeOrNamespace = scope;
            if (scope is Uno.Compiler.API.Domain.IL.Types.ClassType)
            {
                n.BlockBase = (scope as Uno.Compiler.API.Domain.IL.Types.ClassType).Block;
            }

            if (scope is Block)
            {
                return(Visit(scope as Block, n, offset));
            }

            var name = n.Name;

            if (n.Name != "<root>" && name.Contains('<'))
            {
                name = name.Substring(0, name.IndexOf('<'));
            }

            // Check if we are not inside the right node
            if (!(n.StartOffset < offset && n.EndOffset >= offset))
            {
                return(false);
            }

            NodePath.Add(n);

            if (n.Children != null)
            {
                foreach (var c in n.Children)
                {
                    // If current scope is a data type, check if a type member has a match with the child node, if so let them have precedence
                    if (scope is DataType)
                    {
                        var dt = scope as DataType;

                        if (c.Type == NodeType.Constructor)
                        {
                            foreach (var m in dt.Constructors)
                            {
                                if (m.Source.Offset == c.StartOffset)
                                {
                                    if (Visit(m, c, offset))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (var m in dt.EnumerateMembers())
                            {
                                if (m.Name == c.Name)
                                {
                                    if (Visit(m, c, offset))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }

                    // Check if a child scope has a match with the child node, if so let them have precedence
                    foreach (var cn in scope.EnumerateNestedScopes())
                    {
                        if (cn.Name == c.Name)
                        {
                            if (Visit(cn, c, offset))
                            {
                                return(true);
                            }
                        }
                    }
                    if (Visit(scope, c, offset))
                    {
                        return(true);
                    }
                }
            }

            return(true);
        }
Beispiel #4
0
        bool Visit(BlockBase b, Node n, int offset)
        {
            n.BlockBase = b;
            // Check if we are not inside the right node
            if (!(n.StartOffset < offset && n.EndOffset >= offset))
            {
                return(false);
            }

            NodePath.Add(n);

            // Add metaproperties from lambda draw.
            var metaProperties = new List <MetaProperty>();

            foreach (var i in b.Members)
            {
                if (i.Type == BlockMemberType.Apply)
                {
                    var applyItem = i as Apply;
                    if (applyItem.Block.Parent == b)
                    {
                        foreach (var c in applyItem.Block.Members)
                        {
                            if (c.Type == BlockMemberType.MetaProperty)
                            {
                                metaProperties.Add(c as MetaProperty);
                            }
                        }
                    }
                }
            }

            if (n.Children != null)
            {
                foreach (var c in n.Children)
                {
                    foreach (var db in b.EnumerateNestedScopes())
                    {
                        if (Visit(db, c, offset))
                        {
                            return(true);
                        }
                    }

                    if (c.Type == NodeType.MetaProperty)
                    {
                        foreach (var m in metaProperties)
                        {
                            if (m.Name == c.Name)
                            {
                                if (Visit(m, c, offset))
                                {
                                    return(true);
                                }
                            }
                        }
                    }

                    foreach (var i in b.Members)
                    {
                        if (i.Type == BlockMemberType.Apply && c.Type == NodeType.Apply)
                        {
                            c.ApplyItem = i as Apply;
                            continue;
                        }

                        if (i.Type == BlockMemberType.MetaProperty && c.Type == NodeType.MetaProperty)
                        {
                            var mp = i as MetaProperty;
                            if (mp.Name == c.Name)
                            {
                                if (Visit(mp, c, offset))
                                {
                                    return(true);
                                }
                            }
                        }
                    }

                    if (Visit(b, c, offset))
                    {
                        return(true);
                    }
                }
            }

            return(true);
        }
Beispiel #5
0
 public void Add(Node n)
 {
     NodePath.Add(n);
 }