本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeBinding.dimensions方法的典型用法代码示例。如果您正苦于以下问题:Java TypeBinding.dimensions方法的具体用法?Java TypeBinding.dimensions怎么用?Java TypeBinding.dimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeBinding
的用法示例。
在下文中一共展示了TypeBinding.dimensions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typeBindingToSignature
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
private static String typeBindingToSignature(TypeBinding binding) {
binding = binding.erasure();
if (binding != null && binding.isBaseType()) {
return new String (binding.sourceName());
} else if (binding instanceof ReferenceBinding) {
String pkg = binding.qualifiedPackageName() == null ? "" : new String(binding.qualifiedPackageName());
String qsn = binding.qualifiedSourceName() == null ? "" : new String(binding.qualifiedSourceName());
return pkg.isEmpty() ? qsn : (pkg + "." + qsn);
} else if (binding instanceof ArrayBinding) {
StringBuilder out = new StringBuilder();
out.append(typeBindingToSignature(binding.leafComponentType()));
for (int i = 0; i < binding.dimensions(); i++) out.append("[]");
return out.toString();
}
return "";
}
示例2: illegalInstanceOfGenericType
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
TypeBinding erasedType = checkedType.leafComponentType().erasure();
StringBuffer recommendedFormBuffer = new StringBuffer(10);
if (erasedType instanceof ReferenceBinding) {
ReferenceBinding referenceBinding = (ReferenceBinding) erasedType;
recommendedFormBuffer.append(referenceBinding.qualifiedSourceName());
} else {
recommendedFormBuffer.append(erasedType.sourceName());
}
int count = erasedType.typeVariables().length;
if (count > 0) {
recommendedFormBuffer.append('<');
for (int i = 0; i < count; i++) {
if (i > 0) {
recommendedFormBuffer.append(',');
}
recommendedFormBuffer.append('?');
}
recommendedFormBuffer.append('>');
}
for (int i = 0, dim = checkedType.dimensions(); i < dim; i++) {
recommendedFormBuffer.append("[]"); //$NON-NLS-1$
}
String recommendedForm = recommendedFormBuffer.toString();
if (checkedType.leafComponentType().isTypeVariable()) {
this.handle(
IProblem.IllegalInstanceofTypeParameter,
new String[] { new String(checkedType.readableName()), recommendedForm, },
new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
location.sourceStart,
location.sourceEnd);
return;
}
this.handle(
IProblem.IllegalInstanceofParameterizedType,
new String[] { new String(checkedType.readableName()), recommendedForm, },
new String[] { new String(checkedType.shortReadableName()), recommendedForm, },
location.sourceStart,
location.sourceEnd);
}
示例3: resolveStatements
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入方法依赖的package包/类
public void resolveStatements() {
super.resolveStatements();
if (this.arguments != null) {
this.scope.problemReporter().annotationMembersCannotHaveParameters(this);
}
if (this.typeParameters != null) {
this.scope.problemReporter().annotationMembersCannotHaveTypeParameters(this);
}
if (this.extendedDimensions != 0) {
this.scope.problemReporter().illegalExtendedDimensions(this);
}
if (this.binding == null) return;
TypeBinding returnTypeBinding = this.binding.returnType;
if (returnTypeBinding != null) {
// annotation methods can only return base types, String, Class, enum type, annotation types and arrays of these
checkAnnotationMethodType: {
TypeBinding leafReturnType = returnTypeBinding.leafComponentType();
if (returnTypeBinding.dimensions() <= 1) { // only 1-dimensional array permitted
switch (leafReturnType.erasure().id) {
case T_byte :
case T_short :
case T_char :
case T_int :
case T_long :
case T_float :
case T_double :
case T_boolean :
case T_JavaLangString :
case T_JavaLangClass :
break checkAnnotationMethodType;
}
if (leafReturnType.isEnum() || leafReturnType.isAnnotationType())
break checkAnnotationMethodType;
}
this.scope.problemReporter().invalidAnnotationMemberType(this);
}
if (this.defaultValue != null) {
MemberValuePair pair = new MemberValuePair(this.selector, this.sourceStart, this.sourceEnd, this.defaultValue);
pair.binding = this.binding;
pair.resolveTypeExpecting(this.scope, returnTypeBinding);
this.binding.setDefaultValue(org.eclipse.jdt.internal.compiler.lookup.ElementValuePair.getValue(this.defaultValue));
} else { // let it know it does not have a default value so it won't try to find it
this.binding.setDefaultValue(null);
}
}
}