play2-source-position-mappers/src/main/java/com/google/code/play2/spm/routes/Play2RoutesSourcePositionMapper.java
@Override
    public SourcePosition map( SourcePosition p ) throws IOException
    {
        SourcePosition result = null;

        File generatedFile = p.getFile();
        if ( generatedFile != null && generatedFile.isFile() )
        {
            String[] generatedFileLines = readFileAsString( generatedFile ).split( "\n" );
            if ( generatedFileLines[0].startsWith( Play2RoutesGeneratedSource.SOURCE_PREFIX ) // play 2.2.x - 2.3.x
                || Arrays.asList( generatedFileLines ).contains( GENERATOR_LINE ) ) // play 2.4.x +
            {
                Play2RoutesGeneratedSource generatedSource = new Play2RoutesGeneratedSource( generatedFileLines );
                String sourceFileName = generatedSource.getSourceFileName();
                if ( sourceFileName != null )
                {
                    File sourceFile = new File( sourceFileName );
                    if ( sourceFile.isFile() )
                    {
                        int sourceLine = generatedSource.mapLine( p.getLine() );
                        String[] sourceFileLines = readFileAsString( sourceFile ).split( "\n" );
                        if ( sourceFileLines.length >= sourceLine )
                        {
                            String sourceLineContent = sourceFileLines[sourceLine - 1];
                            if ( sourceLineContent.endsWith( "\r" ) ) // remove trailing CR (on Windows)
                            {
                                sourceLineContent = sourceLineContent.substring( 0, sourceLineContent.length() - 1 );
                            }
                            result = new Play2RoutesSourcePosition( sourceLine, sourceLineContent, sourceFile );
                        }
                    }
                }
            }
        }
        return result;
    }
@Override
    public SourcePosition map( SourcePosition p ) throws IOException
    {
        SourcePosition result = null;

        File generatedFile = p.getFile();
        if ( generatedFile != null && generatedFile.isFile() )
        {
            String[] generatedFileLines = readFileAsString( generatedFile ).split( "\n" );
            if ( generatedFileLines[0].startsWith( Play2RoutesGeneratedSource.SOURCE_PREFIX ) // play 2.2.x - 2.3.x
                || Arrays.asList( generatedFileLines ).contains( GENERATOR_LINE ) ) // play 2.4.x +
            {
                Play2RoutesGeneratedSource generatedSource = new Play2RoutesGeneratedSource( generatedFileLines );
                String sourceFileName = generatedSource.getSourceFileName();
                if ( sourceFileName != null )
                {
                    File sourceFile = new File( sourceFileName );
                    if ( sourceFile.isFile() )
                    {
                        int sourceLine = generatedSource.mapLine( p.getLine() );
                        String[] sourceFileLines = readFileAsString( sourceFile ).split( "\n" );
                        if ( sourceFileLines.length >= sourceLine )
                        {
                            String sourceLineContent = sourceFileLines[sourceLine - 1];
                            if ( sourceLineContent.endsWith( "\r" ) ) // remove trailing CR (on Windows)
                            {
                                sourceLineContent = sourceLineContent.substring( 0, sourceLineContent.length() - 1 );
                            }
                            result = new Play2RoutesSourcePosition( sourceLine, sourceLineContent, sourceFile );
                        }
                    }
                }
            }
        }
        return result;
    }
Performs mapping from the position in generated source file to the position in {@code routes} file it was
generated from.<br>
<br>
Returns:
<ul>
<li>position in {@code routes} file</li>
<li>{@code null} value if file of the input position is not recognized as generated from {@code routes} file</li>
</ul>

@param p compilation error/warning position in generated file
@return position in {@code routes} file or {@code null} value if file of the input position is not recognized as
generated from {@code routes} file
@throws IOException I/O exception during generated or original source file reading