Search in sources :

Example 1 with PerlNamespaceDefinitionMixin

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

the class PerlElementFactory method createPackageName.

// fixme probably we don't need package name and sub. just identifier
public static PerlNamespaceElementImpl createPackageName(Project project, String name) {
    PerlFileImpl file = createFile(project, "package " + name + ";");
    PerlNamespaceDefinitionMixin def = PsiTreeUtil.findChildOfType(file, PerlNamespaceDefinitionMixin.class);
    assert def != null;
    return (PerlNamespaceElementImpl) def.getNamespaceElement();
}
Also used : PerlNamespaceElementImpl(com.perl5.lang.perl.psi.impl.PerlNamespaceElementImpl) PerlFileImpl(com.perl5.lang.perl.psi.impl.PerlFileImpl) PerlNamespaceDefinitionMixin(com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin)

Example 2 with PerlNamespaceDefinitionMixin

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

the class NamespaceTestCase method getNamespaceInFile.

protected PerlNamespaceDefinitionMixin getNamespaceInFile(@NotNull String fileName, @NotNull String namespaceName) {
    myFixture.configureByFile(fileName);
    PsiFile file = myFixture.getFile();
    PerlNamespaceDefinitionMixin namespaceDefinition = null;
    for (PerlNamespaceDefinitionMixin element : PsiTreeUtil.findChildrenOfType(file, PerlNamespaceDefinitionMixin.class)) {
        if (StringUtil.equals(element.getName(), namespaceName)) {
            namespaceDefinition = element;
            break;
        }
    }
    assertNotNull(namespaceDefinition);
    namespaceDefinition.subtreeChanged();
    return namespaceDefinition;
}
Also used : PsiFile(com.intellij.psi.PsiFile) PerlNamespaceDefinitionMixin(com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin)

Example 3 with PerlNamespaceDefinitionMixin

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

the class NamespaceParentsDetectionTest method doTest.

public void doTest(String fileName, @NotNull String namespaceName, String[] parentsList) {
    PerlNamespaceDefinitionMixin namespaceDefinition = getNamespaceInFile(fileName, namespaceName);
    List<String> parents = namespaceDefinition.getParentNamespacesNamesFromPsi();
    assertEquals(new ArrayList<>(Arrays.asList(parentsList)), parents);
}
Also used : PerlNamespaceDefinitionMixin(com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin)

Aggregations

PerlNamespaceDefinitionMixin (com.perl5.lang.perl.psi.mixins.PerlNamespaceDefinitionMixin)3 PsiFile (com.intellij.psi.PsiFile)1 PerlFileImpl (com.perl5.lang.perl.psi.impl.PerlFileImpl)1 PerlNamespaceElementImpl (com.perl5.lang.perl.psi.impl.PerlNamespaceElementImpl)1