public virtual INode Visit(ICompilationUnit unit, T data)
        {
            CompilationUnit newUnit = CreateInstance(unit, data);

            foreach (IUsing u in unit.Usings)
            {
                newUnit.Add((IUsing)u.AcceptVisitor(this, data));
            }
            foreach (IAttribute a in unit.Attributes)
            {
                newUnit.Add((IAttribute)a.AcceptVisitor(this, data));
            }
            foreach (IType t in unit.Types)
            {
                newUnit.Add((IType)t.AcceptVisitor(this, data));
            }
            return(newUnit);
        }
示例#2
0
            public override object VisitTypeDeclaration(ICSharpCode.OldNRefactory.Ast.TypeDeclaration typeDeclaration, object data)
            {
                DomType type = new DomType(cu,
                                           TranslateClassType(typeDeclaration.Type),
                                           (Modifiers)typeDeclaration.Modifier,
                                           typeDeclaration.Name,
                                           new DomLocation(typeDeclaration.StartLocation.Line, typeDeclaration.StartLocation.Column),
                                           currentNamespace.Count > 0 ? currentNamespace.Peek() : "",
                                           TranslateRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation));

                if (currentType.Count > 0)
                {
                    currentType.Peek().Add(type);
                }
                else
                {
                    cu.Add(type);
                }

                if (typeDeclaration.BaseTypes != null)
                {
                    foreach (ICSharpCode.OldNRefactory.Ast.TypeReference baseType in typeDeclaration.BaseTypes)
                    {
                        if (type.BaseType == null)
                        {
                            type.BaseType = TranslateTypeReference(baseType);
                        }
                        else
                        {
                            type.AddInterfaceImplementation(TranslateTypeReference(baseType));
                        }
                    }
                }
                currentType.Push(type);
                typeDeclaration.AcceptChildren(this, data);
                currentType.Pop();

                return(null);
            }