本文整理汇总了Java中com.intellij.psi.PsiReferenceProvider类的典型用法代码示例。如果您正苦于以下问题:Java PsiReferenceProvider类的具体用法?Java PsiReferenceProvider怎么用?Java PsiReferenceProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiReferenceProvider类属于com.intellij.psi包,在下文中一共展示了PsiReferenceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerReferenceProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(PlatformPatterns.psiElement(YAMLScalar.class),
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (isConfigFile(element)) {
String valueText = ((YAMLScalar) element).getTextValue();
List<MacroResolver.Match> matches = new MacroResolver().resolve(valueText);
List<PsiReference> references = new ArrayList<>();
matches.stream()
.filter(match -> !match.isEscaped())
.map(match -> resolvePsiReferences(element, match.getReference(), (element instanceof YAMLQuotedText ? 1 : 0) + match.getStartPos()))
.forEach(references::addAll);
return references.toArray(new PsiReference[references.size()]);
}
return PsiReference.EMPTY_ARRAY;
}
});
}
示例2: registerReferenceProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (isLiteralOfConfigurationAnnotation(element) || isCoffigMethod(element)) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
List<PsiReference> psiReferences = resolvePsiReferences(element, value, 1);
return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
return PsiReference.EMPTY_ARRAY;
}
});
}
示例3: createTagsReferenceProvider
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
PsiReferenceProvider createTagsReferenceProvider() {
return new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) {
return Optional.ofNullable(element.getText())
.map(text -> new PsiReference[]{
new TagReference(
element,
element.getText(),
traversal)})
.orElse(TagReference.EMPTY_ARRAY);
}
};
}
示例4: registerNamedReferenceProvider
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
private void registerNamedReferenceProvider(@NotNull String[] names,
final PsiNamePatternCondition<?> nameCondition,
@NotNull Class scopeClass,
final boolean caseSensitive,
@NotNull PsiReferenceProvider provider,
final double priority,
@NotNull ElementPattern pattern) {
NamedObjectProviderBinding providerBinding = myNamedBindingsMap.get(scopeClass);
if (providerBinding == null) {
myNamedBindingsMap.put(scopeClass, providerBinding = new NamedObjectProviderBinding() {
@Override
protected String getName(@NotNull final PsiElement position) {
return nameCondition.getPropertyValue(position);
}
});
}
providerBinding.registerProvider(names, pattern, caseSensitive, provider, priority);
}
示例5: registerProvider
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
public void registerProvider(@NonNls @NotNull String[] names,
@NotNull ElementPattern filter,
boolean caseSensitive,
@NotNull PsiReferenceProvider provider,
final double priority) {
final Map<String, List<ProviderInfo<ElementPattern>>> map = caseSensitive ? myNamesToProvidersMap : myNamesToProvidersMapInsensitive;
for (final String attributeName : names) {
String key = caseSensitive ? attributeName : attributeName.toLowerCase();
List<ProviderInfo<ElementPattern>> psiReferenceProviders = map.get(key);
if (psiReferenceProviders == null) {
map.put(key, psiReferenceProviders = new SmartList<ProviderInfo<ElementPattern>>());
}
psiReferenceProviders.add(new ProviderInfo<ElementPattern>(provider, filter, priority));
}
}
示例6: registerReferenceProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
// references from same language
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(KUserId.class).withLanguage(KLanguage.INSTANCE),
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(PsiElement element, ProcessingContext context) {
if (element instanceof KUserId) {
final String key = element.getText();
return new PsiReference[]{new KReference((KUserId)element, new TextRange(0, key.length()))};
}
return new PsiReference[0];
}
}
);
}
示例7: addAcceptableReferenceProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@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));
}
}
}
示例8: registerNamedReferenceProvider
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
private void registerNamedReferenceProvider(@NotNull String[] names,
final PsiNamePatternCondition<?> nameCondition,
@NotNull Class scopeClass,
final boolean caseSensitive,
@NotNull PsiReferenceProvider provider,
final double priority,
@NotNull ElementPattern pattern) {
NamedObjectProviderBinding<PsiReferenceProvider> providerBinding = myNamedBindingsMap.get(scopeClass);
if (providerBinding == null) {
myNamedBindingsMap.put(scopeClass, providerBinding = new NamedObjectProviderBinding<PsiReferenceProvider>() {
@Override
protected String getName(final PsiElement position) {
return nameCondition.getPropertyValue(position);
}
});
}
providerBinding.registerProvider(names, pattern, caseSensitive, provider, priority);
}
示例9: getPairsByElement
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@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;
}
示例10: addMatchingProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
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));
}
}
}
示例11: addAcceptableReferenceProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@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));
}
}
}
示例12: registerNamedReferenceProvider
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
private void registerNamedReferenceProvider(@Nonnull String[] names,
final PsiNamePatternCondition<?> nameCondition,
@Nonnull Class scopeClass,
final boolean caseSensitive,
@Nonnull PsiReferenceProvider provider,
final double priority,
@Nonnull ElementPattern pattern) {
NamedObjectProviderBinding<PsiReferenceProvider> providerBinding = myNamedBindingsMap.get(scopeClass);
if (providerBinding == null) {
providerBinding = ConcurrencyUtil.cacheOrGet(myNamedBindingsMap, scopeClass, new NamedObjectProviderBinding<PsiReferenceProvider>() {
@Override
protected String getName(final PsiElement position) {
return nameCondition.getPropertyValue(position);
}
});
}
providerBinding.registerProvider(names, pattern, caseSensitive, provider, priority);
}
示例13: getPairsByElement
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
@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;
}
示例14: addMatchingProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
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));
}
}
}
示例15: registerReferenceProviders
import com.intellij.psi.PsiReferenceProvider; //导入依赖的package包/类
public void registerReferenceProviders(PsiReferenceRegistrar registrar)
{
registrar.registerReferenceProvider(psiElement(XmlAttributeValue.class).withParent(xmlAttribute().withLocalName("name", "href", "mode", "elements", "exclude-result-prefixes",
"extension-element-prefixes", "stylesheet-prefix").withParent(xmlTag().withNamespace(XsltSupport.XSLT_NS))), new XsltReferenceProvider());
registrar.registerReferenceProvider(xmlAttributeValue().withValue(string().matches("[^()]+")).withParent(xmlAttribute("as").withParent(xmlTag().withNamespace(XsltSupport.XSLT_NS))),
SchemaTypeProvider.INSTANCE);
registrar.registerReferenceProvider(xmlAttributeValue().withParent(xmlAttribute("as").withParent(xmlTag().withNamespace(XsltSupport.XSLT_NS))).withValue(string().contains(":")),
new PsiReferenceProvider()
{
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context)
{
return new PsiReference[]{new NamespacePrefixReference(element)};
}
});
}