コード例 #1
0
  private static Collection<FqName> getJetExtensionFunctions(
      @NotNull final String referenceName,
      @NotNull JetSimpleNameExpression expression,
      @NotNull Project project) {
    JetShortNamesCache namesCache = JetCacheManager.getInstance(project).getNamesCache();
    Collection<DeclarationDescriptor> jetCallableExtensions =
        namesCache.getJetCallableExtensions(
            new Condition<String>() {
              @Override
              public boolean value(String callableExtensionName) {
                return callableExtensionName.equals(referenceName);
              }
            },
            expression,
            GlobalSearchScope.allScope(project));

    return Sets.newHashSet(
        Collections2.transform(
            jetCallableExtensions,
            new Function<DeclarationDescriptor, FqName>() {
              @Override
              public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) {
                assert declarationDescriptor != null;
                return DescriptorUtils.getFQName(declarationDescriptor).toSafe();
              }
            }));
  }
コード例 #2
0
  private static Collection<FqName> getJetTopLevelFunctions(
      @NotNull String referenceName, JetSimpleNameExpression expression, @NotNull Project project) {
    JetShortNamesCache namesCache = JetCacheManager.getInstance(project).getNamesCache();
    Collection<FunctionDescriptor> topLevelFunctions =
        namesCache.getTopLevelFunctionDescriptorsByName(
            referenceName, expression, GlobalSearchScope.allScope(project));

    return Sets.newHashSet(
        Collections2.transform(
            topLevelFunctions,
            new Function<DeclarationDescriptor, FqName>() {
              @Override
              public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) {
                assert declarationDescriptor != null;
                return DescriptorUtils.getFQName(declarationDescriptor).toSafe();
              }
            }));
  }