use of com.perl5.lang.perl.psi.utils.PerlSubAnnotations in project Perl5-IDEA by Camelcade.
the class PerlSubDefinitionElementType method serialize.
@Override
public void serialize(@NotNull PerlSubDefinitionStub stub, @NotNull StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getPackageName());
dataStream.writeName(stub.getSubName());
PerlSubArgument.serializeList(dataStream, stub.getSubArgumentsList());
PerlSubAnnotations subAnnotations = stub.getAnnotations();
if (subAnnotations == null) {
dataStream.writeBoolean(false);
} else {
dataStream.writeBoolean(true);
subAnnotations.serialize(dataStream);
}
}
use of com.perl5.lang.perl.psi.utils.PerlSubAnnotations in project Perl5-IDEA by Camelcade.
the class PerlClassAccessorWrapper method calcLightElementsFromPsi.
@NotNull
@Override
public List<PerlDelegatingLightNamedElement> calcLightElementsFromPsi() {
String packageName = PerlPackageUtil.getContextPackageName(this);
if (StringUtil.isEmpty(packageName)) {
return Collections.emptyList();
}
List<PsiElement> listElements = getCallArgumentsList();
if (listElements.isEmpty()) {
return Collections.emptyList();
}
List<PerlDelegatingLightNamedElement> result = new ArrayList<>();
for (PsiElement listElement : listElements) {
if (!isAcceptableIdentifierElement(listElement)) {
continue;
}
String baseName = ElementManipulators.getValueText(listElement);
PerlSubAnnotations subAnnotations = computeSubAnnotations(this, listElement);
for (Function<String, String> computation : getNamesComputations()) {
result.add(new PerlClassAccessorMethod(this, baseName, computation, CLASS_ACCESSOR_METHOD, listElement, packageName, subAnnotations));
}
}
return result;
}
use of com.perl5.lang.perl.psi.utils.PerlSubAnnotations in project Perl5-IDEA by Camelcade.
the class PerlSub method getReturns.
/**
* Calculates type of return value. By default - checks annotations
*
* @param contextPackage package this sub been invoked from, useful to return $self
* @param arguments invocation arguments
* @return type of return value if can be calculated, or null
*/
@Nullable
default String getReturns(@Nullable String contextPackage, @NotNull List<PsiElement> arguments) {
PerlSubAnnotations subAnnotations = getAnnotations();
if (subAnnotations == null) {
return null;
}
String returns = subAnnotations.getReturns();
return PACKAGE_ANY.equals(returns) ? contextPackage : returns;
}
Aggregations