Procházet zdrojové kódy

Remove dead code brought up by the main method removal and fix visibility

Timur Sağlam před 5 roky
rodič
revize
a9f94482ed

+ 0 - 1
jplag.frontend-utils/src/main/java/jplag/InputState.java

@@ -14,7 +14,6 @@ public class InputState extends LexerSharedInputState {
     public int column = 0;
     public int tokColumn = 0;
 
-    // public int guessing = 0;
     public InputState(InputBuffer inbuf) {
         super(inbuf);
         column = 1;

+ 4 - 4
jplag.frontend-utils/src/main/java/jplag/ParserToken.java

@@ -4,23 +4,23 @@ public class ParserToken extends antlr.Token {
     /**
      * This variable holds the line number of the current token.
      */
-    protected int _line = -1;
+    private int _line = -1;
 
     /**
      * This variable holds the column of the current token in its line.
      */
-    protected int _column = -1;
+    private int _column = -1;
 
     /**
      * This variable holds the label of the current token.
      */
-    protected String _text = null;
+    private String _text = null;
 
     /**
      * This variable holds the identifier of the current token.
      */
 
-    protected int _id = -1;
+    private int _id = -1;
 
     public ParserToken() {
         super();

+ 0 - 22
jplag.frontend-utils/src/main/java/jplag/StrippedProgram.java

@@ -1,22 +0,0 @@
-package jplag;
-
-/**
- * This is a stripped version of the JPlag main class Program to be used during front end development only.
- */
-public class StrippedProgram implements ProgramI {
-    @Override
-    public void addError(String errorMsg) {
-        System.err.println(errorMsg);
-    }
-
-    @Override
-    public void print(String normalMsg, String longMsg) {
-        if (longMsg != null) {
-            System.out.println(longMsg);
-        } else if (normalMsg != null) {
-            System.out.println(normalMsg);
-        } else {
-            System.out.println("Someboy messed up - no message given");
-        }
-    }
-}

+ 2 - 59
jplag.frontend-utils/src/main/java/jplag/Structure.java

@@ -1,32 +1,23 @@
 package jplag;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
 /** The tokenlist */ // TODO PB: The name 'Structure' is very generic and should be changed to something more descriptive.
 public class Structure implements TokenConstants {
     public Token[] tokens = new Token[0];
     Table table = null;
     int hash_length = -1;
 
-    int files; // number of END_FILE tokens
     private int numberOfTokens;
 
     public Structure() {
         tokens = new Token[400];
-        files = numberOfTokens = 0;
+        numberOfTokens = 0;
     }
 
     public final int size() {
         return numberOfTokens;
     }
 
-    public final void ensureCapacity(int minCapacity) {
+   private final void ensureCapacity(int minCapacity) {
         int oldCapacity = tokens.length;
         if (minCapacity > oldCapacity) {
             Token[] oldTokens = tokens;
@@ -48,8 +39,6 @@ public class Structure implements TokenConstants {
         // just to make sure
 
         tokens[numberOfTokens++] = token;
-        if (token.type == FILE_END)
-            files++;
     }
 
     @Override
@@ -70,50 +59,4 @@ public class Structure implements TokenConstants {
         }
         return buffer.toString();
     }
-
-    public void save(File file) {
-
-        try {
-            ObjectOutputStream input = new ObjectOutputStream((new FileOutputStream(file)));
-
-            input.writeInt(numberOfTokens);
-            input.writeInt(hash_length);
-            input.writeInt(files);
-
-            for (int i = 0; i < numberOfTokens; i++)
-                input.writeObject(tokens[i]);
-            input.flush();
-            input.close();
-        } catch (IOException e) {
-            System.out.println("Error writing file: " + file.toString());
-        }
-    }
-
-    /* returns "true" when successful */
-    public boolean load(File file) {
-        try {
-            ObjectInputStream input = new ObjectInputStream((new FileInputStream(file)));
-
-            int newNumberOfTokens = input.readInt();
-            hash_length = input.readInt();
-            files = input.readInt();
-            ensureCapacity(newNumberOfTokens);
-            numberOfTokens = newNumberOfTokens;
-            for (int i = 0; i < numberOfTokens; i++) {
-                tokens[i] = (Token) input.readObject();
-            }
-            input.close();
-            table = null;
-        } catch (FileNotFoundException e) {
-            System.out.println("File not found: " + file.toString());
-            return false;
-        } catch (IOException e) {
-            System.out.println("Error reading file: " + file.toString() + " (" + e + ")");
-            return false;
-        } catch (ClassNotFoundException e) {
-            System.out.println("Class not found in file: " + file.toString());
-            return false;
-        }
-        return true;
-    }
 }

+ 0 - 8
jplag.frontend-utils/src/main/java/jplag/Table.java

@@ -137,12 +137,4 @@ public class Table { // TODO TS: We need to deal with this abomination.
             System.arraycopy(oldData, 0, data[index], 0, oldData.length);
         }
     }
-
-    public final void count_dist(int[] dist) {
-        for (int i = 0; i < size; i++)
-            if (data[i] == null)
-                dist[0]++;
-            else
-                dist[(data[i][0] < dist.length ? data[i][0] : dist.length - 1)]++;
-    }
 }

+ 4 - 4
jplag.frontend-utils/src/main/java/jplag/UnicodeReader.java

@@ -34,11 +34,11 @@ import java.io.Reader;
  * </pre>
  */
 public class UnicodeReader extends Reader {
-    PushbackInputStream internalIn;
+    private PushbackInputStream internalIn;
 
-    InputStreamReader internalIn2 = null;
+    private InputStreamReader internalIn2 = null;
 
-    String defaultEnc;
+    private String defaultEnc;
 
     private static final int BOM_SIZE = 4;
 
@@ -60,7 +60,7 @@ public class UnicodeReader extends Reader {
     /**
      * Read-ahead four bytes and check for BOM marks. Extra bytes are unread back to the stream, only BOM bytes are skipped.
      */
-    protected void init() throws IOException {
+    private void init() throws IOException {
         if (internalIn2 != null)
             return;
 

+ 0 - 4
jplag.frontend.chars/src/main/java/jplag/chars/CharToken.java

@@ -28,9 +28,5 @@ public class CharToken extends jplag.Token {
 	@Override
     public int getIndex() { return index; }
 
-	public static String type2string(int type, Parser parser) {
-		return "" + parser.reverseMapping(type);
-	}
-
 	public static int numberOfTokens() { return 36;	}
 }

+ 1 - 1
jplag.frontend.chars/src/main/java/jplag/chars/Parser.java

@@ -28,7 +28,7 @@ public class Parser extends jplag.Parser implements jplag.TokenConstants {
 		return struct;
 	}
 
-	public boolean parseFile(File dir, String file) {
+	private boolean parseFile(File dir, String file) {
 		char[] buffer = new char[4096];
 		int type;
 		int length;

+ 1 - 3
jplag.frontend.csharp-1.2/src/main/java/jplag/csharp/Parser.java

@@ -50,14 +50,12 @@ public class Parser extends jplag.Parser implements CSharpTokenConstants {
 		return true;
 	}
 
-	public void add(int type, antlr.Token tok) {
+	private void add(int type, antlr.Token tok) {
 		if (tok == null) {
 			System.out.println("tok == null  ERROR!");
 			return;
 		}
 		struct.addToken(new CSharpToken(type, currentFile, tok.getLine(), tok.getColumn(), tok.getText().length()));
-		//     System.out.println("type: " + CSharpToken.type2string(type) +
-		// 		       " text: '"+tok.getText()+"'");
 	}
 
 	public void add(int type, CSharpParser p) {

+ 1 - 1
jplag.frontend.java-1.2/src/main/java/jplag/java/Parser.java

@@ -27,7 +27,7 @@ public class Parser extends jplag.Parser implements JavaTokenConstants {
 		return struct;
 	}
 
-	public boolean parseFile(File dir, String file) {
+	private boolean parseFile(File dir, String file) {
 		InputState inputState = null;
 		try {
 			FileInputStream fis = new FileInputStream(new File(dir, file));

+ 1 - 1
jplag.frontend.python-3/src/main/java/jplag/python3/Parser.java

@@ -36,7 +36,7 @@ public class Parser extends jplag.Parser implements Python3TokenConstants {
         return struct;
     }
 
-    public boolean parseFile(File dir, String file) {
+    private boolean parseFile(File dir, String file) {
         BufferedInputStream fis;
 
         CharStream input;