Java 类com.intellij.openapi.util.ModificationTracker 实例源码

项目:intellij-ce-playground    文件:ClsFileImpl.java   
@SuppressWarnings("deprecation")
@Override
@NotNull
public PsiElement getNavigationElement() {
  for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
    if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
      PsiFile navigationElement = ((ClsCustomNavigationPolicyEx)customNavigationPolicy).getFileNavigationElement(this);
      if (navigationElement != null) {
        return navigationElement;
      }
    }
  }

  return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiElement>() {
    @Nullable
    @Override
    public Result<PsiElement> compute() {
      PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
      ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
      return Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
    }
  });
}
项目:intellij-ce-playground    文件:ArtifactBySourceFileFinderImpl.java   
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
  if (myFile2Artifacts == null) {
    myFile2Artifacts =
      CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
        public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
          MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
          List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
          trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
          for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
            ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
          }
          return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
        }
      }, false);
  }
  return myFile2Artifacts;
}
项目:intellij-ce-playground    文件:XmlEntityCache.java   
public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl) {
  synchronized(PsiLock.LOCK) {
    final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
    final String name = decl.getName();
    if (cachingMap.containsKey(name)) return;
    final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl);

    cachingMap.put(
      name, CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<XmlEntityDecl>() {
        @Override
        public Result<XmlEntityDecl> compute() {
          PsiElement declElement = declPointer.getElement();
          if (declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl)declElement).getName()))
            return new Result<XmlEntityDecl>((XmlEntityDecl)declElement, declElement);
          cachingMap.put(name,null);
          return new Result<XmlEntityDecl>(null, ModificationTracker.NEVER_CHANGED);
        }
      },
      false
    ));
  }
}
项目:intellij-ce-playground    文件:DefinitionResolver.java   
@Override
public Result<Map<String, Set<Define>>> compute() {
  try {
    myScope.acceptChildren(this);

    final PsiElement psiElement = myScope.getPsiElement();
    if (psiElement == null || !psiElement.isValid()) {
      return Result.create(null, ModificationTracker.EVER_CHANGED);
    }

    final PsiFile file = psiElement.getContainingFile();
    if (myVisitedFiles.get() != null) {
      myVisitedFiles.get().add(file);
      return Result.create(myDefines.get(), myVisitedFiles.get().toArray());
    } else {
      return Result.create(myDefines.get(), file);
    }
  } finally {
    myVisitedFiles.remove();
    myDefines.remove();
  }
}
项目:intellij-ce-playground    文件:RngNsDescriptor.java   
@Override
public Object[] getDependences() {
  if (myPattern != null) {
    if (DumbService.isDumb(myElement.getProject())) {
      return new Object[] { ModificationTracker.EVER_CHANGED, ExternalResourceManager.getInstance()};
    }
    final Object[] a = { myElement, ExternalResourceManager.getInstance() };
    final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<XmlFile>();
    RelaxIncludeIndex.processForwardDependencies(myFile, processor);
    if (processor.getCollection().size() > 0) {
      return ArrayUtil.mergeArrays(a, processor.toArray());
    } else {
      return a;
    }
  }
  return new Object[]{ ModificationTracker.EVER_CHANGED };
}
项目:intellij-ce-playground    文件:ProjectResourceCachedValueProvider.java   
@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);
    }
  }
  myDependencyModificationCountOnCompute = calculateModificationCountFrom(newDependencies);
  myDependencies = newDependencies;
  return Result.create(merge(values), this);
}
项目:intellij-ce-playground    文件:MvcFramework.java   
@Nullable
public static MvcFramework getInstance(@Nullable final Module module) {
  if (module == null) {
    return null;
  }

  final Project project = module.getProject();

  return CachedValuesManager.getManager(project).getCachedValue(module, new CachedValueProvider<MvcFramework>() {
    @Override
    public Result<MvcFramework> compute() {
      final ModificationTracker tracker = MvcModuleStructureSynchronizer.getInstance(project).getFileAndRootsModificationTracker();
      for (final MvcFramework framework : EP_NAME.getExtensions()) {
        if (framework.hasSupport(module)) {
          return Result.create(framework, tracker);
        }
      }
      return Result.create(null, tracker);

    }
  });
}
项目:tools-idea    文件:ArtifactBySourceFileFinderImpl.java   
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
  if (myFile2Artifacts == null) {
    myFile2Artifacts =
      CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
        public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
          MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
          List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
          trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
          for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
            ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
          }
          return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
        }
      }, false);
  }
  return myFile2Artifacts;
}
项目:tools-idea    文件:DefinitionResolver.java   
public Result<Map<String, Set<Define>>> compute() {
  try {
    myScope.acceptChildren(this);

    final PsiElement psiElement = myScope.getPsiElement();
    if (psiElement == null || !psiElement.isValid()) {
      return Result.create(null, ModificationTracker.EVER_CHANGED);
    }

    final PsiFile file = psiElement.getContainingFile();
    if (myVisitedFiles.get() != null) {
      myVisitedFiles.get().add(file);
      return Result.create(myDefines.get(), myVisitedFiles.get().toArray());
    } else {
      return Result.create(myDefines.get(), file);
    }
  } finally {
    myVisitedFiles.remove();
    myDefines.remove();
  }
}
项目:tools-idea    文件:RngNsDescriptor.java   
public Object[] getDependences() {
  if (myPattern != null) {
    if (DumbService.isDumb(myElement.getProject())) {
      return new Object[] { ModificationTracker.EVER_CHANGED, ExternalResourceManager.getInstance()};
    }
    final Object[] a = { myElement, ExternalResourceManager.getInstance() };
    final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<XmlFile>();
    RelaxIncludeIndex.processForwardDependencies(myFile, processor);
    if (processor.getCollection().size() > 0) {
      return ArrayUtil.mergeArrays(a, processor.toArray());
    } else {
      return a;
    }
  }
  return new Object[]{ ModificationTracker.EVER_CHANGED };
}
项目:tools-idea    文件:MvcFramework.java   
@Nullable
public static MvcFramework getInstance(@Nullable final Module module) {
  if (module == null) {
    return null;
  }

  final Project project = module.getProject();

  return CachedValuesManager.getManager(project).getCachedValue(module, new CachedValueProvider<MvcFramework>() {
    @Override
    public Result<MvcFramework> compute() {
      final ModificationTracker tracker = MvcModuleStructureSynchronizer.getInstance(project).getFileAndRootsModificationTracker();
      for (final MvcFramework framework : EP_NAME.getExtensions()) {
        if (framework.hasSupport(module)) {
          return Result.create(framework, tracker);
        }
      }
      return Result.create(null, tracker);

    }
  });
}
项目:consulo    文件:ArtifactBySourceFileFinderImpl.java   
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
  if (myFile2Artifacts == null) {
    myFile2Artifacts =
      CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
        public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
          MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
          List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
          trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
          for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
            ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
          }
          return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
        }
      }, false);
  }
  return myFile2Artifacts;
}
项目:consulo-xml    文件:XmlEntityCache.java   
public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl)
{
    synchronized(LOCK)
    {
        final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
        final String name = decl.getName();
        if(cachingMap.containsKey(name))
        {
            return;
        }
        final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl);

        cachingMap.put(name, CachedValuesManager.getManager(file.getProject()).createCachedValue(() ->
        {
            PsiElement declElement = declPointer.getElement();
            if(declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl) declElement).getName()))
            {
                return new CachedValueProvider.Result<>((XmlEntityDecl) declElement, declElement);
            }
            cachingMap.put(name, null);
            return new CachedValueProvider.Result<>(null, ModificationTracker.NEVER_CHANGED);
        }, false));
    }
}
项目:consulo-xml    文件:DefinitionResolver.java   
@Override
public Result<Map<String, Set<Define>>> compute() {
  try {
    myScope.acceptChildren(this);

    final PsiElement psiElement = myScope.getPsiElement();
    if (psiElement == null || !psiElement.isValid()) {
      return Result.create(null, ModificationTracker.EVER_CHANGED);
    }

    final PsiFile file = psiElement.getContainingFile();
    if (myVisitedFiles.get() != null) {
      myVisitedFiles.get().add(file);
      return Result.create(myDefines.get(), myVisitedFiles.get().toArray());
    } else {
      return Result.create(myDefines.get(), file);
    }
  } finally {
    myVisitedFiles.remove();
    myDefines.remove();
  }
}
项目:consulo-xml    文件:RngNsDescriptor.java   
@Override
public Object[] getDependences() {
  if (myPattern != null) {
    if (DumbService.isDumb(myElement.getProject())) {
      return new Object[] { ModificationTracker.EVER_CHANGED, ExternalResourceManager.getInstance()};
    }
    final Object[] a = { myElement, ExternalResourceManager.getInstance() };
    final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<>();
    RelaxIncludeIndex.processForwardDependencies(myFile, processor);
    if (processor.getCollection().size() > 0) {
      return ArrayUtil.mergeArrays(a, processor.toArray());
    } else {
      return a;
    }
  }
  return new Object[]{ ModificationTracker.EVER_CHANGED };
}
项目:consulo-java    文件:ProjectBytecodeAnalysis.java   
public PsiAnnotation createContractAnnotation(String contractValue)
{
    Map<String, PsiAnnotation> cache = CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<Map<String, PsiAnnotation>>()
    {
        @Nullable
        @Override
        public Result<Map<String, PsiAnnotation>> compute()
        {
            Map<String, PsiAnnotation> map = new ConcurrentFactoryMap<String, PsiAnnotation>()
            {
                @Nullable
                @Override
                protected PsiAnnotation create(String attrs)
                {
                    return createAnnotationFromText("@org.jetbrains.annotations.Contract(" + attrs + ")");
                }
            };
            return CachedValueProvider.Result.create(map, ModificationTracker.NEVER_CHANGED);
        }
    });
    return cache.get(contractValue);
}
项目:catberry-idea-plugin    文件:TemplateEngineProvider.java   
public TemplateEngineProvider(Project project, NotNullLazyValue<ModificationTracker> tracker) {
  super(project);

  this.tracker = tracker;
  for (TemplateEngine engine : TemplateEngine.values()) {
    engines.put("catberry-" + engine, engine);
  }
}
项目:intellij-ce-playground    文件:ProjectBytecodeAnalysis.java   
public PsiAnnotation getNotNullAnnotation() {
  return CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<PsiAnnotation>() {
    @Nullable
    @Override
    public Result<PsiAnnotation> compute() {
      return Result.create(createAnnotationFromText("@" + AnnotationUtil.NOT_NULL), ModificationTracker.NEVER_CHANGED);
    }
  });
}
项目:intellij-ce-playground    文件:ProjectBytecodeAnalysis.java   
public PsiAnnotation getNullableAnnotation() {
  return CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<PsiAnnotation>() {
    @Nullable
    @Override
    public Result<PsiAnnotation> compute() {
      return Result.create(createAnnotationFromText("@" + AnnotationUtil.NULLABLE), ModificationTracker.NEVER_CHANGED);
    }
  });
}
项目:intellij-ce-playground    文件:ComputableActionGroup.java   
@NotNull
@Override
protected final CachedValueProvider<AnAction[]> createChildrenProvider(@NotNull final ActionManager actionManager) {
  return new CachedValueProvider<AnAction[]>() {
    @Nullable
    @Override
    public Result<AnAction[]> compute() {
      return Result.create(computeChildren(actionManager), ModificationTracker.NEVER_CHANGED);
    }
  };
}
项目:intellij-ce-playground    文件:FacetFinderImpl.java   
@Override
public <F extends Facet> ModificationTracker getAllFacetsOfTypeModificationTracker(FacetTypeId<F> type) {
  AllFacetsOfTypeModificationTracker tracker = myAllFacetTrackers.get(type);
  if (tracker == null) {
    tracker = new AllFacetsOfTypeModificationTracker<F>(myProject, type);
    Disposer.register(myProject, tracker);
    myAllFacetTrackers.put(type, tracker);
  }
  return tracker;
}
项目:intellij-ce-playground    文件:ProjectResourceCachedValueProvider.java   
private static long calculateModificationCountFrom(List<ModificationTracker> dependencies) {
  long total = 0;
  for (ModificationTracker tracker : dependencies) {
    total += tracker.getModificationCount();
  }
  return total;
}
项目:intellij-ce-playground    文件:MavenIndex.java   
@Nullable
@Override
public Result<String> compute() {
  return Result.create(StringUtil.join(myRegisteredRepositoryIds, ","), new ModificationTracker() {
    @Override
    public long getModificationCount() {
      return myRegisteredRepositoryIds.hashCode();
    }
  });
}
项目:tools-idea    文件:FacetFinderImpl.java   
@Override
public <F extends Facet> ModificationTracker getAllFacetsOfTypeModificationTracker(FacetTypeId<F> type) {
  AllFacetsOfTypeModificationTracker tracker = myAllFacetTrackers.get(type);
  if (tracker == null) {
    tracker = new AllFacetsOfTypeModificationTracker<F>(myProject, type);
    Disposer.register(myProject, tracker);
    myAllFacetTrackers.put(type, tracker);
  }
  return tracker;
}
项目:consulo    文件:ComputableActionGroup.java   
@Nonnull
@Override
protected final CachedValueProvider<AnAction[]> createChildrenProvider(@Nonnull final ActionManager actionManager) {
  return new CachedValueProvider<AnAction[]>() {
    @Nullable
    @Override
    public Result<AnAction[]> compute() {
      return Result.create(computeChildren(actionManager), ModificationTracker.NEVER_CHANGED);
    }
  };
}
项目:consulo    文件:PsiModificationTrackerImpl.java   
@Nonnull
public ModificationTracker forLanguages(@Nonnull Condition<Language> condition) {
  if (!ourEnableLanguageTracker.asBoolean()) return this;
  return () -> {
    long result = 0;
    for (Language l : myLanguageTrackers.keySet()) {
      if (condition.value(l)) continue;
      result += myLanguageTrackers.get(l).getModificationCount();
    }
    return result;
  };
}
项目:consulo-java    文件:ClsFileImpl.java   
@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(this);
        ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
        return CachedValueProvider.Result.create(target, this, target.getContainingFile(), tracker);
    });
}
项目:consulo-java    文件:ProjectBytecodeAnalysis.java   
public PsiAnnotation getNotNullAnnotation()
{
    return CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<PsiAnnotation>()
    {
        @Nullable
        @Override
        public Result<PsiAnnotation> compute()
        {
            return CachedValueProvider.Result.create(ProjectBytecodeAnalysis.this.createAnnotationFromText("@" + AnnotationUtil.NOT_NULL), ModificationTracker.NEVER_CHANGED);
        }
    });
}
项目:consulo-java    文件:ProjectBytecodeAnalysis.java   
public PsiAnnotation getNullableAnnotation()
{
    return CachedValuesManager.getManager(myProject).getCachedValue(myProject, new CachedValueProvider<PsiAnnotation>()
    {
        @Nullable
        @Override
        public Result<PsiAnnotation> compute()
        {
            return CachedValueProvider.Result.create(ProjectBytecodeAnalysis.this.createAnnotationFromText("@" + AnnotationUtil.NULLABLE), ModificationTracker.NEVER_CHANGED);
        }
    });
}
项目:intellij-tasks-navigate    文件:ToTaskReference.java   
@NotNull
@Override
public Result<Map<String, TaskPsiElement>> compute() {
  return Result.<Map<String, TaskPsiElement>>create(new SoftHashMap<String, TaskPsiElement>(), new ModificationTracker() {
    @Override
    public long getModificationCount() {
      return 0;
    }
  });
}
项目:hybris-integration-intellij-idea-plugin    文件:ModuleDepDiagramDataModel.java   
@NotNull
@Override
public ModificationTracker getModificationTracker() {
    //noinspection ReturnOfThis
    return this;
}
项目:hybris-integration-intellij-idea-plugin    文件:BpDiagramDataModel.java   
@Contract(pure = true)
@NotNull
@Override
public ModificationTracker getModificationTracker() {
    return this;
}
项目:catberry-idea-plugin    文件:ComponentsDirectoriesProvider.java   
public ComponentsDirectoriesProvider(Project project, NotNullLazyValue<ModificationTracker> tracker) {
  super(project);
  this.tracker = tracker;
}
项目:catberry-idea-plugin    文件:StoresDirectoryProvider.java   
public StoresDirectoryProvider(Project project, NotNullLazyValue<ModificationTracker> tracker) {
  super(project);
  this.tracker = tracker;
}
项目:intellij-ce-playground    文件:ComplexPackagingElementType.java   
@Nullable
public ModificationTracker getAllSubstitutionsModificationTracker(@NotNull Project project) {
  return null;
}
项目:intellij-ce-playground    文件:ArtifactManagerImpl.java   
@Override
public ModificationTracker getModificationTracker() {
  return myModificationTracker;
}
项目:intellij-ce-playground    文件:ProjectFileIndexFacade.java   
@NotNull
@Override
public ModificationTracker getRootModificationTracker() {
  return ProjectRootManager.getInstance(myProject);
}
项目:intellij-ce-playground    文件:EncodingProjectManagerImpl.java   
@NotNull
public ModificationTracker getModificationTracker() {
  return myModificationTracker;
}
项目:intellij-ce-playground    文件:FacetModificationTrackingService.java   
@NotNull
public abstract ModificationTracker getFacetModificationTracker(@NotNull Facet facet);
项目:intellij-ce-playground    文件:MockDumbService.java   
@Override
public ModificationTracker getModificationTracker() {
  return new SimpleModificationTracker();
}