lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [2/5] lucenenet git commit: Lucene.Net.QueryParser: refactored members that accept IEnumerable<T> to IList<T> (per Lucene)
Date Wed, 01 Feb 2017 12:49:27 GMT
Lucene.Net.QueryParser: refactored members that accept IEnumerable<T> to IList<T>
(per Lucene)


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/deff1771
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/deff1771
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/deff1771

Branch: refs/heads/api-work
Commit: deff17716805bb5fcecd84a1b23ff41fbaa0c976
Parents: fe8795b
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Feb 1 18:19:14 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Feb 1 18:19:14 2017 +0700

----------------------------------------------------------------------
 .../Surround/Parser/QueryParser.cs                | 18 +++++++++---------
 .../Surround/Query/AndQuery.cs                    |  2 +-
 .../Surround/Query/ComposedQuery.cs               |  8 ++++----
 .../Surround/Query/DistanceQuery.cs               |  2 +-
 .../Surround/Query/FieldsQuery.cs                 | 10 +++++-----
 .../Surround/Query/NotQuery.cs                    |  2 +-
 .../Surround/Query/OrQuery.cs                     |  2 +-
 .../Surround/Query/SrndBooleanQuery.cs            |  8 ++++----
 .../TestApiConsistency.cs                         | 12 ++++++------
 9 files changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Parser/QueryParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Parser/QueryParser.cs b/src/Lucene.Net.QueryParser/Surround/Parser/QueryParser.cs
