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


Java TypeKind.NULL属性代码示例

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


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

示例1: visitTypeVariable

@Override
public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) {
    Element e = t.asElement();
    if (e != null) {
        String name = e.getSimpleName().toString();
        if (!CAPTURED_WILDCARD.equals(name))
            return DEFAULT_VALUE.append(name);
    }
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getLowerBound();
    if (bound != null && bound.getKind() != TypeKind.NULL) {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    } else {
        bound = t.getUpperBound();
        if (bound != null && bound.getKind() != TypeKind.NULL) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.TYPEVAR)
                bound = ((TypeVariable)bound).getLowerBound();
            visit(bound, p);
        }
    }
    return DEFAULT_VALUE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SpringXMLConfigCompletionItem.java

示例2: resolveType

static TypeMirror resolveType(CompilationInfo info, TreePath path) {
    TypeMirror tm = info.getTrees().getTypeMirror(path);
    
    if (tm != null && tm.getKind() == TypeKind.NULL) {
        List<? extends TypeMirror> targetType = CreateElementUtilities.resolveType(new HashSet<ElementKind>(), info, path.getParentPath(), path.getLeaf(), (int) info.getTrees().getSourcePositions().getStartPosition(path.getCompilationUnit(), path.getLeaf()), new TypeMirror[1], new int[1]);
        
        if (targetType != null && !targetType.isEmpty()) {
            tm = targetType.get(0);
        } else {
            TypeElement object = info.getElements().getTypeElement("java.lang.Object");
            tm = object != null ? object.asType() : null;
        }
    }
    if (!Utilities.isValidType(tm)) {
        return null;
    } else {
        return tm;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:IntroduceHint.java

示例3: CreateEnumConstant

public CreateEnumConstant(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, TypeMirror proposedType, FileObject targetFile) {
    this.name = name;
    this.inFQN = target.getQualifiedName().toString();
    this.cpInfo = info.getClasspathInfo();
    this.targetFile = targetFile;
    this.target = ElementHandle.create(target);
    if (proposedType.getKind() == TypeKind.NULL) {
        TypeElement tel = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
        if (tel != null) {
            proposedType = tel.asType();
            this.proposedType = TypeMirrorHandle.create(proposedType);
        } else {
            this.proposedType = null;
        }
    } else {
        this.proposedType = TypeMirrorHandle.create(proposedType);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CreateEnumConstant.java

示例4: run

public List<Fix> run(CompilationInfo info, String diagnosticKey, int offset, TreePath treePath, Data<Void> data) {
    List<Fix> result = new ArrayList<Fix>();
    List<TypeMirror> targetType = new ArrayList<TypeMirror>();
    TreePath[] tmTree = new TreePath[1];
    ExpressionTree[] expression = new ExpressionTree[1];
    Tree[] leaf = new Tree[1];
    
    computeType(info, offset, targetType, tmTree, expression, leaf);
    
    if (!targetType.isEmpty()) {
        TreePath expressionPath = TreePath.getPath(info.getCompilationUnit(), expression[0]); //XXX: performance
        for (TypeMirror type : targetType) {
            if (type.getKind() != TypeKind.NULL) {
                result.add(new AddCastFix(info, expressionPath, tmTree[0], type).toEditorFix());
            }
        }
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AddCast.java

示例5: AddParameterOrLocalFix

public AddParameterOrLocalFix(CompilationInfo info,
                              TypeMirror type, String name,
                              ElementKind kind,
                              int /*!!!Position*/ unresolvedVariable) {
    this.file = info.getFileObject();
    if (type.getKind() == TypeKind.NULL || type.getKind() == TypeKind.NONE) {
        TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
        if (te != null) {
            type = te.asType();
            this.type = TypeMirrorHandle.create(type);
        } else {
            this.type = null;
        }
    } else {
        this.type = TypeMirrorHandle.create(type);
    }
    this.name = name;
    this.kind = kind;

    TreePath treePath = info.getTreeUtilities().pathFor(unresolvedVariable + 1);
    tpHandle = new TreePathHandle[1];
    tpHandle[0] = TreePathHandle.create(treePath, info);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AddParameterOrLocalFix.java

示例6: checkAmbiguous

/**
 * Checks whether a method or constructor call would become ambiguous if the parameter type changes.
 * 
 * @param info compilation context
 * @param parentExec path to the constructor or method invocation
 * @param argIndex
 * @param casteeType
 * @return 
 */
private static boolean checkAmbiguous(CompilationInfo info, final TreePath parentExec, int argIndex, TypeMirror casteeType, TreePath realArgTree) {
    CharSequence altType = info.getTypeUtilities().getTypeName(casteeType, TypeUtilities.TypeNameOptions.PRINT_FQN);
    String prefix = null;
    if (casteeType != null && !(casteeType.getKind() == TypeKind.NULL || casteeType.getKind() == TypeKind.INTERSECTION)) {
        prefix = "(" + altType + ")"; // NOI18N
    }
    Tree leaf = parentExec.getLeaf();
    List<? extends Tree> arguments;
    if (leaf instanceof MethodInvocationTree) {
        MethodInvocationTree mi = (MethodInvocationTree)leaf;
        arguments = mi.getArguments();
    } else {
        arguments = ((NewClassTree)leaf).getArguments();
    }
    Tree argTree = arguments.get(argIndex);
    TreePath argPath = new TreePath(parentExec, argTree);
    return !Utilities.checkAlternativeInvocation(info, parentExec, argPath, realArgTree, prefix);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TooStrongCast.java

示例7: visitTypeVariable

@Override
public Void visitTypeVariable(TypeVariable type, Void p) {
    Element e = type.asElement();
    if (e != null) {
        CharSequence name = e.getSimpleName();
        if (!CAPTURED_WILDCARD.contentEquals(name)) {
            builder.append(name);
            return null;
        }
    }
    builder.append("?"); //NOI18N
    TypeMirror bound = type.getLowerBound();
    if (bound != null && bound.getKind() != TypeKind.NULL) {
        builder.append(" super "); //NOI18N
        visit(bound);
    } else {
        bound = type.getUpperBound();
        if (bound != null && bound.getKind() != TypeKind.NULL) {
            builder.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.TYPEVAR)
                bound = ((TypeVariable)bound).getLowerBound();
            visit(bound);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AutoImport.java

示例8: getKind

public TypeKind getKind() {
    switch (tag) {
    case BYTE:      return TypeKind.BYTE;
    case CHAR:      return TypeKind.CHAR;
    case SHORT:     return TypeKind.SHORT;
    case INT:       return TypeKind.INT;
    case LONG:      return TypeKind.LONG;
    case FLOAT:     return TypeKind.FLOAT;
    case DOUBLE:    return TypeKind.DOUBLE;
    case BOOLEAN:   return TypeKind.BOOLEAN;
    case VOID:      return TypeKind.VOID;
    case BOT:       return TypeKind.NULL;
    case NONE:      return TypeKind.NONE;
    default:        return TypeKind.OTHER;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:16,代码来源:Type.java

示例9: visitTypeVariable

@Override
public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) {
    Element e = t.asElement();
    if (e != null) {
        String name = e.getSimpleName().toString();
        if (!CAPTURED_WILDCARD.equals(name)) {
            return DEFAULT_VALUE.append(name);
        }
    }
    DEFAULT_VALUE.append("?"); //NOI18N
    if (!insideCapturedWildcard) {
        insideCapturedWildcard = true;
        TypeMirror bound = t.getLowerBound();
        if (bound != null && bound.getKind() != TypeKind.NULL) {
            DEFAULT_VALUE.append(" super "); //NOI18N
            visit(bound, p);
        } else {
            bound = t.getUpperBound();
            if (bound != null && bound.getKind() != TypeKind.NULL) {
                DEFAULT_VALUE.append(" extends "); //NOI18N
                if (bound.getKind() == TypeKind.TYPEVAR) {
                    bound = ((TypeVariable)bound).getLowerBound();
                }
                visit(bound, p);
            }
        }
        insideCapturedWildcard = false;
    }
    return DEFAULT_VALUE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:JavaSymbolProvider.java

示例10: visitTypeVariable

@Override
public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) {
    Element e = t.asElement();
    if (e != null) {
        String name = e.getSimpleName().toString();
        if (!CAPTURED_WILDCARD.equals(name))
            return DEFAULT_VALUE.append(name);
    }
    DEFAULT_VALUE.append("?"); //NOI18N
    if (!insideCapturedWildcard) {
        insideCapturedWildcard = true;
        TypeMirror bound = t.getLowerBound();
        if (bound != null && bound.getKind() != TypeKind.NULL) {
            DEFAULT_VALUE.append(" super "); //NOI18N
            visit(bound, p);
        } else {
            bound = t.getUpperBound();
            if (bound != null && bound.getKind() != TypeKind.NULL) {
                DEFAULT_VALUE.append(" extends "); //NOI18N
                if (bound.getKind() == TypeKind.TYPEVAR)
                    bound = ((TypeVariable)bound).getLowerBound();
                visit(bound, p);
            }
        }
        insideCapturedWildcard = false;
    }
    return DEFAULT_VALUE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:TypeUtilities.java

示例11: purify

private TypeMirror purify(CompilationInfo info, TypeMirror targetType) {
    if (targetType != null && targetType.getKind() == TypeKind.ERROR) {
        targetType = info.getTrees().getOriginalType((ErrorType) targetType);
    }

    if (targetType == null || targetType.getKind() == /*XXX:*/TypeKind.ERROR || targetType.getKind() == TypeKind.NONE || targetType.getKind() == TypeKind.NULL) return null;

    return Utilities.resolveTypeForDeclaration(info, targetType);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ChangeMethodReturnType.java

示例12: CreateFieldFix

public CreateFieldFix(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, TypeMirror proposedType, FileObject targetFile) {
    this.name = name;
    this.inFQN = Utilities.target2String(target);
    this.cpInfo = info.getClasspathInfo();
    this.modifiers = modifiers;
    this.targetFile = targetFile;
    this.target = ElementHandle.create(target);
    if (proposedType.getKind() == TypeKind.NULL || proposedType.getKind() == TypeKind.NONE) {
        TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
        proposedType = te == null ? null : te.asType();
    }
    this.proposedType = proposedType == null ? null : TypeMirrorHandle.create(proposedType);
    this.remote = !org.openide.util.Utilities.compareObjects(info.getFileObject(), targetFile);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CreateFieldFix.java

示例13: purify

private TypeMirror purify(CompilationInfo info, TypeMirror targetType) {
    if (targetType != null && targetType.getKind() == TypeKind.ERROR) {
        targetType = info.getTrees().getOriginalType((ErrorType) targetType);
    }

    if (targetType == null || targetType.getKind() == /*XXX:*/TypeKind.ERROR || targetType.getKind() == TypeKind.NONE || targetType.getKind() == TypeKind.NULL) return null;

    return Utilities.resolveCapturedType(info, targetType);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ExpectedTypeResolver.java

示例14: printlnPrintStream

@TriggerPatterns({
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "java.lang.Object[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "int[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "short[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "byte[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "long[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "float[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "double[]", variable = "$v")
            }
    ),
    @TriggerPattern(
            value="$s.println($v)",
            constraints = {
                @ConstraintVariableType(type = "java.io.PrintStream", variable = "$s"),
                @ConstraintVariableType(type = "boolean[]", variable = "$v")
            }
    )
})
public static ErrorDescription printlnPrintStream(HintContext ctx) {
    TreePath arrayRef = ctx.getVariables().get("$v");
    TypeMirror m = ctx.getInfo().getTrees().getTypeMirror(arrayRef);
    if (!Utilities.isValidType(m) || m.getKind() == TypeKind.NULL) {
        return null;
    }
    return printPrintStream(ctx);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:ArrayStringConversions.java

示例15: needsErasure

private static boolean needsErasure(TypeMirror typeMirror) {
    return typeMirror.getKind() != TypeKind.NONE && typeMirror.getKind() != TypeKind.VOID && !typeMirror.getKind().isPrimitive() && typeMirror.getKind() != TypeKind.OTHER &&
                    typeMirror.getKind() != TypeKind.NULL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:MethodSubstitutionVerifier.java


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