Java Code Examples for com.intellij.psi.PsiReferenceService#Hints

The following examples show how to use com.intellij.psi.PsiReferenceService#Hints . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleProviderBinding.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void addAcceptableReferenceProviders(@Nonnull PsiElement position,
                                            @Nonnull List<ProviderInfo<Provider, ProcessingContext>> list,
                                            @Nonnull PsiReferenceService.Hints hints) {
  for (ProviderInfo<Provider, ElementPattern> trinity : myProviderPairs) {
    if (hints != PsiReferenceService.Hints.NO_HINTS && !((PsiReferenceProvider)trinity.provider).acceptsHints(position, hints)) {
      continue;
    }

    final ProcessingContext context = new ProcessingContext();
    if (hints != PsiReferenceService.Hints.NO_HINTS) {
      context.put(PsiReferenceService.HINTS, hints);
    }
    boolean suitable = false;
    try {
      suitable = trinity.processingContext.accepts(position, context);
    }
    catch (IndexNotReadyException ignored) {
    }
    if (suitable) {
      list.add(new ProviderInfo<Provider, ProcessingContext>(trinity.provider, context, trinity.priority));
    }
  }
}
 
Example 2
Source File: PsiReferenceRegistrarImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
List<ProviderBinding.ProviderInfo<PsiReferenceProvider,ProcessingContext>> getPairsByElement(@Nonnull PsiElement element,
                                                                                             @Nonnull PsiReferenceService.Hints hints) {
  final Class<? extends PsiElement> clazz = element.getClass();
  List<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>> ret = null;

  for (Class aClass : myKnownSupers.get(clazz)) {
    SimpleProviderBinding<PsiReferenceProvider> simpleBinding = myBindingsMap.get(aClass);
    NamedObjectProviderBinding<PsiReferenceProvider> namedBinding = myNamedBindingsMap.get(aClass);
    if (simpleBinding == null && namedBinding == null) continue;

    if (ret == null) ret = new SmartList<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>>();
    if (simpleBinding != null) {
      simpleBinding.addAcceptableReferenceProviders(element, ret, hints);
    }
    if (namedBinding != null) {
      namedBinding.addAcceptableReferenceProviders(element, ret, hints);
    }
  }
  return ret == null ? Collections.<ProviderBinding.ProviderInfo<PsiReferenceProvider, ProcessingContext>>emptyList() : ret;
}
 
Example 3
Source File: NamedObjectProviderBinding.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void addMatchingProviders(final PsiElement position,
                                  @Nullable final List<ProviderInfo<Provider, ElementPattern>> providerList,
                                  @Nonnull List<ProviderInfo<Provider, ProcessingContext>> ret,
                                  PsiReferenceService.Hints hints) {
  if (providerList == null) return;

  for (ProviderInfo<Provider, ElementPattern> trinity : providerList) {
    if (hints != PsiReferenceService.Hints.NO_HINTS && !((PsiReferenceProvider)trinity.provider).acceptsHints(position, hints)) {
      continue;
    }

    final ProcessingContext context = new ProcessingContext();
    if (hints != PsiReferenceService.Hints.NO_HINTS) {
      context.put(PsiReferenceService.HINTS, hints);
    }
    boolean suitable = false;
    try {
      suitable = trinity.processingContext.accepts(position, context);
    }
    catch (IndexNotReadyException ignored) {
    }
    if (suitable) {
      ret.add(new ProviderInfo<Provider, ProcessingContext>(trinity.provider, context, trinity.priority));
    }
  }
}
 
Example 4
Source File: NamedObjectProviderBinding.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addAcceptableReferenceProviders(@Nonnull PsiElement position, @Nonnull List<ProviderInfo<Provider, ProcessingContext>> list, @Nonnull PsiReferenceService.Hints hints) {
  String name = getName(position);
  if (name != null) {
    addMatchingProviders(position, myNamesToProvidersMap.get(name), list, hints);
    addMatchingProviders(position, myNamesToProvidersMapInsensitive.get(name.toLowerCase()), list, hints);
  }
}
 
Example 5
Source File: MockReferenceProvidersRegistry.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected PsiReference[] doGetReferencesFromProviders(PsiElement context, PsiReferenceService.Hints hints) {
  return PsiReference.EMPTY_ARRAY;
}
 
Example 6
Source File: ProviderBinding.java    From consulo with Apache License 2.0 4 votes vote down vote up
void addAcceptableReferenceProviders(@Nonnull PsiElement position,
@Nonnull List<ProviderInfo<T, ProcessingContext>> list,
@Nonnull PsiReferenceService.Hints hints);