本文整理汇总了Java中com.intellij.psi.PsiImportStatement类的典型用法代码示例。如果您正苦于以下问题:Java PsiImportStatement类的具体用法?Java PsiImportStatement怎么用?Java PsiImportStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiImportStatement类属于com.intellij.psi包,在下文中一共展示了PsiImportStatement类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: value
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
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 ];
}
示例2: isReferenceToAnnotation
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
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;
}
示例3: visitClass
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
@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);
}
}
}
示例4: visitImportStatement
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
@Override
public void visitImportStatement(PsiImportStatement statement) {
mVisitor.report("PsiImportStatement", statement.getText(), statement);
super.visitElement(statement);
}
示例5: CollidingClassImportUsageInfo
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
public CollidingClassImportUsageInfo(PsiImportStatement element, PsiElement referencedElement) {
super(element, referencedElement);
myImportStatement = element;
}
示例6: getImportStatement
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
public PsiImportStatement getImportStatement() {
return myImportStatement;
}
示例7: RemoveImportUsageInfo
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
public RemoveImportUsageInfo(PsiImportStatement importStatement) {
super(importStatement);
myImportStatement = importStatement;
}
示例8: ensureBoundModelIsValid
import com.intellij.psi.PsiImportStatement; //导入依赖的package包/类
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");
}
});
}
}
}