Search in sources :

Example 1 with ModificationTracker

use of com.intellij.openapi.util.ModificationTracker in project android by JetBrains.

the class ProjectResourceCachedValueProvider method compute.

@Nullable
@Override
public final Result<T> compute() {
    AndroidFacet[] facets = myComponent.getDataBindingEnabledFacets();
    List<V> values = Lists.newArrayList();
    List<ModificationTracker> newDependencies = Lists.newArrayList();
    newDependencies.add(myComponent);
    Collections.addAll(newDependencies, myAdditionalTrackers);
    for (AndroidFacet facet : facets) {
        CachedValue<V> cachedValue = getCachedValue(facet);
        // we know this for sure since it is created from createCacheProvider
        if (cachedValue.getValueProvider() instanceof ModificationTracker) {
            newDependencies.add((ModificationTracker) cachedValue.getValueProvider());
        }
        V result = cachedValue.getValue();
        if (result != null) {
            values.add(result);
        }
    }
    myDependencies = Collections.unmodifiableList(newDependencies);
    myDependencyModificationCountOnCompute = calculateModificationCountFrom(myDependencies);
    return Result.create(merge(values), this);
}
Also used : ModificationTracker(com.intellij.openapi.util.ModificationTracker) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ModificationTracker

use of com.intellij.openapi.util.ModificationTracker in project intellij-community by JetBrains.

the class ClsFileImpl method getNavigationElement.

@Override
@NotNull
@SuppressWarnings("deprecation")
public PsiElement getNavigationElement() {
    for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
        if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
            try {
                PsiFile navigationElement = ((ClsCustomNavigationPolicyEx) customNavigationPolicy).getFileNavigationElement(this);
                if (navigationElement != null) {
                    return navigationElement;
                }
            } catch (IndexNotReadyException ignore) {
            }
        }
    }
    return CachedValuesManager.getCachedValue(this, () -> {
        PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
        ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
        return CachedValueProvider.Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
    });
}
Also used : IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) ModificationTracker(com.intellij.openapi.util.ModificationTracker) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ModificationTracker (com.intellij.openapi.util.ModificationTracker)2 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1