Java 类com.intellij.psi.PsiImportStaticStatement 实例源码

项目:intellij-ce-playground    文件:InlineStaticImportHandler.java   
@Override
public void inlineElement(Project project, Editor editor, PsiElement element) {
  final PsiImportStaticStatement staticStatement = PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class);
  final List<PsiJavaCodeReferenceElement> referenceElements =
    collectReferencesThrough(element.getContainingFile(), null, staticStatement);

  RefactoringEventData data = new RefactoringEventData();
  data.addElement(element);
  project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(REFACTORING_ID, data);


  new WriteCommandAction(project, REFACTORING_NAME){
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      replaceAllAndDeleteImport(referenceElements, null, staticStatement);
    }
  }.execute();
  project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(REFACTORING_ID, null);
}
项目:consulo-java    文件:ImportsHighlightUtil.java   
static HighlightInfo checkStaticOnDemandImportResolvesToClass(PsiImportStaticStatement statement)
{
    if(statement.isOnDemand() && statement.resolveTargetClass() == null)
    {
        PsiJavaCodeReferenceElement ref = statement.getImportReference();
        if(ref != null)
        {
            PsiElement resolve = ref.resolve();
            if(resolve != null)
            {
                return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ObjectUtils.notNull(ref.getReferenceNameElement(), ref)).descriptionAndTooltip("Class " + ref
                        .getCanonicalText() + " not found").create();
            }
        }
    }
    return null;
}
项目:consulo-java    文件:StaticImportInspection.java   
@NotNull
@Override
protected InspectionGadgetsFix[] buildFixes(Object... infos)
{
    final List<InspectionGadgetsFix> result = new SmartList<>();
    final PsiImportStaticStatement importStaticStatement = (PsiImportStaticStatement) infos[0];
    final SuppressForTestsScopeFix fix = SuppressForTestsScopeFix.build(this, importStaticStatement);
    ContainerUtil.addIfNotNull(result, fix);
    final PsiClass aClass = importStaticStatement.resolveTargetClass();
    if(aClass != null)
    {
        final String name = aClass.getQualifiedName();
        result.add(new IgnoreClassFix(name, allowedClasses, "Allow static imports for class '" + name + "'"));
    }
    result.add(buildFix(infos));
    return result.toArray(InspectionGadgetsFix.EMPTY_ARRAY);
}
项目:tools-idea    文件:InlineStaticImportHandler.java   
@Override
public void inlineElement(Project project, Editor editor, PsiElement element) {
  final PsiImportStaticStatement staticStatement = PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class);
  final List<PsiJavaCodeReferenceElement> referenceElements =
    collectReferencesThrough(element.getContainingFile(), null, staticStatement);
  new WriteCommandAction(project, REFACTORING_NAME){
    @Override
    protected void run(Result result) throws Throwable {
      replaceAllAndDeleteImport(referenceElements, null, staticStatement);
    }
  }.execute();
}
项目:consulo-java    文件:InlineStaticImportHandler.java   
@Override
public void inlineElement(Project project, Editor editor, PsiElement element) {
  final PsiImportStaticStatement staticStatement = PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class);
  final List<PsiJavaCodeReferenceElement> referenceElements =
    collectReferencesThrough(element.getContainingFile(), null, staticStatement);
  new WriteCommandAction(project, REFACTORING_NAME){
    @Override
    protected void run(Result result) throws Throwable {
      replaceAllAndDeleteImport(referenceElements, null, staticStatement);
    }
  }.execute();
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitImportStaticStatement(PsiImportStaticStatement statement) {
    mVisitor.report("PsiImportStaticStatement", statement.getText(), statement);
    super.visitElement(statement);
}
项目:intellij-ce-playground    文件:InlineStaticImportHandler.java   
@Override
public boolean canInlineElement(PsiElement element) {
  if (element.getContainingFile() == null) return false;
  return PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class) != null;
}
项目:intellij-ce-playground    文件:ReplaceStaticImportUsageInfo.java   
public ReplaceStaticImportUsageInfo(final PsiImportStaticStatement staticImportStatement, final PsiClass[] targetClass) {
  super(staticImportStatement);
  myStaticImportStatement = staticImportStatement;
  myTargetClasses = targetClass;
}
项目:tools-idea    文件:InlineStaticImportHandler.java   
@Override
public boolean canInlineElement(PsiElement element) {
  if (element.getContainingFile() == null) return false;
  return PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class) != null;
}
项目:tools-idea    文件:ReplaceStaticImportUsageInfo.java   
public ReplaceStaticImportUsageInfo(final PsiImportStaticStatement staticImportStatement, final PsiClass[] targetClass) {
  super(staticImportStatement);
  myStaticImportStatement = staticImportStatement;
  myTargetClasses = targetClass;
}
项目:consulo-java    文件:InlineStaticImportHandler.java   
@Override
public boolean canInlineElement(PsiElement element) {
  if (element.getContainingFile() == null) return false;
  return PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class) != null;
}
项目:consulo-java    文件:ReplaceStaticImportUsageInfo.java   
public ReplaceStaticImportUsageInfo(final PsiImportStaticStatement staticImportStatement, final PsiClass[] targetClass) {
  super(staticImportStatement);
  myStaticImportStatement = staticImportStatement;
  myTargetClasses = targetClass;
}