Java Code Examples for org.eclipse.xtext.util.JavaVersion#JAVA5

The following examples show how to use org.eclipse.xtext.util.JavaVersion#JAVA5 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XbaseBuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public JavaVersion getJavaVersion(Object context, IPreferenceStore preferenceStore) {
	boolean useCompilerSource = preferenceStore.getBoolean(PREF_USE_COMPILER_SOURCE);
	if (useCompilerSource) {
		IJavaProject javaProject = JavaCore.create(context instanceof IProject ? (IProject) context : null);
		String compilerSource;
		if (javaProject != null && javaProject.exists() && javaProject.getProject().isAccessible()) {
			compilerSource = javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
		} else {
			compilerSource = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
		}
		return fromCompilerSourceLevel(compilerSource);
	} else {
		String stringValue = preferenceStore.getString(PREF_JAVA_VERSION);
		try {
			return JavaVersion.valueOf(stringValue);
		} catch (IllegalArgumentException exception) {
			// Fall back to default value
		}
	}
	return JavaVersion.JAVA5;
}
 
Example 2
Source File: OnTheFlyJavaCompiler.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected String getComplianceLevelArg() {
	JavaVersion javaVersion = JavaVersion.JAVA5;
	if (generatorConfigProvider != null) {
		GeneratorConfig generatorConfig = generatorConfigProvider.get(null);
		javaVersion = generatorConfig.getJavaSourceVersion();
	}
	return javaVersion.getComplianceLevelArg();
}
 
Example 3
Source File: OnTheFlyJavaCompiler.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String getComplianceLevelArg() {
	JavaVersion javaVersion = JavaVersion.JAVA5;
	if (generatorConfigProvider != null) {
		GeneratorConfig generatorConfig = generatorConfigProvider.get(null);
		javaVersion = generatorConfig.getJavaSourceVersion();
	}
	return javaVersion.getComplianceLevelArg();
}
 
Example 4
Source File: XbaseBuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public JavaVersion fromCompilerSourceLevel(String compilerSource) {
	JavaVersion javaVersion = JavaVersion.fromQualifier(compilerSource);
	if (javaVersion == null)
		javaVersion = JavaVersion.JAVA5;
	return javaVersion;
}