本文整理了Java中com.sun.tools.javac.code.Types.isArray()
方法的一些代码示例,展示了Types.isArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.isArray()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:isArray
暂无
代码示例来源:origin: google/error-prone
@Override
public boolean apply(Type type, VisitorState state) {
return type != null && state.getTypes().isArray(type);
}
};
代码示例来源:origin: google/error-prone
@Override
public boolean matches(Tree t, VisitorState state) {
Type type = getType(t);
return type != null && state.getTypes().isArray(type);
}
};
代码示例来源:origin: google/error-prone
/**
* Given an {@link ExpressionTree} that represents an argument of array type, rewrites it to wrap
* it in a call to either {@link java.util.Arrays#hashCode} if it is single dimensional, or {@link
* java.util.Arrays#deepHashCode} if it is multidimensional.
*/
private static String rewriteArrayArgument(ExpressionTree arg, VisitorState state) {
Types types = state.getTypes();
Type argType = ASTHelpers.getType(arg);
Preconditions.checkState(types.isArray(argType), "arg must be of array type");
if (types.isArray(types.elemtype(argType))) {
return "Arrays.deepHashCode(" + state.getSourceForNode(arg) + ")";
} else {
return "Arrays.hashCode(" + state.getSourceForNode(arg) + ")";
}
}
}
代码示例来源:origin: google/error-prone
@Override
public boolean matches(Tree t, VisitorState state) {
Type type = getType(t);
return type != null
&& state.getTypes().isArray(type)
&& state.getTypes().elemtype(type).isPrimitive();
}
};
代码示例来源:origin: google/error-prone
if (types.isArray(getType(arg))) {
return NO_MATCH;
boolean trueIsArray = types.isArray(getType(cond.getTrueExpression()));
if (!(trueIsArray ^ types.isArray(getType(cond.getFalseExpression())))) {
return NO_MATCH;
代码示例来源:origin: google/error-prone
if (elemType.isPrimitive() || types.isArray(elemType)) {
fix = SuggestedFix.builder().replace(tree, rewriteArrayArgument(arg, state));
if (types.isArray(ASTHelpers.getType(arg))) {
fix.replace(arg, rewriteArrayArgument(arg, state));
代码示例来源:origin: google/error-prone
if (!types.isArray(varargsArgumentType)
|| !types.elemtype(varargsArgumentType).isPrimitive()) {
return false;
代码示例来源:origin: com.google.errorprone/error_prone_check_api
@Override
public boolean apply(Type type, VisitorState state) {
return type != null && state.getTypes().isArray(type);
}
};
代码示例来源:origin: com.google.errorprone/error_prone_core
/**
* Given an {@link ExpressionTree} that represents an argument of array type, rewrites it to wrap
* it in a call to either {@link java.util.Arrays#hashCode} if it is single dimensional, or {@link
* java.util.Arrays#deepHashCode} if it is multidimensional.
*/
private static String rewriteArrayArgument(ExpressionTree arg, Types types) {
Type argType = ASTHelpers.getType(arg);
Preconditions.checkState(types.isArray(argType), "arg must be of array type");
if (types.isArray(types.elemtype(argType))) {
return "Arrays.deepHashCode(" + arg + ")";
} else {
return "Arrays.hashCode(" + arg + ")";
}
}
}
代码示例来源:origin: cincheo/jsweet
} else {
if ("<init>".equals(memberReference.name.toString())) {
if (context.types.isArray(memberReference.expr.type)) {
print("new Array<");
substituteAndPrintType(((JCArrayTypeTree) memberReference.expr).elemtype);
代码示例来源:origin: com.google.errorprone/error_prone_check_api
@Override
public boolean matches(Tree t, VisitorState state) {
Type type = getType(t);
return type != null && state.getTypes().isArray(type);
}
};
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.lowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.lowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: sc.fiji/javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.lowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: konsoletyper/teavm-javac
void validateAnnotationType(DiagnosticPosition pos, Type type) {
if (type.isPrimitive()) return;
if (types.isSameType(type, syms.stringType)) return;
if ((type.tsym.flags() & Flags.ENUM) != 0) return;
if ((type.tsym.flags() & Flags.ANNOTATION) != 0) return;
if (types.cvarLowerBound(type).tsym == syms.classType.tsym) return;
if (types.isArray(type) && !types.isArray(types.elemtype(type))) {
validateAnnotationType(pos, types.elemtype(type));
return;
}
log.error(pos, "invalid.annotation.member.type");
}
代码示例来源:origin: com.google.errorprone/error_prone_check_api
@Override
public boolean matches(Tree t, VisitorState state) {
Type type = getType(t);
return type != null
&& state.getTypes().isArray(type)
&& state.getTypes().elemtype(type).isPrimitive();
}
};
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
public void visitIndexed(JCArrayAccess tree) {
Type owntype = syms.errType;
Type atype = attribExpr(tree.indexed, env);
attribExpr(tree.index, env, syms.intType);
if (types.isArray(atype))
owntype = types.elemtype(atype);
else if (atype.tag != ERROR)
log.error(tree.pos(), "array.req.but.found", atype);
if ((pkind & VAR) == 0) owntype = capture(owntype);
result = check(tree, owntype, VAR, pkind, pt);
}
代码示例来源:origin: sc.fiji/javac
public void visitIndexed(JCArrayAccess tree) {
Type owntype = syms.errType;
Type atype = attribExpr(tree.indexed, env);
attribExpr(tree.index, env, syms.intType);
if (types.isArray(atype))
owntype = types.elemtype(atype);
else if (atype.tag != ERROR)
log.error(tree.pos(), "array.req.but.found", atype);
if ((pkind & VAR) == 0) owntype = capture(owntype);
result = check(tree, owntype, VAR, pkind, pt);
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public void visitIndexed(JCArrayAccess tree) {
Type owntype = types.createErrorType(tree.type);
Type atype = attribExpr(tree.indexed, env);
attribExpr(tree.index, env, syms.intType);
if (types.isArray(atype))
owntype = types.elemtype(atype);
else if (!atype.hasTag(ERROR))
log.error(tree.pos(), "array.req.but.found", atype);
if ((pkind() & VAR) == 0) owntype = capture(owntype);
result = check(tree, owntype, VAR, resultInfo);
}
代码示例来源:origin: konsoletyper/teavm-javac
public void visitIndexed(JCArrayAccess tree) {
Type owntype = types.createErrorType(tree.type);
Type atype = attribExpr(tree.indexed, env);
attribExpr(tree.index, env, syms.intType);
if (types.isArray(atype))
owntype = types.elemtype(atype);
else if (!atype.hasTag(ERROR))
log.error(tree.pos(), "array.req.but.found", atype);
if ((pkind() & VAR) == 0) owntype = capture(owntype);
result = check(tree, owntype, VAR, resultInfo);
}
内容来源于网络,如有侵权,请联系作者删除!