Java Code Examples for org.eclipse.xtext.util.JavaVersion#values()

The following examples show how to use org.eclipse.xtext.util.JavaVersion#values() . 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: AbstractOutputComparingCompilerTests.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void compilesTo(final CharSequence xbaseCode, final CharSequence result,
		Pair<JavaVersion, JavaVersion> minAndMaxVersion) throws Exception {
	int min = minAndMaxVersion.getKey().ordinal();
	int max = minAndMaxVersion.getValue().ordinal();
	if (min > max)
		throw new IllegalArgumentException();
	for (int i = min; i <= max; i++) {
		JavaVersion version = JavaVersion.values()[i];
		assertCompilesTo(result, xbaseCode, version);
	}
}
 
Example 2
Source File: WizardNewXtextProjectCreationPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void fillBreeCombo(Combo comboToFill) {
	Set<String> brees = Sets.newLinkedHashSet();
	Set<String> availableBrees = Sets.newHashSet();
	for (IExecutionEnvironment ee : JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments()) {
		availableBrees.add(ee.getId());
	}
	for (JavaVersion supportedVersion : JavaVersion.values()) {
		if (supportedVersion.isAtLeast(JavaVersion.JAVA6)) {
			String bree = supportedVersion.getBree();
			if (availableBrees.contains(bree))
				brees.add(bree);
		}
	}
	String[] array = brees.toArray(new String[] {});
	String selectionMemento = comboToFill.getText();
	comboToFill.setItems(array);
	int index = comboToFill.indexOf(selectionMemento);
	String defaultBree = JREContainerProvider.getDefaultBREE();
	if (index < 0) {
		if (brees.contains(defaultBree)) {
			comboToFill.select(comboToFill.indexOf(defaultBree));
		} else {
			comboToFill.select(array.length - 1);
		}
	}
	comboToFill.select(index);
}
 
Example 3
Source File: XbaseBuilderConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void updateVersionCombo() {
	boolean useCompliance = useComplianceButton.getSelection();
	versionCombo.setEnabled(!useCompliance);
	if (useCompliance) {
		String javaSourceOption = javaValue(JavaCore.COMPILER_SOURCE);
		JavaVersion javaVersion = preferenceAccess.fromCompilerSourceLevel(javaSourceOption);
		JavaVersion selectedVersion = JavaVersion.values()[versionCombo.getSelectionIndex()];
		if (javaVersion != selectedVersion) {
			versionCombo.select(javaVersion.ordinal());
		}
	}
}
 
Example 4
Source File: XtendBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.8
 */
public void setJavaSourceVersion(final String javaSourceVersion) {
	JavaVersion javaVersion = JavaVersion.fromQualifier(javaSourceVersion);
	if(javaVersion == null) {
		List<String> qualifiers = Lists.newArrayList();
		for (JavaVersion version : JavaVersion.values())
			qualifiers.addAll(version.getAllQualifiers());
		
		throw new IllegalArgumentException("Unknown Java Version Qualifier: '" + javaSourceVersion + "'. Valid values are: '" + Joiner.on(", ").join(qualifiers) + "'");
	}
	generatorConfig.setJavaSourceVersion(javaVersion);
}
 
Example 5
Source File: SarlBatchCompiler.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Change the version of the Java source to be used for the generated Java files.
 *
 * @param version the Java version.
 */
public void setJavaSourceVersion(String version) {
	final JavaVersion javaVersion = JavaVersion.fromQualifier(version);
	if (javaVersion == null) {
		final List<String> qualifiers = new ArrayList<>();
		for (final JavaVersion vers : JavaVersion.values()) {
			qualifiers.addAll(vers.getAllQualifiers());
		}

		throw new RuntimeException(MessageFormat.format(
				Messages.SarlBatchCompiler_0, version, Joiner.on(Messages.SarlBatchCompiler_1).join(qualifiers)));
	}
	getGeneratorConfig().setJavaSourceVersion(javaVersion);
}