90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
// Copyright (c) Microsoft Open Technologies, Inc.
|
|
// All Rights Reserved
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
|
|
// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
|
// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
|
|
// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR
|
|
// NON-INFRINGEMENT.
|
|
// See the Apache 2 License for the specific language governing
|
|
// permissions and limitations under the License.
|
|
|
|
using System;
|
|
using System.Globalization;
|
|
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
|
|
using Microsoft.AspNet.Razor.Text;
|
|
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
|
|
using Microsoft.Internal.Web.Utils;
|
|
|
|
namespace Microsoft.AspNet.Razor.Test.Framework
|
|
{
|
|
internal class RawTextSymbol : ISymbol
|
|
{
|
|
public SourceLocation Start { get; private set; }
|
|
public string Content { get; private set; }
|
|
|
|
public RawTextSymbol(SourceLocation start, string content)
|
|
{
|
|
if (content == null)
|
|
{
|
|
throw new ArgumentNullException("content");
|
|
}
|
|
|
|
Start = start;
|
|
Content = content;
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
RawTextSymbol other = obj as RawTextSymbol;
|
|
return Equals(Start, other.Start) && Equals(Content, other.Content);
|
|
}
|
|
|
|
internal bool EquivalentTo(ISymbol sym)
|
|
{
|
|
return Equals(Start, sym.Start) && Equals(Content, sym.Content);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCodeCombiner.Start()
|
|
.Add(Start)
|
|
.Add(Content)
|
|
.CombinedHash;
|
|
}
|
|
|
|
public void OffsetStart(SourceLocation documentStart)
|
|
{
|
|
Start = documentStart + Start;
|
|
}
|
|
|
|
public void ChangeStart(SourceLocation newStart)
|
|
{
|
|
Start = newStart;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return String.Format(CultureInfo.InvariantCulture, "{0} RAW - [{1}]", Start, Content);
|
|
}
|
|
|
|
internal void CalculateStart(Span prev)
|
|
{
|
|
if (prev == null)
|
|
{
|
|
Start = SourceLocation.Zero;
|
|
}
|
|
else
|
|
{
|
|
Start = new SourceLocationTracker(prev.Start).UpdateLocation(prev.Content).CurrentLocation;
|
|
}
|
|
}
|
|
}
|
|
}
|