Beispiel #1
0
        /// <summary>
        /// Addproperties the specified m.
        /// </summary>
        /// <param name="m">The m.</param>
        /// <param name="ast">The ast.</param>
        /// <returns></returns>
        public PropertyCreator addproperty(IProperty m, AstNode ast)
        {
            if (properties == null)
            {
                properties = new ArrayList();
            }

            PropertyCreator me = new PropertyCreator();

            me.name = m.FullName;

            me.typename = m.ReturnType.FullName;

            me.ast = ast;

            me.start = new Point(m.Region.BeginColumn, m.Region.BeginLine);

            me.end = new Point(m.Region.EndColumn, m.Region.EndLine);

            properties.Add(me);

            return(me);
        }
Beispiel #2
0
        public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
        {
            mapper.loadAttributes(typeDeclaration);

            Dictionary <string, object> d = new Dictionary <string, object>();

            Console.WriteLine(typeDeclaration.Name + " : ");
            b.Append(typeDeclaration.Name + " : ");
            b.Append(typeDeclaration.GetRegion().ToString());
            b.Append(typeDeclaration.StartLocation.ToString() + "\n");
            b.Append(Resolver.UnresolvedFile.FileName);

            d.Add("Namespace", Namespace);
            d.Add("Name", typeDeclaration.Name);
            d.Add("Region", typeDeclaration.GetRegion().ToString());
            d.Add("Location", typeDeclaration.ToString());
            d.Add("FileName", Resolver.UnresolvedFile.FileName.ToString());
            d.Add("FullFileName", filename);

            mapper.classname = typeDeclaration.Name;

            mapper.classcode = typeDeclaration.Region.ToString();

            mapper.start = new Point(typeDeclaration.StartLocation.Column, typeDeclaration.StartLocation.Line);

            mapper.end = new Point(typeDeclaration.EndLocation.Column, typeDeclaration.EndLocation.Line);

            if (wm != null)
            {
                wm.SetShared(typeDeclaration.Name, d);
            }

            var typeResolveResult = Resolver.Resolve(typeDeclaration);

            if (typeResolveResult.IsError == true)
            {
                return;
            }

            mapper.Namespace = typeResolveResult.Type.Namespace;

            ITypeDefinition def = typeResolveResult.Type.GetDefinition();

            b.Append(def.Accessibility.ToString() + " : ");

            foreach (ITypeParameter p in def.TypeParameters)
            {
                b.Append("\t" + p.Name + " : ");
            }

            foreach (IProperty property in typeResolveResult.Type.GetProperties(property => true))
            {
                //Console.Write("\t" + method.Name + " : ");
                //b.Append("\t" + method.Name + " : ");

                //d.Add("Men", method.Name);
                //d.Add("Loc", method.Region.ToString());
                //d.Add("Reg", method.BodyRegion.ToString());

                AstNode ast = syntax.GetNodeContaining(property.Region.Begin, property.Region.End);

                PropertyCreator fc = mapper.addproperty(property, ast);
            }

            foreach (IMember member in typeResolveResult.Type.GetMembers(member => true))
            {
                //Console.Write("\t" + method.Name + " : ");
                //b.Append("\t" + method.Name + " : ");

                //d.Add("Men", method.Name);
                //d.Add("Loc", method.Region.ToString());
                //d.Add("Reg", method.BodyRegion.ToString());

                AstNode ast = syntax.GetNodeContaining(member.Region.Begin, member.Region.End);

                MemberCreator fc = mapper.addmember(member, ast);
            }

            foreach (IField field in typeResolveResult.Type.GetFields(field => true))
            {
                //Console.Write("\t" + method.Name + " : ");
                //b.Append("\t" + method.Name + " : ");

                //d.Add("Men", method.Name);
                //d.Add("Loc", method.Region.ToString());
                //d.Add("Reg", method.BodyRegion.ToString());

                AstNode ast = syntax.GetNodeContaining(field.Region.Begin, field.Region.End);

                FieldCreator fc = mapper.addfield(field, ast);
            }

            List <ResolveResult> r = typeResolveResult.GetChildResults().ToList();

            foreach (IMethod method in typeResolveResult.Type.GetMethods(method => true))
            {
                //Console.Write("\t" + method.Name + " : ");
                //b.Append("\t" + method.Name + " : ");

                //d.Add("Men", method.Name);
                //d.Add("Loc", method.Region.ToString());
                //d.Add("Reg", method.BodyRegion.ToString());

                AstNode ast = syntax.GetNodeContaining(method.Region.Begin, method.Region.End);

                MethodCreator mc = mapper.addmethod(method, ast);

                if (method.Parameters.Count == 0)
                {
                    Console.WriteLine("void");
                    b.Append("void");
                    // d.Add("Par", "void");
                }
                else
                {
                    IParameter[] parameters = method.Parameters.ToArray();

                    string[] p = new string[method.Parameters.Count];
                    int      i = 0;
                    foreach (var parameter in method.Parameters)
                    {
                        Console.WriteLine(parameter + " ");
                        b.Append(parameter + " ");
                        p[i++] = parameter.ToString();

                        mc.createparameter(ast, parameter);
                    }

                    //   d.Add("Par", p);

                    Console.WriteLine();
                    b.AppendLine();
                }
            }

            foreach (IEvent ev in typeResolveResult.Type.GetEvents(ev => true))
            {
                //Console.Write("\t" + ev.Name + " : ");
                //b.Append("\t" + ev.Name + " : ");

                //d.Add("Men", method.Name);
                //d.Add("Loc", method.Region.ToString());
                //d.Add("Reg", method.BodyRegion.ToString());

                AstNode ast = syntax.GetNodeContaining(ev.Region.Begin, ev.Region.End);

                EventCreator mc = mapper.addevent(ev, ast);

                //IAttribute v = ev.GetAttribute(, true);

                //if (ev.Parameters.Count == 0)
                //{
                //    Console.WriteLine("void");
                //    b.Append("void");
                //    d.Add("Par", "void");
                //}
                //else
                //{
                //    IParameter[] parameters = method.Parameters.ToArray();

                //    string[] p = new string[method.Parameters.Count];
                //    int i = 0;
                //    foreach (var parameter in method.Parameters)
                //    {
                //        Console.WriteLine(parameter + " ");
                //        b.Append(parameter + " ");
                //        p[i++] = parameter.ToString();

                //        mc.createparameter(ast, parameter);

                //    }

                //    d.Add("Par", p);

                //    Console.WriteLine();
                //    b.AppendLine();
                //}
            }

            base.VisitTypeDeclaration(typeDeclaration);
        }