oops, wrong directory

cmurphy [2007-12-05 20:24:14]
oops, wrong directory
Filename
testplugin/Compiler.java
testplugin/TestClass.java
testplugin/XMLWriter.java
testplugin/XmlClient.java
diff --git a/testplugin/Compiler.java b/testplugin/Compiler.java
deleted file mode 100644
index 9ab9532..0000000
--- a/testplugin/Compiler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package testplugin.actions;
-
-/**
- *
- * TODO: why does the "carat" not get put in the write place when writing to the console?
- */
-
-import java.util.Calendar;
-import java.util.Date;
-import java.io.File;
-import com.sun.tools.javac.Main;
-
-//import javax.sql.rowset.spi.XmlReader;
-import javax.swing.JOptionPane;
-import java.io.PrintWriter;
-
-public class Compiler {
-	public static String compileFile(String javaFile, String displayName)
-	{
-		XMLWriter out = null;
-		//int status = -1;
-		String errors = null;
-
-		String outputFile = null;
-
-		try
-		{
-			// create the output file
-
-			Calendar now = Calendar.getInstance();
-			now.setTime(new Date());
-			outputFile = System.getProperty("user.name") + "-" + displayName + "-" + (now.get(Calendar.MONTH)+1) + "-" +  now.get(Calendar.DAY_OF_MONTH) + "-" +  now.get(Calendar.HOUR_OF_DAY) + "-" + now.get(Calendar.MINUTE) + "-" + now.get(Calendar.SECOND) + ".xml";
-
-			//JOptionPane.showMessageDialog(null, "output is" + outputFile);
-			File file = new File(outputFile);
-			out = new XMLWriter(file);
-
-			// write the header
-			out.writeHeader();
-
-			// create the arguments necessary for compilation.
-			String[] args = new String[1];
-			args[0] = javaFile;
-			//JOptionPane.showMessageDialog(null, "about to compile " + javaFile);
-			// do the compilation
-			//Main javac = new Main();
-			Main.compile(args, out);
-			errors = out.getErrors();
-			if (errors == null || errors.equals(""))
-				JOptionPane.showMessageDialog(null, "Compiled " + displayName + " successfully.");
-			else
-				JOptionPane.showMessageDialog(null, "Errors occurred while compiling " + displayName + ". See below.");
-
-			//System.out.println(status);
-			//JOptionPane.showMessageDialog(null, "errors: " + errors);
-			// write the footer
-			out.writeFooter();
-
-		}
-		catch (Throwable e)
-		{
-			e.printStackTrace();
-			errors = "Entered catch. Error at " + e.getMessage() + " cause:" + e.getCause();
-			JOptionPane.showMessageDialog(null, "An unexpected error occurred " + e.getMessage() + e.toString());
-		}
-		finally
-		{
-			try { out.flush(); } catch (Exception e) { }
-			try { out.close(); } catch (Exception e) { }
-		}
-
-		// now send the file to where it needs to go
-		try
-		{
-			XmlClient client = new XmlClient("localhost", 1234);
-			if (client != null) client.readAndSendFile(outputFile);
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-		}
-
-		return(errors);
-	}
-
-
-
-	public static void main(String[] args)
-	{
-		Compiler.compileFile("D:/Retina/Eclipse plugin/src/testplugin/actions/TestClass.java", "TestClass.java");
-	}
-}
diff --git a/testplugin/TestClass.java b/testplugin/TestClass.java
deleted file mode 100644
index 63787ba..0000000
--- a/testplugin/TestClass.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package testplugin.actions;
-
-public class TestClass {
-
-	public static void main(String[] args)
-	{
-		int x = 4;
-		x = -9;
-		System.out.println("hello");
-
-		int e = 4
-	}
-	public int e = 3;
-
-}
diff --git a/testplugin/XMLWriter.java b/testplugin/XMLWriter.java
deleted file mode 100644
index b38fe30..0000000
--- a/testplugin/XMLWriter.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Writes out to the XML file.
- *
- * @author - Chris Murphy
- */
-package testplugin.actions;
-
-import java.io.*;
-import java.util.Calendar;
-import java.util.Date;
-
-public class XMLWriter extends PrintWriter {
-	StringBuffer errorBfr;
-	public XMLWriter(File file) throws FileNotFoundException
-    {
-	super(file);
-	errorBfr = new StringBuffer();
-    }
-
-	/**
-	 * Getter
-	 * @return a string containing all the errors encountered.
-	 */
-	public String getErrors() {
-		return(errorBfr.toString());
-	}
-
-	// whether or not we're currently writing out an error message
-    private boolean writing = false;
-
-    // a counter to use when we're skipping lines
-    private int counter = 0;
-
-	/**
-	 * Writes to the xml file
-	 * @params s the string to be written to the file
-	 */
-    public void println(String s)
-    {
-	// TODO: how do we know which line to write?
-	if (s.contains(".java:"))
-	{
-		// this is kind of a hack but we want to extract the name of the file and such and just get the error
-		// we're assuming that the error message starts after the third colon (but only on Windows!!!)
-		int index = s.indexOf(':');
-		String error = s.substring(index+1);
-		index = error.indexOf(':');
-		error = error.substring(index+1);
-		index = error.indexOf(':');
-		error = error.substring(index+1).trim();
-		//System.out.println(error);
-
-		// if it's a problem with something already being defined, just extract that
-		if (error.contains("already defined")) error = "already defined";
-		// if they're trying to access a non-static thing from a static method
-		else if (error.contains("static context"))
-		{
-			if (error.contains("non-static method")) error = "non-static method cannot be referenced from a static context";
-			else if (error.contains("non-static variable")) error = "non-static variable cannot be referenced from a static context";
-		}
-
-
-		// this is where we write the actual error message
-	    super.println("\n\t\t<measure name=\"errors\">");
-	    super.println("\t\t\t<error>");
-	    super.println("\t\t\t\t" + error);
-	    super.println("\t\t\t</error>");
-
-	    // indicate that we're currently writing an error
-	    writing = true;
-
-	    // to skip two lines when there's an unexpected type... this will print the line of code
-	    if (error.equals("unexpected type")) counter = 2;
-
-	}
-	else if (writing)
-	{
-		if (counter == 0)
-		{
-			// now we write the message itself
-			super.println("\t\t\t<message>");
-			super.println("\t\t\t\t" + s);
-			super.println("\t\t\t</message>");
-			super.println("\t\t</measure>");
-			// and we're done
-			writing = false;
-		}
-		else
-			counter--;
-	}
-
-	// we want EVERYTHING printed to the view.
-	errorBfr.append(s);
-	errorBfr.append(System.getProperty("line.separator"));
-	//System.out.println(s);
-    }
-
-    /**
-     * Writes a header to the XML file.
-     *
-     */
-    public void writeHeader()
-    {
-	super.println("<measurements>");
-	super.println("\t<metric name=\"compilation_errors\" measure=\"true\">");
-	super.println("\t\t<user name=\"" + System.getProperty("user.name") + "\"/>");
-	super.println("\t\t<time>");
-	Calendar now = Calendar.getInstance();
-	now.setTime(new Date());
-	super.println("\t\t\t<year>" + now.get(Calendar.YEAR) + "</year>");
-	super.println("\t\t\t<month>" + (now.get(Calendar.MONTH)+1) + "</month>");
-	super.println("\t\t\t<day>" + now.get(Calendar.DAY_OF_MONTH) + "</day>");
-	super.println("\t\t\t<hour>" + now.get(Calendar.HOUR_OF_DAY) + "</hour>");
-	super.println("\t\t\t<minute>" + now.get(Calendar.MINUTE) + "</minute>");
-	super.println("\t\t\t<second>" + now.get(Calendar.SECOND) + "</second>");
-	super.println("\t\t</time>");
-    }
-
-    /**
-     * Writes a footer to the XML file.
-     *
-     */
-    public void writeFooter()
-    {
-	super.println("\n\t</metric>");
-	super.println("</measurements>");
-    }
-}
diff --git a/testplugin/XmlClient.java b/testplugin/XmlClient.java
deleted file mode 100644
index 4f7d419..0000000
--- a/testplugin/XmlClient.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package testplugin.actions;
-
-/**
- * TODO: why does the error popup not appear when it can't connect to the server?
- * TODO: handle errors more gracefully if something happens while reading/sending the file
- */
-
-import java.io.*;
-import java.net.*;
-import java.util.Scanner;
-
-import javax.swing.JOptionPane;
-
-public class XmlClient
-{
-    // the output stream for writing to the server
-    private PrintWriter out;
-
-    /**
-     * Creates a new object, which connects to the server
-     */
-    public XmlClient(String host, int port)
-    {
-		try
-		{
-		    Socket connect = new Socket(host, port);
-
-		    // get the output stream
-		    out = new PrintWriter(connect.getOutputStream());
-		}
-		catch (Exception e)
-		{
-		    System.out.println("Cannot create XmlClient!");
-			JOptionPane.showMessageDialog(null, "An unexpected error occurred " + e.getMessage() + e.toString());
-		    e.printStackTrace();
-		}
-    }
-
-
-    /**
-     * Reads the file from the disk and then sends it to the server
-     * @param filename the full path to the file to send to the server
-     */
-    public void readAndSendFile(String filename)
-    {
-		try
-		{
-		    // create a File object
-		    File file = new File(filename);
-
-		    // create a Scanner
-		    Scanner scan = new Scanner(file);
-
-			// this is the string we'll send to the server
-			// it starts with the filename in the first line
-		   	String fileContent=filename;
-
-		    // keep looping as long as there is something to read
-		    while (scan.hasNext())
-		    {
-				// read one line of the file
-				String line = scan.nextLine();
-
-				// append the lines read from the file together
-				//System.out.println(line);
-
-				fileContent = fileContent + "\n" + line;
-		    }
-
-		    //signifies we're done reading the file
-		    String line = "END";
-		    fileContent = fileContent + "\n" + line;
-
-			// now write the contents of the file to the network connection
-			//System.out.println(fileContent);
-			out.write(fileContent + "\n");
-			out.flush();
-		}
-		catch (FileNotFoundException e)
-		{
-		    System.out.println("That file doesn't exist");
-		}
-		catch (Exception e)
-		{
-		    e.printStackTrace();
-		}
-		finally
-		{
-			try { out.close(); } catch (Exception e) { }
-		}
-
-    }
-
-    /*
-     * The main method of the client - for running it as a standalone app only
-     *
-     */
-    public static void main(String[] args)
-    {
-		if (args.length < 3)
-		{
-		    System.out.println("Please specify the host name, port number and file name!");
-		    System.exit(0);
-		}
-
-		String host = args[0];
-		int port = Integer.parseInt(args[1]);
-		XmlClient xc = new XmlClient(host, port);
-		String filename = args[2];
-	    xc.readAndSendFile(filename);
-    }
-
-
-}