From: Kevin W. <kev...@us...> - 2004-12-31 18:23:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28167 Modified Files: ClauseParser.cs FilterTranslator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ClauseParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/ClauseParser.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ClauseParser.cs 22 Nov 2004 03:53:07 -0000 1.7 --- ClauseParser.cs 31 Dec 2004 18:23:33 -0000 1.8 *************** *** 1,84 **** - using System; using System.Collections; - using NHibernate; using NHibernate.Util; ! namespace NHibernate.Hql { ! /// <summary> /// Parses the hibernate query into its constituent clauses. /// </summary> ! public class ClauseParser : IParser { ! private IParser child; ! private IList selectTokens; ! private bool cacheSelectTokens = false; ! private bool byExpected = false; private int parenCount = 0; ! ! public virtual void Token(string token, QueryTranslator q) { string lcToken = token.ToLower(); ! ! if ( token.Equals(StringHelper.OpenParen ) ) { parenCount++; } ! else if ( token.Equals(StringHelper.ClosedParen ) ) { parenCount--; } ! if (byExpected && !lcToken.Equals("by")) { ! throw new QueryException("BY expected after GROUP or ORDER: " + token); } - - bool isClauseStart = parenCount==0; //ignore subselect keywords ! if (isClauseStart) { ! if (lcToken.Equals("select")) { selectTokens = new ArrayList(); cacheSelectTokens = true; ! } ! else if (lcToken.Equals("from")) { child = new FromParser(); ! child.Start(q); cacheSelectTokens = false; ! } ! else if (lcToken.Equals("where")) { ! EndChild(q); child = new WhereParser( q.Dialect ); ! child.Start(q); ! } ! else if (lcToken.Equals("order")) { ! EndChild(q); child = new OrderByParser(); byExpected = true; ! } ! else if (lcToken.Equals("having")) { ! EndChild(q); child = new HavingParser( q.Dialect ); ! child.Start(q); ! } ! else if (lcToken.Equals("group")) { ! EndChild(q); child = new GroupByParser(); byExpected = true; ! } ! else if (lcToken.Equals("by")) { ! if (!byExpected) throw new QueryException("GROUP or ORDER expected before BY"); ! child.Start(q); byExpected = false; ! } ! else { isClauseStart = false; --- 1,90 ---- using System.Collections; using NHibernate.Util; ! namespace NHibernate.Hql ! { /// <summary> /// Parses the hibernate query into its constituent clauses. /// </summary> ! public class ClauseParser : IParser ! { private IParser child; ! private IList selectTokens; ! private bool cacheSelectTokens = false; ! private bool byExpected = false; private int parenCount = 0; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public virtual void Token( string token, QueryTranslator q ) { string lcToken = token.ToLower(); ! ! if( token.Equals( StringHelper.OpenParen ) ) { parenCount++; } ! else if( token.Equals( StringHelper.ClosedParen ) ) { parenCount--; } ! if( byExpected && !lcToken.Equals( "by" ) ) { ! throw new QueryException( "BY expected after GROUP or ORDER: " + token ); } ! bool isClauseStart = parenCount == 0; //ignore subselect keywords ! ! if( isClauseStart ) { ! if( lcToken.Equals( "select" ) ) { selectTokens = new ArrayList(); cacheSelectTokens = true; ! } ! else if( lcToken.Equals( "from" ) ) { child = new FromParser(); ! child.Start( q ); cacheSelectTokens = false; ! } ! else if( lcToken.Equals( "where" ) ) { ! EndChild( q ); child = new WhereParser( q.Dialect ); ! child.Start( q ); ! } ! else if( lcToken.Equals( "order" ) ) { ! EndChild( q ); child = new OrderByParser(); byExpected = true; ! } ! else if( lcToken.Equals( "having" ) ) { ! EndChild( q ); child = new HavingParser( q.Dialect ); ! child.Start( q ); ! } ! else if( lcToken.Equals( "group" ) ) { ! EndChild( q ); child = new GroupByParser(); byExpected = true; ! } ! else if( lcToken.Equals( "by" ) ) { ! if( !byExpected ) ! { ! throw new QueryException( "GROUP or ORDER expected before BY" ); ! } ! child.Start( q ); byExpected = false; ! } ! else { isClauseStart = false; *************** *** 86,138 **** } ! if (!isClauseStart) { ! if (cacheSelectTokens) { ! selectTokens.Add(token); ! } ! else { ! if (child == null) { ! throw new QueryException("query must begin with SELECT or FROM: " + token); } ! else { ! child.Token(token, q); } } } } ! ! private void EndChild(QueryTranslator q) { ! if (child == null) { //null child could occur for no from clause in a filter cacheSelectTokens = false; ! } ! else { ! child.End(q); } } ! ! public virtual void Start(QueryTranslator q) { } ! ! public virtual void End(QueryTranslator q) { ! EndChild(q); ! if (selectTokens != null) { child = new SelectParser(); ! child.Start(q); ! foreach (string item in selectTokens) { ! Token(item, q); } ! child.End(q); } byExpected = false; --- 92,152 ---- } ! if( !isClauseStart ) { ! if( cacheSelectTokens ) { ! selectTokens.Add( token ); ! } ! else { ! if( child == null ) { ! throw new QueryException( "query must begin with SELECT or FROM: " + token ); } ! else { ! child.Token( token, q ); } } } } ! ! private void EndChild( QueryTranslator q ) { ! if( child == null ) { //null child could occur for no from clause in a filter cacheSelectTokens = false; ! } ! else { ! child.End( q ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void Start( QueryTranslator q ) { } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void End( QueryTranslator q ) { ! EndChild( q ); ! if( selectTokens != null ) { child = new SelectParser(); ! child.Start( q ); ! foreach( string item in selectTokens ) { ! Token( item, q ); } ! child.End( q ); } byExpected = false; Index: FilterTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FilterTranslator.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FilterTranslator.cs 21 Nov 2004 22:56:28 -0000 1.8 --- FilterTranslator.cs 31 Dec 2004 18:23:33 -0000 1.9 *************** *** 1,14 **** - using System; using System.Collections; - using NHibernate; - using NHibernate.Engine; using System.Runtime.CompilerServices; ! namespace NHibernate.Hql { ! ! public class FilterTranslator : QueryTranslator { ! public FilterTranslator(Dialect.Dialect d) : base(d) { } --- 1,16 ---- using System.Collections; using System.Runtime.CompilerServices; + using NHibernate.Engine; ! namespace NHibernate.Hql { ! /// <summary></summary> ! public class FilterTranslator : QueryTranslator { ! /// <summary> ! /// ! /// </summary> ! /// <param name="d"></param> ! public FilterTranslator( Dialect.Dialect d ) : base( d ) { } *************** *** 18,29 **** /// times. Subsequent invocations are no-ops. /// </summary> ! [MethodImpl(MethodImplOptions.Synchronized)] ! public void Compile(string collectionRole, ISessionFactoryImplementor factory, string queryString, IDictionary replacements, bool scalar) { ! if (!Compiled) { this.factory = factory; // yick! ! AddFromCollection("this", collectionRole); ! base.Compile(factory, queryString, replacements, scalar); } } --- 20,31 ---- /// times. Subsequent invocations are no-ops. /// </summary> ! [MethodImpl( MethodImplOptions.Synchronized )] ! public void Compile( string collectionRole, ISessionFactoryImplementor factory, string queryString, IDictionary replacements, bool scalar ) { ! if( !Compiled ) { this.factory = factory; // yick! ! AddFromCollection( "this", collectionRole ); ! base.Compile( factory, queryString, replacements, scalar ); } } |