<commit_before>package org.ossmeter.platform;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.ossmeter.platform.util.ExtensionPointHelper;

import com.googlecode.pongo.runtime.PongoCollection;

public class ExtensionPointMetricProviderManager implements IMetricProviderManager {
	
	protected List<IMetricProvider> metricProviders;
	protected final String metricProviderExtensionPointId = "org.ossmeter.platform.metricprovider";
	protected final String metricProviderManagerExtensionPointId = "org.ossmeter.platform.managers.metricprovider";

	protected List<? extends PongoCollection> metricCollections = null;
	
	public List<IMetricProvider> getMetricProviders() {
		if (metricProviders == null) { // TODO: This needs some better logic. This will not pick up any MPs added during runtime.
			metricProviders = new ArrayList<IMetricProvider>();
			
			// Load the standard MP extensions
			for(IConfigurationElement configurationElement : ExtensionPointHelper.getConfigurationElementsForExtensionPoint(metricProviderExtensionPointId)){
				try {
					metricProviders.add((IMetricProvider) configurationElement.createExecutableExtension("provider"));
				} catch (CoreException e) {
					e.printStackTrace();
				}
			}
			
			// Load extension points via custom managers 
			System.err.println("Custom Extension Point managers: ");
			for(IConfigurationElement configurationElement : ExtensionPointHelper.getConfigurationElementsForExtensionPoint(metricProviderManagerExtensionPointId)){
				try {
					IMetricProviderManager impm = (IMetricProviderManager) configurationElement.createExecutableExtension("manager");
					System.out.println("\t" + impm.getClass().toString());
					
					//metricProviders.addAll(impm.getMetricProviders()); // FIXME: Commented out whilst determining how to properly resolve rascal URIs
				} catch (CoreException e) {
					e.printStackTrace();
				}
			}
			System.err.println("Registered metric providers: ");
			for (IMetricProvider imp : metricProviders) {<commit_msg>Added the ability for IMetricProviderManagers to register metrics with the platform.<commit_after>package org.ossmeter.platform;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.ossmeter.platform.util.ExtensionPointHelper;

import com.googlecode.pongo.runtime.PongoCollection;

public class ExtensionPointMetricProviderManager implements IMetricProviderManager {
	
	protected List<IMetricProvider> metricProviders;
	protected final String metricProviderExtensionPointId = "org.ossmeter.platform.metricprovider";
	protected final String metricProviderManagerExtensionPointId = "org.ossmeter.platform.managers.metricprovider";

	protected List<? extends PongoCollection> metricCollections = null;
	
	public List<IMetricProvider> getMetricProviders() {
		if (metricProviders == null) { // TODO: This needs some better logic. This will not pick up any MPs added during runtime.
			metricProviders = new ArrayList<IMetricProvider>();
			
			// Load the standard MP extensions
			for(IConfigurationElement configurationElement : ExtensionPointHelper.getConfigurationElementsForExtensionPoint(metricProviderExtensionPointId)){
				try {
					metricProviders.add((IMetricProvider) configurationElement.createExecutableExtension("provider"));
				} catch (CoreException e) {
					e.printStackTrace();
				}
			}
			
			// Load extension points via custom managers 
			System.err.println("Custom Extension Point managers: ");
			for(IConfigurationElement configurationElement : ExtensionPointHelper.getConfigurationElementsForExtensionPoint(metricProviderManagerExtensionPointId)){
				try {
					IMetricProviderManager impm = (IMetricProviderManager) configurationElement.createExecutableExtension("manager");
					System.err.println("\t" + impm.getClass().toString());
					metricProviders.addAll(impm.getMetricProviders());
				} catch (CoreException e) {
					e.printStackTrace();
				}
			}
			System.err.println("Registered metric providers: ");
			for (IMetricProvider imp : metricProviders) {
{'fraction_non_alphanumeric': 0.08605200945626477, 'fraction_numerical': 0.0, 'mean_word_length': 5.631661442006269, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4269338', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1023, 'n_words': 241}