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

Process @{namespace}::EXPORT correctly #2896

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

blindpirate
Copy link
Contributor

@blindpirate blindpirate commented Sep 4, 2024

Fixes #2494

Currently, only @EXPORT = ... can be recognized. This PR adds support for @{namespace}::EXPORT = ....

This is how it works:

image

@hurricup
Copy link
Collaborator

hurricup commented Sep 4, 2024

Will be able to check this on the weekend, thank you.

@hurricup
Copy link
Collaborator

hurricup commented Sep 4, 2024

I would also recommend to run all tests configuration (require some local setup though), now we have

2024-09-04T07:05:47.4238555Z     Caused by: java.lang.NullPointerException: Cannot invoke "com.intellij.psi.PsiElement.getText()" because the return value of "com.intellij.psi.PsiElement.getFirstChild()" is null
2024-09-04T07:05:47.4241216Z     	at com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin$ExporterInfo.extractExport(PerlNamespaceDefinitionMixin.java:256)
2024-09-04T07:05:47.4243368Z     	at com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin$ExporterInfo.process(PerlNamespaceDefinitionMixin.java:273)
2024-09-04T07:05:47.4245433Z     	at com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin$ExporterInfo.process(PerlNamespaceDefinitionMixin.java:249)
2024-09-04T07:05:47.4247323Z     	at com.perl5.lang.perl.psi.utils.PerlPsiUtil.processNamespaceStatements(PerlPsiUtil.java:429)
2024-09-04T07:05:47.4249027Z     	at com.perl5.lang.perl.psi.utils.PerlPsiUtil.processNamespaceStatements(PerlPsiUtil.java:432)
2024-09-04T07:05:47.4250933Z     	at com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin.computeExporterInfo(PerlNamespaceDefinitionMixin.java:196)
2024-09-04T07:05:47.4252730Z     	at com.intellij.openapi.util.ClearableLazyValue$1.compute(ClearableLazyValue.java:16)
2024-09-04T07:05:47.4254264Z     	at com.intellij.openapi.util.ClearableLazyValue.getValue(ClearableLazyValue.java:43)
2024-09-04T07:05:47.4256129Z     	at com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin.getExporterInfo(PerlNamespaceDefinitionMixin.java:191)
2024-09-04T07:05:47.4258561Z     	at com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin.getEXPORT(PerlNamespaceDefinitionMixin.java:158)
2024-09-04T07:05:47.4261120Z     	at com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionData.<init>(PerlNamespaceDefinitionData.java:60)
2024-09-04T07:05:47.4263151Z     	at com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionData.<init>(PerlNamespaceDefinitionData.java:46)
2024-09-04T07:05:47.4265218Z     	at com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionElementType.createStub(PerlNamespaceDefinitionElementType.java:60)
2024-09-04T07:05:47.4268029Z     	at com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionElementType.createStub(PerlNamespaceDefinitionElementType.java:38)
2024-09-04T07:05:47.4270163Z     	at com.intellij.psi.stubs.DefaultStubBuilder$StubBuildingWalkingVisitor.createStub(DefaultStubBuilder.java:81)
2024-09-04T07:05:47.4272085Z     	at com.intellij.psi.stubs.DefaultStubBuilder$StubBuildingWalkingVisitor.visitNode(DefaultStubBuilder.java:58)
2024-09-04T07:05:47.4274371Z     	at com.intellij.psi.stubs.DefaultStubBuilder$StubBuildingWalkingVisitor.buildStubTree(DefaultStubBuilder.java:53)
2024-09-04T07:05:47.4276173Z     	at com.intellij.psi.stubs.DefaultStubBuilder.buildStubTreeFor(DefaultStubBuilder.java:31)
2024-09-04T07:05:47.4277716Z     	at com.intellij.psi.stubs.DefaultStubBuilder.buildStubTree(DefaultStubBuilder.java:22)
2024-09-04T07:05:47.4279193Z     	at com.intellij.psi.stubs.StubTreeBuilder.lambda$buildStubTree$1(StubTreeBuilder.java:142)
2024-09-04T07:05:47.4280166Z     	at com.intellij.psi.stubs.StubTreeBuilder.handleStubBuilderException(StubTreeBuilder.java:98)

@blindpirate
Copy link
Contributor Author

There is another corner case fixed in this PR, which was not supported before::

use subs our @EXPORT_OK = qw(
        opset opset_to_hex opdump
);

Though this use subs seems redundant?

return target;
}

public void extractExport(PsiElement element, String exportName, List<String> target) {

Check warning

Code scanning / QDJVMC

Can use bounded wildcard Warning

Can generalize to ? super String
@hurricup
Copy link
Collaborator

hurricup commented Sep 7, 2024

god, i can't look at my own code without tears after 7 years. but this is probably a good thing.

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

Successfully merging this pull request may close these issues.

False positive "Unresolved sub" inspection on boolean subs
2 participants