make sure no debug information is lost from the Rascal interpreter by logging it all with log4j

Jurgen J. Vinju Jurgen J. Vinju 2014-06-17

added platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/LoggerWriter.java
changed platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/RascalManager.java
changed platform/org.ossmeter.code.model/org.ossmeter.code.model.java/src/Java.rsc
copied platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/OSSMeterURIResolver.java -> platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/RascalMonitor.java
platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/LoggerWriter.java Diff Switch to side-by-side view
Loading...
platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/RascalManager.java Diff Switch to side-by-side view
Loading...
platform/org.ossmeter.code.model/org.ossmeter.code.model.java/src/Java.rsc Diff Switch to side-by-side view
Loading...
platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/OSSMeterURIResolver.java to platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/RascalMonitor.java
--- a/platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/OSSMeterURIResolver.java
+++ b/platform-extensions/org.ossmeter.platform.metricmanager.rascal/src/org/ossmeter/metricprovider/rascal/RascalMonitor.java
@@ -1,109 +1,64 @@
 package org.ossmeter.metricprovider.rascal;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
+import org.eclipse.imp.pdb.facts.ISourceLocation;
+import org.ossmeter.platform.logging.OssmeterLogger;
+import org.rascalmpl.interpreter.IRascalMonitor;
 
-import org.rascalmpl.uri.IURIInputOutputResolver;
+public class RascalMonitor implements IRascalMonitor {
+	private final OssmeterLogger log;
 
-public class OSSMeterURIResolver implements IURIInputOutputResolver{
-	private Map<String, File> projectsMap = new HashMap<>();
-
-	public void addProject(String projectName, File localStorage) {
-		projectsMap.put(projectName, localStorage);
-	}
-	
-	private File getFile(URI uri) throws IOException {
-		if (projectsMap.containsKey(uri.getAuthority())) {
-			return projectsMap.get(uri.getAuthority());
-		}
-		throw new FileNotFoundException(uri.toString());
+	public RascalMonitor(OssmeterLogger log) {
+		this.log = log;
 	}
 	
 	@Override
-	public InputStream getInputStream(URI uri) throws IOException {
-		return new FileInputStream(getFile(uri));
-	}
-
-//	@Override
-	public Charset getCharset(URI uri) throws IOException {
-		return null;
+	public void startJob(String name) {
+		log.info(name);
 	}
 
 	@Override
-	public boolean exists(URI uri) {
-		try {
-			return getFile(uri).exists();
-		} catch (IOException e) {
-			return false;
-		}
+	public void startJob(String name, int totalWork) {
+		log.info(name);
 	}
 
 	@Override
-	public long lastModified(URI uri) throws IOException {
-		return getFile(uri).lastModified();
+	public void startJob(String name, int workShare, int totalWork) {
+		log.info(name);
 	}
 
 	@Override
-	public boolean isDirectory(URI uri) {
-		try {
-			return getFile(uri).isDirectory();
-		} catch (IOException e) {
-			return false;
-		}
+	public void event(String name) {
+		log.info("\t" + name);
+
 	}
 
 	@Override
-	public boolean isFile(URI uri) {
-		try {
-			return getFile(uri).isFile();
-		} catch (IOException e) {
-			return false;
-		}
+	public void event(String name, int inc) {
+		log.info("\t" + name);
 	}
 
 	@Override
-	public String[] listEntries(URI uri) throws IOException {
-		return getFile(uri).list();
+	public void event(int inc) {
+		log.info("\tworked");
 	}
 
 	@Override
-	public String scheme() {
-		return "ossm";
+	public int endJob(boolean succeeded) {
+		return 1;
 	}
 
 	@Override
-	public boolean supportsHost() {
+	public boolean isCanceled() {
 		return false;
 	}
 
 	@Override
-	public OutputStream getOutputStream(URI uri, boolean append)
-			throws IOException {
-		return new FileOutputStream(getFile(uri));
-	}
-
-	public void remove(URI uri) throws IOException {
-	  getFile(uri).delete();
-	}
-	
-	@Override
-	public void mkDirectory(URI uri) throws IOException {
-		getFile(uri).mkdir();
+	public void todo(int work) {
 	}
 
 	@Override
-	public URI getResourceURI(URI uri) throws IOException {
-		return getFile(uri).toURI();
+	public void warning(String message, ISourceLocation src) {
+		log.warn( message + " at " + src);
 	}
 
 }
-