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


Java TypeConversionUtil.isPrimitiveWrapper方法代码示例

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


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

示例1: applyUnboxedRelation

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
private boolean applyUnboxedRelation(DfaVariableValue dfaLeft, DfaValue dfaRight, boolean negated) {
  PsiType type = dfaLeft.getVariableType();
  if (!TypeConversionUtil.isPrimitiveWrapper(type)) {
    return true;
  }
  if (negated) {
    // from the fact "wrappers are not the same" it does not follow that "unboxed values are not equal"
    return true;
  }

  DfaBoxedValue.Factory boxedFactory = myFactory.getBoxedFactory();
  DfaValue unboxedLeft = boxedFactory.createUnboxed(dfaLeft);
  DfaValue unboxedRight = boxedFactory.createUnboxed(dfaRight);
  return applyRelation(unboxedLeft, unboxedRight, false) &&
         checkCompareWithBooleanLiteral(unboxedLeft, unboxedRight, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:DfaMemoryStateImpl.java

示例2: visitMethodCallExpression

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  if (!HardcodedMethodConstants.TO_STRING.equals(methodName)) {
    return;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 0) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  final String className = aClass.getQualifiedName();
  if (!TypeConversionUtil.isPrimitiveWrapper(className)) {
    return;
  }
  if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:NumericToStringInspection.java

示例3: indexStub

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void indexStub(@NotNull final PsiMethodStub stub, @NotNull final IndexSink sink) {
  final String name = stub.getName();
  if (name != null) {
    sink.occurrence(JavaStubIndexKeys.METHODS, name);
    if (RecordUtil.isStaticNonPrivateMember(stub)) {
      sink.occurrence(JavaStubIndexKeys.JVM_STATIC_MEMBERS_NAMES, name);
      sink.occurrence(JavaStubIndexKeys.JVM_STATIC_MEMBERS_TYPES, stub.getReturnTypeText(false).getShortTypeText());
    }
  }

  Set<String> methodTypeParams = null;
  for (StubElement stubElement : stub.getChildrenStubs()) {
    if (stubElement instanceof PsiTypeParameterListStub) {
      for (Object tStub : stubElement.getChildrenStubs()) {
        if (tStub instanceof PsiTypeParameterStub) {
          if (methodTypeParams == null) {
            methodTypeParams = new HashSet<String>();
          }
          methodTypeParams.add(((PsiTypeParameterStub)tStub).getName());
        }
      }
    }
    else if (stubElement instanceof PsiParameterListStub) {
      for (StubElement paramStub : ((PsiParameterListStub)stubElement).getChildrenStubs()) {
        if (paramStub instanceof PsiParameterStub) {
          TypeInfo type = ((PsiParameterStub)paramStub).getType(false);
          if (type.arrayCount > 0) continue;
          String typeName = type.getShortTypeText();
          if (TypeConversionUtil.isPrimitive(typeName) || TypeConversionUtil.isPrimitiveWrapper(typeName)) continue;
          sink.occurrence(JavaStubIndexKeys.METHOD_TYPES, typeName);
          if (methodTypeParams != null && methodTypeParams.contains(typeName)) {
            sink.occurrence(JavaStubIndexKeys.METHOD_TYPES, TYPE_PARAMETER_PSEUDO_NAME);
            methodTypeParams = null;
          }
        }
      }
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:JavaMethodElementType.java

示例4: buildVisitor

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new JavaElementVisitor() {
    @Override
    public void visitField(PsiField field) {
      analyzeCodeBlock(field, holder, isOnTheFly);
    }

    @Override
    public void visitMethod(PsiMethod method) {
      analyzeCodeBlock(method.getBody(), holder, isOnTheFly);
    }

    @Override
    public void visitClassInitializer(PsiClassInitializer initializer) {
      analyzeCodeBlock(initializer.getBody(), holder, isOnTheFly);
    }

    @Override
    public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
      super.visitMethodReferenceExpression(expression);
      final PsiElement resolve = expression.resolve();
      if (resolve instanceof PsiMethod) {
        final PsiType methodReturnType = ((PsiMethod)resolve).getReturnType();
        if (TypeConversionUtil.isPrimitiveWrapper(methodReturnType) && NullableNotNullManager.isNullable((PsiMethod)resolve)) {
          final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(expression);
          if (TypeConversionUtil.isPrimitiveAndNotNull(returnType)) {
            holder.registerProblem(expression, InspectionsBundle.message("dataflow.message.unboxing.method.reference"));
          }
        }
      }
    }

    @Override
    public void visitIfStatement(PsiIfStatement statement) {
      PsiExpression condition = statement.getCondition();
      if (BranchingInstruction.isBoolConst(condition)) {
        LocalQuickFix fix = createSimplifyBooleanExpressionFix(condition, condition.textMatches(PsiKeyword.TRUE));
        holder.registerProblem(condition, "Condition is always " + condition.getText(), fix);
      }
    }

  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:DataFlowInspectionBase.java

示例5: createReturnTypePanel

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Nullable
private JPanel createReturnTypePanel() {
  if (TypeConversionUtil.isPrimitiveWrapper(myReturnType) && myNullness == Nullness.NULLABLE) {
    return null;
  }
  final TypeSelectorManagerImpl manager = new TypeSelectorManagerImpl(myProject, myReturnType, findOccurrences(), areTypesDirected()) {
    @Override
    public PsiType[] getTypesForAll(boolean direct) {
      final PsiType[] types = super.getTypesForAll(direct);
      return !isVoidReturn() ? types : ArrayUtil.prepend(PsiType.VOID, types);
    }
  };
  mySelector = manager.getTypeSelector();
  final JComponent component = mySelector.getComponent();
  if (component instanceof JComboBox) {
    if (isVoidReturn()) {
      mySelector.selectType(PsiType.VOID);
    }
    final JPanel returnTypePanel = new JPanel(new BorderLayout(2, 0));
    final JLabel label = new JLabel(RefactoringBundle.message("changeSignature.return.type.prompt"));
    returnTypePanel.add(label, BorderLayout.NORTH);
    returnTypePanel.add(component, BorderLayout.SOUTH);
    DialogUtil.registerMnemonic(label, component);
    ((JComboBox)component).addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (myGenerateAnnotations != null) {
          final PsiType selectedType = mySelector.getSelectedType();
          final boolean enabled = PsiUtil.resolveClassInType(selectedType) != null;
          if (!enabled) {
            myGenerateAnnotations.setSelected(false);
          }
          myGenerateAnnotations.setEnabled(enabled);
        }
        updateSignature();
      }
    });
    return returnTypePanel;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:ExtractMethodDialog.java


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