Search in sources :

Example 1 with MetadataPsiElementBase

use of com.intellij.extapi.psi.MetadataPsiElementBase in project intellij-community by JetBrains.

the class PsiProximityComparator method getProximity.

@Nullable
public static WeighingComparable<PsiElement, ProximityLocation> getProximity(final Computable<PsiElement> elementComputable, final PsiElement context, ProcessingContext processingContext) {
    PsiElement element = elementComputable.compute();
    if (element == null)
        return null;
    if (element instanceof MetadataPsiElementBase)
        return null;
    if (context == null)
        return null;
    Module contextModule = processingContext.get(MODULE_BY_LOCATION);
    if (contextModule == null) {
        contextModule = ModuleUtilCore.findModuleForPsiElement(context);
        processingContext.put(MODULE_BY_LOCATION, contextModule);
    }
    if (contextModule == null)
        return null;
    return new WeighingComparable<>(elementComputable, new ProximityLocation(context, contextModule, processingContext), PROXIMITY_WEIGHERS);
}
Also used : MetadataPsiElementBase(com.intellij.extapi.psi.MetadataPsiElementBase) Module(com.intellij.openapi.module.Module) WeighingComparable(com.intellij.psi.WeighingComparable) PsiElement(com.intellij.psi.PsiElement) ProximityLocation(com.intellij.psi.util.ProximityLocation) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

MetadataPsiElementBase (com.intellij.extapi.psi.MetadataPsiElementBase)1 Module (com.intellij.openapi.module.Module)1 PsiElement (com.intellij.psi.PsiElement)1 WeighingComparable (com.intellij.psi.WeighingComparable)1 ProximityLocation (com.intellij.psi.util.ProximityLocation)1 Nullable (org.jetbrains.annotations.Nullable)1