View | Details | Raw Unified | Return to bug 218603 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/JavaCore.java (+18 lines)
Lines 117-122 Link Here
117
import org.eclipse.core.runtime.SubProgressMonitor;
117
import org.eclipse.core.runtime.SubProgressMonitor;
118
import org.eclipse.core.runtime.jobs.ISchedulingRule;
118
import org.eclipse.core.runtime.jobs.ISchedulingRule;
119
import org.eclipse.jdt.core.compiler.CharOperation;
119
import org.eclipse.jdt.core.compiler.CharOperation;
120
import org.eclipse.jdt.core.compiler.IProblem;
120
import org.eclipse.jdt.core.search.IJavaSearchConstants;
121
import org.eclipse.jdt.core.search.IJavaSearchConstants;
121
import org.eclipse.jdt.core.search.IJavaSearchScope;
122
import org.eclipse.jdt.core.search.IJavaSearchScope;
122
import org.eclipse.jdt.core.search.SearchEngine;
123
import org.eclipse.jdt.core.search.SearchEngine;
Lines 124-129 Link Here
124
import org.eclipse.jdt.core.search.TypeNameRequestor;
125
import org.eclipse.jdt.core.search.TypeNameRequestor;
125
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
126
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
126
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
127
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
128
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
127
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
129
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
128
import org.eclipse.jdt.internal.core.*;
130
import org.eclipse.jdt.internal.core.*;
129
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
131
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
Lines 2852-2857 Link Here
2852
	}
2854
	}
2853
2855
2854
	/**
2856
	/**
2857
	 * Returns the option that can be used to tune the severity of the compiler 
2858
	 * problem identified by problemID if any, null otherwise. Non-null return
2859
	 * values are taken from the constants defined by this class which names 
2860
	 * start with COMPILER_PB and for which the possible values of the option 
2861
	 * are defined by <code>{ "error", "warning", "ignore" }</code>. A null 
2862
	 * return value means that the problemID is unknown or that it matches a 
2863
	 * problem which severity cannot be tuned.
2864
	 * @param problemID one of the problem IDs defined by {@link IProblem}
2865
	 * @return the option that can be used to tune the severity of the compiler 
2866
	 *         problem identified by problemID if any, null otherwise
2867
	 */
2868
	public static String getCompilerProblemSeverityTuningOption(int problemID) {
2869
		return CompilerOptions.optionKeyFromIrritant(ProblemReporter.getIrritant(problemID));
2870
	}
2871
	
