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

        File generatedFile = p.getFile();
        int generatedOffset = p.getOffset();
        if ( generatedFile != null && generatedFile.isFile() && generatedOffset >= 0 )
        {
            Play2TemplateGeneratedSource generated = getGeneratedSource( generatedFile );
            if ( generated != null )
            {
                String sourceFileName = generated.getSourceFileName();
                if ( sourceFileName != null )
                {
                    File sourceFile = new File( sourceFileName );
                    if ( sourceFile.isFile() )
                    {
                        int sourceOffset = generated.mapPosition( generatedOffset );
                        String sourceFileContent = readFileAsString( sourceFile );
                        if ( sourceFileContent.length() > sourceOffset )
                        {
                            String[] sourceFileLines = sourceFileContent.split( "\n" );
                            Play2TemplateLocation sourceLocation =
                                new Play2TemplateMapping( sourceFileLines ).location( sourceOffset );
                            //if ( sourceLocation != null )
                            //{
                                result = new Play2TemplateSourcePosition( sourceFile, sourceLocation );
                            //}
                        }
                    }
                }
            }
        }
        return result;
    }
@Override
    public SourcePosition map( SourcePosition p ) throws IOException
    {
        SourcePosition result = null;

        File generatedFile = p.getFile();
        int generatedOffset = p.getOffset();
        if ( generatedFile != null && generatedFile.isFile() && generatedOffset >= 0 )
        {
            Play2TemplateGeneratedSource generated = getGeneratedSource( generatedFile );
            if ( generated != null )
            {
                String sourceFileName = generated.getSourceFileName();
                if ( sourceFileName != null )
                {
                    File sourceFile = new File( sourceFileName );
                    if ( sourceFile.isFile() )
                    {
                        int sourceOffset = generated.mapPosition( generatedOffset );
                        String sourceFileContent = readFileAsString( sourceFile );
                        if ( sourceFileContent.length() > sourceOffset )
                        {
                            String[] sourceFileLines = sourceFileContent.split( "\n" );
                            Play2TemplateLocation sourceLocation =
                                new Play2TemplateMapping( sourceFileLines ).location( sourceOffset );
                            //if ( sourceLocation != null )
                            //{
                                result = new Play2TemplateSourcePosition( sourceFile, sourceLocation );
                            //}
                        }
                    }
                }
            }
        }
        return result;
    }
Performs mapping from the position in generated source file to the position in Twirl template file it was
generated from.<br>
<br>
Returns:
<ul>
<li>position in Twirl template file</li>
<li>{@code null} value if file of the input position is not recognized as generated from Twirl template 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 Twirl template file
@throws IOException I/O exception during generated or original source file reading