コード例 #1
0
 private void AddParameterTypes(INamedTypeSymbol typeSymbol, FAMIX.Type type)
 {
     foreach (var typeParameter in typeSymbol.TypeParameters)
     {
         (type as ParameterizableClass).Parameters.Add(importer.EnsureType(typeParameter, typeof(FAMIX.ParameterType)) as FAMIX.ParameterType);
     }
 }
コード例 #2
0
        public FAMIX.Type EnsureType(ISymbol aType, String typeKind)
        {
            string fullName = helper.FullTypeName(aType);

            if (Types.has(fullName))
            {
                return(Types.Named(fullName));
            }

            FAMIX.Type type = repository.New <FAMIX.Type>(typeKind);
            type.isStub = true;

            Types.Add(fullName, type);

            if (typeKind.Equals(typeof(FAMIX.ArgumentType).FullName))
            {
                var parameterizedClass = EnsureType(aType.OriginalDefinition);
                (type as FAMIX.ArgumentType).parameterizableClass = parameterizedClass as FAMIX.ParameterizableClass;
            }

            type.name = helper.TypeName(aType);
            if (aType.ContainingType != null)
            {
                var containingType = EnsureType(aType.ContainingType);
                type.container = containingType;
            }
            else
            if (aType.ContainingNamespace != null)
            {
                var ns = EnsureNamespace(aType.ContainingNamespace);
                type.container = ns;
            }
            return(type);
        }
コード例 #3
0
        private void LinkWithInheritance(FAMIX.Type subClass, FAMIX.Type superClass)
        {
            Inheritance inheritance = CreateNewAssociation <Inheritance>(typeof(FAMIX.Inheritance).FullName);

            inheritance.subclass   = subClass;
            inheritance.superclass = superClass;
            superClass.AddSubInheritance(inheritance);
            subClass.AddSuperInheritance(inheritance);
        }
コード例 #4
0
ファイル: ASTVisitor.cs プロジェクト: lotbr101/roslyn2famix
    private void ComputeFanout(FAMIX.Type currentType)
    {
        //  currentType.Methods.ForEach(method=>method.OutgoingInvocations.ForEach())
        var types = currentType.Methods.SelectMany(
            method => method.OutgoingInvocations.SelectMany(
                invocation => invocation.Candidates.SelectMany(called => new FAMIX.Type[] { (called as Method).parentType }))).Distinct <FAMIX.Type>();
        var fanout = types.Sum <FAMIX.Type>(type => type == currentType ? 0 : 1);

        currentType.fanOut = fanout;
    }
コード例 #5
0
    public override void VisitEnumDeclaration(EnumDeclarationSyntax node)
    {
        var typeSymbol = importer.model.GetDeclaredSymbol(node);

        FAMIX.Type type = importer.EnsureType(typeSymbol);

        currentTypeStack.Push(type);
        importer.CreateSourceAnchor(type, node);
        type.isStub = false;
        base.VisitEnumDeclaration(node);
        currentTypeStack.Pop();
    }
コード例 #6
0
ファイル: ASTVisitor.cs プロジェクト: lotbr101/roslyn2famix
    public override void VisitStructDeclaration(StructDeclarationSyntax node)
    {
        var typeSymbol = semanticModel.GetDeclaredSymbol(node);

        FAMIX.Type type = importer.EnsureType(typeSymbol, typeof(FAMIX.Class));
        node.Modifiers.ToList <SyntaxToken>().ForEach(token => type.Modifiers.Add(token.Text));
        currentTypeStack.Push(type);
        importer.CreateSourceAnchor(type, node);
        type.isStub = false;
        base.VisitStructDeclaration(node);
        currentTypeStack.Pop();
    }
コード例 #7
0
        internal FAMIX.Type EnsureBinaryType(INamedTypeSymbol superType)
        {
            string fullName = helper.FullTypeName(superType.OriginalDefinition);

            if (Types.has(fullName))
            {
                return(Types.Named(fullName));
            }

            FAMIX.Type binaryType = RealEnsureType(superType.OriginalDefinition);
            var        members    = superType.GetMembers();

            foreach (var member in members)
            {
                if (member is IPropertySymbol)
                {
                    var attr = EnsureProperty((IPropertySymbol)member) as FAMIX.Attribute;
                    binaryType.AddAttribute(attr);
                    attr.parentType = binaryType;
                }

                if (member is IFieldSymbol)
                {
                    var attr = EnsureField((IFieldSymbol)member) as FAMIX.Attribute;
                    binaryType.AddAttribute(attr);
                    attr.parentType = binaryType;
                }
                if (member is IMethodSymbol)
                {
                    var methd = EnsureMethod(member as IMethodSymbol) as FAMIX.Method;
                    binaryType.AddMethod(methd);
                    methd.parentType = binaryType;
                }
            }

            if (superType.BaseType != null)
            {
                var superDuper = EnsureType(superType.BaseType.OriginalDefinition);
                LinkWithInheritance(binaryType, superDuper);
            }

            foreach (var inter in superType.AllInterfaces)
            {
                var superDuper = EnsureType(inter.OriginalDefinition);
                LinkWithInheritance(binaryType, superDuper);
            }
            return(binaryType);
        }
