Esempio n. 1
0
        public static string BuildTypeNamespace(D_Parser.Dom.INode n)
        {
            var path = "";

            var curNode = n.Parent;

            while (curNode != null)
            {
                path = curNode.Name + "." + path;

                if (curNode == curNode.Parent)
                {
                    break;
                }

                curNode = curNode.Parent;
            }

            return(path.TrimEnd('.'));
        }
Esempio n. 2
0
        public static string GetNodeParamString(D_Parser.Dom.INode node)
        {
            string result = "";
            string sep    = "";

            if (node is DMethod)
            {
                foreach (D_Parser.Dom.INode param in (node as DMethod).Parameters)
                {
                    if (param.Type != null)
                    {
                        result = result + sep + param.Type.ToString();
                    }
                    sep = ", ";
                }
                if (result.Length != 0)
                {
                    result = "(" + result + ")";
                }
            }
            return(result);
        }
Esempio n. 3
0
 /*
  * public static INode ConvertDParserToDomNode(D_Parser.Dom.INode n, ParsedDocument doc)
  * {
  *      //TODO: DDoc comments!
  *
  *      if (n is DMethod)
  *      {
  *              var dm = n as DMethod;
  *
  *              var domMethod = new DomMethod(
  *                      n.Name,
  *                      GetNodeModifiers(dm),
  *                      dm.SpecialType == DMethod.MethodType.Constructor ? MethodModifier.IsConstructor : MethodModifier.None,
  *                      FromCodeLocation(n.StartLocation),
  *                      GetBlockBodyRegion(dm),
  *                      GetReturnType(n));
  *
  *              foreach (var pn in dm.Parameters)
  *                      domMethod.Add(new DomParameter(domMethod, pn.Name, GetReturnType(pn)));
  *
  *
  *              domMethod.AddTypeParameter(GetTypeParameters(dm));
  *
  *              foreach (var subNode in dm) domMethod.AddChild(ConvertDParserToDomNode(subNode, doc));
  *
  *              return domMethod;
  *      }
  *      else if (n is DEnum)
  *      {
  *              var de = n as DEnum;
  *
  *              var domType = new DomType(
  *                      doc.CompilationUnit,
  *                      ClassType.Enum,
  *                      GetNodeModifiers(de),
  *                      n.Name,
  *                      FromCodeLocation(n.StartLocation),
  *                      BuildTypeNamespace(n), GetBlockBodyRegion(de));
  *
  *              foreach (var subNode in de)
  *                      domType.Add(ConvertDParserToDomNode(subNode, doc) as IMember);
  *              return domType;
  *      }
  *      else if (n is DClassLike)
  *      {
  *              var dc = n as DClassLike;
  *
  *              ClassType ct = ClassType.Unknown;
  *
  *              switch (dc.ClassType)
  *              {
  *                      case DTokens.Template:
  *                      case DTokens.Class:
  *                              ct = ClassType.Class;
  *                              break;
  *                      case DTokens.Interface:
  *                              ct = ClassType.Interface;
  *                              break;
  *                      case DTokens.Union:
  *                      case DTokens.Struct:
  *                              ct = ClassType.Struct;
  *                              break;
  *              }
  *
  *              var domType = new DomType(
  *                      doc.CompilationUnit,
  *                      ct,
  *                      GetNodeModifiers(dc),
  *                      n.Name,
  *                      FromCodeLocation(n.StartLocation),
  *                      BuildTypeNamespace(n),
  *                      GetBlockBodyRegion(dc));
  *
  *              domType.AddTypeParameter(GetTypeParameters(dc));
  *              foreach (var subNode in dc)
  *                      domType.Add(ConvertDParserToDomNode(subNode, doc) as IMember);
  *              return domType;
  *      }
  *      else if (n is DVariable)
  *      {
  *              var dv = n as DVariable;
  *              return new DomField(n.Name, GetNodeModifiers(dv), FromCodeLocation(n.StartLocation), GetReturnType(n));
  *      }
  *      return null;
  * }
  */
 public static string BuildTypeNamespace(D_Parser.Dom.INode n)
 {
     return((n.NodeRoot as IAbstractSyntaxTree).ModuleName);
 }
