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

The following examples show how to use org.eclipse.xtext.util.JavaVersion#JAVA8 . 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: JavaDerivedStateComputer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected CompilerOptions getCompilerOptions(JavaConfig javaConfig) {
	JavaVersion sourceVersion = JavaVersion.JAVA8;
	JavaVersion targetVersion = JavaVersion.JAVA8;
	if (javaConfig != null) {
		if (javaConfig.getJavaSourceLevel() != null) {
			sourceVersion = javaConfig.getJavaSourceLevel();
		}
		if (javaConfig.getJavaTargetLevel() != null) {
			targetVersion = javaConfig.getJavaTargetLevel();

		}
	}
	if (JavaVersion.JAVA7.equals(sourceVersion)) {
		JavaDerivedStateComputer.LOG.warn(
				"The java source language has been configured with Java 7. JDT will not produce signature information for generic @Override methods in this version, which might lead to follow up issues.");
	}
	long sourceLevel = toJdtVersion(sourceVersion);
	long targetLevel = toJdtVersion(targetVersion);
	CompilerOptions compilerOptions = new CompilerOptions();
	compilerOptions.targetJDK = targetLevel;
	compilerOptions.inlineJsrBytecode = true;
	compilerOptions.sourceLevel = sourceLevel;
	compilerOptions.produceMethodParameters = true;
	compilerOptions.produceReferenceInfo = true;
	compilerOptions.originalSourceLevel = targetLevel;
	compilerOptions.complianceLevel = sourceLevel;
	compilerOptions.originalComplianceLevel = targetLevel;
	return compilerOptions;
}
 
Example 2
Source File: AbstractSarlUiTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the injection modules to be used.
 *
 * @return the injection modules.
 */
protected Module[] getInjectionModules() {
	return new Module[] {
			new Module() {
				@Override
				public void configure(Binder binder) {
					final JavaVersion version = JavaVersion.JAVA8;
					binder.bind(JavaVersion.class).toProvider(() -> version);
					binder.bind(ProjectCreator.class).toProvider(() -> {
						return new JavaProjectCreator(version);
					}).asEagerSingleton();
				}
			},	
	};
}
 
Example 3
Source File: AbstractDocumentationMojo.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Create a parser for the given file.
 *
 * @param inputFile the file to be parsed.
 * @return the parser.
 * @throws MojoExecutionException if the parser cannot be created.
 * @throws IOException if a classpath entry cannot be found.
 */
@SuppressWarnings("checkstyle:npathcomplexity")
protected AbstractMarkerLanguageParser createLanguageParser(File inputFile) throws MojoExecutionException, IOException {
	final AbstractMarkerLanguageParser parser;
	if (isFileExtension(inputFile, MarkdownParser.MARKDOWN_FILE_EXTENSIONS)) {
		parser = this.injector.getInstance(MarkdownParser.class);
	} else {
		throw new MojoExecutionException(MessageFormat.format(Messages.AbstractDocumentationMojo_3, inputFile));
	}
	parser.setGithubExtensionEnable(this.githubExtension);

	final SarlDocumentationParser internalParser = parser.getDocumentParser();

	if (this.isLineContinuationEnable) {
		internalParser.setLineContinuation(SarlDocumentationParser.DEFAULT_LINE_CONTINUATION);
	} else {
		internalParser.addLowPropertyProvider(createProjectProperties());
	}

	final ScriptExecutor scriptExecutor = internalParser.getScriptExecutor();
	final StringBuilder cp = new StringBuilder();
	final List<File> fullCp = getClassPath();
	for (final File cpElement : fullCp) {
		if (cp.length() > 0) {
			cp.append(File.pathSeparator);
		}
		cp.append(cpElement.getAbsolutePath());
	}
	scriptExecutor.setClassPath(cp.toString());
	scriptExecutor.setClassLoaderBuilder(it -> getProjectClassLoader(it, fullCp, fullCp.size()));
	final String bootPath = getBootClassPath();
	if (!Strings.isEmpty(bootPath)) {
		scriptExecutor.setBootClassPath(bootPath);
	}
	JavaVersion version = null;
	if (!Strings.isEmpty(this.source)) {
		version = JavaVersion.fromQualifier(this.source);
	}
	if (version == null) {
		version = JavaVersion.JAVA8;
	}
	scriptExecutor.setJavaSourceVersion(version.getQualifier());
	scriptExecutor.setTempFolder(this.tempDirectory.getAbsoluteFile());

	internalParser.addLowPropertyProvider(createProjectProperties());
	internalParser.addLowPropertyProvider(this.session.getCurrentProject().getProperties());
	internalParser.addLowPropertyProvider(this.session.getUserProperties());
	internalParser.addLowPropertyProvider(this.session.getSystemProperties());
	internalParser.addLowPropertyProvider(createGeneratorProperties());
	final Properties defaultValues = createDefaultValueProperties();
	if (defaultValues != null) {
		internalParser.addLowPropertyProvider(defaultValues);
	}
	return parser;
}