<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.ui.compare

import com.google.inject.Inject
import org.apache.log4j.Logger
import org.eclipse.xtext.xtext.generator.AbstractGeneratorFragment2
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
import org.eclipse.xtext.xtext.generator.model.TypeReference

import static extension org.eclipse.xtext.GrammarUtil.*

/**
 * Contributes the registration of compare infrastructure. 
 * 
 * @author <NAME> - Initial contribution and API
 */
class CompareFragment2 extends AbstractGeneratorFragment2 {

	private static final Logger log = Logger.getLogger(CompareFragment2);
	
	@Inject
	extension XtextGeneratorNaming

	override generate() {
		if (log.isInfoEnabled()) {
			log.info("generating Compare Framework infrastructure");
		}

		if (projectConfig.eclipsePlugin.manifest != null) {
			projectConfig.eclipsePlugin.manifest.requiredBundles += "org.eclipse.xtext.ui"
		}

		new GuiceModuleAccess.BindingFactory()
				.addTypeToType(
					new TypeReference("org.eclipse.compare.IViewerCreator"),
					new TypeReference("org.eclipse.xtext.ui.compare.DefaultViewerCreator")
				).contributeTo(language.eclipsePluginGenModule);

		if (projectConfig.eclipsePlugin.pluginXml != null) {
			projectConfig.eclipsePlugin.pluginXml.entries += '''
			<extension point="org.eclipse.compare.contentViewers">
				<viewer id="grammar.name.compare.contentViewers"
					class="grammar.eclipsePluginExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
					extensions="language.fileExtensions.join(",")">
				</viewer>
			</extension>
			<extension point="org.eclipse.compare.contentMergeViewers">
				<viewer id="grammar.name.compare.contentMergeViewers"
					class="grammar.eclipsePluginExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
					extensions="language.fileExtensions.join(",")" label="grammar.simpleName Compare">
				</viewer>
			</extension>
			<extension point="org.eclipse.ui.editors.documentProviders">
				<provider id="grammar.name.editors.documentProviders"
					class="grammar.eclipsePluginExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
					extensions="language.fileExtensions.join(",")">
				</provider>
			</extension>
			<extension point="org.eclipse.team.core.fileTypes">
				FOR modelFileExtension : language.fileExtensions
				<fileTypes
					extension="modelFileExtension"
					type="text">
				</fileTypes>
				ENDFOR 
			</extension>
			'''
		}
	}	
}<commit_msg>[xtext generator] added missing dependency addition in 'CompareFragment2'<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.ui.compare

import com.google.inject.Inject
import org.apache.log4j.Logger
import org.eclipse.xtext.xtext.generator.AbstractGeneratorFragment2
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
import org.eclipse.xtext.xtext.generator.model.TypeReference

import static extension org.eclipse.xtext.GrammarUtil.*

/**
 * Contributes the registration of compare infrastructure. 
 * 
 * @author <NAME> - Initial contribution and API
 */
class CompareFragment2 extends AbstractGeneratorFragment2 {

	private static final Logger log = Logger.getLogger(CompareFragment2);
	
	@Inject
	extension XtextGeneratorNaming

	override generate() {
		if (log.isInfoEnabled()) {
			log.info("generating Compare Framework infrastructure");
		}

		if (projectConfig.eclipsePlugin?.manifest != null) {
			projectConfig.eclipsePlugin.manifest.requiredBundles += #[
				"org.eclipse.compare", "org.eclipse.xtext.ui"
			]
		}

		new GuiceModuleAccess.BindingFactory()
				.addTypeToType(
					new TypeReference("org.eclipse.compare.IViewerCreator"),
					new TypeReference("org.eclipse.xtext.ui.compare.DefaultViewerCreator")
				).contributeTo(language.eclipsePluginGenModule);

		if (projectConfig.eclipsePlugin?.pluginXml != null) {
			projectConfig.eclipsePlugin.pluginXml.entries += '''
			<extension point="org.eclipse.compare.contentViewers">
				<viewer id="grammar.name.compare.contentViewers"
					class="grammar.eclipsePluginExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
					extensions="language.fileExtensions.join(",")">
				</viewer>
			</extension>
			<extension point="org.eclipse.compare.contentMergeViewers">
				<viewer id="grammar.name.compare.contentMergeViewers"
					class="grammar.eclipsePluginExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
					extensions="language.fileExtensions.join(",")" label="grammar.simpleName Compare">
				</viewer>
			</extension>
			<extension point="org.eclipse.ui.editors.documentProviders">
				<provider id="grammar.name.editors.documentProviders"
					class="grammar.eclipsePluginExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
					extensions="language.fileExtensions.join(",")">
				</provider>
			</extension>
			<extension point="org.eclipse.team.core.fileTypes">
				FOR modelFileExtension : language.fileExtensions
				<fileTypes
					extension="modelFileExtension"
					type="text">
				</fileTypes>
				ENDFOR 
			</extension>
			'''
		}
	}	
}
{'fraction_non_alphanumeric': 0.15874539926388223, 'fraction_numerical': 0.0043206913106096975, 'mean_word_length': 5.188118811881188, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '1925199', 'n_tokens_mistral': 1971, 'n_tokens_neox': 1696, 'n_words': 296}