当我使用 MIME:Entity 类型的输入参数定义子例程时,我遇到自动完成问题。
从子程序的角度来看,它是一个参考。如何让 IDE 理解此输入参数的类型为 MIME:Enity 并为我提供自动完成功能?
sub subWithNoAutocompleteOnEnity
{
my ($entity) = @_;
my $test = MIME::Entity;
bless $entity, $test;
if ($entity->parts(0)) {
print("Say hello")
}
}
my $parser = MIME::Parser->new;
my $entity = $parser->parse_open("$inputDirectory/$filename");
subWithNoAutocompleteOnEnity($entity)
可以使用 TYPE 属性声明词法变量,请参阅 https://perldoc.perl.org/functions/my。
尝试以下操作:
use MIME::Entity;
sub subWithNoAutocompleteOnEntity
{
# Using the type MIME::Entity to help the Perl plugin to autocomplete
my MIME::Entity $entity = shift;
if ($entity->parts(0)) {
print("Say hello")
}
}