Search in sources :

Example 1 with PerlNamespaceDefinitionStub

use of com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub in project Perl5-IDEA by Camelcade.

the class MasonNamespaceDefinitionImpl method getParentNamespaceDefinitions.

@Override
public List<PerlNamespaceDefinitionElement> getParentNamespaceDefinitions() {
    List<String> parentsPaths;
    PerlNamespaceDefinitionStub stub = getStub();
    if (stub != null) {
        parentsPaths = stub.getParentNamespacesNames();
    } else {
        parentsPaths = getParentNamespacesNamesFromPsi();
    }
    VirtualFile containingFile = MasonCoreUtil.getContainingVirtualFile(getContainingFile());
    List<PerlNamespaceDefinitionElement> parentsNamespaces;
    if (!parentsPaths.isEmpty() && containingFile != null) {
        parentsNamespaces = Mason2Util.collectComponentNamespacesByPaths(getProject(), parentsPaths, containingFile.getParent());
    } else {
        String autobaseParent = getParentNamespaceFromAutobase();
        if (autobaseParent != null) {
            parentsNamespaces = Mason2Util.getMasonNamespacesByAbsolutePath(getProject(), autobaseParent);
        } else {
            parentsNamespaces = new ArrayList<>();
        }
    }
    if (parentsNamespaces.isEmpty()) {
        parentsNamespaces.addAll(PerlPackageUtil.getNamespaceDefinitions(getProject(), MASON_DEFAULT_COMPONENT_PARENT));
    }
    return parentsNamespaces;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlNamespaceDefinitionElement(com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement) PerlNamespaceDefinitionStub(com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub)

Example 2 with PerlNamespaceDefinitionStub

use of com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub in project Perl5-IDEA by Camelcade.

the class PerlNamespaceDefinitionElementType method deserialize.

@NotNull
@Override
public PerlNamespaceDefinitionStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
    String packageName = PerlStubSerializationUtil.readString(dataStream);
    PerlMroType mroType = PerlMroType.valueOf(PerlStubSerializationUtil.readString(dataStream));
    List<String> parentNamespaces = PerlStubSerializationUtil.readStringsList(dataStream);
    List<String> EXPORT = PerlStubSerializationUtil.readStringsList(dataStream);
    List<String> EXPORT_OK = PerlStubSerializationUtil.readStringsList(dataStream);
    Map<String, List<String>> EXPORT_TAGS = PerlStubSerializationUtil.readStringListMap(dataStream);
    assert packageName != null;
    assert parentNamespaces != null;
    assert EXPORT != null;
    assert EXPORT_OK != null;
    return createStubElement(parentStub, packageName, mroType, parentNamespaces, EXPORT, EXPORT_OK, EXPORT_TAGS, desearializeAnnotations(dataStream));
}
Also used : PerlMroType(com.perl5.lang.perl.psi.mro.PerlMroType) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PerlNamespaceDefinitionStub

use of com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub in project Perl5-IDEA by Camelcade.

the class PerlNamespaceDefinitionElementType method serialize.

@Override
public void serialize(@NotNull PerlNamespaceDefinitionStub stub, @NotNull StubOutputStream dataStream) throws IOException {
    dataStream.writeName(stub.getPackageName());
    dataStream.writeName(stub.getMroType().toString());
    PerlStubSerializationUtil.writeStringsList(dataStream, stub.getParentNamespacesNames());
    PerlStubSerializationUtil.writeStringsList(dataStream, stub.getEXPORT());
    PerlStubSerializationUtil.writeStringsList(dataStream, stub.getEXPORT_OK());
    PerlStubSerializationUtil.writeStringListMap(dataStream, stub.getEXPORT_TAGS());
    PerlNamespaceAnnotations namespaceAnnotations = stub.getAnnotations();
    if (namespaceAnnotations == null) {
        dataStream.writeBoolean(false);
    } else {
        dataStream.writeBoolean(true);
        namespaceAnnotations.serialize(dataStream);
    }
}
Also used : PerlNamespaceAnnotations(com.perl5.lang.perl.psi.utils.PerlNamespaceAnnotations)

Example 4 with PerlNamespaceDefinitionStub

use of com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub in project Perl5-IDEA by Camelcade.

the class PerlNamespaceDefinitionMixin method getMroType.

@Override
public PerlMroType getMroType() {
    PerlNamespaceDefinitionStub stub = getStub();
    if (stub != null) {
        return stub.getMroType();
    }
    if (mroTypeCache == null) {
        MroSearcher searcher = new MroSearcher();
        PerlPsiUtil.processNamespaceStatements(this, searcher);
        mroTypeCache = searcher.getResult();
    }
    return mroTypeCache;
}
Also used : PerlNamespaceDefinitionStub(com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub)

Aggregations

PerlNamespaceDefinitionStub (com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PerlNamespaceDefinitionElement (com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement)1 PerlMroType (com.perl5.lang.perl.psi.mro.PerlMroType)1 PerlNamespaceAnnotations (com.perl5.lang.perl.psi.utils.PerlNamespaceAnnotations)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1