本文整理汇总了Java中org.eclipse.jdt.internal.compiler.impl.CompilerOptions.getSeverity方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerOptions.getSeverity方法的具体用法?Java CompilerOptions.getSeverity怎么用?Java CompilerOptions.getSeverity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.impl.CompilerOptions
的用法示例。
在下文中一共展示了CompilerOptions.getSeverity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNeedForAssignedCast
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入方法依赖的package包/类
/**
* Complain if assigned expression is cast, but not actually used as such, e.g. Object o = (List) object;
*/
public static void checkNeedForAssignedCast(BlockScope scope, TypeBinding expectedType, CastExpression rhs) {
CompilerOptions compilerOptions = scope.compilerOptions();
if (compilerOptions.getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return;
TypeBinding castedExpressionType = rhs.expression.resolvedType;
// int i = (byte) n; // cast still had side effect
// double d = (float) n; // cast to float is unnecessary
if (castedExpressionType == null || rhs.resolvedType.isBaseType()) return;
//if (castedExpressionType.id == T_null) return; // tolerate null expression cast
if (castedExpressionType.isCompatibleWith(expectedType, scope)) {
if (compilerOptions.isAnnotationBasedNullAnalysisEnabled && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8) {
// are null annotations compatible, too?
if (NullAnnotationMatching.analyse(expectedType, castedExpressionType, -1).isAnyMismatch())
return; // already reported unchecked cast (nullness), say no more.
}
scope.problemReporter().unnecessaryCast(rhs);
}
}
示例2: reportRawReferences
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入方法依赖的package包/类
void reportRawReferences() {
CompilerOptions compilerOptions = this.type.scope.compilerOptions();
if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
|| compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined
return;
}
/* Code below is only for a method that does not override/implement a super type method. If it were to,
it would have been handled in checkAgainstInheritedMethods.
*/
Object [] methodArray = this.currentMethods.valueTable;
for (int s = methodArray.length; --s >= 0;) {
if (methodArray[s] == null) continue;
MethodBinding[] current = (MethodBinding[]) methodArray[s];
for (int i = 0, length = current.length; i < length; i++) {
MethodBinding currentMethod = current[i];
if ((currentMethod.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) == 0) {
AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
if (methodDecl == null) return;
TypeBinding [] parameterTypes = currentMethod.parameters;
Argument[] arguments = methodDecl.arguments;
for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
TypeBinding parameterType = parameterTypes[j];
Argument arg = arguments[j];
if (parameterType.leafComponentType().isRawType()
&& compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
&& (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
}
}
if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration) {
TypeReference returnType = ((MethodDeclaration) methodDecl).returnType;
TypeBinding methodType = currentMethod.returnType;
if (returnType != null) {
if (methodType.leafComponentType().isRawType()
&& compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
&& (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
}
}
}
}
}
}
}