Holds a filename (FileName), a line number (Line) and a position in the line (PosInLine), representing a position in a source code file.
Line and column numbering both start at one (1). Line=0 signifies nowhere in particular. Instances are immutable.
Inheritance: LineAndCol
コード例 #1
0
 protected void Reset(CharSource source, SourcePos startingPos = null)
 {
     _source      = source;
     _lineOffsets = InternalList <int> .Empty;
     _lineOffsets.Add(0);
     _startingPos = startingPos;
 }
コード例 #2
0
        public override bool Equals(object obj)
        {
            SourcePos other = obj as SourcePos;

            if (other == null)
            {
                return(false);
            }
            return(other._fileName == _fileName && base.Equals(obj));
        }
コード例 #3
0
        public SourcePos IndexToLine(int index)
        {
            SourcePos pos  = _obj.IndexToLine(index);
            int       line = pos.Line;
            string    fn   = pos.FileName;

            if (Remaps.Remap(ref line, ref fn))
            {
                return(new SourcePosAndIndex(index, fn ?? FileName, line, pos.PosInLine));
            }
            return(pos);
        }
コード例 #4
0
ファイル: ISourceFile.cs プロジェクト: sizzles/ecsharp
 public SourceFile(CharSource source, SourcePos startingPos = null) : base(source, startingPos)
 {
     _source = source;
 }
コード例 #5
0
ファイル: IndexPositionMapper.cs プロジェクト: bel-uwa/Loyc
 /// <summary>Initializes CharIndexPositionMapper.</summary>
 /// <param name="source">An immutable list of characters.</param>
 /// <param name="startingPos">Optional. The first character of <c>source</c>
 /// will be considered to have the file name and line number specified by
 /// this object. If this is null, IndexToLine() will return a blank file
 /// name ("").</param>
 public IndexPositionMapper(IListSource <char> source, SourcePos startingPos = null)
 {
     _source = source;
     _lineOffsets.Add(0);
     _startingPos = startingPos;
 }
コード例 #6
0
 /// <summary>Initializes CharIndexPositionMapper.</summary>
 /// <param name="source">An immutable list of characters.</param>
 /// <param name="startingPos">Optional. The first character of <c>source</c>
 /// will be considered to have the file name and line number specified by
 /// this object. If this is null, IndexToLine() will return a blank file
 /// name ("").</param>
 public IndexPositionMapper(CharSource source, SourcePos startingPos = null)
 {
     Reset(source, startingPos);
 }