Lucene.Net.Core.Analysis.TypeAttribute refactor: made the class partial, and 
renamed TypeAttribute_Fields > TypeAttribute as well. The field is attached to 
the concrete type (unfortunately), but at least this way the syntax is the same 
as it was in Lucene and the field is physically in the same file as the 
interface.


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

Branch: refs/heads/api-work
Commit: 018790f5068e61beb0afc5f4a40fbd480112d957
Parents: f0a0754
Author: Shad Storhaug <[email protected]>
Authored: Fri Mar 3 13:31:30 2017 +0700
Committer: Shad Storhaug <[email protected]>
Committed: Sun Mar 5 17:08:37 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Analysis/Token.cs           | 28 ++++++++++----------
 .../Analysis/TokenAttributes/ITypeAttribute.cs  |  8 +++++-
 .../Analysis/TokenAttributes/TypeAttribute.cs   |  8 +++---
 .../Analysis/Shingle/ShingleFilterTest.cs       |  4 +--
 src/Lucene.Net.Tests/Analysis/TestToken.cs      |  2 +-
 .../TokenAttributes/TestSimpleAttributeImpl.cs  |  2 +-
 6 files changed, 29 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/018790f5/src/Lucene.Net.Core/Analysis/Token.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/Token.cs 
b/src/Lucene.Net.Core/Analysis/Token.cs
index 71ef711..e0cb10f 100644
--- a/src/Lucene.Net.Core/Analysis/Token.cs
+++ b/src/Lucene.Net.Core/Analysis/Token.cs
@@ -76,27 +76,27 @@ namespace Lucene.Net.Analysis
     /// for details.</para>
     /// <para>Typical Token reuse patterns:
     /// <list type="bullet">
-    ///     <item> Copying text from a string (type is reset to <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> if not specified):
+    ///     <item> Copying text from a string (type is reset to <see 
cref="TypeAttribute.DEFAULT_TYPE"/> if not specified):
     ///     <code>
     ///         return reusableToken.Reinit(string, startOffset, endOffset[, 
type]);
     ///     </code>
     ///     </item>
-    ///     <item> Copying some text from a string (type is reset to <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> if not specified):
+    ///     <item> Copying some text from a string (type is reset to <see 
cref="TypeAttribute.DEFAULT_TYPE"/> if not specified):
     ///     <code>
     ///         return reusableToken.Reinit(string, 0, string.Length, 
startOffset, endOffset[, type]);
     ///     </code>
     ///     </item>
-    ///     <item> Copying text from char[] buffer (type is reset to <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> if not specified):
+    ///     <item> Copying text from char[] buffer (type is reset to <see 
cref="TypeAttribute.DEFAULT_TYPE"/> if not specified):
     ///     <code>
     ///         return reusableToken.Reinit(buffer, 0, buffer.Length, 
startOffset, endOffset[, type]);
     ///     </code>
     ///     </item>
-    ///     <item> Copying some text from a char[] buffer (type is reset to 
<see cref="TypeAttribute_Fields.DEFAULT_TYPE"/> if not specified):
+    ///     <item> Copying some text from a char[] buffer (type is reset to 
<see cref="TypeAttribute.DEFAULT_TYPE"/> if not specified):
     ///     <code>
     ///         return reusableToken.Reinit(buffer, start, end - start, 
startOffset, endOffset[, type]);
     ///     </code>
     ///     </item>
-    ///     <item> Copying from one one <see cref="Token"/> to another (type 
is reset to <see cref="TypeAttribute_Fields.DEFAULT_TYPE"/> if not specified):
+    ///     <item> Copying from one one <see cref="Token"/> to another (type 
is reset to <see cref="TypeAttribute.DEFAULT_TYPE"/> if not specified):
     ///     <code>
     ///         return reusableToken.Reinit(source.Buffer, 0, source.Length, 
source.StartOffset, source.EndOffset[, source.Type]);
     ///     </code>
@@ -119,7 +119,7 @@ namespace Lucene.Net.Analysis
     public class Token : CharTermAttribute, ITypeAttribute, 
IPositionIncrementAttribute, IFlagsAttribute, IOffsetAttribute, 
IPayloadAttribute, IPositionLengthAttribute
     {
         private int startOffset, endOffset;
-        private string type = 
TokenAttributes.TypeAttribute_Fields.DEFAULT_TYPE;
+        private string type = TypeAttribute.DEFAULT_TYPE;
         private int flags;
         private BytesRef payload;
         private int positionIncrement = 1;
@@ -381,7 +381,7 @@ namespace Lucene.Net.Analysis
             positionIncrement = 1;
             flags = 0;
             startOffset = endOffset = 0;
-            type = TokenAttributes.TypeAttribute_Fields.DEFAULT_TYPE;
+            type = TokenAttributes.TypeAttribute.DEFAULT_TYPE;
         }
 
         public override object Clone()
