Search in sources :

Example 1 with PsiPerlGlobSlot

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

the class PerlStringContentCompletionProvider method addCompletions.

@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull final CompletionResultSet result) {
    PsiElement element = parameters.getPosition();
    PsiElement parent = element.getParent();
    if (parent instanceof PsiLanguageInjectionHost && PerlInjectionUtil.hasInjections(parent)) {
        return;
    }
    if (// exporter assignments
    EXPORT_ASSIGNED_STRING_CONTENT.accepts(element)) {
        PerlStringCompletionUtil.fillWithExportableEntities(element, result);
    } else if (// hash indexes
    SIMPLE_HASH_INDEX.accepts(element)) {
        PsiPerlHashIndex indexElement = PsiTreeUtil.getParentOfType(element, PsiPerlHashIndex.class);
        if (indexElement != null && indexElement.getParent() instanceof PsiPerlGlobSlot) {
            PerlStringCompletionUtil.fillWithRefTypes(result);
        } else {
            PerlStringCompletionUtil.fillWithHashIndexes(element, result);
        }
    } else if (// use or no parameters
    USE_PARAMETERS_PATTERN.accepts(element)) {
        PerlStringCompletionUtil.fillWithUseParameters(element, result);
    } else if (// #@Inject some
    parent != null && parent.getParent() instanceof PsiPerlAnnotationInject) {
        PerlStringCompletionUtil.fillWithInjectableMarkers(element, result);
        result.stopHere();
    } else if (// HERE-DOC openers
    STRING_CONTENT_IN_HEREDOC_OPENER_PATTERN.accepts(element)) {
        PerlStringCompletionUtil.fillWithInjectableMarkers(element, result);
        PerlStringCompletionUtil.fillWithHeredocOpeners(element, result);
    } else if (// begin of string or qw element
    STRING_CONTENT_IN_LIST_OR_STRING_START.accepts(element)) {
        PerlStringCompletionUtil.fillWithRefTypes(result);
        PerlPackageCompletionUtil.fillWithAllPackageNames(element, result);
    }
}
Also used : PsiLanguageInjectionHost(com.intellij.psi.PsiLanguageInjectionHost) PsiPerlGlobSlot(com.perl5.lang.perl.psi.PsiPerlGlobSlot) PsiPerlHashIndex(com.perl5.lang.perl.psi.PsiPerlHashIndex) PsiPerlAnnotationInject(com.perl5.lang.perl.psi.PsiPerlAnnotationInject) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PsiLanguageInjectionHost (com.intellij.psi.PsiLanguageInjectionHost)1 PsiPerlAnnotationInject (com.perl5.lang.perl.psi.PsiPerlAnnotationInject)1 PsiPerlGlobSlot (com.perl5.lang.perl.psi.PsiPerlGlobSlot)1 PsiPerlHashIndex (com.perl5.lang.perl.psi.PsiPerlHashIndex)1