本文整理汇总了Java中com.intellij.psi.PsiPrimitiveType类的典型用法代码示例。如果您正苦于以下问题:Java PsiPrimitiveType类的具体用法?Java PsiPrimitiveType怎么用?Java PsiPrimitiveType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiPrimitiveType类属于com.intellij.psi包,在下文中一共展示了PsiPrimitiveType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withInstanceofValue
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@Nullable
public DfaVariableState withInstanceofValue(DfaTypeValue dfaType) {
if (dfaType.getDfaType().getPsiType() instanceof PsiPrimitiveType) return this;
if (checkInstanceofValue(dfaType.getDfaType())) {
DfaVariableState result = dfaType.isNullable() ? withNullability(Nullness.NULLABLE) : this;
List<DfaPsiType> moreGeneric = ContainerUtil.newArrayList();
for (DfaPsiType alreadyInstanceof : myInstanceofValues) {
if (dfaType.getDfaType().isAssignableFrom(alreadyInstanceof)) {
return result;
}
if (alreadyInstanceof.isAssignableFrom(dfaType.getDfaType())) {
moreGeneric.add(alreadyInstanceof);
}
}
HashSet<DfaPsiType> newInstanceof = ContainerUtil.newHashSet(myInstanceofValues);
newInstanceof.removeAll(moreGeneric);
newInstanceof.add(dfaType.getDfaType());
result = createCopy(newInstanceof, myNotInstanceofValues, result.myNullability);
return result;
}
return null;
}
示例2: matchParameters
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
private static MatchResult matchParameters(final PsiMethod method, final ChainCompletionContext context, final Set<String> additionalExcludedNames) {
int matched = 0;
int unMatched = 0;
boolean hasTarget = false;
for (final PsiParameter parameter : method.getParameterList().getParameters()) {
final PsiType type = parameter.getType();
final String canonicalText = type.getCanonicalText();
if (context.contains(canonicalText) || type instanceof PsiPrimitiveType) {
matched++;
}
else {
unMatched++;
}
if (context.getTarget().getClassQName().equals(canonicalText) || additionalExcludedNames.contains(canonicalText)) {
hasTarget = true;
}
}
return new MatchResult(matched, unMatched, hasTarget);
}
示例3: visitArrayInitializerExpression
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@Override
public void visitArrayInitializerExpression(
PsiArrayInitializerExpression expression) {
super.visitArrayInitializerExpression(expression);
final PsiType type = expression.getType();
if (type == null) {
return;
}
final PsiType componentType = type.getDeepComponentType();
if (!(componentType instanceof PsiPrimitiveType)) {
return;
}
final int numElements = calculateNumElements(expression);
if (numElements <= m_limit) {
return;
}
registerError(expression, Integer.valueOf(numElements));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:OverlyLargePrimitiveArrayInitializerInspection.java
示例4: getTypeString
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@NotNull
public static String getTypeString(@NotNull ExtractMethodInfoHelper helper, boolean forPresentation, @NotNull String modifier) {
if (!helper.specifyType()) {
return modifier.isEmpty() ? "def " : "";
}
PsiType type = helper.getOutputType();
final PsiPrimitiveType unboxed = PsiPrimitiveType.getUnboxedType(type);
if (unboxed != null) type = unboxed;
final String returnType = StringUtil.notNullize(forPresentation ? type.getPresentableText() : type.getCanonicalText());
if (StringUtil.isEmptyOrSpaces(returnType) || "null".equals(returnType)) {
return modifier.isEmpty() ? "def " : "";
}
else {
return returnType + " ";
}
}
示例5: isValidArrayOrPrimitiveType
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
/**
* Returns false if <code>type</code> is a multiple levels of collections or arrays. Returns true
* otherwise.
*
* @param type The PsiType been validated.
* @param project The project that has the PsiElement associated with <code>type</code>.
*/
public boolean isValidArrayOrPrimitiveType(PsiType type, Project project) {
if (type instanceof PsiArrayType) {
PsiArrayType arrayType = (PsiArrayType) type;
if (arrayType.getComponentType() instanceof PsiPrimitiveType) {
return true;
} else {
return isValidInnerArrayType(arrayType.getComponentType(), project);
}
}
// Check if type is a Collection
PsiClassType collectionType =
JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection");
if (collectionType.isAssignableFrom(type)) {
assert (type instanceof PsiClassType);
PsiClassType classType = (PsiClassType) type;
PsiType[] typeParams = classType.getParameters();
assert (typeParams.length > 0);
return isValidInnerArrayType(typeParams[0], project);
}
return true;
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:31,代码来源:MethodParameterTypeInspection.java
示例6: annotate
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
public void annotate(final PsiElement element, final AnnotationHolder holder) {
if (!VtlReferenceContributor.VTLVARIABLE_COMMENT.accepts(element)) {
return;
}
final String text = element.getText();
final String[] nameAndType = VtlFile.findVariableNameAndTypeAndScopeFilePath(text);
if (nameAndType == null) {
return;
}
final VtlImplicitVariable variable = ((VtlFile) element.getContainingFile()).findImplicitVariable(nameAndType[0]);
if (variable == null || variable.getPsiType() instanceof PsiPrimitiveType) {
return;
}
for (PsiReference javaRef : VtlReferenceContributor.getReferencesToJavaTypes(element)) {
if(javaRef.resolve() == null) {
TextRange range = javaRef.getRangeInElement().shiftRight(element.getTextRange().getStartOffset());
holder.createErrorAnnotation(range, VelocityBundle.message("invalid.java.type"));
}
}
}
示例7: postProcessContracts
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@NotNull
private static List<StandardMethodContract> postProcessContracts(@NotNull PsiMethodImpl method, MethodData data, List<PreContract> rawContracts)
{
List<StandardMethodContract> contracts = ContainerUtil.concat(rawContracts, c -> c.toContracts(method, data.methodBody(method)));
if(contracts.isEmpty())
{
return Collections.emptyList();
}
final PsiType returnType = method.getReturnType();
if(returnType != null && !(returnType instanceof PsiPrimitiveType))
{
contracts = boxReturnValues(contracts);
}
List<StandardMethodContract> compatible = ContainerUtil.filter(contracts, contract -> isContractCompatibleWithMethod(method, returnType, contract));
if(compatible.size() > MAX_CONTRACT_COUNT)
{
LOG.debug("Too many contracts for " + PsiUtil.getMemberQualifiedName(method) + ", shrinking the list");
return compatible.subList(0, MAX_CONTRACT_COUNT);
}
return compatible;
}
示例8: inferNullity
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
public static Nullness inferNullity(PsiMethodImpl method)
{
if(!InferenceFromSourceUtil.shouldInferFromSource(method))
{
return Nullness.UNKNOWN;
}
PsiType type = method.getReturnType();
if(type == null || type instanceof PsiPrimitiveType)
{
return Nullness.UNKNOWN;
}
return CachedValuesManager.getCachedValue(method, () ->
{
MethodData data = ContractInferenceIndexKt.getIndexedData(method);
NullityInferenceResult result = data == null ? null : data.getNullity();
Nullness nullness = result == null ? null : RecursionManager.doPreventingRecursion(method, true, () -> result.getNullness(method, data.methodBody(method)));
if(nullness == null)
{
nullness = Nullness.UNKNOWN;
}
return CachedValueProvider.Result.create(nullness, method, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
});
}
示例9: isReturnTypeCompatible
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
static boolean isReturnTypeCompatible(@Nullable PsiType returnType, @NotNull MethodContract.ValueConstraint returnValue)
{
if(returnValue == MethodContract.ValueConstraint.ANY_VALUE || returnValue == MethodContract.ValueConstraint.THROW_EXCEPTION)
{
return true;
}
if(PsiType.VOID.equals(returnType))
{
return false;
}
if(PsiType.BOOLEAN.equals(returnType))
{
return returnValue == MethodContract.ValueConstraint.TRUE_VALUE || returnValue == MethodContract.ValueConstraint.FALSE_VALUE;
}
if(!(returnType instanceof PsiPrimitiveType))
{
return returnValue == MethodContract.ValueConstraint.NULL_VALUE || returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE;
}
return false;
}
示例10: isAvailable
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement)
{
if(!super.isAvailable(project, file, startElement, endElement))
{
return false;
}
PsiModifierListOwner owner = getContainer(file, startElement.getTextRange().getStartOffset());
if(owner == null || AnnotationUtil.isAnnotated(owner, getAnnotationsToRemove()[0], false, false))
{
return false;
}
if(owner instanceof PsiMethod)
{
PsiType returnType = ((PsiMethod) owner).getReturnType();
return returnType != null && !(returnType instanceof PsiPrimitiveType);
}
return true;
}
示例11: getTypeShortName
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@Nullable
private static String getTypeShortName(@NotNull final PsiType type)
{
if(type instanceof PsiPrimitiveType)
{
return ((PsiPrimitiveType) type).getBoxedTypeName();
}
if(type instanceof PsiClassType)
{
return ((PsiClassType) type).getClassName();
}
if(type instanceof PsiArrayType)
{
return getTypeShortName(((PsiArrayType) type).getComponentType()) + "[]";
}
return null;
}
示例12: getNextStep
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@Override
protected int getNextStep(int step)
{
if(step + 1 == getNonNullStepCode())
{
if(templateDependsOnFieldsNullability())
{
for(MemberInfo classField : myClassFields)
{
if(classField.isChecked())
{
PsiField field = (PsiField) classField.getMember();
if(!(field.getType() instanceof PsiPrimitiveType))
{
return getNonNullStepCode();
}
}
}
}
return step;
}
return super.getNextStep(step);
}
示例13: isSubtypeable
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
public static boolean isSubtypeable(PsiExpression expr)
{
final PsiType type = expr.getType();
if(type instanceof PsiPrimitiveType)
{
return false;
}
if(type instanceof PsiClassType)
{
final PsiClass psiClass = ((PsiClassType) type).resolve();
if(psiClass != null && psiClass.hasModifierProperty(PsiModifier.FINAL))
{
return false;
}
}
return true;
}
示例14: getValueForType
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
private String getValueForType( PsiType type )
{
if( type instanceof PsiPrimitiveType )
{
if( type.getCanonicalText().equals( "boolean" ) )
{
return "false";
}
return "0";
}
return "null";
}
示例15: renderElement
import com.intellij.psi.PsiPrimitiveType; //导入依赖的package包/类
@Override
public void renderElement(LookupElementPresentation presentation) {
final PsiClass psiClass = getPsiClass();
if (psiClass != null) {
presentation.setIcon(presentation.isReal() ? psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY) : EMPTY_ICON);
presentation.setTailText(" (" + PsiFormatUtil.getPackageDisplayName(psiClass) + ")", true);
}
final PsiType type = getPsiType();
presentation.setItemText(type.getPresentableText());
presentation.setItemTextBold(type instanceof PsiPrimitiveType);
}