Example #1
0
        public static DList <Token> ToNormalTokens(SparseAList <EditorToken> eTokens)
        {
            var output = new DList <Token>();
            int?index  = null;

            for (;;)
            {
                EditorToken eTok = eTokens.NextHigherItem(ref index);
                if (index == null)
                {
                    break;
                }
                output.Add(eTok.ToToken(index.Value));
            }
            return(output);
        }
Example #2
0
        public virtual IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            EnsureLexed(span.Snapshot, span.End.Position);

            List <ClassificationSpan> tags = new List <ClassificationSpan>();
            int?position = span.Start.Position + 1;
            var eToken   = _tokens.NextLowerItem(ref position);

            do
            {
                var tag = MakeClassificationSpan(span.Snapshot, eToken.ToToken(position ?? 0, false));
                if (tag != null)
                {
                    tags.Add(tag);
                }
                eToken = _tokens.NextHigherItem(ref position);
            } while (position != null && position < span.End.Position);
            return(tags);
        }
Example #3
0
        public void TestNextHigherItem()
        {
            var alist = new SparseAList <int>(_maxLeafSize, _maxInnerSize);
            int?i;

            for (i = 0; i < 100; i++)
            {
                alist.Add(i.Value);
            }
            alist.InsertSpace(50, 1000000000);
            i = null;
            Assert.AreEqual(alist.NextHigherItem(ref i), 0);
            Assert.AreEqual(i.Value, 0);
            i = int.MinValue;
            Assert.AreEqual(alist.NextHigherItem(ref i), 0);
            Assert.AreEqual(i.Value, 0);
            Assert.AreEqual(alist.NextHigherItem(ref i), 1);
            Assert.AreEqual(i.Value, 1);
            i = 49;
            Assert.AreEqual(alist.NextHigherItem(ref i), 50);
            Assert.AreEqual(i.Value, 1000000050);
            i = 50;
            Assert.AreEqual(alist.NextHigherItem(ref i), 50);
            Assert.AreEqual(i.Value, 1000000050);
            i = 1000000049;
            Assert.AreEqual(alist.NextHigherItem(ref i), 50);
            Assert.AreEqual(i.Value, 1000000050);
            i = 1000000098;
            Assert.AreEqual(alist.NextHigherItem(ref i), 99);
            Assert.AreEqual(i.Value, 1000000099);
            Assert.AreEqual(alist.NextHigherItem(ref i), default(int));
            Assert.AreEqual(i.HasValue, false);
            i = 1000000100;
            Assert.AreEqual(alist.NextHigherItem(ref i), default(int));
            Assert.AreEqual(i.HasValue, false);
            i = int.MaxValue;
            Assert.AreEqual(alist.NextHigherItem(ref i), default(int));
            Assert.AreEqual(i.HasValue, false);

            // Place a value at the edge of integer space
            alist.Clear();
            alist.InsertSpace(0, int.MaxValue - 1);
            alist.Add(777);
            i = int.MinValue;
            Assert.AreEqual(alist.NextHigherItem(ref i), 777);
            Assert.AreEqual(i.Value, int.MaxValue);
            Assert.AreEqual(alist.NextLowerItem(ref i), default(int));
            Assert.AreEqual(i.HasValue, false);
        }
Example #4
0
		public static DList<Token> ToNormalTokens(SparseAList<EditorToken> eTokens)
		{
			var output = new DList<Token>();
			int? index = null;
			for (;;) {
				EditorToken eTok = eTokens.NextHigherItem(ref index);
				if (index == null) break;
				output.Add(eTok.ToToken(index.Value));
			}
			return output;
		}