2872
	/**
2855
	 * Returns a table of all known configurable options with their default values.
2873
	 * Returns a table of all known configurable options with their default values.
2856
	 * These options allow to configure the behaviour of the underlying components.
2874
	 * These options allow to configure the behaviour of the underlying components.
2857
	 * The client may safely use the result as a template that they can modify and
2875
	 * The client may safely use the result as a template that they can modify and
(-)src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java (+158 lines)
Lines 902-905 Link Here
902
	}
902
	}
903
	return (String) categoryNames.get(new Integer(category));
903
	return (String) categoryNames.get(new Integer(category));
904
}
904
}
905
// compiler problems tuning
906
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=218603
907
public void testONLY_012_compiler_problems_tuning() {
908
	try {
909
		class ProblemAttributes {
910
			boolean skip;
911
			String option;
912
			ProblemAttributes(String option) {
913
				this.option = option;
914
			}
915
			ProblemAttributes(boolean skip) {
916
				this.skip = skip;
917
			}
918
		}
919
		ProblemAttributes SKIP = new ProblemAttributes(true);		
920
		Map expectedProblemAttributes = new HashMap();
921
		expectedProblemAttributes.put("ObjectHasNoSuperclass", SKIP);
922
		expectedProblemAttributes.put("UndefinedType", SKIP);
923
		expectedProblemAttributes.put("NotVisibleType", SKIP);
924
		expectedProblemAttributes.put("AmbiguousType", SKIP);
925
		expectedProblemAttributes.put("UsingDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
926
		expectedProblemAttributes.put("InternalTypeNameProvided", SKIP);
927
		expectedProblemAttributes.put("UnusedPrivateType", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
928
		expectedProblemAttributes.put("IncompatibleTypesInEqualityOperator", SKIP);
929
		expectedProblemAttributes.put("IncompatibleTypesInConditionalOperator", SKIP);
930
		expectedProblemAttributes.put("TypeMismatch", SKIP);
931
		expectedProblemAttributes.put("IndirectAccessToStaticType", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
932
		expectedProblemAttributes.put("MissingEnclosingInstanceForConstructorCall", SKIP);
933
		expectedProblemAttributes.put("MissingEnclosingInstance", SKIP);
934
		expectedProblemAttributes.put("IncorrectEnclosingInstanceReference", SKIP);
935
		expectedProblemAttributes.put("IllegalEnclosingInstanceSpecification", SKIP);
936
		expectedProblemAttributes.put("CannotDefineStaticInitializerInLocalType", SKIP);
937
		expectedProblemAttributes.put("OuterLocalMustBeFinal", SKIP);
938
		expectedProblemAttributes.put("CannotDefineInterfaceInLocalType", SKIP);
939
		expectedProblemAttributes.put("IllegalPrimitiveOrArrayTypeForEnclosingInstance", SKIP);
940
		expectedProblemAttributes.put("EnclosingInstanceInConstructorCall", SKIP);
941
		expectedProblemAttributes.put("AnonymousClassCannotExtendFinalClass", SKIP);
942
		expectedProblemAttributes.put("CannotDefineAnnotationInLocalType", SKIP);
943
		expectedProblemAttributes.put("CannotDefineEnumInLocalType", SKIP);
944
		expectedProblemAttributes.put("NonStaticContextForEnumMemberType", SKIP);
945
		expectedProblemAttributes.put("TypeHidingType", new ProblemAttributes(JavaCore.COMPILER_PB_TYPE_PARAMETER_HIDING));
946
		expectedProblemAttributes.put("UndefinedName", SKIP);
947
		expectedProblemAttributes.put("UninitializedLocalVariable", SKIP);
948
		expectedProblemAttributes.put("VariableTypeCannotBeVoid", SKIP);
949
		expectedProblemAttributes.put("VariableTypeCannotBeVoidArray", SKIP);
950
		expectedProblemAttributes.put("CannotAllocateVoidArray", SKIP);
951
		expectedProblemAttributes.put("RedefinedLocal", SKIP);
952
		expectedProblemAttributes.put("RedefinedArgument", SKIP);
953
		expectedProblemAttributes.put("DuplicateFinalLocalInitialization", SKIP);
954
		expectedProblemAttributes.put("NonBlankFinalLocalAssignment", SKIP);
955
		expectedProblemAttributes.put("ParameterAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_PARAMETER_ASSIGNMENT));
956
		expectedProblemAttributes.put("FinalOuterLocalAssignment", SKIP);
957
		expectedProblemAttributes.put("LocalVariableIsNeverUsed", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_LOCAL));
958
		expectedProblemAttributes.put("ArgumentIsNeverUsed", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PARAMETER));
959
		expectedProblemAttributes.put("BytecodeExceeds64KLimit", SKIP);
960
		expectedProblemAttributes.put("BytecodeExceeds64KLimitForClinit", SKIP);
961
		expectedProblemAttributes.put("TooManyArgumentSlots", SKIP);
962
		expectedProblemAttributes.put("TooManyLocalVariableSlots", SKIP);
963
		expectedProblemAttributes.put("TooManySyntheticArgumentSlots", SKIP);
964
		expectedProblemAttributes.put("TooManyArrayDimensions", SKIP);
965
		expectedProblemAttributes.put("BytecodeExceeds64KLimitForConstructor", SKIP);
966
		expectedProblemAttributes.put("UndefinedField", SKIP);
967
		expectedProblemAttributes.put("NotVisibleField", SKIP);
968
		expectedProblemAttributes.put("AmbiguousField", SKIP);
969
		expectedProblemAttributes.put("UsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
970
		expectedProblemAttributes.put("NonStaticFieldFromStaticInvocation", SKIP);
971
		expectedProblemAttributes.put("ReferenceToForwardField", SKIP);
972
		expectedProblemAttributes.put("NonStaticAccessToStaticField", new ProblemAttributes(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER));
973
		expectedProblemAttributes.put("UnusedPrivateField", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
974
		expectedProblemAttributes.put("IndirectAccessToStaticField", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
975
		expectedProblemAttributes.put("UnqualifiedFieldAccess", new ProblemAttributes(JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS));
976
		expectedProblemAttributes.put("FinalFieldAssignment", SKIP);
977
		expectedProblemAttributes.put("UninitializedBlankFinalField", SKIP);
978
		expectedProblemAttributes.put("DuplicateBlankFinalFieldInitialization", SKIP);
979
		expectedProblemAttributes.put("LocalVariableHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
980
		expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
981
		expectedProblemAttributes.put("FieldHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_FIELD_HIDING));
982
		expectedProblemAttributes.put("FieldHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_FIELD_HIDING));
983
		expectedProblemAttributes.put("ArgumentHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
984
		expectedProblemAttributes.put("ArgumentHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
985
		expectedProblemAttributes.put("MissingSerialVersion", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_SERIAL_VERSION));
986
		expectedProblemAttributes.put("UndefinedMethod", SKIP);
987
		expectedProblemAttributes.put("NotVisibleMethod", SKIP);
988
		expectedProblemAttributes.put("AmbiguousMethod", SKIP);
989
		expectedProblemAttributes.put("UsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
990
		expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", SKIP);
991
		expectedProblemAttributes.put("VoidMethodReturnsValue", SKIP);
992
		expectedProblemAttributes.put("MethodReturnsVoid", SKIP);
993
		expectedProblemAttributes.put("MethodRequiresBody", SKIP);
994
		expectedProblemAttributes.put("ShouldReturnValue", SKIP);
995
		expectedProblemAttributes.put("MethodButWithConstructorName", new ProblemAttributes(JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME));
996
		expectedProblemAttributes.put("MissingReturnType", SKIP);
997
		expectedProblemAttributes.put("BodyForNativeMethod", SKIP);
998
		expectedProblemAttributes.put("BodyForAbstractMethod", SKIP);
999
		expectedProblemAttributes.put("NoMessageSendOnBaseType", SKIP);
1000
		expectedProblemAttributes.put("ParameterMismatch", SKIP);
1001
		expectedProblemAttributes.put("NoMessageSendOnArrayType", SKIP);
1002
		expectedProblemAttributes.put("NonStaticAccessToStaticMethod", new ProblemAttributes(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER));
1003
		expectedProblemAttributes.put("UnusedPrivateMethod", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1004
		expectedProblemAttributes.put("IndirectAccessToStaticMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
1005
		expectedProblemAttributes.put("MissingTypeInMethod", SKIP);
1006
		expectedProblemAttributes.put("MissingTypeInConstructor", SKIP);
1007
		expectedProblemAttributes.put("UndefinedConstructor", SKIP);
1008
		expectedProblemAttributes.put("NotVisibleConstructor", SKIP);
1009
		expectedProblemAttributes.put("AmbiguousConstructor", SKIP);
1010
		expectedProblemAttributes.put("UsingDeprecatedConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
1011
		expectedProblemAttributes.put("UnusedPrivateConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
1012
		expectedProblemAttributes.put("InstanceFieldDuringConstructorInvocation", SKIP);
1013
		expectedProblemAttributes.put("InstanceMethodDuringConstructorInvocation", SKIP);
1014
		expectedProblemAttributes.put("RecursiveConstructorInvocation", SKIP);
1015
		expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", SKIP);
1016
		expectedProblemAttributes.put("InvalidExplicitConstructorCall", SKIP);
1017
		expectedProblemAttributes.put("UndefinedConstructorInDefaultConstructor", SKIP);
1018
		expectedProblemAttributes.put("NotVisibleConstructorInDefaultConstructor", SKIP);
1019
		expectedProblemAttributes.put("AmbiguousConstructorInDefaultConstructor", SKIP);
1020
		expectedProblemAttributes.put("UndefinedConstructorInImplicitConstructorCall", SKIP);
1021
		expectedProblemAttributes.put("NotVisibleConstructorInImplicitConstructorCall", SKIP);
1022
		expectedProblemAttributes.put("AmbiguousConstructorInImplicitConstructorCall", SKIP);
1023
		expectedProblemAttributes.put("UnhandledExceptionInDefaultConstructor", SKIP);
1024
		expectedProblemAttributes.put("UnhandledExceptionInImplicitConstructorCall", SKIP);
1025
		expectedProblemAttributes.put("ArrayReferenceRequired", SKIP);
1026
		expectedProblemAttributes.put("NoImplicitStringConversionForCharArrayExpression", new ProblemAttributes(JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION));
1027
		expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", SKIP);
1028
		expectedProblemAttributes.put("NonConstantExpression", SKIP);
1029
		expectedProblemAttributes.put("NumericValueOutOfRange", SKIP);
1030
		expectedProblemAttributes.put("IllegalCast", SKIP);
1031
		expectedProblemAttributes.put("InvalidClassInstantiation", SKIP);
1032
		expectedProblemAttributes.put("CannotDefineDimensionExpressionsWithInit", SKIP);
1033
		expectedProblemAttributes.put("MustDefineEitherDimensionExpressionsOrInitializer", SKIP);
1034
		expectedProblemAttributes.put("InvalidOperator", SKIP);
1035
		expectedProblemAttributes.put("CodeCannotBeReached", SKIP);
1036
		expectedProblemAttributes.put("CannotReturnInInitializer", SKIP);
1037
		expectedProblemAttributes.put("InitializerMustCompleteNormally", SKIP);
1038
		expectedProblemAttributes.put("InvalidVoidExpression", SKIP);
1039
		expectedProblemAttributes.put("MaskedCatch", new ProblemAttributes(JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK));
1040
		expectedProblemAttributes.put("DuplicateDefaultCase", SKIP);
1041
		expectedProblemAttributes.put("UnreachableCatch", SKIP);
1042
		expectedProblemAttributes.put("UnhandledException", SKIP);
1043
		expectedProblemAttributes.put("IncorrectSwitchType", SKIP);
1044
		expectedProblemAttributes.put("DuplicateCase", SKIP);
1045
		expectedProblemAttributes.put("DuplicateLabel", SKIP);
1046
		expectedProblemAttributes.put("InvalidBreak", SKIP);
1047
		expectedProblemAttributes.put("InvalidContinue", SKIP);
1048
		expectedProblemAttributes.put("UndefinedLabel", SKIP);
1049
		expectedProblemAttributes.put("InvalidTypeToSynchronized", SKIP);
1050
		expectedProblemAttributes.put("InvalidNullToSynchronized", SKIP);
1051
		expectedProblemAttributes.put("CannotThrowNull", SKIP);
1052
		expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT));
1053
		expectedProblemAttributes.put("PossibleAccidentalBooleanAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT));
1054
		expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
1055
		expectedProblemAttributes.put("UnnecessaryCast", new ProblemAttributes(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK));
1056
		expectedProblemAttributes.put("UnnecessaryArgumentCast", SKIP);
1057
		expectedProblemAttributes.put("UnnecessaryInstanceof", new ProblemAttributes(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK));
1058
		expectedProblemAttributes.put("FinallyMustCompleteNormally", new ProblemAttributes(JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING));
1059
		expectedProblemAttributes.put("UnusedMethodDeclaredThrownException", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING));
1060
		expectedProblemAttributes.put("UnusedConstructorDeclaredThrownException", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING));
1061
		expectedProblemAttributes.put("InvalidCatchBlockSequence", SKIP);
1062
		expectedProblemAttributes.put("EmptyControlFlowStatement", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));

Return to bug 218603