Bug 565438 - [15] Consolidate all language feature support error
handling

Add utility method JavaFeature#isSupported()

Change-Id: Ic0d09805f0f11d83122e5d6e7481064170b28f69
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
index b2dd075..f9a9e10 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
@@ -75,6 +75,11 @@
 	public char[][] getRestrictedKeywords() {
 		return this.restrictedKeywords;
 	}
+	public boolean isSupported(CompilerOptions options) {
+		if (this.isPreview)
+			return options.enablePreviewFeatures;
+		return this.getCompliance() <= options.sourceLevel;
+	}
 
 	JavaFeature(long compliance, String name, char[][] restrictedKeywords, boolean isPreview) {
         this.compliance = compliance;