コード例 #8
0
ファイル: ASTVisitor.cs プロジェクト: lotbr101/roslyn2famix
 private void AddSuperInterfaces(INamedTypeSymbol typeSymbol, FAMIX.Type type)
 {
     foreach (var inter in typeSymbol.Interfaces)
     {
         FAMIX.Type fInterface = (FAMIX.Type)importer.EnsureType(inter, typeof(FAMIX.Class));
         if (fInterface is FAMIX.Class)
         {
             (fInterface as FAMIX.Class).isInterface = true;
         }
         Inheritance inheritance = importer.CreateNewAssociation <Inheritance>("FAMIX.Inheritance");
         inheritance.subclass   = type;
         inheritance.superclass = fInterface;
         fInterface.AddSubInheritance(inheritance);
         type.AddSuperInheritance(inheritance);
     }
 }
コード例 #9
0
ファイル: ASTVisitor.cs プロジェクト: lotbr101/roslyn2famix
    public override void VisitClassDeclaration(ClassDeclarationSyntax node)
    {
        var typeSymbol = semanticModel.GetDeclaredSymbol(node);

        FAMIX.Type type = type = importer.EnsureType(typeSymbol, typeof(FAMIX.Class));
        node.Modifiers.ToList <SyntaxToken>().ForEach(token => type.Modifiers.Add(token.Text));
        var superType = typeSymbol.BaseType;

        if (superType != null)
        {
            FAMIX.Type baseType = null;
            if (superType.DeclaringSyntaxReferences.Length == 0)
            {
                baseType = importer.EnsureBinaryType(superType);
            }
            else
            {
                baseType = importer.EnsureType(typeSymbol.BaseType, typeof(FAMIX.Class));
            }
            Inheritance inheritance = importer.CreateNewAssociation <Inheritance>(typeof(FAMIX.Inheritance).FullName);
            inheritance.subclass   = type;
            inheritance.superclass = baseType;
            baseType.AddSubInheritance(inheritance);
            type.AddSuperInheritance(inheritance);
        }

        //type.name = node.Identifier.ToString();
        AddSuperInterfaces(typeSymbol, type);
        AddAnnotations(typeSymbol, type);
        AddParameterTypes(typeSymbol, type);
        currentTypeStack.Push(type);
        importer.CreateSourceAnchor(type, node);
        type.isStub = false;
        if (type.container != null)
        {
            type.container.isStub = false;
        }
        base.VisitClassDeclaration(node);
        ComputeFanout(currentTypeStack.Peek() as FAMIX.Type);
        currentTypeStack.Pop();
    }
コード例 #10
0
        public void CreateSourceAnchor(FAMIX.Type sourcedEntity, ClassDeclarationSyntax node)
        {
            var        lineSpan   = node.SyntaxTree.GetLineSpan(node.Span);
            FileAnchor fileAnchor = CreateNewFileAnchor(node, ref lineSpan);
            var        loc        = lineSpan.EndLinePosition.Line - lineSpan.StartLinePosition.Line;

            if (node.Modifiers.ToFullString().Contains("partial"))
            {
                if (sourcedEntity.sourceAnchor == null)
                {
                    sourcedEntity.sourceAnchor = new MultipleFileAnchor();
                    repository.Add(sourcedEntity.sourceAnchor);
                }
                (sourcedEntity.sourceAnchor as MultipleFileAnchor).AddAllFile(fileAnchor);
            }
            else
            {
                sourcedEntity.sourceAnchor = fileAnchor;
            }
            (sourcedEntity as FAMIX.Type).numberOfLinesOfCode += loc;

            repository.Add(fileAnchor);
        }
コード例 #11
0
 public void AddArgument(FAMIX.Type one)
 {
     arguments.Add(one);
 }
コード例 #12
0
 public void AddType(FAMIX.Type one)
 {
     types.Add(one);
 }
コード例 #13
0
 public void AddType(FAMIX.Type one)
 {
     types.Add(one);
     one.container = this;
 }
コード例 #14
0
 public FAMIX.Implements CreateImplementsFor(FAMIX.Type implementingClass)
 {
     FAMIX.Implements implements = this.CreateNewEntity <FAMIX.Implements>(typeof(FAMIX.Implements).FullName);
     implements.ImplementingClass = implementingClass;
     return(implements);
 }
コード例 #15
0
 protected abstract void SetType(FAMIX.Type type);
コード例 #16
0
 public void SetSuperType(FAMIX.Type superType)
 {
     this.superclass = (FAMIX.Class)superType;
     this.subclass.AddSuperInheritance(this);
     this.superclass.AddSubInheritance(this);
 }
コード例 #17
0
 public virtual FAMIX.Type TypeUsing(VisualBasicModelBuilder importer)
 {
     FAMIX.Type type = importer.EnsureType(this.RelatedSymbol);
     this.SetType(type);
     return(type);
 }
コード例 #18
0
 public FAMIX.Inheritance CreateInheritanceFor(FAMIX.Type inheritingClass)
 {
     FAMIX.Inheritance inheritance = this.CreateNewEntity <FAMIX.Inheritance>(typeof(FAMIX.Inheritance).FullName);
     inheritance.subclass = inheritingClass;
     return(inheritance);
 }