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

项目:polygene-java    文件:PolygeneFacetType.java   
public final boolean value( PsiFile psiFile )
{
    final boolean[] hasPolygeneImportPackage = new boolean[]{ false };

    psiFile.accept( new JavaElementVisitor()
    {
        @Override
        public final void visitImportStatement( PsiImportStatement statement )
        {
            String packageName = statement.getQualifiedName();
            if( packageName != null && packageName.startsWith( "org.apache.polygene" ) )
            {
                hasPolygeneImportPackage[ 0 ] = true;
            }
        }

        @Override
        public void visitReferenceExpression( PsiReferenceExpression expression )
        {
            // Ignore
        }
    } );
    return hasPolygeneImportPackage[ 0 ];
}
项目:consulo-java    文件:OrderEntryFix.java   
private static ThreeState isReferenceToAnnotation(final PsiElement psiElement)
{
    if(psiElement.getLanguage() == JavaLanguage.INSTANCE && !PsiUtil.isLanguageLevel5OrHigher(psiElement))
    {
        return ThreeState.NO;
    }
    if(PsiTreeUtil.getParentOfType(psiElement, PsiAnnotation.class) != null)
    {
        return ThreeState.YES;
    }
    if(PsiTreeUtil.getParentOfType(psiElement, PsiImportStatement.class) != null)
    {
        return ThreeState.UNSURE;
    }
    return ThreeState.NO;
}
项目:tools-idea    文件:SingleClassImportInspection.java   
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  if (!(aClass.getParent() instanceof PsiJavaFile)) {
    return;
  }
  if (FileTypeUtils.isInJsp(aClass.getContainingFile())) {
    return;
  }
  final PsiJavaFile file = (PsiJavaFile)aClass.getParent();
  if (file == null) {
    return;
  }
  if (!file.getClasses()[0].equals(aClass)) {
    return;
  }
  final PsiImportList importList = file.getImportList();
  if (importList == null) {
    return;
  }
  final PsiImportStatement[] importStatements =
    importList.getImportStatements();
  for (final PsiImportStatement importStatement : importStatements) {
    if (!importStatement.isOnDemand()) {
      registerError(importStatement);
    }
  }
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitImportStatement(PsiImportStatement statement) {
    mVisitor.report("PsiImportStatement", statement.getText(), statement);
    super.visitElement(statement);
}
项目:intellij-ce-playground    文件:CollidingClassImportUsageInfo.java   
public CollidingClassImportUsageInfo(PsiImportStatement element, PsiElement referencedElement) {
  super(element, referencedElement);
  myImportStatement = element;
}
项目:intellij-ce-playground    文件:CollidingClassImportUsageInfo.java   
public PsiImportStatement getImportStatement() {
  return myImportStatement;
}
项目:intellij-ce-playground    文件:RemoveImportUsageInfo.java   
public RemoveImportUsageInfo(PsiImportStatement importStatement) {
  super(importStatement);
  myImportStatement = importStatement;
}
项目:tools-idea    文件:CollidingClassImportUsageInfo.java   
public CollidingClassImportUsageInfo(PsiImportStatement element, PsiElement referencedElement) {
  super(element, referencedElement);
  myImportStatement = element;
}
项目:tools-idea    文件:CollidingClassImportUsageInfo.java   
public PsiImportStatement getImportStatement() {
  return myImportStatement;
}
项目:tools-idea    文件:RemoveImportUsageInfo.java   
public RemoveImportUsageInfo(PsiImportStatement importStatement) {
  super(importStatement);
  myImportStatement = importStatement;
}
项目:errai-intellij-idea-plugin    文件:BoundModelValidInspection.java   
private static void ensureBoundModelIsValid(ProblemsHolder holder, PsiAnnotation annotation) {
  final BoundMetaData boundMetaData = DataBindUtil.getBoundMetaData(annotation);

  if (!boundMetaData.getBindingMetaData().isValidBindableModel()) {
    final PsiClass boundClass = boundMetaData.getBindingMetaData().getBoundClass();
    if (boundClass != null) {
      final PsiVariable var = (PsiVariable) Util.getImmediateOwnerElement(annotation);
      if (var == null) {
        return;
      }
      final PsiTypeElement typeElement = var.getTypeElement();
      if (typeElement == null) {
        return;
      }
      holder.registerProblem(typeElement, "The model type (" + boundClass.getQualifiedName() + ") is not bindable.");
    }
    else {
      final Collection<AnnotationSearchResult> autoBoundAnnotations
          = boundMetaData.getBindingMetaData().getModelAnnotations();

      if (autoBoundAnnotations.size() > 1) {
        holder.registerProblem(annotation, "Multiple model binding annotations found");
      }
    }
  }
  else {
    final PsiElement element = Util.getMethodOrField(annotation);

    if (!Util.elementIsAnnotated(element, Types.JAVAX_INJECT)) {
      holder.registerProblem(annotation, "Model specifier is not injected", new LocalQuickFix() {
        @NotNull
        @Override
        public String getName() {
          return "Add @Inject to class member";
        }

        @NotNull
        @Override
        public String getFamilyName() {
          return GroupNames.BUGS_GROUP_NAME;
        }

        @Override
        public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
          final JavaPsiFacade instance = JavaPsiFacade.getInstance(project);
          final PsiElementFactory elementFactory = instance.getElementFactory();

          final PsiImportStatement importJavaxInject = instance.getElementFactory()
              .createImportStatement(
                  instance.findClass(Types.JAVAX_INJECT,
                      ProjectScope.getAllScope(project))
              );

          final PsiImportList importList = ((PsiJavaFile) PsiUtil.getTopLevelClass(element).getParent()).getImportList();
          importList.add(importJavaxInject);

          ((PsiModifierListOwner) element).getModifierList().addAnnotation("Inject");
        }
      });
    }
  }
}
项目:consulo-java    文件:CollidingClassImportUsageInfo.java   
public CollidingClassImportUsageInfo(PsiImportStatement element, PsiElement referencedElement) {
  super(element, referencedElement);
  myImportStatement = element;
}
项目:consulo-java    文件:CollidingClassImportUsageInfo.java   
public PsiImportStatement getImportStatement() {
  return myImportStatement;
}
项目:consulo-java    文件:RemoveImportUsageInfo.java   
public RemoveImportUsageInfo(PsiImportStatement importStatement) {
  super(importStatement);
  myImportStatement = importStatement;
}