CloneSet229


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
55230.989compilation_unit
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1551
src/NHibernate/Hql/Classic/GroupByParser.cs
2521
src/NHibernate/Hql/Classic/OrderByParser.cs
Clone Instance
1
Line Count
55
Source Line
1
Source File
src/NHibernate/Hql/Classic/GroupByParser.cs

using NHibernate.Util;

namespace NHibernate.Hql.Classic
{
        /// <summary> 
        /// Parses the GROUP BY clause of an aggregate query
        /// </summary>
        public class GroupByParser : IParser
        {
                //this is basically a copy/paste of OrderByParser ... might be worth refactoring

                // This uses a PathExpressionParser but notice that compound paths are not valid,
                // only bare names and simple paths:

                // SELECT p FROM p IN CLASS eg.Person GROUP BY p.Name, p.Address, p

                // The reason for this is SQL doesn't let you sort by an expression you are
                // not returning in the result set.

                private readonly PathExpressionParser pathExpressionParser = new PathExpressionParser();

                public void Token(string token, QueryTranslator q)
                {
                        if (q.IsName(StringHelper.Root(token)))
                        {
                                ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
                                q.AppendGroupByToken(pathExpressionParser.WhereColumn);
                                pathExpressionParser.AddAssociation(q);
                        }
                        else if (token.StartsWith(ParserHelper.HqlVariablePrefix))
                        {
                                q.AddNamedParameter(token.Substring(1));
                                q.AppendGroupByParameter();
                        }
                             else
                        {
                                q.AppendGroupByToken(token);
                        }
                }

                public void Start(QueryTranslator q)
                {
                }

                public void End(QueryTranslator q)
                {
                }

                public GroupByParser()
                {
                        pathExpressionParser.UseThetaStyleJoin = true;
                }

        }
}


Clone Instance
2
Line Count
52
Source Line
1
Source File
src/NHibernate/Hql/Classic/OrderByParser.cs

using NHibernate.Util;

namespace NHibernate.Hql.Classic
{
        /// <summary> 
        /// Parses the ORDER BY clause of a query
        /// </summary>
        public class OrderByParser : IParser
        {
                // This uses a PathExpressionParser but notice that compound paths are not valid,
                // only bare names and simple paths:

                // SELECT p FROM p IN CLASS eg.Person ORDER BY p.Name, p.Address, p

                // The reason for this is SQL doesn't let you sort by an expression you are
                // not returning in the result set.

                private readonly PathExpressionParser pathExpressionParser = new PathExpressionParser();

                public void Token(string token, QueryTranslator q)
                {
                        if (q.IsName(StringHelper.Root(token)))
                        {
                                ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
                                q.AppendOrderByToken(pathExpressionParser.WhereColumn);
                                pathExpressionParser.AddAssociation(q);
                        }
                        else if (token.StartsWith(ParserHelper.HqlVariablePrefix))
                        {
                                q.AddNamedParameter(token.Substring(1));
                                q.AppendOrderByParameter();
                        }
                             else
                        {
                                q.AppendOrderByToken(token);
                        }
                }

                public void Start(QueryTranslator q)
                {
                }

                public void End(QueryTranslator q)
                {
                }

                public OrderByParser()
                {
                        pathExpressionParser.UseThetaStyleJoin = true;
                }

        }
}


Clone AbstractionParameter Count: 3Parameter Bindings

using NHibernate.Util;
namespace NHibernate.Hql.Classic
{
   /// <summary> 
   /// Parses the GROUP BY clause of an aggregate query
   /// Parses the ORDER BY clause of a query
   /// </summary>
   public class [[#variable56af7ca0]]: IParser
   {
      //this is basically a copy/paste of OrderByParser ... might be worth refactoring
      // This uses a PathExpressionParser but notice that compound paths are not valid,
      // only bare names and simple paths:
      // SELECT p FROM p IN CLASS eg.Person GROUP BY p.Name, p.Address, p
      // SELECT p FROM p IN CLASS eg.Person ORDER BY p.Name, p.Address, p
      // The reason for this is SQL doesn't let you sort by an expression you are
      // not returning in the result set.
      private readonly PathExpressionParser pathExpressionParser = new PathExpressionParser();

      public void Token(string token, QueryTranslator q)
      {
         if (q.IsName(StringHelper.Root(token)))
         {
            ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
            q. [[#variable56af7c20]](pathExpressionParser.WhereColumn);
            pathExpressionParser.AddAssociation(q);
         }
         else
         if (token.StartsWith(ParserHelper.HqlVariablePrefix))
         {
            q.AddNamedParameter(token.Substring(1));
            q. [[#variable56af7c00]]();
         }
         else
         {
            q. [[#variable56af7c20]](token);
         }
      }

      public void Start(QueryTranslator q)
      {
      }

      public void End(QueryTranslator q)
      {
      }

      public [[#variable56af7ca0]]()
      {
         pathExpressionParser.UseThetaStyleJoin = true;
      }

   }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#56af7ca0]]
GroupByParser 
12[[#56af7ca0]]
OrderByParser 
21[[#56af7c20]]
AppendGroupByToken 
22[[#56af7c20]]
AppendOrderByToken 
31[[#56af7c00]]
AppendGroupByParameter 
32[[#56af7c00]]
AppendOrderByParameter