Exemplo n.º 1
0
        public override void Visit(DVariable n)
        {
            if (n.NameHash == 0 && n.ContainsAttribute(DTokens.Override))
            {
                prv  = new MethodOverrideCompletionProvider(n, cdgen);
                halt = true;
                return;
            }

            if (n.IsAlias)
            {
                // alias |
                // alias id = |
                // NOT alias Type |
                if (IsIncompleteDeclaration(n.Type))
                {
                    prv  = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, MemberFilter.All | MemberFilter.BlockKeywords);
                    halt = true;
                    return;
                }
            }
            else if (n.Initializer != null)
            {
                initializedNode    = n;
                handlesInitializer = true;
                n.Initializer.Accept(this);
                handlesInitializer = false;
            }

            if (!halt)
            {
                VisitDNode(n);
            }

            // auto |
            if (!halt && n.NameHash == 0 &&
                (n.ContainsAttribute(DTokens.Auto) || DParser.ContainsStorageClass(n.Attributes) != Modifier.Empty))
            {
                halt = true;
                explicitlyNoCompletion = true;
            }
        }
Exemplo n.º 2
0
        public override void Visit(DVariable n)
        {
            if (n.NameHash == 0 && n.ContainsAttribute(DTokens.Override))
            {
                prv  = new MethodOverrideCompletionProvider(n, cdgen);
                halt = true;
                return;
            }

            if (n.IsAlias)
            {
                // alias |
                // alias id = |
                // NOT alias Type |
                if (IsIncompleteDeclaration(n.Type))
                {
                    prv  = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, scopedStatement);
                    halt = true;
                }
            }
            else if (n.Initializer != null)
            {
                handlesInitializer = true;
                n.Initializer.Accept(this);
                handlesInitializer = false;
            }

            if (!halt)
            {
                VisitDNode(n);
            }

            // auto |
            if (!halt && n.NameHash == 0 && n.ContainsAttribute(DTokens.Auto))
            {
                halt = true;
                explicitlyNoCompletion = true;
            }
        }
Exemplo n.º 3
0
        public IconId Visit(DVariable dv)
        {
            if (dv.IsAlias)
            {
                // TODO: does declaring an alias private/protected/package actually have a meaning?
                return(iconIdWithProtectionAttr(dv, "alias"));
            }

            if (dv.ContainsPropertyAttribute())
            {
                return(iconIdWithProtectionAttr(dv, "property"));
            }

            if (dv.Type is DelegateDeclaration)
            {
                return(iconIdWithProtectionAttr(dv, "delegate"));
            }

            if (dv.ContainsAttribute(DTokens.Const) || (dv.ContainsAttribute(DTokens.Enum) && dv.Initializer == null))
            {
                return(iconIdWithProtectionAttr(dv, "literal", true));
            }

            var realParent = dv.Parent as DNode;

            if (realParent is DClassLike || dv.Parent is DModule)
            {
                return(iconIdWithProtectionAttr(dv, "field", true));
            }

            if (realParent is DMethod)
            {
                // FIXME: first parameter of class constructors is always displayed as a local, not a parameter
                if ((realParent as DMethod).Parameters.Contains(dv))
                {
                    if (dv.ContainsAttribute(DTokens.Ref))
                    {
                        return(GetNodeImage("ref_parameter"));
                    }
                    else if (dv.ContainsAttribute(DTokens.Lazy))
                    {
                        return(GetNodeImage("lazy_parameter"));
                    }
                    else if (dv.ContainsAttribute(DTokens.Out))
                    {
                        return(GetNodeImage("out_parameter"));
                    }
                    else
                    {
                        return(GetNodeImage("parameter"));
                    }
                    // TODO: immutable, scope?
                }
                return(GetNodeImage("local"));
            }

            TemplateParameter tpar;

            if (realParent != null && realParent.TryGetTemplateParameter(dv.NameHash, out tpar))
            {
                return(GetNodeImage("parameter"));
            }

            // Probably only static properties are left now
            return(iconIdWithProtectionAttr(dv, "field", true));
        }