Java 类com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry 实例源码

项目:arma-intellij-plugin    文件:SQFString.java   
@NotNull
@Override
public PsiReference[] getReferences() {
    List<SQFVariableInStringReference> currentFileRefs = SQFScope.getVariableReferencesFor(this);
    PsiReference[] refsFromProviders = ReferenceProvidersRegistry.getReferencesFromProviders(this);
    if (currentFileRefs.size() == 0 && refsFromProviders.length == 0) {
        return PsiReference.EMPTY_ARRAY;
    }
    PsiReference[] refsAsArray = new PsiReference[currentFileRefs.size() + refsFromProviders.length];
    int i = 0;
    for (; i < currentFileRefs.size(); i++) {
        refsAsArray[i] = currentFileRefs.get(i);
    }
    for (int j = 0; j < refsFromProviders.length; i++, j++) {
        refsAsArray[i] = refsFromProviders[j];
    }
    return refsAsArray;
}
项目:intellij-ce-playground    文件:XmlTokenImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  final IElementType elementType = getElementType();

  if (elementType == XmlTokenType.XML_DATA_CHARACTERS ||
      elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this);
  } else if (elementType == XmlTokenType.XML_NAME && getParent() instanceof PsiErrorElement) {
    final PsiElement element = getPrevSibling();

    if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) {
      return new PsiReference[] {TagNameReference.createTagNameReference(this, getNode(), false)};
    }
  }

  return super.getReferences();
}
项目:arma-intellij-plugin    文件:SQFString.java   
@NotNull
@Override
public PsiReference[] getReferences() {
    List<SQFVariableInStringReference> currentFileRefs = SQFScope.getVariableReferencesFor(this);
    PsiReference[] refsFromProviders = ReferenceProvidersRegistry.getReferencesFromProviders(this);
    if (currentFileRefs.size() == 0 && refsFromProviders.length == 0) {
        return PsiReference.EMPTY_ARRAY;
    }
    PsiReference[] refsAsArray = new PsiReference[currentFileRefs.size() + refsFromProviders.length];
    int i = 0;
    for (; i < currentFileRefs.size(); i++) {
        refsAsArray[i] = currentFileRefs.get(i);
    }
    for (int j = 0; j < refsFromProviders.length; i++, j++) {
        refsAsArray[i] = refsFromProviders[j];
    }
    return refsAsArray;
}
项目:tools-idea    文件:XmlTokenImpl.java   
@NotNull
public PsiReference[] getReferences() {
  final IElementType elementType = getElementType();

  if (elementType == XmlTokenType.XML_DATA_CHARACTERS ||
      elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this);
  } else if (elementType == XmlTokenType.XML_NAME && getParent() instanceof PsiErrorElement) {
    final PsiElement element = getPrevSibling();

    if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) {
      return new PsiReference[] {TagNameReference.createTagNameReference(this, getNode(), false)};
    }
  }

  return super.getReferences();
}
项目:consulo-xml    文件:XmlTokenImpl.java   
@NotNull
public PsiReference[] getReferences() {
  final IElementType elementType = getElementType();

  if (elementType == XmlTokenType.XML_DATA_CHARACTERS ||
      elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this, XmlToken.class);
  } else if (elementType == XmlTokenType.XML_NAME && getParent() instanceof PsiErrorElement) {
    final PsiElement element = getPrevSibling();

    if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) {
      return new PsiReference[] {TagNameReference.createTagNameReference(this, getNode(), false)};
    }
  }

  return super.getReferences();
}
项目:consulo-xml    文件:XmlDoctypeImpl.java   
@Override
@NotNull
public PsiReference[] getReferences()
{
    final PsiElement dtdUrlElement = getDtdUrlElement();

    PsiReference uriRef = null;
    if(dtdUrlElement != null)
    {
        uriRef = createUrlReference(dtdUrlElement);
    }

    final PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(this);

    return uriRef == null ? refs : ArrayUtil.mergeArrays(new PsiReference[]{uriRef}, refs);
}
项目:intellij-ce-playground    文件:PsiDocTokenImpl.java   
@NotNull
@Override
public PsiReference[] getReferences() {
  if (getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA) {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiDocToken.class);
  }
  return super.getReferences();
}
项目:intellij-ce-playground    文件:DaemonAnalyzerTestCase.java   
@Override
protected void setUp() throws Exception {
  super.setUp();

  final LocalInspectionTool[] tools = configureLocalInspectionTools();

  CodeInsightTestFixtureImpl.configureInspections(tools, getProject(), Collections.<String>emptyList(),
                                                  getTestRootDisposable());

  DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
  daemonCodeAnalyzer.prepareForTest();
  final StartupManagerImpl startupManager = (StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject());
  startupManager.runStartupActivities();
  startupManager.startCacheUpdate();
  startupManager.runPostStartupActivities();
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);

  if (isPerformanceTest()) {
    IntentionManager.getInstance().getAvailableIntentionActions();  // hack to avoid slowdowns in PyExtensionFactory
    PathManagerEx.getTestDataPath(); // to cache stuff
    ReferenceProvidersRegistry.getInstance(); // pre-load tons of classes
    InjectedLanguageManager.getInstance(getProject()); // zillion of Dom Sem classes
    LanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE); // pile of annotator classes loads
    LanguageAnnotators.INSTANCE.allForLanguage(StdLanguages.XML);
    ProblemHighlightFilter.EP_NAME.getExtensions();
    Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
    Extensions.getExtensions(XmlSchemaProvider.EP_NAME);
    Extensions.getExtensions(XmlFileNSInfoProvider.EP_NAME);
    Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
    Extensions.getExtensions(IndexPatternBuilder.EP_NAME);
  }
}
项目:intellij-ce-playground    文件:PsiReferenceServiceImpl.java   
@NotNull
@Override
public List<PsiReference> getReferences(@NotNull PsiElement element, @NotNull Hints hints) {
  if (element instanceof ContributedReferenceHost) {
    return Arrays.asList(ReferenceProvidersRegistry.getReferencesFromProviders(element, hints));
  }
  else {
    return Arrays.asList(element.getReferences());
  }
}
项目:intellij-ce-playground    文件:JsonLiteralMixin.java   
@NotNull
@Override
public PsiReference[] getReferences() {
  final long count = getManager().getModificationTracker().getModificationCount();
  if (count != myModCount) {
    synchronized (myRefLock) {
      if (count != myModCount) {
        myRefs = ReferenceProvidersRegistry.getReferencesFromProviders(this);
        myModCount = count;
      }
    }
  }

  return myRefs;
}
项目:intellij-ce-playground    文件:XmlTagImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  ProgressManager.checkCanceled();
  final ASTNode startTagName = XmlChildRole.START_TAG_NAME_FINDER.findChild(this);
  if (startTagName == null) return PsiReference.EMPTY_ARRAY;
  final ASTNode endTagName = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(this);
  List<PsiReference> refs = new ArrayList<PsiReference>();
  String prefix = getNamespacePrefix();

  TagNameReference startTagRef = TagNameReference.createTagNameReference(this, startTagName, true);
  if (startTagRef != null) {
    refs.add(startTagRef);
  }
  if (!prefix.isEmpty()) {
    refs.add(createPrefixReference(startTagName, prefix, startTagRef));
  }
  if (endTagName != null) {
    TagNameReference endTagRef = TagNameReference.createTagNameReference(this, endTagName, false);
    if (endTagRef != null) {
      refs.add(endTagRef);
    }
    prefix = XmlUtil.findPrefixByQualifiedName(endTagName.getText());
    if (StringUtil.isNotEmpty(prefix)) {
      refs.add(createPrefixReference(endTagName, prefix, endTagRef));
    }
  }


  // ArrayList.addAll() makes a clone of the collection
  //noinspection ManualArrayToCollectionCopy
  for (PsiReference ref : ReferenceProvidersRegistry.getReferencesFromProviders(this, XmlTag.class)) {
    refs.add(ref);
  }

  return ContainerUtil.toArray(refs, new PsiReference[refs.size()]);
}
项目:intellij-ce-playground    文件:XmlAttributeValueImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  PsiReference[] cachedReferences = myCachedReferences;
  final long curModCount = getManager().getModificationTracker().getModificationCount();
  if (cachedReferences != null && myModCount == curModCount) {
    return cachedReferences;
  }
  cachedReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this);
  myCachedReferences = cachedReferences;
  myModCount = curModCount;
  return cachedReferences;
}
项目:intellij-ce-playground    文件:XmlDoctypeImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  final PsiElement dtdUrlElement = getDtdUrlElement();

  PsiReference uriRef = null;
  if (dtdUrlElement != null) {
    uriRef = createUrlReference(dtdUrlElement);
  }

  final PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(this);

  return uriRef == null ? refs : ArrayUtil.mergeArrays(new PsiReference[] {uriRef}, refs);
}
项目: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();
}
项目:intellij    文件:JavaClassQualifiedNameReference.java   
@Override
public PsiReference[] getReferences(String attributeName, StringLiteral literal) {
  if (!JAVA_CLASS_STRING_TYPES.contains(attributeName)) {
    return PsiReference.EMPTY_ARRAY;
  }
  return ReferenceProvidersRegistry.getReferencesFromProviders(literal);
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotKeyword element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
public static PsiReference getReference(RobotKeywordArg element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotJavaClassReference element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotResourceFile element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotScalarVariable element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotScalarAssignment element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotScalarAssignmentLhs element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotScalarDefaultArgValue element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:robot-intellij-plugin    文件:RobotImplUtil.java   
@Nullable
public static PsiReference getReference(RobotArgumentDef element) {
    PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(element);
    if (refs.length <= 0) {
        return null;
    }
    return refs[0];
}
项目:tools-idea    文件:PsiReferenceServiceImpl.java   
@Override
public List<PsiReference> getReferences(@NotNull PsiElement element, @NotNull Hints hints) {
  if (element instanceof ContributedReferenceHost) {
    return Arrays.asList(ReferenceProvidersRegistry.getReferencesFromProviders(element, hints));
  }
  else {
    return Arrays.asList(element.getReferences());
  }
}
项目:tools-idea    文件:XmlTagImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  ProgressManager.checkCanceled();
  final ASTNode startTagName = XmlChildRole.START_TAG_NAME_FINDER.findChild(this);
  if (startTagName == null) return PsiReference.EMPTY_ARRAY;
  final ASTNode endTagName = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(this);
  List<PsiReference> refs = new ArrayList<PsiReference>();
  String prefix = getNamespacePrefix();

  TagNameReference startTagRef = TagNameReference.createTagNameReference(this, startTagName, true);
  if (startTagRef != null) {
    refs.add(startTagRef);
  }
  if (prefix.length() > 0) {
    refs.add(createPrefixReference(startTagName, prefix, startTagRef));
  }
  if (endTagName != null) {
    TagNameReference endTagRef = TagNameReference.createTagNameReference(this, endTagName, false);
    if (endTagRef != null) {
      refs.add(endTagRef);
    }
    prefix = XmlUtil.findPrefixByQualifiedName(endTagName.getText());
    if (StringUtil.isNotEmpty(prefix)) {
      refs.add(createPrefixReference(endTagName, prefix, endTagRef));
    }
  }


  // ArrayList.addAll() makes a clone of the collection
  //noinspection ManualArrayToCollectionCopy
  for (PsiReference ref : ReferenceProvidersRegistry.getReferencesFromProviders(this, XmlTag.class)) {
    refs.add(ref);
  }

  return ContainerUtil.toArray(refs, new PsiReference[refs.size()]);
}
项目:tools-idea    文件:XmlAttributeValueImpl.java   
@NotNull
public PsiReference[] getReferences() {
  PsiReference[] cachedReferences = myCachedReferences;
  final long curModCount = getManager().getModificationTracker().getModificationCount();
  if (cachedReferences != null && myModCount == curModCount) {
    return cachedReferences;
  }
  cachedReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this, XmlAttributeValue.class);
  myCachedReferences = cachedReferences;
  myModCount = curModCount;
  return cachedReferences;
}
项目:tools-idea    文件:XmlDoctypeImpl.java   
@NotNull
public PsiReference[] getReferences() {
  final PsiElement dtdUrlElement = getDtdUrlElement();

  PsiReference uriRef = null;
  if (dtdUrlElement != null) {
    uriRef = createUrlReference(dtdUrlElement);
  }

  final PsiReference[] refs = ReferenceProvidersRegistry.getReferencesFromProviders(this);

  return uriRef == null ? refs : ArrayUtil.mergeArrays(new PsiReference[] {uriRef}, refs);
}
项目: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    文件:PsiReferenceServiceImpl.java   
@RequiredReadAction
@Nonnull
@Override
public List<PsiReference> getReferences(@Nonnull PsiElement element, @Nonnull Hints hints) {
  if (element instanceof ContributedReferenceHost) {
    return Arrays.asList(ReferenceProvidersRegistry.getReferencesFromProviders(element, hints));
  }
  if (element instanceof HintedReferenceHost) {
    return Arrays.asList(((HintedReferenceHost)element).getReferences(hints));
  }
  return Arrays.asList(element.getReferences());
}
项目:consulo-xml    文件:XmlAttributeValueImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  PsiReference[] cachedReferences = myCachedReferences;
  final long curModCount = getManager().getModificationTracker().getModificationCount();
  if (cachedReferences != null && myModCount == curModCount) {
    return cachedReferences;
  }
  cachedReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this);
  myCachedReferences = cachedReferences;
  myModCount = curModCount;
  return cachedReferences;
}
项目:consulo-java    文件:JavadocCompletionTest.java   
public void testCustomReferenceProvider() throws Exception {
  PsiReferenceRegistrarImpl registrar =
    (PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(JavaLanguage.INSTANCE);
  PsiReferenceProvider provider = new PsiReferenceProvider() {
    @Override
    @NotNull
    public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
      return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {

        @Override
        public PsiElement resolve() {
          return element;
        }

        @Override
        @NotNull
        public Object[] getVariants() {
          return new Object[]{"1", "2", "3"};
        }
      }};
    }
  };
  try {
    registrar.registerReferenceProvider(PsiDocTag.class, provider);
    configureByFile("ReferenceProvider.java");
    assertStringItems("1", "2", "3");
  }
  finally {
    registrar.unregisterReferenceProvider(PsiDocTag.class, provider);
  }
}
项目:smcplugin    文件:SmcNamedElementImpl.java   
public PsiReference getReference() {
    return ReferenceProvidersRegistry.getReferencesFromProviders(this).length > 0 ?
            ReferenceProvidersRegistry.getReferencesFromProviders(this)[0] : null;
}
项目:intellij-ce-playground    文件:PsiDocTagImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiReferenceService.Hints.NO_HINTS);
}
项目:intellij-ce-playground    文件:PsiCoreCommentImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiComment.class);
}
项目:intellij-ce-playground    文件:PsiPlainTextFileImpl.java   
@Override
@NotNull
public PsiReference[] getReferences() {
  return ReferenceProvidersRegistry.getReferencesFromProviders(this,PsiPlainTextFile.class);
}
项目: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);
}
项目:intellij-ce-playground    文件:JsonPropertyMixin.java   
@NotNull
@Override
public PsiReference[] getReferences() {
  final PsiReference[] fromProviders = ReferenceProvidersRegistry.getReferencesFromProviders(this);
  return ArrayUtil.prepend(new JsonPropertyNameReference(this), fromProviders);
}
项目:intellij-ce-playground    文件:PyStringLiteralExpressionImpl.java   
@NotNull
public PsiReference[] getReferences() {
  return ReferenceProvidersRegistry.getReferencesFromProviders(this, PsiReferenceService.Hints.NO_HINTS);
}
项目:intellij-ce-playground    文件:CommandLineElement.java   
@NotNull
@Override
public final PsiReference[] getReferences() {
  // We need it to enable reference injection
  return ReferenceProvidersRegistry.getReferencesFromProviders(this);
}