index 5a9d0c1..9866981 100644
--- a/src/Lucene.Net.QueryParser/Surround/Parser/QueryParser.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Parser/QueryParser.cs
@@ -91,7 +91,7 @@ namespace Lucene.Net.QueryParsers.Surround.Parser
         }
 
         protected virtual SrndQuery GetFieldsQuery(
-            SrndQuery q, IEnumerable<string> fieldNames)
+            SrndQuery q, IList<string> fieldNames)
         {
             /* FIXME: check acceptable subquery: at least one subquery should not be
              * a fields query.
@@ -99,17 +99,17 @@ namespace Lucene.Net.QueryParsers.Surround.Parser
             return new FieldsQuery(q, fieldNames, fieldOperator);
         }
 
-        protected virtual SrndQuery GetOrQuery(IEnumerable<SrndQuery> queries, bool
infix, Token orToken)
+        protected virtual SrndQuery GetOrQuery(IList<SrndQuery> queries, bool infix,
Token orToken)
         {
             return new OrQuery(queries, infix, orToken.Image);
         }
 
-        protected virtual SrndQuery GetAndQuery(IEnumerable<SrndQuery> queries, bool
infix, Token andToken)
+        protected virtual SrndQuery GetAndQuery(IList<SrndQuery> queries, bool infix,
Token andToken)
         {
             return new AndQuery(queries, infix, andToken.Image);
         }
 
-        protected virtual SrndQuery GetNotQuery(IEnumerable<SrndQuery> queries, Token
notToken)
+        protected virtual SrndQuery GetNotQuery(IList<SrndQuery> queries, Token notToken)
         {
             return new NotQuery(queries, notToken.Image);
         }
@@ -132,7 +132,7 @@ namespace Lucene.Net.QueryParsers.Surround.Parser
         }
 
         protected virtual SrndQuery GetDistanceQuery(
-            IEnumerable<SrndQuery> queries,
+            IList<SrndQuery> queries,
             bool infix,
             Token dToken,
             bool ordered)
@@ -195,14 +195,14 @@ namespace Lucene.Net.QueryParsers.Surround.Parser
         public SrndQuery FieldsQuery()
         {
             SrndQuery q;
-            IEnumerable<string> fieldNames;
+            IList<string> fieldNames;
             fieldNames = OptionalFields();
             q = OrQuery();
             { if (true) return (fieldNames == null) ? q : GetFieldsQuery(q, fieldNames);
}
             throw new Exception("Missing return statement in function");
         }
 
-        public IEnumerable<string> OptionalFields()
+        public IList<string> OptionalFields()
         {
             Token fieldName;
             IList<string> fieldNames = null;
@@ -429,7 +429,7 @@ namespace Lucene.Net.QueryParsers.Surround.Parser
         public SrndQuery PrefixOperatorQuery()
         {
             Token oprt;
-            IEnumerable<SrndQuery> queries;
+            IList<SrndQuery> queries;
             switch ((jj_ntk == -1) ? Jj_ntk() : jj_ntk)
             {
                 case RegexpToken.OR:
@@ -464,7 +464,7 @@ namespace Lucene.Net.QueryParsers.Surround.Parser
             throw new Exception("Missing return statement in function");
         }
 
-        public IEnumerable<SrndQuery> FieldsQueryList()
+        public IList<SrndQuery> FieldsQueryList()
         {
             SrndQuery q;
             IList<SrndQuery> queries = new List<SrndQuery>();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/AndQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/AndQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/AndQuery.cs
index cb53f6c..c792029 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/AndQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/AndQuery.cs
@@ -25,7 +25,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     /// </summary>
     public class AndQuery : ComposedQuery
     {
-        public AndQuery(IEnumerable<SrndQuery> queries, bool inf, string opName)
+        public AndQuery(IList<SrndQuery> queries, bool inf, string opName)
             : base(queries, inf, opName)
         {
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
index e35780d..5e6c4ac 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/ComposedQuery.cs
@@ -27,16 +27,16 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     /// </summary>
     public abstract class ComposedQuery : SrndQuery
     {
-        public ComposedQuery(IEnumerable<SrndQuery> qs, bool operatorInfix, string
opName)
+        public ComposedQuery(IList<SrndQuery> qs, bool operatorInfix, string opName)
         {
             Recompose(qs);
             this.operatorInfix = operatorInfix;
             this.m_opName = opName;
         }
 
-        protected virtual void Recompose(IEnumerable<SrndQuery> queries)
+        protected virtual void Recompose(IList<SrndQuery> queries)
         {
-            if (queries.Count() < 2) throw new InvalidOperationException("Too few subqueries");
+            if (queries.Count < 2) throw new InvalidOperationException("Too few subqueries");
             this.m_queries = new List<SrndQuery>(queries);
         }
 
@@ -57,7 +57,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
         private bool operatorInfix;
         public virtual bool IsOperatorInfix { get { return operatorInfix; } } /* else prefix
operator */
 
-        public virtual IEnumerable<Search.Query> MakeLuceneSubQueriesField(string fn,
BasicQueryFactory qf)
+        public virtual IList<Search.Query> MakeLuceneSubQueriesField(string fn, BasicQueryFactory
qf)
         {
             List<Search.Query> luceneSubQueries = new List<Search.Query>();
             IEnumerator<SrndQuery> sqi = GetSubQueriesEnumerator();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/DistanceQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/DistanceQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/DistanceQuery.cs
index 5169343..9489a64 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/DistanceQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/DistanceQuery.cs
@@ -28,7 +28,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     public class DistanceQuery : ComposedQuery, IDistanceSubQuery
     {
         public DistanceQuery(
-            IEnumerable<SrndQuery> queries,
+            IList<SrndQuery> queries,
             bool infix,
             int opDistance,
             string opName,

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/FieldsQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/FieldsQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/FieldsQuery.cs
index c6c648c..6cfe78b 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/FieldsQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/FieldsQuery.cs
@@ -27,14 +27,14 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     public class FieldsQuery : SrndQuery /* mostly untested */
     {
         private SrndQuery q;
-        private IEnumerable<string> fieldNames;
+        private IList<string> fieldNames;
         private readonly char fieldOp;
         private readonly string orOperatorName = "OR"; /* for expanded queries, not normally
visible */
 
-        public FieldsQuery(SrndQuery q, IEnumerable<string> fieldNames, char fieldOp)
+        public FieldsQuery(SrndQuery q, IList<string> fieldNames, char fieldOp)
         {
             this.q = q;
-            this.fieldNames = new List<string>(fieldNames);
+            this.fieldNames = fieldNames;
             this.fieldOp = fieldOp;
         }
 
@@ -54,7 +54,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
 
         public virtual Search.Query MakeLuceneQueryNoBoost(BasicQueryFactory qf)
         {
-            if (fieldNames.Count() == 1)
+            if (fieldNames.Count == 1)
             { /* single field name: no new queries needed */
                 return q.MakeLuceneQueryFieldNoBoost(fieldNames.FirstOrDefault(), qf);
             }
@@ -79,7 +79,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
             return MakeLuceneQueryNoBoost(qf); /* use this.fieldNames instead of fieldName
*/
         }
 
-        public virtual IEnumerable<string> FieldNames { get { return fieldNames; }
}
+        public virtual IList<string> FieldNames { get { return fieldNames; } }
 
         public virtual char FieldOperator { get { return fieldOp; } }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
index 0820198..64a0633 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/NotQuery.cs
@@ -26,7 +26,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     /// </summary>
     public class NotQuery : ComposedQuery
     {
-        public NotQuery(IEnumerable<SrndQuery> queries, string opName)
+        public NotQuery(IList<SrndQuery> queries, string opName)
             : base(queries, true /* infix */, opName)
         {
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/OrQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/OrQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/OrQuery.cs
index d164740..30b883e 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/OrQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/OrQuery.cs
@@ -25,7 +25,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     /// </summary>
     public class OrQuery : ComposedQuery, IDistanceSubQuery
     {
-        public OrQuery(IEnumerable<SrndQuery> queries, bool infix, string opName)
+        public OrQuery(IList<SrndQuery> queries, bool infix, string opName)
             : base(queries, infix, opName)
         {
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
index 49bbd9e..25b21c3 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/SrndBooleanQuery.cs
@@ -26,7 +26,7 @@ namespace Lucene.Net.QueryParsers.Surround.Query
     {
         public static void AddQueriesToBoolean(
             BooleanQuery bq,
-            IEnumerable<Search.Query> queries,
+            IList<Search.Query> queries,
             Occur occur)
         {
             foreach (var query in queries)
@@ -36,12 +36,12 @@ namespace Lucene.Net.QueryParsers.Surround.Query
         }
 
         public static Search.Query MakeBooleanQuery(
-            IEnumerable<Search.Query> queries,
+            IList<Search.Query> queries,
             Occur occur)
         {
-            if (queries.Count() <= 1)
+            if (queries.Count <= 1)
             {
-                throw new InvalidOperationException("Too few subqueries: " + queries.Count());
+                throw new InvalidOperationException("Too few subqueries: " + queries.Count);
             }
             BooleanQuery bq = new BooleanQuery();
             AddQueriesToBoolean(bq, queries, occur);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/deff1771/src/Lucene.Net.Tests.QueryParser/TestApiConsistency.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/TestApiConsistency.cs b/src/Lucene.Net.Tests.QueryParser/TestApiConsistency.cs
index b28ace3..26b0896 100644
--- a/src/Lucene.Net.Tests.QueryParser/TestApiConsistency.cs
+++ b/src/Lucene.Net.Tests.QueryParser/TestApiConsistency.cs
@@ -103,12 +103,12 @@ namespace Lucene.Net.QueryParsers
 
         // LUCENENET NOTE: This test is only for identifying members who were changed from
         // ICollection, IList or ISet to IEnumerable during the port (that should be changed
back)
-        //[Test, LuceneNetSpecific]
-        //[TestCase(typeof(Lucene.Net.QueryParsers.Classic.ICharStream))]
-        //public override void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly)
-        //{
-        //    base.TestForMembersAcceptingOrReturningIEnumerable(typeFromTargetAssembly);
-        //}
+        [Test, LuceneNetSpecific]
+        [TestCase(typeof(Lucene.Net.QueryParsers.Classic.ICharStream))]
+        public override void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly)
+        {
+            base.TestForMembersAcceptingOrReturningIEnumerable(typeFromTargetAssembly);
+        }
 
         [Test, LuceneNetSpecific]
         [TestCase(typeof(Lucene.Net.QueryParsers.Classic.ICharStream))]


Mime
View raw message