<commit_before>/*******************************************************************************
 * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.xtext.generator

import com.google.inject.Inject
import org.eclipse.xtend2.lib.StringConcatenationClient
import org.eclipse.xtext.Grammar
import org.eclipse.xtext.resource.containers.IAllContainersState
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
import org.eclipse.xtext.xtext.generator.xbase.XbaseUsageDetector

import static extension org.eclipse.xtext.GrammarUtil.*
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*

package class ImplicitFragment extends AbstractXtextGeneratorFragment {
	
	@Inject extension XbaseUsageDetector
	
	@Inject extension XtextGeneratorNaming naming
	
	override generate() {
		if (projectConfig.runtime.manifest !== null) {
			projectConfig.runtime.manifest.requiredBundles.addAll(#[
				'org.eclipse.xtext', 'org.eclipse.xtext.util', 'org.eclipse.xtend.lib'
			])
			projectConfig.runtime.manifest.importedPackages.add('org.apache.log4j')
		}
		if (projectConfig.eclipsePlugin.manifest !== null) {
			projectConfig.eclipsePlugin.manifest.requiredBundles.addAll(#[
				'org.eclipse.xtext.ui', 'org.eclipse.xtext.ui.shared', 'org.eclipse.ui.editors', 'org.eclipse.ui', 'org.eclipse.xtend.lib'
			])
			projectConfig.eclipsePlugin.manifest.importedPackages.add('org.apache.log4j')
		}
		if (projectConfig.eclipsePlugin.pluginXml !== null) {
			projectConfig.eclipsePlugin.pluginXml.entries += grammar.implicitPluginXmlEnties
		}
		
		val StringConcatenationClient expression = ''''org.eclipse.xtext.ui.shared.Access'.typeRef.getJavaProjectsState()'''
		val bindingFactory = new GuiceModuleAccess.BindingFactory()
			.addTypeToProviderInstance(IAllContainersState.typeRef, expression)
		if (inheritsXbase(grammar)) {
			bindingFactory.addTypeToType('org.eclipse.xtext.ui.editor.XtextEditor'.typeRef,
					'org.eclipse.xtext.xbase.ui.editor.XbaseEditor'.typeRef)
				.addTypeToType('org.eclipse.xtext.ui.editor.model.XtextDocumentProvider'.typeRef,<commit_msg>[xtext generator] fine-tuning of '...xtend.lib' dependency addition in 'ImplicitFragment'<commit_after>/*******************************************************************************
 * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.xtext.generator

import com.google.inject.Inject
import org.eclipse.xtend2.lib.StringConcatenationClient
import org.eclipse.xtext.Grammar
import org.eclipse.xtext.resource.containers.IAllContainersState
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
import org.eclipse.xtext.xtext.generator.xbase.XbaseUsageDetector

import static extension org.eclipse.xtext.GrammarUtil.*
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*

package class ImplicitFragment extends AbstractXtextGeneratorFragment {
	
	@Inject extension XbaseUsageDetector
	
	@Inject extension XtextGeneratorNaming naming
	
	@Inject extension CodeConfig
	
	override generate() {
		if (projectConfig.runtime.manifest !== null) {
			projectConfig.runtime.manifest.requiredBundles.addAll(#[
				'org.eclipse.xtext', 'org.eclipse.xtext.util'
			])
			
			if (preferXtendStubs) {
				projectConfig.runtime.manifest.requiredBundles += 'org.eclipse.xtend.lib' 
			}
			
			projectConfig.runtime.manifest.importedPackages.add('org.apache.log4j')
		}
		
		if (projectConfig.eclipsePlugin.manifest !== null) {
			projectConfig.eclipsePlugin.manifest.requiredBundles.addAll(#[
				'org.eclipse.xtext.ui', 'org.eclipse.xtext.ui.shared', 'org.eclipse.ui.editors', 'org.eclipse.ui'
			])
			
			if (preferXtendStubs) {
				projectConfig.eclipsePlugin.manifest.requiredBundles += 'org.eclipse.xtend.lib' 
			}
			
			projectConfig.eclipsePlugin.manifest.importedPackages.add('org.apache.log4j')
		}
		
		if (projectConfig.eclipsePlugin.pluginXml !== null) {
			projectConfig.eclipsePlugin.pluginXml.entries += grammar.implicitPluginXmlEnties
		}
		
		val StringConcatenationClient expression = ''''org.eclipse.xtext.ui.shared.Access'.typeRef.getJavaProjectsState()'''
		val bindingFactory = new GuiceModuleAccess.BindingFactory()
			.addTypeToProviderInstance(IAllContainersState.typeRef, expression)
		if (inheritsXbase(grammar)) {
			bindingFactory.addTypeToType('org.eclipse.xtext.ui.editor.XtextEditor'.typeRef,
					'org.eclipse.xtext.xbase.ui.editor.XbaseEditor'.typeRef)
				.addTypeToType('org.eclipse.xtext.ui.editor.model.XtextDocumentProvider'.typeRef,
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.00421455938697318, 'mean_word_length': 5.477667493796526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2503347', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1510, 'n_words': 242}