示例#1
0
 private void WriteSourceMap(SyntaxNodeOrToken node, Position pos, string str)
 {
     if (node.Kind() == SyntaxKind.IdentifierName || node.Kind() == SyntaxKind.IdentifierToken || node.Kind() == SyntaxKind.ObjectCreationExpression)
     {
         System.Diagnostics.Debug.WriteLine($"{node} ---> [{node.Kind()} | {pos}] ---> {str}");
         _sourceMapOutput.AddMapping(node, pos);
     }
 }
示例#2
0
        public void AddMapping(SyntaxNodeOrToken node, Position pos)
        {
            var srcPos = node.GetLocation().GetLineSpan().StartLinePosition;
            if (_line == pos.Line)
            {
                if (_mapping.Length > 0 && _mapping[_mapping.Length - 1] != ';')
                    _mapping.Append(',');
            }
            else
            {
                while (_line < pos.Line)
                {
                    _mapping.Append(';');
                    _line++;
                }
            }

            _mapping.Append(Base64VLQEncoding.Encode(pos.Column));
            _mapping.Append(Base64VLQEncoding.Encode(_srcIdx));
            _mapping.Append(Base64VLQEncoding.Encode(srcPos.Line));
            _mapping.Append(Base64VLQEncoding.Encode(srcPos.Character));
        }
示例#3
0
 public Position Write(char ch)
 {
     if (_newLine)
     {
         this.WriteIndent();
         _column += IndentLength;
     }
     Position start = new Position(_line, _column);
     this.WriteContent(ch);
     if (System.Environment.NewLine.Length == 1 && System.Environment.NewLine[0] == ch)
     {
         this._newLine = true;
         _line++;
         _column = 0;
     }
     else
     {
         this._newLine = false;
         _column += 1;
     }
     return start;
 }
示例#4
0
 public Position WriteLine(string str)
 {
     if (_newLine)
     {
         this.WriteIndent();
         _column += IndentLength;
     }
     Position start = new Position(_line, _column);
     this.WriteContent(str);
     this.Correction(str);
     if (!str.EndsWith(System.Environment.NewLine))
         this.WriteContent(System.Environment.NewLine);
     this._newLine = true;
     _line++;
     _column = 0;
     return start;
 }
示例#5
0
 public Position WriteLine()
 {
     Position start = new Position(_line, _column);
     this.WriteContent(System.Environment.NewLine);
     this._newLine = true;
     _line++;
     _column = 0;
     return start;
 }
示例#6
0
 public Position Write(string str)
 {
     if (_newLine)
     {
         this.WriteIndent();
         _column += IndentLength;
     }
     Position start = new Position(_line, _column);
     this.WriteContent(str);
     int colCorrection = Correction(str);
     if (str.EndsWith(System.Environment.NewLine))
     {
         this._newLine = true;
         _line++;
         _column = 0;
     }
     else
     {
         this._newLine = false;
         _column += colCorrection;
     }
     return start;
 }