@@ -460,7 +460,7 @@ namespace Lucene.Net.Analysis
             positionIncrement = 1;
             flags = 0;
             startOffset = endOffset = 0;
-            type = TokenAttributes.TypeAttribute_Fields.DEFAULT_TYPE;
+            type = TokenAttributes.TypeAttribute.DEFAULT_TYPE;
         }
 
         /// <summary>
@@ -486,7 +486,7 @@ namespace Lucene.Net.Analysis
         /// Shorthand for calling <see cref="Clear"/>,
         /// <see cref="CopyBuffer(char[], int, int)"/>,
         /// <see cref="SetOffset"/>,
-        /// <see cref="Type"/> (set) on <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> </summary>
+        /// <see cref="Type"/> (set) on <see 
cref="TypeAttribute.DEFAULT_TYPE"/> </summary>
         /// <returns> this <see cref="Token"/> instance  </returns>
         public virtual Token Reinit(char[] newTermBuffer, int newTermOffset, 
int newTermLength, int newStartOffset, int newEndOffset)
         {
@@ -495,7 +495,7 @@ namespace Lucene.Net.Analysis
             CopyBuffer(newTermBuffer, newTermOffset, newTermLength);
             startOffset = newStartOffset;
             endOffset = newEndOffset;
-            type = TokenAttributes.TypeAttribute_Fields.DEFAULT_TYPE;
+            type = TokenAttributes.TypeAttribute.DEFAULT_TYPE;
             return this;
         }
 
@@ -537,7 +537,7 @@ namespace Lucene.Net.Analysis
         /// Shorthand for calling <see cref="Clear"/>,
         /// <see cref="Append(string)"/>,
         /// <see cref="SetOffset"/>,
-        /// <see cref="Type"/> (set) on <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> </summary>
+        /// <see cref="Type"/> (set) on <see 
cref="TypeAttribute.DEFAULT_TYPE"/> </summary>
         /// <returns> this <see cref="Token"/> instance  </returns>
         public virtual Token Reinit(string newTerm, int newStartOffset, int 
newEndOffset)
         {
@@ -546,7 +546,7 @@ namespace Lucene.Net.Analysis
             Append(newTerm);
             startOffset = newStartOffset;
             endOffset = newEndOffset;
-            type = TokenAttributes.TypeAttribute_Fields.DEFAULT_TYPE;
+            type = TokenAttributes.TypeAttribute.DEFAULT_TYPE;
             return this;
         }
 
@@ -554,7 +554,7 @@ namespace Lucene.Net.Analysis
         /// Shorthand for calling <see cref="Clear"/>,
         /// <see cref="Append(string, int, int)"/>,
         /// <see cref="SetOffset"/>,
-        /// <see cref="Type"/> (set) on <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> </summary>
+        /// <see cref="Type"/> (set) on <see 
cref="TypeAttribute.DEFAULT_TYPE"/> </summary>
         /// <returns> this <see cref="Token"/> instance  </returns>
         public virtual Token Reinit(string newTerm, int newTermOffset, int 
newTermLength, int newStartOffset, int newEndOffset)
         {
@@ -563,7 +563,7 @@ namespace Lucene.Net.Analysis
             Append(newTerm, newTermOffset, newTermOffset + newTermLength);
             startOffset = newStartOffset;
             endOffset = newEndOffset;
-            type = TokenAttributes.TypeAttribute_Fields.DEFAULT_TYPE;
+            type = TokenAttributes.TypeAttribute.DEFAULT_TYPE;
             return this;
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/018790f5/src/Lucene.Net.Core/Analysis/TokenAttributes/ITypeAttribute.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/TokenAttributes/ITypeAttribute.cs 
b/src/Lucene.Net.Core/Analysis/TokenAttributes/ITypeAttribute.cs
index fd5af3e..466d05a 100644
--- a/src/Lucene.Net.Core/Analysis/TokenAttributes/ITypeAttribute.cs
+++ b/src/Lucene.Net.Core/Analysis/TokenAttributes/ITypeAttribute.cs
@@ -29,7 +29,13 @@ namespace Lucene.Net.Analysis.TokenAttributes
         string Type { get; set; }
     }
 
