Search in sources :

Example 1 with PsiPerlStringList

use of com.perl5.lang.perl.psi.PsiPerlStringList in project Perl5-IDEA by Camelcade.

the class PerlMooseExtendsStatementImpl method getParentsList.

@NotNull
protected List<String> getParentsList() {
    List<String> result = new ArrayList<>();
    PsiElement expr = getExpr();
    if (expr != null) {
        if (expr instanceof PerlString) {
            String content = ElementManipulators.getValueText(expr);
            if (!content.isEmpty()) {
                result.add(content);
            }
        } else if (expr instanceof PsiPerlCommaSequenceExpr) {
            PsiElement element = expr.getFirstChild();
            while (element != null) {
                if (element instanceof PerlString) {
                    String content = ElementManipulators.getValueText(element);
                    if (!content.isEmpty()) {
                        result.add(content);
                    }
                }
                element = element.getNextSibling();
            }
        } else if (expr instanceof PsiPerlStringList) {
            for (PsiElement element : PerlPsiUtil.collectStringElements(expr.getFirstChild())) {
                String content = element.getText();
                if (!content.isEmpty()) {
                    result.add(content);
                }
            }
        } else {
        // todo we need to somehow mark statement as bad
        }
    }
    return result;
}
Also used : PerlString(com.perl5.lang.perl.psi.PerlString) ArrayList(java.util.ArrayList) PsiPerlStringList(com.perl5.lang.perl.psi.PsiPerlStringList) PerlString(com.perl5.lang.perl.psi.PerlString) PsiPerlCommaSequenceExpr(com.perl5.lang.perl.psi.PsiPerlCommaSequenceExpr) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PerlString (com.perl5.lang.perl.psi.PerlString)1 PsiPerlCommaSequenceExpr (com.perl5.lang.perl.psi.PsiPerlCommaSequenceExpr)1 PsiPerlStringList (com.perl5.lang.perl.psi.PsiPerlStringList)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1