Java 类com.intellij.psi.PsiReferenceService 实例源码

项目:intellij-ce-playground    文件:SingleTargetRequestResultProcessor.java   
@Override
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull final Processor<PsiReference> consumer) {
  if (!myTarget.isValid()) {
    return false;
  }

  final List<PsiReference> references = ourReferenceService.getReferences(element,
                                                                          new PsiReferenceService.Hints(myTarget, offsetInElement));
  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < references.size(); i++) {
    PsiReference ref = references.get(i);
    ProgressManager.checkCanceled();
    if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) {
      return false;
    }
  }
  return true;
}
项目:tools-idea    文件:SimpleProviderBinding.java   
@Override
public void addAcceptableReferenceProviders(@NotNull PsiElement position,
                                            @NotNull List<ProviderInfo<Provider, ProcessingContext>> list,
                                            @NotNull 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));
    }
  }
}
项目:tools-idea    文件:PsiReferenceRegistrarImpl.java   
@NotNull
List<ProviderBinding.ProviderInfo<PsiReferenceProvider,ProcessingContext>> getPairsByElement(@NotNull PsiElement element,
                                                                                             @NotNull 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;
}
项目:tools-idea    文件:NamedObjectProviderBinding.java   
private void addMatchingProviders(final PsiElement position,
                                  @Nullable final List<ProviderInfo<Provider, ElementPattern>> providerList,
                                  @NotNull 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));
    }
  }
}
项目:consulo    文件:SingleTargetRequestResultProcessor.java   
@Override
public boolean processTextOccurrence(@Nonnull PsiElement element, int offsetInElement, @Nonnull final Processor<PsiReference> consumer) {
  if (!myTarget.isValid()) {
    return false;
  }

  final List<PsiReference> references = ourReferenceService.getReferences(element, new PsiReferenceService.Hints(myTarget, offsetInElement));
  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < references.size(); i++) {
    PsiReference ref = references.get(i);
    ProgressManager.checkCanceled();
    if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) {
      return false;
    }
  }
  return true;
}
项目:consulo    文件:SimpleProviderBinding.java   
@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));
    }
  }
}
项目:consulo    文件:PsiReferenceRegistrarImpl.java   
@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;
}
项目:consulo    文件:NamedObjectProviderBinding.java   
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));
    }
  }
}
项目:intellij-ce-playground    文件:FindUsagesHelper.java   
protected static boolean processUsagesInText(@NotNull final PsiElement element,
                                             @NotNull Collection<String> stringToSearch,
                                             @NotNull GlobalSearchScope searchScope,
                                             @NotNull Processor<UsageInfo> processor) {
  final TextRange elementTextRange = ApplicationManager.getApplication().runReadAction(new NullableComputable<TextRange>() {
    @Override
    public TextRange compute() {
      if (!element.isValid() || element instanceof PsiCompiledElement) return null;
      return element.getTextRange();
    }
  });
  UsageInfoFactory factory = new UsageInfoFactory() {
    @Override
    public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) {
      if (elementTextRange != null
          && usage.getContainingFile() == element.getContainingFile()
          && elementTextRange.contains(startOffset)
          && elementTextRange.contains(endOffset)) {
        return null;
      }

      PsiReference someReference = usage.findReferenceAt(startOffset);
      if (someReference != null) {
        PsiElement refElement = someReference.getElement();
        for (PsiReference ref : PsiReferenceService.getService().getReferences(refElement, new PsiReferenceService.Hints(element, null))) {
          if (element.getManager().areElementsEquivalent(ref.resolve(), element)) {
            TextRange range = ref.getRangeInElement().shiftRight(refElement.getTextRange().getStartOffset() - usage.getTextRange().getStartOffset());
            return new UsageInfo(usage, range.getStartOffset(), range.getEndOffset(), true);
          }
        }
      }

      return new UsageInfo(usage, startOffset, endOffset, true);
    }
  };
  for (String s : stringToSearch) {
    if (!PsiSearchHelperImpl.processTextOccurrences(element, s, searchScope, processor, factory)) return false;
  }
  return true;
}
项目:intellij-ce-playground    文件:PsiReferenceRegistrarImpl.java   
@NotNull
List<ProviderBinding.ProviderInfo<ProcessingContext>> getPairsByElement(@NotNull PsiElement element,
                                                                                             @NotNull PsiReferenceService.Hints hints) {

  final ProviderBinding[] bindings = myBindingCache.get(element.getClass());
  if (bindings.length == 0) return Collections.emptyList();

  List<ProviderBinding.ProviderInfo<ProcessingContext>> ret = ContainerUtil.newSmartList();
  for (ProviderBinding binding : bindings) {
    binding.addAcceptableReferenceProviders(element, ret, hints);
  }
  return ret;
}
项目:intellij-ce-playground    文件:NamedObjectProviderBinding.java   
@Override
public void addAcceptableReferenceProviders(@NotNull PsiElement position,
                                            @NotNull List<ProviderInfo<ProcessingContext>> list,
                                            @NotNull 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);
  }
}
项目:intellij-ce-playground    文件:NamedObjectProviderBinding.java   
static void addMatchingProviders(@NotNull PsiElement position,
                                 @Nullable final List<ProviderInfo<ElementPattern>> providerList,
                                 @NotNull Collection<ProviderInfo<ProcessingContext>> output,
                                 @NotNull PsiReferenceService.Hints hints) {
  if (providerList == null) return;

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < providerList.size(); i++) {
    ProviderInfo<ElementPattern> info = providerList.get(i);
    if (hints != PsiReferenceService.Hints.NO_HINTS && !info.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 = info.processingContext.accepts(position, context);
    }
    catch (IndexNotReadyException ignored) {
    }
    if (suitable) {
      output.add(new ProviderInfo<ProcessingContext>(info.provider, context, info.priority));
    }
  }
}
项目:intellij-ce-playground    文件:XPath2TypeElementImpl.java   
@NotNull
public PsiReference[] getReferences() {
  final PrefixedName prefixedName = getQName();
  if (prefixedName != null && prefixedName.getPrefix() != null) {
    final PsiReference[] references =
      ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiReferenceService.Hints.NO_HINTS);

    final PrefixReferenceImpl reference = new PrefixReferenceImpl(this, ((PrefixedNameImpl)prefixedName).getPrefixNode());
    return references.length > 0 ? ArrayUtil.append(references, reference) : new PsiReference[]{ reference };
  }
  return super.getReferences();
}
项目:tools-idea    文件:SingleTargetRequestResultProcessor.java   
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull final Processor<PsiReference> consumer) {
  final List<PsiReference> references = ourReferenceService.getReferences(element,
                                                                          new PsiReferenceService.Hints(myTarget, offsetInElement));
  for (PsiReference ref : references) {
    ProgressManager.checkCanceled();
    if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) {
      return false;
    }
  }
  return true;
}
项目:tools-idea    文件:NamedObjectProviderBinding.java   
@Override
public void addAcceptableReferenceProviders(@NotNull PsiElement position,
                                            @NotNull List<ProviderInfo<Provider, ProcessingContext>> list,
                                            @NotNull 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);
  }
}
项目:tools-idea    文件:XPath2TypeElementImpl.java   
@NotNull
public PsiReference[] getReferences() {
  final PrefixedName prefixedName = getQName();
  if (prefixedName != null && prefixedName.getPrefix() != null) {
    final PsiReference[] references =
      ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiReferenceService.Hints.NO_HINTS);

    final PrefixReferenceImpl reference = new PrefixReferenceImpl(this, ((PrefixedNameImpl)prefixedName).getPrefixNode());
    return references.length > 0 ? ArrayUtil.append(references, reference) : new PsiReference[]{ reference };
  }
  return super.getReferences();
}
项目:consulo-csharp    文件:CSharpConstantExpressionImpl.java   
@NotNull
@Override
@RequiredReadAction
public PsiReference[] getReferences()
{
    return PsiReferenceService.getService().getContributedReferences(this);
}
项目:consulo    文件:FindUsagesHelper.java   
public static boolean processUsagesInText(@Nonnull final PsiElement element,
                                             @Nonnull Collection<String> stringToSearch,
                                             @Nonnull GlobalSearchScope searchScope,
                                             @Nonnull Processor<UsageInfo> processor) {
  final TextRange elementTextRange = ApplicationManager.getApplication().runReadAction(new NullableComputable<TextRange>() {
    @Override
    public TextRange compute() {
      if (!element.isValid() || element instanceof PsiCompiledElement) return null;
      return element.getTextRange();
    }
  });
  UsageInfoFactory factory = new UsageInfoFactory() {
    @Override
    public UsageInfo createUsageInfo(@Nonnull PsiElement usage, int startOffset, int endOffset) {
      if (elementTextRange != null
          && usage.getContainingFile() == element.getContainingFile()
          && elementTextRange.contains(startOffset)
          && elementTextRange.contains(endOffset)) {
        return null;
      }

      PsiReference someReference = usage.findReferenceAt(startOffset);
      if (someReference != null) {
        PsiElement refElement = someReference.getElement();
        for (PsiReference ref : PsiReferenceService.getService().getReferences(refElement, new PsiReferenceService.Hints(element, null))) {
          if (element.getManager().areElementsEquivalent(ref.resolve(), element)) {
            TextRange range = ref.getRangeInElement().shiftRight(refElement.getTextRange().getStartOffset() - usage.getTextRange().getStartOffset());
            return new UsageInfo(usage, range.getStartOffset(), range.getEndOffset(), true);
          }
        }
      }

      return new UsageInfo(usage, startOffset, endOffset, true);
    }
  };
  for (String s : stringToSearch) {
    if (!PsiSearchHelperImpl.processTextOccurrences(element, s, searchScope, processor, factory)) return false;
  }
  return true;
}
项目:consulo    文件:NamedObjectProviderBinding.java   
@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);
  }
}
项目:consulo-xml    文件:XmlAttributeImpl.java   
@Override
public PsiReference getReference()
{
    final PsiReference[] refs = getReferences(PsiReferenceService.Hints.NO_HINTS);
    if(refs.length > 0)
    {
        return refs[0];
    }
    return null;
}
项目:consulo-xml    文件:XmlAttributeImpl.java   
/**
 * Use {@link #getReferences(PsiReferenceService.Hints)} instead of calling or overriding this method.
 */
