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


Java PsiVariable.getTypeElement方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiVariable.getTypeElement方法的典型用法代码示例。如果您正苦于以下问题:Java PsiVariable.getTypeElement方法的具体用法?Java PsiVariable.getTypeElement怎么用?Java PsiVariable.getTypeElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiVariable的用法示例。


在下文中一共展示了PsiVariable.getTypeElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitVariable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
  super.visitVariable(variable);
  final PsiType type = variable.getType();
  final PsiType componentType = type.getDeepComponentType();
  if (!(componentType instanceof PsiClassType)) {
    return;
  }
  final String className = ((PsiClassType)componentType).getClassName();
  @NonNls final String javaLangReflect = "java.lang.reflect.";
  if (!className.startsWith(javaLangReflect)) {
    return;
  }
  final PsiTypeElement typeElement = variable.getTypeElement();
  if (typeElement == null) {
    return;
  }
  registerError(typeElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaLangReflectInspection.java

示例2: satisfiedBy

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiVariable)) {
    return false;
  }
  if (ErrorUtil.containsError(element)) {
    return false;
  }
  final PsiVariable var = (PsiVariable)element;
  final PsiTypeElement typeElement = var.getTypeElement();
  if (typeElement == null) {
    return false; // Could be true for enum constants.
  }

  final PsiType elementType = typeElement.getType();
  final PsiType type = var.getType();
  return elementType.getArrayDimensions() != type.getArrayDimensions();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SimplifyVariablePredicate.java

示例3: visitVariable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable var) {
  super.visitVariable(var);
  final PsiType declaredType = var.getType();
  if (declaredType.getArrayDimensions() == 0) {
    return;
  }
  final PsiTypeElement typeElement = var.getTypeElement();
  if (typeElement == null) {
    return; // Could be true for enum constants.
  }
  final PsiType elementType = typeElement.getType();
  if (elementType.equals(declaredType)) {
    return;
  }
  registerVariableError(var);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:CStyleArrayDeclarationInspection.java

示例4: visitVariable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
  super.visitVariable(variable);
  final PsiType type = variable.getType();
  final String typeString = type.getCanonicalText();
  if (!"java.lang.ProcessBuilder".equals(typeString)) {
    return;
  }
  final PsiTypeElement typeElement = variable.getTypeElement();
  if (typeElement == null) {
    return;
  }
  registerError(typeElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UseOfProcessBuilderInspection.java

示例5: isAvailable

import com.intellij.psi.PsiVariable; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement)
{
	final PsiVariable myVariable = (PsiVariable) startElement;
	return myVariable.isValid() && myVariable.getTypeElement() != null && myVariable.getManager().isInProject(myVariable) && getReturnType() != null && getReturnType().isValid() &&
			!TypeConversionUtil.isNullType(getReturnType()) && !TypeConversionUtil.isVoidType(getReturnType());
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:8,代码来源:VariableTypeFix.java

示例6: ensureBoundModelIsValid

import com.intellij.psi.PsiVariable; //导入方法依赖的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");
        }
      });
    }
  }
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:63,代码来源:BoundModelValidInspection.java


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