示例#1
0
 void BuildCompletionData(MemberSymbol mrr, IBlockNode currentlyScopedBlock, bool isVariableInstance = false)
 {
     if (mrr.Base != null)
     {
         BuildCompletionData(mrr.Base,
                             currentlyScopedBlock,
                             mrr is AliasedType ? isVariableInstance : true,             // True if we obviously have a variable handled here. Otherwise depends on the samely-named parameter..
                             mrr);
     }
     else
     {
         StaticTypePropertyProvider.AddGenericProperties(mrr, CompletionDataGenerator, mrr.Definition, false);
     }
 }
示例#2
0
        void BuildCompletionData(
            AbstractType rr,
            IBlockNode currentlyScopedBlock,
            bool isVariableInstance   = false,
            AbstractType resultParent = null)
        {
            if (rr == null)
            {
                return;
            }

            if (rr.DeclarationOrExpressionBase is ITypeDeclaration)
            {
                isVariableInstance |= (rr.DeclarationOrExpressionBase as ITypeDeclaration).ExpressesVariableAccess;
            }

            if (rr is MemberSymbol)
            {
                BuildCompletionData((MemberSymbol)rr, currentlyScopedBlock, isVariableInstance);
            }

            // A module path has been typed
            else if (!isVariableInstance && rr is ModuleSymbol)
            {
                BuildCompletionData((ModuleSymbol)rr);
            }

            else if (rr is PackageSymbol)
            {
                BuildCompletionData((PackageSymbol)rr);
            }

            #region A type was referenced directly
            else if (rr is EnumType)
            {
                var en = (EnumType)rr;

                foreach (var e in en.Definition)
                {
                    CompletionDataGenerator.Add(e);
                }
            }

            else if (rr is TemplateIntermediateType)
            {
                var tr  = (TemplateIntermediateType)rr;
                var vis = ItemVisibility.All;

                bool HasSameAncestor = HaveSameAncestors(currentlyScopedBlock, tr.Definition);
                bool IsThis = false, IsSuper = false;

                if (tr.DeclarationOrExpressionBase is TokenExpression)
                {
                    int token = ((TokenExpression)tr.DeclarationOrExpressionBase).Token;
                    IsThis  = token == DTokens.This;
                    IsSuper = token == DTokens.Super;
                }

                // Cases:

                // myVar. (located in basetype definition)		<-- Show everything
                // this.                                        <-- Show everything
                if (IsThis || (isVariableInstance && HasSameAncestor))
                {
                    vis = ItemVisibility.All;
                }

                // myVar. (not located in basetype definition)  <-- Show public and public static members
                else if (isVariableInstance && !HasSameAncestor)
                {
                    vis = ItemVisibility.PublicMembers | ItemVisibility.PublicStaticMembers;
                }

                // super.                                       <-- Show protected|public or protected|public static base type members
                else if (IsSuper)
                {
                    vis = ItemVisibility.ProtectedMembers | ItemVisibility.PublicMembers | ItemVisibility.PublicStaticMembers;
                }

                // myClass. (not located in myClass)			<-- Show public static members
                else if (!isVariableInstance && !HasSameAncestor)
                {
                    vis = ItemVisibility.PublicStaticMembers;
                }

                // myClass. (located in myClass)				<-- Show all static members
                else if (!isVariableInstance && HasSameAncestor)
                {
                    vis = ItemVisibility.StaticMembers;
                }

                BuildCompletionData(tr, vis);

                if (resultParent == null)
                {
                    StaticTypePropertyProvider.AddGenericProperties(rr, CompletionDataGenerator, tr.Definition);
                }

                StaticTypePropertyProvider.AddClassTypeProperties(CompletionDataGenerator, tr.Definition);
            }
            #endregion

            #region Things like int. or char.
            else if (rr is PrimitiveType)
            {
                var primType = (PrimitiveType)rr;

                if (resultParent == null)
                {
                    StaticTypePropertyProvider.AddGenericProperties(rr, CompletionDataGenerator, null);
                }

                if (primType.TypeToken > 0)
                {
                    // Determine whether float by the var's base type
                    bool isFloat = DTokens.BasicTypes_FloatingPoint[primType.TypeToken];

                    // Float implies integral props
                    if (DTokens.BasicTypes_Integral[primType.TypeToken] || isFloat)
                    {
                        StaticTypePropertyProvider.AddIntegralTypeProperties(primType.TypeToken, rr, CompletionDataGenerator, null, isFloat);
                    }

                    if (isFloat)
                    {
                        StaticTypePropertyProvider.AddFloatingTypeProperties(primType.TypeToken, rr, CompletionDataGenerator, null);
                    }
                }
            }
            #endregion

            else if (rr is PointerType)
            {
                var pt = (PointerType)rr;
                if (!(pt.Base is PrimitiveType && pt.Base.DeclarationOrExpressionBase is PointerDecl))
                {
                    BuildCompletionData(pt.Base, currentlyScopedBlock, true, pt);
                }
            }

            else if (rr is AssocArrayType)
            {
                var ar = (AssocArrayType)rr;

                if (ar is ArrayType)
                {
                    StaticTypePropertyProvider.AddArrayProperties(rr, CompletionDataGenerator, ar.DeclarationOrExpressionBase as ArrayDecl);
                }
                else
                {
                    StaticTypePropertyProvider.AddAssocArrayProperties(rr, CompletionDataGenerator, ar.DeclarationOrExpressionBase as ArrayDecl);
                }
            }
        }