com.intellij.openapi.project.Project.putUserData()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中com.intellij.openapi.project.Project.putUserData()方法的一些代码示例,展示了Project.putUserData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.putUserData()方法的具体详情如下:
包路径:com.intellij.openapi.project.Project
类名称:Project
方法名:putUserData

Project.putUserData介绍

暂无

代码示例

代码示例来源:origin: KronicDeth/intellij-elixir

private static void deleteLevel(@NotNull Project project) {
  project.putUserData(LEVEL, null);
}

代码示例来源:origin: KronicDeth/intellij-elixir

private static void putLevel(@NotNull Project project) {
  project.putUserData(LEVEL, level(project));
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * @param dataHolderKey Main data to cache
 * @param dataHolderNames Cache extracted name Set
 */
static public synchronized <T> Map<String, List<T>> getSetDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<T>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, T> ID, @NotNull final GlobalSearchScope scope) {
  CachedValue<Map<String, List<T>>> cache = project.getUserData(dataHolderKey);
  if(cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() -> {
      Map<String, List<T>> items = new HashMap<>();
      final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
      getIndexKeysCache(project, dataHolderNames, ID).stream().forEach(service ->
        items.put(service, fileBasedIndex.getValues(ID, service, scope))
      );
      return CachedValueProvider.Result.create(items, PsiModificationTracker.MODIFICATION_COUNT);
    }, false);
    project.putUserData(dataHolderKey, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * There several methods that just need to check for names, as they also needed for value extraction, so cache them also
 */
static public synchronized Set<String> getIndexKeysCache(@NotNull final Project project, @NotNull Key<CachedValue<Set<String>>> dataHolderKey, @NotNull final ID<String, ?> ID) {
  CachedValue<Set<String>> cache = project.getUserData(dataHolderKey);
  if(cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(SymfonyProcessors.createResult(project, ID), PsiModificationTracker.MODIFICATION_COUNT), false
    );
    project.putUserData(dataHolderKey, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * @param dataHolderKey Main data to cache
 * @param dataHolderNames Cache extracted name Set
 */
static public synchronized Map<String, List<String>> getStringDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<String>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, String> ID, @NotNull final GlobalSearchScope scope) {
  CachedValue<Map<String, List<String>>> cache = project.getUserData(dataHolderKey);
  if(cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() -> {
      Map<String, List<String>> strings = new HashMap<>();
      final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
      getIndexKeysCache(project, dataHolderNames, ID).stream().forEach(parameterName -> {
        // just for secure
        if(parameterName == null) {
          return;
        }
        strings.put(parameterName, fileBasedIndex.getValues(ID, parameterName, scope));
      });
      return CachedValueProvider.Result.create(strings, PsiModificationTracker.MODIFICATION_COUNT);
    }, false);
    project.putUserData(dataHolderKey, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
private Map<String, PsiVariable> getGlobals(@NotNull Project project) {
  CachedValue<Map<String, PsiVariable>> cache = project.getUserData(CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(getGlobalsInner(project), PsiModificationTracker.MODIFICATION_COUNT), false
    );
    project.putUserData(CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
public static Map<String, Collection<ContainerService>> getDecoratedServices(@NotNull Project project) {
  CachedValue<Map<String, Collection<ContainerService>>> cache = project.getUserData(SERVICE_DECORATION_CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(getDecoratedServicesInner(project), PsiModificationTracker.MODIFICATION_COUNT)
    , false);
    project.putUserData(SERVICE_DECORATION_CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
public static Collection<EventDispatcherSubscribedEvent> getSubscribedEvents(final @NotNull Project project) {
  CachedValue<Collection<EventDispatcherSubscribedEvent>> cache = project.getUserData(EVENT_SUBSCRIBERS);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(getSubscribedEventsProxy(project), PsiModificationTracker.MODIFICATION_COUNT), false
    );
    project.putUserData(EVENT_SUBSCRIBERS, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
synchronized public static Map<String, Route> getAllRoutes(final @NotNull Project project) {
  CachedValue<Map<String, Route>> cache = project.getUserData(ROUTE_CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(getAllRoutesProxy(project), PsiModificationTracker.MODIFICATION_COUNT),
      false
    );
    project.putUserData(ROUTE_CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
public static Collection<String> getEnvironmentVariables(@NotNull Project project) {
  CachedValue<Set<String>> cache = project.getUserData(DOT_ENV_VARIABLE_CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() -> {
      Set<String> items = new HashSet<>();
      DotEnvUtil.visitEnvironment(project, pair ->
        items.add(pair.getFirst())
      );
      return CachedValueProvider.Result.create(items, PsiModificationTracker.MODIFICATION_COUNT);
      }, false
    );
    project.putUserData(DOT_ENV_VARIABLE_CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * Get all services that extends a given "parent" id
 */
@NotNull
public static Map<String, Collection<ContainerService>> getParentServices(@NotNull Project project) {
  CachedValue<Map<String, Collection<ContainerService>>> cache = project.getUserData(SERVICE_PARENT);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
        CachedValueProvider.Result.create(getParentServicesInner(project), PsiModificationTracker.MODIFICATION_COUNT)
      , false);
    project.putUserData(SERVICE_PARENT, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * Search for all "Symfony\Component\Config\Definition\Builder\TreeBuilder::root" elements
 */
@NotNull
public static Map<String, Collection<String>> getTreeSignatures(@NotNull Project project) {
  CachedValue<Map<String, Collection<String>>> cache = project.getUserData(TREE_SIGNATURE_CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
        CachedValueProvider.Result.create(visitTreeSignatures(project), PsiModificationTracker.MODIFICATION_COUNT)
      , false);
    project.putUserData(TREE_SIGNATURE_CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

private static boolean compare(@NotNull Project project, @NotNull String version, @NotNull Comparator comparator) {
  CachedValue<Set<String>> cache = project.getUserData(CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(getVersions(project), PsiModificationTracker.MODIFICATION_COUNT),
      false
    );
    project.putUserData(CACHE, cache);
  }
  for (String s : cache.getValue()) {
    if(comparator.accepts(s)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * Extract parameter on php file
 *
 * return array_merge(
 *  array(
 *      'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
 *      'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
 *  ),
 *  $this->getEnvParameters(false)
 *  );
 */
@NotNull
public static Collection<String> getParameterParameters(@NotNull Project project) {
  CachedValue<Collection<String>> cache = project.getUserData(KERNEL_PARAMETER_CACHE);
  if(cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() ->
      CachedValueProvider.Result.create(getParameterParametersInner(project), PsiModificationTracker.MODIFICATION_COUNT),
      false
    );
    project.putUserData(KERNEL_PARAMETER_CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
@Override
public Collection<TwigPath> getNamespaces(@NotNull TwigNamespaceExtensionParameter parameter) {
  CachedValue<Collection<TwigPath>> cache = parameter.getProject().getUserData(CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(parameter.getProject()).createCachedValue(() ->
        CachedValueProvider.Result.create(getTwigPaths(parameter), PsiModificationTracker.MODIFICATION_COUNT),
      false
    );
    parameter.getProject().putUserData(CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

}, false);
project.putUserData(DOCTRINE_REPOSITORY_CACHE, cache);

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@NotNull
@Override
public Collection<TwigPath> getNamespaces(final @NotNull TwigNamespaceExtensionParameter parameter) {
  CachedValue<Collection<TwigPath>> cache = parameter.getProject().getUserData(CACHE);
  if (cache == null) {
    cache = CachedValuesManager.getManager(parameter.getProject()).createCachedValue(() ->
      CachedValueProvider.Result.create(getNamespacesInner(parameter), PsiModificationTracker.MODIFICATION_COUNT),
      false
    );
    parameter.getProject().putUserData(CACHE, cache);
  }
  return cache.getValue();
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * Generate a mapped template name file multiple relation:
 *
 * foo.html.twig => ["views/foo.html.twig", "templates/foo.html.twig"]
 */
@NotNull
public static synchronized Map<String, Set<VirtualFile>> getTemplateMap(@NotNull Project project, boolean usePhp) {
  Map<String, Set<VirtualFile>> templateMapProxy;
  // cache twig and all files,
  // only PHP files we dont need to cache
  if(!usePhp) {
    // cache twig files only, most use case
    CachedValue<Map<String, Set<VirtualFile>>> cache = project.getUserData(TEMPLATE_CACHE_TWIG);
    if (cache == null) {
      cache = CachedValuesManager.getManager(project).createCachedValue(new MyAllTemplateFileMapCachedValueProvider(project), false);
      project.putUserData(TEMPLATE_CACHE_TWIG, cache);
    }
    templateMapProxy = cache.getValue();
  } else {
    // cache all files
    CachedValue<Map<String, Set<VirtualFile>>> cache = project.getUserData(TEMPLATE_CACHE_ALL);
    if (cache == null) {
      cache = CachedValuesManager.getManager(project).createCachedValue(new MyAllTemplateFileMapCachedValueProvider(project, true), false);
      project.putUserData(TEMPLATE_CACHE_ALL, cache);
    }
    templateMapProxy = cache.getValue();
  }
  return templateMapProxy;
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

);
project.putUserData(FILTERS_CACHE, cache);
);
project.putUserData(FUNCTION_CACHE, cache);
);
project.putUserData(TEST_CACHE, cache);
);
project.putUserData(OPERATORS_CACHE, cache);

代码示例来源:origin: Haehnchen/idea-php-toolbox

@NotNull
synchronized public static Collection<PhpToolboxProviderInterface> getProviders(final @NotNull Project project) {
  CachedValue<Collection<PhpToolboxProviderInterface>> cache = project.getUserData(PROVIDER_CACHE);
  if(cache == null) {
    cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getProvidersInner(project), PsiModificationTracker.MODIFICATION_COUNT), false);
    project.putUserData(PROVIDER_CACHE, cache);
  }
  return cache.getValue();
}

相关文章