Search in sources :

Example 1 with BeamFileImpl

use of org.elixir_lang.beam.psi.BeamFileImpl in project intellij-elixir by KronicDeth.

the class StructureViewBuilderProvider method getStructureViewBuilder.

/**
     * Returns the structure view builder for the specified file.
     *
     * @param fileType    file type of the file to provide structure for
     * @param virtualFile The file for which the structure view builder is requested.
     * @param project     The project to which the file belongs.
     * @return The structure view builder, or null if no structure view is available for the file.
     */
@Nullable
@Override
public StructureViewBuilder getStructureViewBuilder(@NotNull FileType fileType, @NotNull VirtualFile virtualFile, @NotNull Project project) {
    PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
    StructureViewBuilder structureViewBuilder = null;
    if (psiFile instanceof BeamFileImpl) {
        BeamFileImpl beamFileImpl = (BeamFileImpl) psiFile;
        PsiElement mirror = beamFileImpl.getMirror();
        if (mirror instanceof ElixirFile) {
            structureViewBuilder = Factory.structureViewBuilder((ElixirFile) mirror);
        }
    }
    return structureViewBuilder;
}
Also used : StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) BeamFileImpl(org.elixir_lang.beam.psi.BeamFileImpl) PsiFile(com.intellij.psi.PsiFile) ElixirFile(org.elixir_lang.psi.ElixirFile) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with BeamFileImpl

use of org.elixir_lang.beam.psi.BeamFileImpl in project intellij-elixir by KronicDeth.

the class ModuleElementImpl method getMirror.

/**
     * Returns the corresponding PSI element in a decompiled file created by IDEA from
     * the library element.
     *
     * @return the counterpart of the element in decompiled file.
     */
@Override
public PsiElement getMirror() {
    TreeElement nonVolatileMirror = mirror;
    if (nonVolatileMirror == null) {
        ((BeamFileImpl) getContainingFile()).getMirror();
        nonVolatileMirror = mirror;
    }
    return SourceTreeToPsiMap.treeElementToPsi(nonVolatileMirror);
}
Also used : BeamFileImpl(org.elixir_lang.beam.psi.BeamFileImpl) TreeElement(com.intellij.psi.impl.source.tree.TreeElement)

Aggregations

BeamFileImpl (org.elixir_lang.beam.psi.BeamFileImpl)2 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 TreeElement (com.intellij.psi.impl.source.tree.TreeElement)1 ElixirFile (org.elixir_lang.psi.ElixirFile)1 Nullable (org.jetbrains.annotations.Nullable)1