@Deprecated
@NotNull
@Override
public final PsiReference[] getReferences()
{
    return getReferences(PsiReferenceService.Hints.NO_HINTS);
}
项目:intellij-ce-playground    文件:SimpleProviderBinding.java   
@Override
public void addAcceptableReferenceProviders(@NotNull PsiElement position,
                                            @NotNull List<ProviderInfo<ProcessingContext>> list,
                                            @NotNull PsiReferenceService.Hints hints) {
  NamedObjectProviderBinding.addMatchingProviders(position, myProviderPairs, list, hints);
}
项目:intellij-ce-playground    文件:ProviderBinding.java   
void addAcceptableReferenceProviders(@NotNull PsiElement position,
@NotNull List<ProviderInfo<ProcessingContext>> list,
@NotNull PsiReferenceService.Hints hints);
项目:intellij-ce-playground    文件:CoreApplicationEnvironment.java   
public CoreApplicationEnvironment(@NotNull Disposable parentDisposable) {
  myParentDisposable = parentDisposable;

  myFileTypeRegistry = new CoreFileTypeRegistry();

  myApplication = createApplication(myParentDisposable);
  ApplicationManager.setApplication(myApplication,
                                    new StaticGetter<FileTypeRegistry>(myFileTypeRegistry),
                                    myParentDisposable);
  myLocalFileSystem = createLocalFileSystem();
  myJarFileSystem = createJarFileSystem();

  Extensions.registerAreaClass(ExtensionAreas.IDEA_PROJECT, null);

  final MutablePicoContainer appContainer = myApplication.getPicoContainer();
  registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {
    @Override
    public Document fun(CharSequence charSequence) {
      return new DocumentImpl(charSequence);
    }
  }, null));

  VirtualFileSystem[] fs = {myLocalFileSystem, myJarFileSystem};
  VirtualFileManagerImpl virtualFileManager = new VirtualFileManagerImpl(fs, MessageBusFactory.newMessageBus(myApplication));
  registerComponentInstance(appContainer, VirtualFileManager.class, virtualFileManager);

  registerApplicationService(EncodingManager.class, new CoreEncodingRegistry());
  registerApplicationService(VirtualFilePointerManager.class, createVirtualFilePointerManager());
  registerApplicationService(DefaultASTFactory.class, new CoreASTFactory());
  registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
  registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
  registerApplicationService(StubTreeLoader.class, new CoreStubTreeLoader());
  registerApplicationService(PsiReferenceService.class, new PsiReferenceServiceImpl());
  registerApplicationService(MetaDataRegistrar.class, new MetaRegistry());

  registerApplicationService(ProgressManager.class, createProgressIndicatorProvider());

  registerApplicationService(JobLauncher.class, createJobLauncher());
  registerApplicationService(CodeFoldingSettings.class, new CodeFoldingSettings());
  registerApplicationService(CommandProcessor.class, new CoreCommandProcessor());
  myApplication.registerService(ApplicationInfo.class, ApplicationInfoImpl.class);
}
项目:tools-idea    文件:MockReferenceProvidersRegistry.java   
@Override
protected PsiReference[] doGetReferencesFromProviders(PsiElement context, PsiReferenceService.Hints hints) {
  return PsiReference.EMPTY_ARRAY;
}
项目:tools-idea    文件:CoreApplicationEnvironment.java   
public CoreApplicationEnvironment(Disposable parentDisposable) {
  myParentDisposable = parentDisposable;
  Extensions.cleanRootArea(myParentDisposable);

  myFileTypeRegistry = new CoreFileTypeRegistry();
  myEncodingRegistry = new CoreEncodingRegistry();

  myApplication = createApplication(myParentDisposable);
  ApplicationManager.setApplication(myApplication,
                                    new StaticGetter<FileTypeRegistry>(myFileTypeRegistry),
                                    new StaticGetter<EncodingRegistry>(myEncodingRegistry),
                                    myParentDisposable);
  myLocalFileSystem = createLocalFileSystem();
  myJarFileSystem = createJarFileSystem();

  Extensions.registerAreaClass(ExtensionAreas.IDEA_PROJECT, null);

  final MutablePicoContainer appContainer = myApplication.getPicoContainer();
  registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {
    @Override
    public Document fun(CharSequence charSequence) {
      return new DocumentImpl(charSequence);
    }
  }, null));

  VirtualFileSystem[] fs = {myLocalFileSystem, myJarFileSystem};
  VirtualFileManagerImpl virtualFileManager = new VirtualFileManagerImpl(fs, new MessageBusImpl(myApplication, null));
  registerComponentInstance(appContainer, VirtualFileManager.class, virtualFileManager);

  registerApplicationService(VirtualFilePointerManager.class, createVirtualFilePointerManager());
  myApplication.registerService(DefaultASTFactory.class, new CoreASTFactory());
  myApplication.registerService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
  myApplication.registerService(ReferenceProvidersRegistry.class, new MockReferenceProvidersRegistry());
  myApplication.registerService(StubTreeLoader.class, new CoreStubTreeLoader());
  myApplication.registerService(PsiReferenceService.class, new PsiReferenceServiceImpl());
  myApplication.registerService(MetaDataRegistrar.class, new MetaRegistry());

  registerApplicationExtensionPoint(ContentBasedFileSubstitutor.EP_NAME, ContentBasedFileSubstitutor.class);
  registerExtensionPoint(Extensions.getRootArea(), BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
  registerExtensionPoint(Extensions.getRootArea(), FileContextProvider.EP_NAME, FileContextProvider.class);

  registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);

  ProgressIndicatorProvider.ourInstance = createProgressIndicatorProvider();

  myApplication.registerService(JobLauncher.class, createJobLauncher());
}
项目:tools-idea    文件:ProviderBinding.java   
void addAcceptableReferenceProviders(@NotNull PsiElement position,
@NotNull List<ProviderInfo<T, ProcessingContext>> list,
@NotNull PsiReferenceService.Hints hints);
项目:tools-idea    文件:FindUsagesHandler.java   
public boolean processUsagesInText(@NotNull final PsiElement element,
                                   @NotNull Processor<UsageInfo> processor,
                                   @NotNull GlobalSearchScope searchScope) {
  Collection<String> stringToSearch = ApplicationManager.getApplication().runReadAction(new NullableComputable<Collection<String>>() {
    @Override
    public Collection<String> compute() {
      return getStringsToSearch(element);
    }
  });
  if (stringToSearch == null) return true;
  final TextRange elementTextRange = ApplicationManager.getApplication().runReadAction(new NullableComputable<TextRange>() {
    @Override
    public TextRange compute() {
      if (!element.isValid()) return null;
      return element.getTextRange();
    }
  });
  TextOccurrencesUtil.UsageInfoFactory factory = new TextOccurrencesUtil.UsageInfoFactory() {
    @Override
    public UsageInfo createUsageInfo(@NotNull PsiElement usage, int startOffset, int endOffset) {
      if (elementTextRange != null
          && usage.getContainingFile() == element.getContainingFile()
          && elementTextRange.contains(startOffset)
          && elementTextRange.contains(endOffset)) {
        return null;
      }

      PsiReference someReference = usage.findReferenceAt(startOffset);
      if (someReference != null) {
        PsiElement refElement = someReference.getElement();
        for (PsiReference ref : PsiReferenceService.getService().getReferences(refElement, new PsiReferenceService.Hints(element, null))) {
          if (element.getManager().areElementsEquivalent(ref.resolve(), element)) {
            TextRange range = ref.getRangeInElement().shiftRight(refElement.getTextRange().getStartOffset() - usage.getTextRange().getStartOffset());
            return new UsageInfo(usage, range.getStartOffset(), range.getEndOffset(), true);
          }
        }

      }

      return new UsageInfo(usage, startOffset, endOffset, true);
    }
  };
  for (String s : stringToSearch) {
    if (!TextOccurrencesUtil.processTextOccurences(element, s, searchScope, processor, factory)) return false;
  }
  return true;
}
项目:consulo-csharp    文件:CSharpCallArgumentListImpl.java   
@NotNull
@Override
public PsiReference[] getReferences()
{
    return PsiReferenceService.getService().getContributedReferences(this);
}
项目:consulo-csharp    文件:CSharpStubMemberImpl.java   
@NotNull
@Override
public PsiReference[] getReferences()
{
    return PsiReferenceService.getService().getContributedReferences(this);
}
项目:consulo    文件:MockReferenceProvidersRegistry.java   
@Override
protected PsiReference[] doGetReferencesFromProviders(PsiElement context, PsiReferenceService.Hints hints) {
  return PsiReference.EMPTY_ARRAY;
}
项目:consulo    文件:CoreApplicationEnvironment.java   
public CoreApplicationEnvironment(@Nonnull Disposable parentDisposable) {
  myParentDisposable = parentDisposable;

  myFileTypeRegistry = new CoreFileTypeRegistry();

  myApplication = createApplication(myParentDisposable);
  ApplicationManager.setApplication(myApplication,
                                    new StaticGetter<>(myFileTypeRegistry),
                                    myParentDisposable);
  myLocalFileSystem = createLocalFileSystem();
  myJarFileSystem = createJarFileSystem();

  Extensions.registerAreaClass(ExtensionAreas.PROJECT, null);

  final MutablePicoContainer appContainer = myApplication.getPicoContainer();
  registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(DocumentImpl::new, null));

  VirtualFileSystem[] fs = {myLocalFileSystem, myJarFileSystem};
  VirtualFileManagerImpl virtualFileManager = new VirtualFileManagerImpl(fs, myApplication.getMessageBus());
  registerComponentInstance(appContainer, VirtualFileManager.class, virtualFileManager);

  registerApplicationExtensionPoint(ASTLazyFactory.EP.getExtensionPointName(), ASTLazyFactory.class);
  registerApplicationExtensionPoint(ASTLeafFactory.EP.getExtensionPointName(), ASTLeafFactory.class);
  registerApplicationExtensionPoint(ASTCompositeFactory.EP.getExtensionPointName(), ASTCompositeFactory.class);

  addExtension(ASTLazyFactory.EP.getExtensionPointName(), new DefaultASTLazyFactory());
  addExtension(ASTLeafFactory.EP.getExtensionPointName(), new DefaultASTLeafFactory());
  addExtension(ASTCompositeFactory.EP.getExtensionPointName(), new DefaultASTCompositeFactory());

  registerApplicationService(EncodingManager.class, new CoreEncodingRegistry());
  registerApplicationService(VirtualFilePointerManager.class, createVirtualFilePointerManager());
  registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
  registerApplicationService(ReferenceProvidersRegistry.class, new MockReferenceProvidersRegistry());
  registerApplicationService(StubTreeLoader.class, new CoreStubTreeLoader());
  registerApplicationService(PsiReferenceService.class, new PsiReferenceServiceImpl());
  registerApplicationService(MetaDataRegistrar.class, new MetaRegistry());

  registerApplicationService(ProgressManager.class, createProgressIndicatorProvider());

  registerApplicationService(JobLauncher.class, createJobLauncher());
  registerApplicationService(CodeFoldingSettings.class, new CodeFoldingSettings());
  registerApplicationService(CommandProcessor.class, new CoreCommandProcessor());
  myApplication.registerService(ApplicationInfo.class, ApplicationInfoImpl.class);
}
项目:consulo    文件:ProviderBinding.java   
void addAcceptableReferenceProviders(@Nonnull PsiElement position,
@Nonnull List<ProviderInfo<T, ProcessingContext>> list,
@Nonnull PsiReferenceService.Hints hints);
项目:consulo-xml    文件:XmlAttributeImpl.java   
@Override
public boolean shouldAskParentForReferences(@NotNull PsiReferenceService.Hints hints)
{
    return false;
}