本文整理汇总了Java中com.intellij.spi.psi.SPIClassProviderReferenceElement类的典型用法代码示例。如果您正苦于以下问题:Java SPIClassProviderReferenceElement类的具体用法?Java SPIClassProviderReferenceElement怎么用?Java SPIClassProviderReferenceElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SPIClassProviderReferenceElement类属于com.intellij.spi.psi包,在下文中一共展示了SPIClassProviderReferenceElement类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.intellij.spi.psi.SPIClassProviderReferenceElement; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
final VirtualFile file = PsiUtilCore.getVirtualFile(element);
if (file != null && file.getFileType() instanceof SPIFileType) {
final String serviceProviderName = file.getName();
final PsiClass psiClass =
ClassUtil.findPsiClass(element.getManager(), serviceProviderName, null, true, element.getContainingFile().getResolveScope());
if (element instanceof PsiFile) {
if (psiClass == null) {
holder.createErrorAnnotation(element, "No service provider \"" + serviceProviderName + "\' found").setFileLevelAnnotation(true);
}
} else if (element instanceof SPIClassProviderReferenceElement) {
final PsiElement resolve = ((SPIClassProviderReferenceElement)element).resolve();
if (resolve == null) {
holder.createErrorAnnotation(element, "Cannot resolve symbol " + element.getText());
} else if (resolve instanceof PsiClass && psiClass != null) {
if (!((PsiClass)resolve).isInheritor(psiClass, true)) {
holder.createErrorAnnotation(element, "Registered extension should implement " + serviceProviderName);
}
}
}
}
}
示例2: annotate
import com.intellij.spi.psi.SPIClassProviderReferenceElement; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
final VirtualFile file = PsiUtilCore.getVirtualFile(element);
if (file != null) {
final String serviceProviderName = file.getName();
final PsiClass psiClass =
ClassUtil.findPsiClass(element.getManager(), serviceProviderName, null, true, element.getContainingFile().getResolveScope());
if (element instanceof SPIFile) {
if (psiClass == null) {
holder.createErrorAnnotation(element, "No service provider \"" + serviceProviderName + "\' found").setFileLevelAnnotation(true);
}
} else if (element instanceof SPIClassProviderReferenceElement) {
final PsiElement resolve = ((SPIClassProviderReferenceElement)element).resolve();
if (resolve == null) {
holder.createErrorAnnotation(element, "Cannot resolve symbol " + element.getText());
} else if (resolve instanceof PsiClass && psiClass != null) {
if (!((PsiClass)resolve).isInheritor(psiClass, true)) {
holder.createErrorAnnotation(element, "Registered extension should implement " + serviceProviderName);
}
}
}
}
}
示例3: getElement
import com.intellij.spi.psi.SPIClassProviderReferenceElement; //导入依赖的package包/类
@Override
protected PsiElement getElement(@NotNull PsiFile file, int offset) {
final SPIClassProviderReferenceElement
providerElement = PsiTreeUtil.getParentOfType(super.getElement(file, offset), SPIClassProviderReferenceElement.class);
if (providerElement != null) {
return providerElement.resolve();
}
return null;
}
示例4: createElement
import com.intellij.spi.psi.SPIClassProviderReferenceElement; //导入依赖的package包/类
@NotNull
@Override
public PsiElement createElement(ASTNode node) {
final IElementType elementType = node.getElementType();
if (elementType == SPIElementTypes.PROVIDERS_LIST) {
return new SPIClassProvidersElementList(node);
}
if (elementType == SPIElementTypes.PROVIDER) {
return new SPIClassProviderReferenceElement(node);
}
if (elementType == SPIElementTypes.PACK) {
return new SPIPackageOrClassReferenceElement(node);
}
return PsiUtilCore.NULL_PSI_ELEMENT;
}
示例5: getElement
import com.intellij.spi.psi.SPIClassProviderReferenceElement; //导入依赖的package包/类
@Override
protected PsiNameIdentifierOwner getElement(PsiFile file, int offset) {
final SPIClassProviderReferenceElement
providerElement = PsiTreeUtil.getParentOfType(file.findElementAt(offset), SPIClassProviderReferenceElement.class);
if (providerElement != null) {
return (PsiClass)providerElement.resolve();
}
return null;
}