Exemple #1
0
        private FileLocation MapLocation(FileLocation fileLocation)
        {
            try
            {
                JsMapFile jsMapFile = JsMapFile.CreateFromString(_FileSystem.ReadAllText(fileLocation.FullPath + ".map"));

                if (jsMapFile != null)
                {
                    JsMappingSegment mapping = jsMapFile.Mappings.Where(m => m.GeneratedLine == fileLocation.LineNumber).FirstOrDefault();

                    if (mapping != null)
                    {
                        return(new FileLocation(
                                   fileLocation.Filename.Replace(jsMapFile.OutputFile, mapping.Source),
                                   fileLocation.FullPath.Replace(jsMapFile.OutputFile, mapping.Source),
                                   mapping.SourceStartingLine,
                                   mapping.SourceStartingColumn));
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            return(null);
        }
Exemple #2
0
        private static IEnumerable <JsMappingSegment> ParseMappings(JsMapFile jsMapFile, string mappings)
        {
            int currentLine                  = 1;
            int previousSourceIndex          = 0;
            int previousSourceStartingLine   = 1;
            int previousSourceStartingColumn = 1;
            int previousSourceNameIndex      = 0;

            foreach (string mappingLine in mappings.Split(';'))
            {
                if (!String.IsNullOrEmpty(mappingLine))
                {
                    int previousGeneratedColumn = 1;
                    foreach (string segment in mappingLine.Split(','))
                    {
                        int[]            map     = VLQDecode(segment);
                        JsMappingSegment mapping = new JsMappingSegment
                        {
                            GeneratedLine   = currentLine,
                            GeneratedColumn = previousGeneratedColumn + map[0]
                        };
                        if (map.Length > 1)
                        {
                            previousSourceIndex          += map[1];
                            mapping.Source                = jsMapFile.SourceFiles[previousSourceIndex];
                            previousSourceStartingLine   += map[2];
                            mapping.SourceStartingLine    = previousSourceStartingLine;
                            previousSourceStartingColumn += map[3];
                            mapping.SourceStartingColumn  = previousSourceStartingColumn;
                            if (map.Length > 4)
                            {
                                previousSourceNameIndex += map[4];
                                mapping.SourceName       = jsMapFile.Names[previousSourceNameIndex];
                            }
                        }
                        yield return(mapping);

                        previousGeneratedColumn = mapping.GeneratedColumn;
                    }
                }
                currentLine++;
            }
        }