mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Introduce extendable comment reference provider type
This commit is contained in:
+12
-2
@@ -19,11 +19,21 @@ import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiReferenceContributor;
|
||||
import com.intellij.psi.PsiReferenceRegistrar;
|
||||
import com.intellij.psi.ReferenceProviderType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ArbitraryPlaceUrlReferenceContributor extends PsiReferenceContributor {
|
||||
public class CommentsReferenceContributor extends PsiReferenceContributor {
|
||||
/**
|
||||
* Use this provider type if your element is not PsiComment but you want to fill it
|
||||
* with the same references as PsiCommit (e.g. it's used for PsiDocToken).
|
||||
*
|
||||
* Also you can register your own reference provider as 'comment reference provider' and it will be
|
||||
* applied to all PsiComment and other elements that uses this provider type for retrieving references.
|
||||
*/
|
||||
public static final ReferenceProviderType COMMENTS_REFERENCE_PROVIDER_TYPE = new ReferenceProviderType("commentsReferenceProvider");
|
||||
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiComment.class), ArbitraryPlaceUrlReferenceProvider.INSTANCE);
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiComment.class), COMMENTS_REFERENCE_PROVIDER_TYPE.getProvider());
|
||||
}
|
||||
}
|
||||
@@ -767,7 +767,9 @@
|
||||
<psi.fileReferenceHelper implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.JarFileReferenceHelper"/>
|
||||
<psi.fileReferenceHelper implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.HttpFileReferenceHelper"/>
|
||||
<psi.fileReferenceHelper implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.NullFileReferenceHelper" order="last"/>
|
||||
<psi.referenceContributor implementation="com.intellij.psi.impl.source.resolve.reference.ArbitraryPlaceUrlReferenceContributor"/>
|
||||
<psi.referenceContributor implementation="com.intellij.psi.impl.source.resolve.reference.CommentsReferenceContributor"/>
|
||||
<referenceProviderType key="commentsReferenceProvider"
|
||||
implementationClass="com.intellij.psi.impl.source.resolve.reference.ArbitraryPlaceUrlReferenceProvider"/>
|
||||
|
||||
<projectConfigurable groupId="editor"
|
||||
groupWeight="140"
|
||||
|
||||
+3
-2
@@ -21,7 +21,7 @@ import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.psi.filters.position.FilterPattern;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ArbitraryPlaceUrlReferenceProvider;
|
||||
import com.intellij.psi.impl.source.resolve.reference.CommentsReferenceContributor;
|
||||
import com.intellij.psi.javadoc.PsiDocToken;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -54,6 +54,7 @@ public class JavaReferenceContributor extends PsiReferenceContributor{
|
||||
return true;
|
||||
}
|
||||
})), filePathReferenceProvider);
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiDocToken.class), ArbitraryPlaceUrlReferenceProvider.INSTANCE);
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiDocToken.class),
|
||||
CommentsReferenceContributor.COMMENTS_REFERENCE_PROVIDER_TYPE.getProvider());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class XmlReferenceContributor extends PsiReferenceContributor {
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlAttlistDecl.class), dtdReferencesProvider);
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementContentSpec.class), dtdReferencesProvider);
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlToken.class), dtdReferencesProvider);
|
||||
registrar.registerReferenceProvider(xmlAttributeValue(), ArbitraryPlaceUrlReferenceProvider.INSTANCE, PsiReferenceRegistrar.LOWER_PRIORITY);
|
||||
registrar.registerReferenceProvider(xmlAttributeValue(), new ArbitraryPlaceUrlReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
|
||||
|
||||
|
||||
URIReferenceProvider uriProvider = new URIReferenceProvider();
|
||||
|
||||
Reference in New Issue
Block a user