当前位置: 首页>>代码示例>>Java>>正文


Java SPIClassProviderReferenceElement类代码示例

本文整理汇总了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);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SPIAnnotator.java

示例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);
        }
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:SPIAnnotator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:SPIGotoSuperHandler.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:SPIParserDefinition.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:SPIGotoSuperHandler.java


注:本文中的com.intellij.spi.psi.SPIClassProviderReferenceElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。