Esempio n. 4
0
        public static MonoDevelop.Projects.Dom.INode ConvertDParserToDomNode(D_Parser.Dom.INode n, ParsedDocument doc)
        {
            //TODO: DDoc comments!

            if (n is DMethod)
            {
                var dm = n as DMethod;

                var domMethod = new DomMethod(
                    n.Name,
                    GetNodeModifiers(dm),
                    dm.SpecialType == DMethod.MethodType.Constructor ? MethodModifier.IsConstructor : MethodModifier.None,
                    FromCodeLocation(n.StartLocation),
                    GetBlockBodyRegion(dm),
                    GetReturnType(n));

                foreach (var pn in dm.Parameters)
                {
                    domMethod.Add(new DomParameter(domMethod, pn.Name, GetReturnType(pn)));
                }


                domMethod.AddTypeParameter(GetTypeParameters(dm));

                foreach (var subNode in dm)
                {
                    domMethod.AddChild(ConvertDParserToDomNode(subNode, doc));
                }

                return(domMethod);
            }
            else if (n is DEnum)
            {
                var de = n as DEnum;

                var domType = new DomType(
                    doc.CompilationUnit,
                    ClassType.Enum,
                    GetNodeModifiers(de),
                    n.Name,
                    FromCodeLocation(n.StartLocation),
                    BuildTypeNamespace(n), GetBlockBodyRegion(de));

                foreach (var subNode in de)
                {
                    domType.Add(ConvertDParserToDomNode(subNode, doc) as IMember);
                }
                return(domType);
            }
            else if (n is DClassLike)
            {
                var dc = n as DClassLike;

                ClassType ct = ClassType.Unknown;

                switch (dc.ClassType)
                {
                case DTokens.Template:
                case DTokens.Class:
                    ct = ClassType.Class;
                    break;

                case DTokens.Interface:
                    ct = ClassType.Interface;
                    break;

                case DTokens.Union:
                case DTokens.Struct:
                    ct = ClassType.Struct;
                    break;
                }

                var domType = new DomType(
                    doc.CompilationUnit,
                    ct,
                    GetNodeModifiers(dc),
                    n.Name,
                    FromCodeLocation(n.StartLocation),
                    BuildTypeNamespace(n),
                    GetBlockBodyRegion(dc));

                domType.AddTypeParameter(GetTypeParameters(dc));
                foreach (var subNode in dc)
                {
                    domType.Add(ConvertDParserToDomNode(subNode, doc) as IMember);
                }
                return(domType);
            }
            else if (n is DVariable)
            {
                var dv = n as DVariable;
                return(new DomField(n.Name, GetNodeModifiers(dv), FromCodeLocation(n.StartLocation), GetReturnType(n)));
            }
            return(null);
        }
Esempio n. 5
0
 public static IReturnType GetReturnType(D_Parser.Dom.INode n)
 {
     return(ToDomType(n.Type));
 }
Esempio n. 6
0
 /*
  * public static INode ConvertDParserToDomNode(D_Parser.Dom.INode n, ParsedDocument doc)
  * {
  *      //TODO: DDoc comments!
  *
  *      if (n is DMethod)
  *      {
  *              var dm = n as DMethod;
  *
  *              var domMethod = new DomMethod(
  *                      n.Name,
  *                      GetNodeModifiers(dm),
  *                      dm.SpecialType == DMethod.MethodType.Constructor ? MethodModifier.IsConstructor : MethodModifier.None,
  *                      FromCodeLocation(n.StartLocation),
  *                      GetBlockBodyRegion(dm),
  *                      GetReturnType(n));
  *
  *              foreach (var pn in dm.Parameters)
  *                      domMethod.Add(new DomParameter(domMethod, pn.Name, GetReturnType(pn)));
  *
  *
  *              domMethod.AddTypeParameter(GetTypeParameters(dm));
  *
  *              foreach (var subNode in dm) domMethod.AddChild(ConvertDParserToDomNode(subNode, doc));
  *
  *              return domMethod;
  *      }
  *      else if (n is DEnum)
  *      {
  *              var de = n as DEnum;
  *
  *              var domType = new DomType(
  *                      doc.CompilationUnit,
  *                      ClassType.Enum,
  *                      GetNodeModifiers(de),
  *                      n.Name,
  *                      FromCodeLocation(n.StartLocation),
  *                      BuildTypeNamespace(n), GetBlockBodyRegion(de));
  *
  *              foreach (var subNode in de)
  *                      domType.Add(ConvertDParserToDomNode(subNode, doc) as IMember);
  *              return domType;
  *      }
  *      else if (n is DClassLike)
  *      {
  *              var dc = n as DClassLike;
  *
  *              ClassType ct = ClassType.Unknown;
  *
  *              switch (dc.ClassType)
  *              {
  *                      case DTokens.Template:
  *                      case DTokens.Class:
  *                              ct = ClassType.Class;
  *                              break;
  *                      case DTokens.Interface:
  *                              ct = ClassType.Interface;
  *                              break;
  *                      case DTokens.Union:
  *                      case DTokens.Struct:
  *                              ct = ClassType.Struct;
  *                              break;
  *              }
  *
  *              var domType = new DomType(
  *                      doc.CompilationUnit,
  *                      ct,
  *                      GetNodeModifiers(dc),
  *                      n.Name,
  *                      FromCodeLocation(n.StartLocation),
  *                      BuildTypeNamespace(n),
  *                      GetBlockBodyRegion(dc));
  *
  *              domType.AddTypeParameter(GetTypeParameters(dc));
  *              foreach (var subNode in dc)
  *                      domType.Add(ConvertDParserToDomNode(subNode, doc) as IMember);
  *              return domType;
  *      }
  *      else if (n is DVariable)
  *      {
  *              var dv = n as DVariable;
  *              return new DomField(n.Name, GetNodeModifiers(dv), FromCodeLocation(n.StartLocation), GetReturnType(n));
  *      }
  *      return null;
  * }
  */
 public static string BuildTypeNamespace(D_Parser.Dom.INode n)
 {
     return((n.NodeRoot as DModule).ModuleName);
 }
 public NoSelectionCustomNode(D_Parser.Dom.INode parent)
 {
     this.Parent = parent;
 }