コード例 #1
0
ファイル: Emitter.cs プロジェクト: nippur72/SourceMaps.CSharp
 private void recordSourceMappingEnd(ISyntaxElement ast)
 {
     if (this.sourceMapper != null && ASTHelpers.isValidAstNode(ast))
     {
         this.recordSourceMappingSpanEnd(ast);
     }
 }
コード例 #2
0
ファイル: Emitter.cs プロジェクト: nippur72/SourceMaps.CSharp
        private void recordSourceMappingSpanStart(ISpan ast)
        {
            if (this.sourceMapper != null && ASTHelpers.isValidSpan(ast))
            {
                LineCol lineCol = new LineCol()
                {
                    line = -1, character = -1
                };
                var sourceMapping = new SourceMapping();
                sourceMapping.start.emittedColumn = this.emitState.column;
                sourceMapping.start.emittedLine   = this.emitState.line;
                // REVIEW: check time consumed by this binary search (about two per leaf statement)
                var lineMap = this.document.lineMap();
                lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol);
                sourceMapping.start.sourceColumn = lineCol.character;
                sourceMapping.start.sourceLine   = lineCol.line + 1;
                lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol);
                sourceMapping.end.sourceColumn = lineCol.character;
                sourceMapping.end.sourceLine   = lineCol.line + 1;

                /*
                 * Debug.assert(!isNaN(sourceMapping.start.emittedColumn));
                 * Debug.assert(!isNaN(sourceMapping.start.emittedLine));
                 * Debug.assert(!isNaN(sourceMapping.start.sourceColumn));
                 * Debug.assert(!isNaN(sourceMapping.start.sourceLine));
                 * Debug.assert(!isNaN(sourceMapping.end.sourceColumn));
                 * Debug.assert(!isNaN(sourceMapping.end.sourceLine));
                 */

                if (this.sourceMapper.currentNameIndex.Count > 0)
                {
                    sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.Count - 1];
                }
                // Set parent and child relationship
                var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.Count - 1];
                siblings.Add(sourceMapping);
                this.sourceMapper.currentMappings.Add(sourceMapping.childMappings);
                this.sourceMapper.increaseMappingLevel(ast);
            }
        }
コード例 #3
0
ファイル: Emitter.cs プロジェクト: nippur72/SourceMaps.CSharp
        private void recordSourceMappingSpanEnd(ISpan ast)
        {
            if (this.sourceMapper != null && ASTHelpers.isValidSpan(ast))
            {
                // Pop source mapping childs
                //this.sourceMapper.currentMappings.pop();
                this.sourceMapper.currentMappings.RemoveAt(this.sourceMapper.currentMappings.Count - 1);

                // Get the last source mapping from sibling list = which is the one we are recording end for
                var siblings      = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.Count - 1];
                var sourceMapping = siblings[siblings.Count - 1];

                sourceMapping.end.emittedColumn = this.emitState.column;
                sourceMapping.end.emittedLine   = this.emitState.line;

                /*
                 * Debug.assert(!isNaN(sourceMapping.end.emittedColumn));
                 * Debug.assert(!isNaN(sourceMapping.end.emittedLine));
                 */

                this.sourceMapper.decreaseMappingLevel(ast);
            }
        }