Example #1
0
        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);
            }
        }
Example #2
0
      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);
         }
      }