本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeBinding.VOID属性的典型用法代码示例。如果您正苦于以下问题:Java TypeBinding.VOID属性的具体用法?Java TypeBinding.VOID怎么用?Java TypeBinding.VOID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.lookup.TypeBinding
的用法示例。
在下文中一共展示了TypeBinding.VOID属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBaseTypeBinding
private TypeBinding getBaseTypeBinding(char[] signature) {
switch (signature[0]) {
case 'I' :
return TypeBinding.INT;
case 'Z' :
return TypeBinding.BOOLEAN;
case 'V' :
return TypeBinding.VOID;
case 'C' :
return TypeBinding.CHAR;
case 'D' :
return TypeBinding.DOUBLE;
case 'B' :
return TypeBinding.BYTE;
case 'F' :
return TypeBinding.FLOAT;
case 'J' :
return TypeBinding.LONG;
case 'S' :
return TypeBinding.SHORT;
case 'N':
return TypeBinding.NULL;
default :
return null;
}
}
示例2: generateStoreSaveValueIfNecessary
public void generateStoreSaveValueIfNecessary(CodeStream codeStream){
// push receiver
codeStream.aload_0();
// push the 2 parameters of "setResult(Object, Class)"
if (this.expression == null || this.expression.resolvedType == TypeBinding.VOID) { // expressionType == VoidBinding if code snippet is the expression "System.out.println()"
// push null
codeStream.aconst_null();
// void.class
codeStream.generateClassLiteralAccessForType(TypeBinding.VOID, null);
} else {
// swap with expression
int valueTypeID = this.expression.resolvedType.id;
if (valueTypeID == T_long || valueTypeID == T_double) {
codeStream.dup_x2();
codeStream.pop();
} else {
codeStream.swap();
}
// generate wrapper if needed
if (this.expression.resolvedType.isBaseType() && this.expression.resolvedType != TypeBinding.NULL) {
codeStream.generateBoxingConversion(this.expression.resolvedType.id);
}
// generate the expression type
codeStream.generateClassLiteralAccessForType(this.expression.resolvedType, null);
}
// generate the invoke virtual to "setResult(Object,Class)"
codeStream.invoke(Opcodes.OPC_invokevirtual, this.setResultMethod, null /* default declaringClass */);
}
示例3: getType
private TypeBinding getType(char[] type) {
TypeBinding binding = null;
int length = type.length;
switch(length) {
case 1 :
switch (type[0]) {
case 'I' :
binding = TypeBinding.INT;
break;
case 'Z' :
binding = TypeBinding.BOOLEAN;
break;
case 'V' :
binding = TypeBinding.VOID;
break;
case 'C' :
binding = TypeBinding.CHAR;
break;
case 'D' :
binding = TypeBinding.DOUBLE;
break;
case 'B' :
binding = TypeBinding.BYTE;
break;
case 'F' :
binding = TypeBinding.FLOAT;
break;
case 'J' :
binding = TypeBinding.LONG;
break;
case 'S' :
binding = TypeBinding.SHORT;
break;
}
break;
default:
int dimensions = 0;
int start = 0;
while (type[start] == '[') {
start++;
dimensions++;
}
binding = this.environment.getType(CharOperation.splitOn('/', type, start + 1, length - 1));
if (dimensions != 0) {
binding = this.environment.createArrayType(binding, dimensions);
}
}
return binding;
}
示例4: analyseCode
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, final FlowInfo flowInfo) {
if (this.ignoreFurtherInvestigation)
return flowInfo;
FlowInfo lambdaInfo = flowInfo.copy(); // what happens in vegas, stays in vegas ...
ExceptionHandlingFlowContext methodContext =
new ExceptionHandlingFlowContext(
flowContext,
this,
this.binding.thrownExceptions,
null,
this.scope,
FlowInfo.DEAD_END);
// nullity and mark as assigned
MethodBinding methodWithParameterDeclaration = argumentsTypeElided() ? this.descriptor : this.binding;
AbstractMethodDeclaration.analyseArguments18(lambdaInfo, this.arguments, methodWithParameterDeclaration);
if (this.arguments != null) {
for (int i = 0, count = this.arguments.length; i < count; i++) {
this.bits |= (this.arguments[i].bits & ASTNode.HasTypeAnnotations);
}
}
lambdaInfo = this.body.analyseCode(this.scope, methodContext, lambdaInfo);
// check for missing returning path for block body's ...
if (this.body instanceof Block) {
TypeBinding returnTypeBinding = expectedResultType();
if ((returnTypeBinding == TypeBinding.VOID)) {
if ((lambdaInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0 || ((Block) this.body).statements == null) {
this.bits |= ASTNode.NeedFreeReturn;
}
} else {
if (lambdaInfo != FlowInfo.DEAD_END) {
this.scope.problemReporter().shouldReturn(returnTypeBinding, this);
}
}
} else { // Expression
if (currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled
&& lambdaInfo.reachMode() == FlowInfo.REACHABLE)
{
Expression expression = (Expression)this.body;
checkAgainstNullAnnotation(flowContext, expression, expression.nullStatus(lambdaInfo, flowContext));
}
}
return flowInfo;
}
示例5: getResolvedCopyForInferenceTargeting
/**
* Get a resolved copy of this lambda for use by type inference, as to avoid spilling any premature
* type results into the original lambda.
*
* @param targetType the target functional type against which inference is attempted, must be a non-null valid functional type
* @return a resolved copy of 'this' or null if significant errors where encountered
*/
public LambdaExpression getResolvedCopyForInferenceTargeting(TypeBinding targetType) {
// note: this is essentially a simplified extract from isCompatibleWith(TypeBinding,Scope).
if (this.shapeAnalysisComplete && this.binding != null)
return this;
targetType = targetType.uncapture(this.enclosingScope);
// TODO: caching
IErrorHandlingPolicy oldPolicy = this.enclosingScope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy);
final CompilerOptions compilerOptions = this.enclosingScope.compilerOptions();
boolean analyzeNPE = compilerOptions.isAnnotationBasedNullAnalysisEnabled;
final LambdaExpression copy = copy();
if (copy == null) {
return null;
}
try {
compilerOptions.isAnnotationBasedNullAnalysisEnabled = false;
copy.setExpressionContext(this.expressionContext);
copy.setExpectedType(targetType);
this.hasIgnoredMandatoryErrors = false;
TypeBinding type = copy.resolveType(this.enclosingScope);
if (type == null || !type.isValidBinding())
return null;
if (this.body instanceof Block) {
if (copy.returnsVoid) {
copy.shapeAnalysisComplete = true;
} else {
copy.valueCompatible = this.returnsValue;
}
} else {
copy.voidCompatible = ((Expression) this.body).statementExpression();
TypeBinding resultType = ((Expression) this.body).resolvedType;
if (resultType == null) // case of a yet-unresolved poly expression?
copy.valueCompatible = true;
else
copy.valueCompatible = (resultType != TypeBinding.VOID);
copy.shapeAnalysisComplete = true;
}
// Do not proceed with data/control flow analysis if resolve encountered errors.
if (!this.hasIgnoredMandatoryErrors && !enclosingScopesHaveErrors()) {
// value compatibility of block lambda's is the only open question.
if (!copy.shapeAnalysisComplete)
copy.valueCompatible = copy.doesNotCompleteNormally();
} else {
if (!copy.returnsVoid)
copy.valueCompatible = true; // optimistically, TODO: is this OK??
}
copy.shapeAnalysisComplete = true;
copy.resultExpressions = this.resultExpressions;
this.resultExpressions = NO_EXPRESSIONS;
} finally {
compilerOptions.isAnnotationBasedNullAnalysisEnabled = analyzeNPE;
this.hasIgnoredMandatoryErrors = false;
this.enclosingScope.problemReporter().switchErrorHandlingPolicy(oldPolicy);
}
return copy;
}
示例6: unusedPrivateMethod
public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
int severity = computeSeverity(IProblem.UnusedPrivateMethod);
if (severity == ProblemSeverities.Ignore) return;
MethodBinding method = methodDecl.binding;
// no report for serialization support 'void readObject(ObjectInputStream)'
if (!method.isStatic()
&& TypeBinding.VOID == method.returnType
&& method.parameters.length == 1
&& method.parameters[0].dimensions() == 0
&& CharOperation.equals(method.selector, TypeConstants.READOBJECT)
&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
return;
}
// no report for serialization support 'void writeObject(ObjectOutputStream)'
if (!method.isStatic()
&& TypeBinding.VOID == method.returnType
&& method.parameters.length == 1
&& method.parameters[0].dimensions() == 0
&& CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
return;
}
// no report for serialization support 'Object readResolve()'
if (!method.isStatic()
&& TypeIds.T_JavaLangObject == method.returnType.id
&& method.parameters.length == 0
&& CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
return;
}
// no report for serialization support 'Object writeReplace()'
if (!method.isStatic()
&& TypeIds.T_JavaLangObject == method.returnType.id
&& method.parameters.length == 0
&& CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
return;
}
if (excludeDueToAnnotation(methodDecl.annotations, IProblem.UnusedPrivateMethod)) return;
this.handle(
IProblem.UnusedPrivateMethod,
new String[] {
new String(method.declaringClass.readableName()),
new String(method.selector),
typesAsString(method, false)
},
new String[] {
new String(method.declaringClass.shortReadableName()),
new String(method.selector),
typesAsString(method, true)
},
severity,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
示例7: unusedPrivateMethod
public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
int severity = computeSeverity(IProblem.UnusedPrivateMethod);
if (severity == ProblemSeverities.Ignore) return;
MethodBinding method = methodDecl.binding;
// no report for serialization support 'void readObject(ObjectInputStream)'
if (!method.isStatic()
&& TypeBinding.VOID == method.returnType
&& method.parameters.length == 1
&& method.parameters[0].dimensions() == 0
&& CharOperation.equals(method.selector, TypeConstants.READOBJECT)
&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
return;
}
// no report for serialization support 'void writeObject(ObjectOutputStream)'
if (!method.isStatic()
&& TypeBinding.VOID == method.returnType
&& method.parameters.length == 1
&& method.parameters[0].dimensions() == 0
&& CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
&& CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
return;
}
// no report for serialization support 'Object readResolve()'
if (!method.isStatic()
&& TypeIds.T_JavaLangObject == method.returnType.id
&& method.parameters.length == 0
&& CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
return;
}
// no report for serialization support 'Object writeReplace()'
if (!method.isStatic()
&& TypeIds.T_JavaLangObject == method.returnType.id
&& method.parameters.length == 0
&& CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
return;
}
if (excludeDueToAnnotation(methodDecl.annotations)) return;
this.handle(
IProblem.UnusedPrivateMethod,
new String[] {
new String(method.declaringClass.readableName()),
new String(method.selector),
typesAsString(method, false)
},
new String[] {
new String(method.declaringClass.shortReadableName()),
new String(method.selector),
typesAsString(method, true)
},
severity,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}