Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
55 | 2 | 3 | 0.989 | compilation_unit |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 55 | 1 | src/NHibernate/Hql/Classic/GroupByParser.cs |
2 | 52 | 1 | src/NHibernate/Hql/Classic/OrderByParser.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; } } } |
| ||||
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; } } } |
| |||
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 Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#56af7ca0]] | GroupByParser |
1 | 2 | [[#56af7ca0]] | OrderByParser |
2 | 1 | [[#56af7c20]] | AppendGroupByToken |
2 | 2 | [[#56af7c20]] | AppendOrderByToken |
3 | 1 | [[#56af7c00]] | AppendGroupByParameter |
3 | 2 | [[#56af7c00]] | AppendOrderByParameter |