use of com.perl5.lang.perl.parser.moose.psi.PerlMooseAugmentStatement in project Perl5-IDEA by Camelcade.
the class PerlMooseInnerReference method resolveInner.
@NotNull
@Override
protected ResolveResult[] resolveInner(boolean incompleteCode) {
List<ResolveResult> result = new ArrayList<>();
PsiElement element = getElement();
String subName = null;
PerlSubDefinitionElement subDefinitionBase = PsiTreeUtil.getParentOfType(element, PerlSubDefinitionElement.class);
if (subDefinitionBase != null) {
subName = subDefinitionBase.getSubName();
}
PerlMooseAugmentStatement augmentStatement = PsiTreeUtil.getParentOfType(element, PerlMooseAugmentStatement.class);
if (augmentStatement != null) {
subName = augmentStatement.getSubName();
}
if (subName != null) {
PerlNamespaceDefinitionElement namespaceDefinition = PsiTreeUtil.getParentOfType(element, PerlNamespaceDefinitionElement.class);
Set<PerlNamespaceDefinitionElement> recursionSet = new THashSet<>();
if (StringUtil.isNotEmpty(subName) && namespaceDefinition != null) {
collectNamespaceMethodsAugmentations(namespaceDefinition, subName, recursionSet, result);
}
}
return result.toArray(new ResolveResult[result.size()]);
}
use of com.perl5.lang.perl.parser.moose.psi.PerlMooseAugmentStatement in project Perl5-IDEA by Camelcade.
the class PerlMooseInnerReference method collectNamespaceMethodsAugmentations.
protected void collectNamespaceMethodsAugmentations(@NotNull PerlNamespaceDefinitionElement namespaceDefinition, @NotNull String subName, Set<PerlNamespaceDefinitionElement> recursionSet, List<ResolveResult> result) {
recursionSet.add(namespaceDefinition);
for (PerlNamespaceDefinitionElement childNamespace : namespaceDefinition.getChildNamespaceDefinitions()) {
if (!recursionSet.contains(childNamespace)) {
boolean noSubclasses = false;
for (PsiElement augmentStatement : getAugmentStatements(childNamespace)) {
if (subName.equals(((PerlMooseAugmentStatement) augmentStatement).getSubName())) {
result.add(new PsiElementResolveResult(augmentStatement));
noSubclasses = true;
}
}
if (!noSubclasses) {
collectNamespaceMethodsAugmentations(childNamespace, subName, recursionSet, result);
}
}
}
}
Aggregations