-    public static class TypeAttribute_Fields
+    // LUCENENET specific - since we can't add a field to an interface,
+    // the concrete type was made into a partial class so we can keep
+    // this together in the same file as the interface.
+    // 
+    // The syntax is the same as it was in Lucene -
+    // TypeAttribute.DEFAULT_TYPE.
+    public partial class TypeAttribute
     {
         /// <summary>
         /// the default type

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/018790f5/src/Lucene.Net.Core/Analysis/TokenAttributes/TypeAttribute.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Analysis/TokenAttributes/TypeAttribute.cs 
b/src/Lucene.Net.Core/Analysis/TokenAttributes/TypeAttribute.cs
index abf77b4..fd9ebb3 100644
--- a/src/Lucene.Net.Core/Analysis/TokenAttributes/TypeAttribute.cs
+++ b/src/Lucene.Net.Core/Analysis/TokenAttributes/TypeAttribute.cs
@@ -24,7 +24,7 @@ namespace Lucene.Net.Analysis.TokenAttributes
 
     /// <summary>
     /// Default implementation of <see cref="ITypeAttribute"/>. </summary>
-    public class TypeAttribute : Attribute, ITypeAttribute
+    public partial class TypeAttribute : Attribute, ITypeAttribute
 #if FEATURE_CLONEABLE
         , ICloneable
 #endif
@@ -32,9 +32,9 @@ namespace Lucene.Net.Analysis.TokenAttributes
         private string type;
 
         /// <summary>
-        /// Initialize this attribute with <see 
cref="TypeAttribute_Fields.DEFAULT_TYPE"/> </summary>
+        /// Initialize this attribute with <see 
cref="TypeAttribute.DEFAULT_TYPE"/> </summary>
         public TypeAttribute()
-            : this(TypeAttribute_Fields.DEFAULT_TYPE)
+            : this(TypeAttribute.DEFAULT_TYPE)
         {
         }
 
@@ -53,7 +53,7 @@ namespace Lucene.Net.Analysis.TokenAttributes
 
         public override void Clear()
         {
-            type = TypeAttribute_Fields.DEFAULT_TYPE;
+            type = TypeAttribute.DEFAULT_TYPE;
         }
 
         public override bool Equals(object other)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/018790f5/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/ShingleFilterTest.cs
----------------------------------------------------------------------
diff --git 
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/ShingleFilterTest.cs 
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/ShingleFilterTest.cs
index ebe7d17..5e8a315 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/ShingleFilterTest.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Shingle/ShingleFilterTest.cs
@@ -412,9 +412,9 @@ namespace Lucene.Net.Analysis.Shingle
         {
             Tokenizer wsTokenizer = new 
WhitespaceTokenizer(TEST_VERSION_CURRENT, new StringReader("please divide this 
sentence"));
             TokenStream filter = new ShingleFilter(wsTokenizer, 2);
-            AssertTokenStreamContents(filter, new string[] { "please", "please 
divide", "divide", "divide this", "this", "this sentence", "sentence" }, new 
int[] { 0, 0, 7, 7, 14, 14, 19 }, new int[] { 6, 13, 13, 18, 18, 27, 27 }, new 
string[] { TypeAttribute_Fields.DEFAULT_TYPE, "shingle", 
TypeAttribute_Fields.DEFAULT_TYPE, "shingle", 
TypeAttribute_Fields.DEFAULT_TYPE, "shingle", TypeAttribute_Fields.DEFAULT_TYPE 
}, new int[] { 1, 0, 1, 0, 1, 0, 1 });
+            AssertTokenStreamContents(filter, new string[] { "please", "please 
divide", "divide", "divide this", "this", "this sentence", "sentence" }, new 
int[] { 0, 0, 7, 7, 14, 14, 19 }, new int[] { 6, 13, 13, 18, 18, 27, 27 }, new 
string[] { TypeAttribute.DEFAULT_TYPE, "shingle", TypeAttribute.DEFAULT_TYPE, 
"shingle", TypeAttribute.DEFAULT_TYPE, "shingle", TypeAttribute.DEFAULT_TYPE }, 
new int[] { 1, 0, 1, 0, 1, 0, 1 });
             wsTokenizer.SetReader(new StringReader("please divide this 
sentence"));
-            AssertTokenStreamContents(filter, new string[] { "please", "please 
divide", "divide", "divide this", "this", "this sentence", "sentence" }, new 
int[] { 0, 0, 7, 7, 14, 14, 19 }, new int[] { 6, 13, 13, 18, 18, 27, 27 }, new 
string[] { TypeAttribute_Fields.DEFAULT_TYPE, "shingle", 
TypeAttribute_Fields.DEFAULT_TYPE, "shingle", 
TypeAttribute_Fields.DEFAULT_TYPE, "shingle", TypeAttribute_Fields.DEFAULT_TYPE 
}, new int[] { 1, 0, 1, 0, 1, 0, 1 });
+            AssertTokenStreamContents(filter, new string[] { "please", "please 
divide", "divide", "divide this", "this", "this sentence", "sentence" }, new 
int[] { 0, 0, 7, 7, 14, 14, 19 }, new int[] { 6, 13, 13, 18, 18, 27, 27 }, new 
string[] { TypeAttribute.DEFAULT_TYPE, "shingle", TypeAttribute.DEFAULT_TYPE, 
"shingle", TypeAttribute.DEFAULT_TYPE, "shingle", TypeAttribute.DEFAULT_TYPE }, 
new int[] { 1, 0, 1, 0, 1, 0, 1 });
         }
 
         [Test]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/018790f5/src/Lucene.Net.Tests/Analysis/TestToken.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Analysis/TestToken.cs 
b/src/Lucene.Net.Tests/Analysis/TestToken.cs
index 5e3fa66..6d749f1 100644
--- a/src/Lucene.Net.Tests/Analysis/TestToken.cs
+++ b/src/Lucene.Net.Tests/Analysis/TestToken.cs
@@ -280,7 +280,7 @@ namespace Lucene.Net.Analysis
                 { typeof(IOffsetAttribute).Name + "#endOffset", 22 },
                 { typeof(IPositionIncrementAttribute).Name + 
"#positionIncrement", 1 },
                 { typeof(IPayloadAttribute).Name + "#payload", null },
-                { typeof(ITypeAttribute).Name + "#type", 
TypeAttribute_Fields.DEFAULT_TYPE },
+                { typeof(ITypeAttribute).Name + "#type", 
TypeAttribute.DEFAULT_TYPE },
                 { typeof(IFlagsAttribute).Name + "#flags", 8 }
             });
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/018790f5/src/Lucene.Net.Tests/Analysis/TokenAttributes/TestSimpleAttributeImpl.cs
----------------------------------------------------------------------
diff --git 
a/src/Lucene.Net.Tests/Analysis/TokenAttributes/TestSimpleAttributeImpl.cs 
b/src/Lucene.Net.Tests/Analysis/TokenAttributes/TestSimpleAttributeImpl.cs
index 609e4dc..434f653 100644
--- a/src/Lucene.Net.Tests/Analysis/TokenAttributes/TestSimpleAttributeImpl.cs
+++ b/src/Lucene.Net.Tests/Analysis/TokenAttributes/TestSimpleAttributeImpl.cs
@@ -36,7 +36,7 @@ namespace Lucene.Net.Analysis.TokenAttributes
             TestUtil.AssertAttributeReflection(new 
PositionIncrementAttribute(), 
Collections.SingletonMap(typeof(IPositionIncrementAttribute).Name + 
"#positionIncrement", (object)1));
             TestUtil.AssertAttributeReflection(new PositionLengthAttribute(), 
Collections.SingletonMap(typeof(IPositionLengthAttribute).Name + 
"#positionLength", (object)1));
             TestUtil.AssertAttributeReflection(new FlagsAttribute(), 
Collections.SingletonMap(typeof(IFlagsAttribute).Name + "#flags", (object)0));
-            TestUtil.AssertAttributeReflection(new TypeAttribute(), 
Collections.SingletonMap(typeof(ITypeAttribute).Name + "#type", 
(object)TypeAttribute_Fields.DEFAULT_TYPE));
+            TestUtil.AssertAttributeReflection(new TypeAttribute(), 
Collections.SingletonMap(typeof(ITypeAttribute).Name + "#type", 
(object)TypeAttribute.DEFAULT_TYPE));
             TestUtil.AssertAttributeReflection(new PayloadAttribute(), 
Collections.SingletonMap(typeof(IPayloadAttribute).Name + "#payload", 
(object)null));
             TestUtil.AssertAttributeReflection(new KeywordAttribute(), 
Collections.SingletonMap(typeof(IKeywordAttribute).Name + "#keyword", 
(object)false));
             TestUtil.AssertAttributeReflection(new OffsetAttribute(), new 
Dictionary<string, object>()

Reply via email to