Beispiel #1
0
        /// <summary>
        /// </summary>
        /// <param name="anonimClass"></param>
        /// <param name="anonymousObjectCreastionExpression"></param>
        /// <returns></returns>
        private Class FillClassProperties(INamedTypeSymbol anonimClass, AnonimClass anonymousObjectCreastionExpression)
        {
            var limClass = anonimClass.ConvertToLimNode( ) as Class;

            limClass.Accessibility = Types.AccessibilityKind.ackInternal;
            limClass.Name          = anonimClass.ToString( );
            var parent =
                ( Scope )MainDeclaration.Instance.LimFactory.getRef(MainDeclaration.Instance.MethodStack.Peek( ).Id);

            limClass.MangledName         = limClass.DemangledName = parent.MangledName + "." + anonimClass;
            limClass.IsCompilerGenerated = true;
            limClass.IsAnonymous         = true;
            limClass.ClassKind           = Types.ClassKind.clkClass;

            Commons.Common.Safe_Edge(parent, "HasMember", limClass.Id);
            MainDeclaration.Instance.LimOrigin.addCompIdCsharpIdLimIdToMap(MainDeclaration.Instance.Component.Id,
                                                                           map[anonymousObjectCreastionExpression], limClass.Id);
            MainDeclaration.Instance.ClassStack.Push(new ClassInfo(limClass.Id));
            LLOC.CollectLineInfos(anonymousObjectCreastionExpression);
            MainDeclaration.Instance.ClassStack.Pop( );
            limClass.SetCLOC(anonymousObjectCreastionExpression);
            Commons.Common.AddIsContainedInEdge(limClass, anonymousObjectCreastionExpression);
            Commons.Common.Safe_Edge(limClass, "BelongsTo", MainDeclaration.Instance.Component.Id);

            return(limClass);
        }
Beispiel #2
0
        /// <summary>
        ///     Fill anonymous class's method properties
        /// </summary>
        /// <param name="member">Method's symbol</param>
        /// <param name="node">Actual node from LIM</param>
        /// <param name="anonymousObjectMemberDeclarator">Symbol's declaring syntax reference</param>
        private void FillGetterMethodNodeProperties(ISymbol member, Method node)
        {
            var anonymousObjectMemberDeclarator =
                anonymousObjectCreastionExpression.Initializers.FirstOrDefault(t => IsGetterMethod(t, member));

            //determine the return type in LIM
            if (anonymousObjectMemberDeclarator != null)
            {
                var returnType = (( IMethodSymbol )member).ReturnType;
                var limType    = returnType.GetLimType( );
                GenerateAttributeAccess(member, node, limType);
                CommonMethodProperties(member, node);
                node.NumberOfStatements = 1;
                node.addReturns(limType);
                node.MethodKind = Types.MethodKind.mekGet;

                MainDeclaration.Instance.LimOrigin.addCompIdCsharpIdLimIdToMap(MainDeclaration.Instance.Component.Id, map[anonymousObjectMemberDeclarator], node.Id);
                node.SetCLOC(anonymousObjectMemberDeclarator);
                MainDeclaration.Instance.MethodStack.Push(new MethodInfo(node.Id));
                RoslynVisitors.RoslynVisitor.Instance.Visit(anonymousObjectMemberDeclarator.Expression);
                LLOC.CollectLineInfos(anonymousObjectMemberDeclarator);
                Commons.Common.FillFromMethodStack(MainDeclaration.Instance.MethodStack.Pop(), false);
                anonymousObjectMemberDeclarator.CreateCommentNode(member);
                Commons.Common.AddIsContainedInEdge(node, anonymousObjectMemberDeclarator);
            }
        }
Beispiel #3
0
        private void fillMemberData(Member limNode, ISymbol roslynNode, bool setHasMember, bool aggregateLLOC = true)
        {
            limNode.Language = Types.LanguageKind.lnkCsharp;

            if (roslynNode.IsInMetadata())
            {
                MainDeclaration.Instance.LimFactory.setFiltered(limNode.Id);
            }

            if (MainDeclaration.Instance.SoftFilter != null)
            {
                if (MainDeclaration.Instance.CurrentFileIsSoftFiltered)
                {
                    MainDeclaration.Instance.LimFactory.setFiltered(limNode.Id);
                }
            }

            #region Accessibility
            switch (roslynNode.DeclaredAccessibility)
            {
            case Accessibility.Private:
                limNode.Accessibility = Types.AccessibilityKind.ackPrivate;
                break;

            case Accessibility.ProtectedAndInternal:
                limNode.Accessibility = Types.AccessibilityKind.ackInternal;
                break;

            case Accessibility.Protected:
                limNode.Accessibility = Types.AccessibilityKind.ackProtected;
                break;

            case Accessibility.Internal:
                limNode.Accessibility = Types.AccessibilityKind.ackInternal;
                break;

            case Accessibility.ProtectedOrInternal:
                limNode.Accessibility = Types.AccessibilityKind.ackProtectedInternal;
                break;

            case Accessibility.Public:
                limNode.Accessibility = Types.AccessibilityKind.ackPublic;
                break;

            default:
                break;
            }
            #endregion

            limNode.IsStatic            = roslynNode.IsStatic;
            limNode.IsCompilerGenerated = false;


            limNode.MangledName   = roslynNode.ToString();
            limNode.DemangledName = limNode.MangledName;

            if (aggregateLLOC && !roslynNode.IsInMetadata())
            {
                INamespaceSymbol ns = null;
                if (roslynNode.Kind == SymbolKind.Namespace)
                {
                    ns = (INamespaceSymbol)roslynNode;
                }

                if (ns == null || (ns != null && !ns.IsGlobalNamespace))
                {
                    foreach (var location in roslynNode.DeclaringSyntaxReferences)
                    {
                        Commons.Common.AddIsContainedInEdge(limNode, location.GetSyntax());
                    }
                }
            }

            Commons.Common.Safe_Edge(limNode, "BelongsTo", MainDeclaration.Instance.Component.Id);

            if (setHasMember)
            {
                ISymbol roslynParent = roslynNode;
                Base    limParent    = null;
                do
                {
                    roslynParent = roslynParent != null?roslynParent.Parent() : null;

                    if (roslynParent != null)
                    {
                        limParent = roslynParent.ConvertToLimNode();

                        if (roslynParent.Kind == SymbolKind.Namespace)
                        {
                            fillMemberData((Member)limParent, roslynParent, true, false);
                        }

                        if (roslynParent.IsInMetadata())
                        {
                            ((Member)limParent).IsCompilerGenerated = true;
                            ((Scope)limParent).MangledName          = ((Scope)limParent).DemangledName = roslynParent.ToString();
                            MainDeclaration.Instance.LimFactory.setFiltered(limParent.Id);
                        }
                    }
                    else
                    {
                        limParent = null;
                    }
                } while (roslynParent != null && !Lim.Asg.Common.getIsScope(limParent));
                if (limParent != null)
                {
                    Scope scope = (Scope)limParent;
                    Commons.Common.Safe_Edge(scope, "HasMember", limNode.Id);
                }
            }

            if (aggregateLLOC && !roslynNode.IsInMetadata() && roslynNode.DeclaringSyntaxReferences.Length > 0)
            {
                foreach (var syntaxNode in roslynNode.DeclaringSyntaxReferences)
                {
                    LLOC.CollectLineInfos(syntaxNode.GetSyntax());
                }
            }
        }