本文整理汇总了Java中com.intellij.psi.PsiReferenceBase类的典型用法代码示例。如果您正苦于以下问题:Java PsiReferenceBase类的具体用法?Java PsiReferenceBase怎么用?Java PsiReferenceBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiReferenceBase类属于com.intellij.psi包,在下文中一共展示了PsiReferenceBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReferencesByElement
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
@NotNull MavenDomConfiguration domCfg,
@NotNull ProcessingContext context) {
return new PsiReference[] {
new PsiReferenceBase<PsiElement>(element, true) {
@Override
public PsiElement resolve() {
return null;
}
@NotNull
@Override
public Object[] getVariants() {
return MavenCompletionReferenceProvider.this.getVariants(this);
}
}
};
}
示例2: getReferencesByElement
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
return new PsiReference[]{
new PsiReferenceBase<PsiElement>(element, mySoft) {
@Nullable
@Override
public PsiElement resolve() {
return null;
}
@NotNull
@Override
public Object[] getVariants() {
return myValues;
}
}
};
}
示例3: getReferencesByElement
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
if (!isApplicable(psiElement)) {
return new PsiReference[]{};
}
PhpIndex phpIndex = PhpIndex.getInstance(psiElement.getProject());
Collection<PhpClass> phpClasses = phpIndex.getClassesByFQN(OuzoUtils.OUZO_MODEL_NAMESPACE + PsiUtils.getContent(psiElement));
PhpClass phpClass = Iterables.getLast(phpClasses, null);
if (phpClass == null) {
return new PsiReference[]{};
}
PsiReferenceBase.Immediate reference = new PsiReferenceBase.Immediate(psiElement, phpClass);
return new PsiReference[]{reference};
}
示例4: getReference
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@Override
@Nullable
public PsiReference getReference() {
final ASTNode foreachNode = findForeachNode();
if (foreachNode == null) {
return null;
}
return new PsiReferenceBase<PsiElement>(this) {
public PsiElement resolve() {
return foreachNode.getLastChildNode().getPsi();
}
public Object[] getVariants() {
return EMPTY_ARRAY;
}
};
}
示例5: testLinksInJavaDoc
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
public void testLinksInJavaDoc() {
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
@SuppressWarnings("SpellCheckingInspection") Set<String> expected = ContainerUtil.newHashSet(
"http://www.unicode.org/unicode/standard/standard.html",
"http://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html",
"https://youtrack.jetbrains.com/issue/IDEA-131621",
"mailto:[email protected]");
Set<String> actual = collectWebReferences().stream().map(PsiReferenceBase::getCanonicalText).collect(Collectors.toSet());
assertEquals(expected, actual);
}
示例6: collectWebReferences
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@NotNull
public static List<WebReference> collectWebReferences() {
final List<WebReference> refs = new ArrayList<>();
myFile.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
for (PsiReference ref : element.getReferences()) {
if (ref instanceof WebReference) refs.add((WebReference)ref);
}
super.visitElement(element);
}
});
assertTrue(refs.stream().allMatch(PsiReferenceBase::isSoft));
return refs;
}
示例7: getReference
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@Override
public PsiReference getReference() {
if (getParent() instanceof RncInclude) {
final TextRange range = TextRange.from(0, getNameNode().getTextLength());
return new PsiReferenceBase<RncDefine>(this, range, true) {
@Override
public PsiElement resolve() {
return RncDefineImpl.this;
}
@Override
@NotNull
public Object[] getVariants() {
final RncInclude parent = (RncInclude)getParent();
final RncFile referencedFile = parent.getReferencedFile();
if (referencedFile == null) {
return EMPTY_ARRAY;
}
final RncGrammar grammar = referencedFile.getGrammar();
if (grammar == null) {
return EMPTY_ARRAY;
}
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
if (map != null) {
return map.keySet().toArray();
}
return EMPTY_ARRAY;
}
};
}
return super.getReference();
}
示例8: getVariants
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@Override
protected Object[] getVariants(@NotNull PsiReferenceBase reference) {
Charset[] charsets = CharsetToolkit.getAvailableCharsets();
LookupElement[] res = new LookupElement[charsets.length];
for (int i = 0; i < charsets.length; i++) {
res[i] = LookupElementBuilder.create(charsets[i].name()).withCaseSensitivity(false);
}
return res;
}
示例9: globReference
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
private static PsiReference globReference(GlobExpression glob, PsiFileSystemItem file) {
return new PsiReferenceBase.Immediate<GlobExpression>(
glob, glob.getReferenceTextRange(), file) {
@Override
public PsiElement bindToElement(@NotNull PsiElement element)
throws IncorrectOperationException {
return glob;
}
};
}
示例10: getReference
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
public PsiReference getReference() {
if (getParent() instanceof RncInclude) {
final TextRange range = TextRange.from(0, getNameNode().getTextLength());
return new PsiReferenceBase<RncDefine>(this, range, true) {
public PsiElement resolve() {
return RncDefineImpl.this;
}
@NotNull
public Object[] getVariants() {
final RncInclude parent = (RncInclude)getParent();
final RncFile referencedFile = parent.getReferencedFile();
if (referencedFile == null) {
return EMPTY_ARRAY;
}
final RncGrammar grammar = referencedFile.getGrammar();
if (grammar == null) {
return EMPTY_ARRAY;
}
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
if (map != null) {
return map.keySet().toArray();
}
return EMPTY_ARRAY;
}
};
}
return super.getReference();
}
示例11: getReferencesByElement
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
if (!isApplicable(psiElement)) {
return new PsiReference[]{};
}
String controller = extractController(PsiUtils.getContent(psiElement));
String action = extractAction(PsiUtils.getContent(psiElement));
PsiReferenceBase.Immediate reference = new PsiReferenceBase.Immediate(psiElement, OuzoUtils.getControllerAction(psiElement.getProject(), controller, action));
return new PsiReference[]{reference};
}
示例12: getPsiReferenceBase
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
private PsiReference[] getPsiReferenceBase(PsiElement psiElement) {
try {
PsiReferenceBase referenceClassInstance = (PsiReferenceBase) this.referenceClass.getDeclaredConstructor(StringLiteralExpression.class).newInstance((StringLiteralExpression) psiElement);
return new PsiReference[]{ referenceClassInstance };
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException ignored) {
}
return new PsiReference[0];
}
示例13: testCustomReferenceProvider
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
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);
}
}
示例14: createReferences
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@Override
@NotNull
public PsiReference[] createReferences(GenericDomValue genericDomValue, PsiElement element, ConvertContext context) {
final GenericAttributeValue<String> e = (GenericAttributeValue<String>)genericDomValue;
if (genericDomValue.getParent() instanceof RngDefine) {
final XmlAttributeValue value = e.getXmlAttributeValue();
if (value == null) {
return PsiReference.EMPTY_ARRAY;
}
return new PsiReference[]{
new PsiReferenceBase<XmlAttributeValue>(value, true) {
@Override
public PsiElement resolve() {
// final XmlTag tag = PsiTreeUtil.getParentOfType(value, XmlTag.class);
// final XmlTag include = getAncestorTag(tag, "include", ProjectLoader.RNG_NAMESPACE);
// final XmlTag grammar = getAncestorTag(tag, "grammar", ProjectLoader.RNG_NAMESPACE);
//
// if (include != null && (grammar == null || PsiTreeUtil.isAncestor(grammar, include, true))) {
// final ResolveResult[] e = new DefinitionReference(getElement(), false).multiResolve(false);
// }
return myElement.getParent().getParent();
}
@Override
@NotNull
public Object[] getVariants() {
final RngInclude include = e.getParentOfType(RngInclude.class, true);
final RngGrammar scope = e.getParentOfType(RngGrammar.class, true);
if (scope != null && include != null && DomUtil.isAncestor(scope, include, true)) {
final XmlFile file = include.getIncludedFile().getValue();
if (file != null) {
final DomFileElement<DomElement> fileElement = scope.getManager().getFileElement(file, DomElement.class);
if (fileElement == null) {
return EMPTY_ARRAY;
}
final Ref<Object[]> ref = new Ref<Object[]>(ArrayUtil.EMPTY_STRING_ARRAY);
fileElement.acceptChildren(new RngDomVisitor(){
@Override
public void visit(RngGrammar grammar) {
final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(grammar);
if (map != null) {
ref.set(map.keySet().toArray());
}
}
});
return ref.get();
}
}
return ArrayUtil.EMPTY_STRING_ARRAY; // TODO: look for unresolved refs;
}
}
};
}
return new PsiReference[]{
new DefinitionReference(e)
};
}
示例15: getReference
import com.intellij.psi.PsiReferenceBase; //导入依赖的package包/类
@Override
public PsiReference getReference() {
final JSGraphQLEndpointNamedTypePsiElement self = this;
final PsiElement nameIdentifier = getNameIdentifier();
if(nameIdentifier != null) {
if(JSGraphQLScalars.SCALAR_TYPES.contains(nameIdentifier.getText())) {
return new PsiReferenceBase.Immediate<PsiElement>(this, TextRange.allOf(nameIdentifier.getText()), getFirstChild());
}
return new PsiReferenceBase<PsiElement>(this, TextRange.from(nameIdentifier.getTextOffset() - self.getTextOffset(), nameIdentifier.getTextLength())) {
@Nullable
@Override
public PsiElement resolve() {
final Collection<JSGraphQLEndpointNamedTypeDefinition> definitions = JSGraphQLEndpointPsiUtil.getKnownDefinitions(
self.getContainingFile(),
JSGraphQLEndpointNamedTypeDefinition.class,
false,
null
);
final JSGraphQLEndpointNamedTypeDefinition resolvedElement = definitions.stream()
.filter(d -> d.getNamedTypeDef() != null && d.getNamedTypeDef().getText().equals(nameIdentifier.getText()))
.findFirst().orElse(null);
if(resolvedElement != null) {
return resolvedElement.getNamedTypeDef();
}
return null;
}
@NotNull
@Override
public Object[] getVariants() {
return NO_VARIANTS;
}
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
return self.setName(newElementName);
}
};
}
return null;
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:42,代码来源:JSGraphQLEndpointNamedTypePsiElement.java