Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dist::Zilla::Role::PPI: lack of filename #499

Open
van-de-bugger opened this issue Oct 7, 2015 · 1 comment
Open

Dist::Zilla::Role::PPI: lack of filename #499

van-de-bugger opened this issue Oct 7, 2015 · 1 comment

Comments

@van-de-bugger
Copy link
Contributor

ppi_document_for_file creates a PPI document is such a way:

my $encoded_content = $file->encoded_content;
...
my $document = PPI::Document->new(\$encoded_content);

Since PPI document is created from string, it does not know its filename. It makes creating error messages hardly possible.

I have requested PP to accept filename argument, so Dist::Zilla can pass filename to the constructor:

my $document = PPI::Document->new(\$encoded_content, filename => $file->name);

Meanwhile, Dist::Zilla can pass filename through file content by using #line directive:

$encoded_content = "#line 1 " . $file->name . "\n" . $encoded_content;
my $document = PPI::Document->new(\$encoded_content);

Later, if PPI implements filename argument, Dist::Zilla can utilize it, keeping #line directive as a backup:

if ( PPI::Document->VERSION() >= XXX ) {
    $document = PPI::Document->new(\$encoded_content, filename => $file->name);
} else {
    $encoded_content = "#line 1 " . $file->name . "\n" . $encoded_content;
    $document = PPI::Document->new(\$encoded_content);
};
@rjbs
Copy link
Owner

rjbs commented Apr 22, 2016

I'd rather wait for PPI to have a facility for this. Adding #line means removing it later, and I'm just a bit concerned about other artifacts that may occur due to this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants