added files

git-svn-id: https://svn.cs.york.ac.uk/svn/ossmeter/Software/source@955 1b171192-1bc4-4300-84b6-1b6fde2e8ce3

a.shahi@cwi.nl a.shahi@cwi.nl 2014-03-05

added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CCData.java
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CC.ecore
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CCDataCollection.java
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CC.emf
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CC.java
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalProjectDeltas.java
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalMetricProvider.java
added metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/MetricProvider.rsc
added metric-providers/org.ossmeter.metricprovider.rascal/schema/ossmeter.rascal.metricprovider.exsd
copied metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalMetricServiceTracker.java -> metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalBundleManifest.java
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CCData.java Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CC.ecore Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CCDataCollection.java Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CC.emf Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/metric/trans/model/CC.java Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalProjectDeltas.java Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalMetricProvider.java Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/MetricProvider.rsc Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/schema/ossmeter.rascal.metricprovider.exsd Diff Switch to side-by-side view
Loading...
metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalMetricServiceTracker.java to metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalBundleManifest.java
--- a/metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalMetricServiceTracker.java
+++ b/metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalBundleManifest.java
@@ -1,51 +1,49 @@
 package org.ossmeter.metricprovider.rascal;
 
-import java.util.ArrayList;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 import java.util.List;
 
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-import org.ossmeter.platform.IMetricProvider;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.osgi.framework.Bundle;
+import org.rascalmpl.interpreter.utils.RascalManifest;
 
-public class RascalMetricServiceTracker implements ServiceTrackerCustomizer<IMetricProvider, IMetricProvider> {
+/**
+ * See @link {@link RascalManifest}. This class adds support for OSGI bundles.
+ */
+public class RascalBundleManifest extends RascalManifest {
 
-	private static RascalMetricServiceTracker instance;
-	
-	List<IMetricProvider> metricProviders;
-	
-	// To prevent instantiation
-	private RascalMetricServiceTracker() {
-		metricProviders = new ArrayList<IMetricProvider>();
-	}
-	
-	public List<IMetricProvider> getRegisteredRascalMetrics() {
-		return metricProviders;
-	}
-	
-	@Override
-	public IMetricProvider addingService(ServiceReference<IMetricProvider> reference) {
+  public List<String> getSourceRoots(Bundle project) {
+    return getSourceRoots(manifest(project));
+  }
+  
+  public String getMainModule(Bundle project) {
+    return getMainModule(manifest(project));
+  }
+  
+  public String getMainFunction(Bundle project) {
+    return getMainFunction(manifest(project));
+  }
+  
+  private InputStream manifest(Bundle bundle) {
+    URL rascalMF = bundle.getResource(META_INF_RASCAL_MF);
 
-		IMetricProvider metric = Rasctivator.getContext().getService(reference);
-		metricProviders.add(metric);
-		
-		return metric;
-	}
+    try {
+      if (rascalMF != null) {
+        return FileLocator.openStream(bundle, new Path(META_INF_RASCAL_MF), false);
+      }
+    }
+    catch (IOException e) {
+      // do nothing, it's expected that some bundles do not have RASCAL.MF files
+    }
+    
+    return null;
+  }
+  
+  public boolean hasManifest(Bundle bundle) {
+    return hasManifest(manifest(bundle));
+  }
+}
 
-	@Override
-	public void modifiedService(ServiceReference<IMetricProvider> reference, IMetricProvider service) {
-		// TODO Nothing to do?
-	}
-
-	@Override
-	public void removedService(ServiceReference<IMetricProvider> reference, IMetricProvider service) {
-		metricProviders.remove(service);
-	}
-
-	public static RascalMetricServiceTracker getInstance() {
-		if (instance == null) {
-			instance = new RascalMetricServiceTracker();
-		}
-			
-		return instance;
-	}
-}