Skip to content
Snippets Groups Projects
Commit 3d2aebe3 authored by Markus Alexander Kuppe's avatar Markus Alexander Kuppe
Browse files

Add type annotation to Vector.

[Refactor][TLC]
parent f63ed6bb
No related branches found
No related tags found
No related merge requests found
......@@ -29,12 +29,11 @@ import pcal.Translator;
/**
* Runs the PCal translator
* @author Simon Zambrovski
* @version $Id$
*/
public class TranslatorJob extends WorkspaceJob
{
private Translator translator;
private Vector callParams;
private Vector<String> callParams;
private IResource fileToBuild;
/**
......@@ -45,7 +44,7 @@ public class TranslatorJob extends WorkspaceJob
super("PCal Translation");
this.translator = new Translator();
this.fileToBuild = fileToBuild;
this.callParams = new Vector();
this.callParams = new Vector<String>();
Activator.getDefault().logDebug("Translating " + fileToBuild.getLocation().toOSString());
......@@ -137,14 +136,14 @@ public class TranslatorJob extends WorkspaceJob
monitor.worked(1);
monitor.setTaskName("Analyzing results");
List errors = translator.getErrorMessages();
List<String> errors = translator.getErrorMessages();
if (errors.size() > 0)
{
monitor.setTaskName("Installing problem markers");
for (int i = 0; i < errors.size(); i++)
{
String errorMessage = (String) errors.get(i);
String errorMessage = errors.get(i);
TLAMarkerHelper.installProblemMarker(fileToBuild, fileToBuild.getName(), IMarker.SEVERITY_ERROR,
detectLocation(errorMessage), errorMessage, monitor,
......@@ -180,7 +179,7 @@ public class TranslatorJob extends WorkspaceJob
};
}
private int[] detectLocation(String message)
private static int[] detectLocation(String message)
{
String LINE = "line ";
String COLUMN = ", column ";
......@@ -219,5 +218,4 @@ public class TranslatorJob extends WorkspaceJob
}
return new int[] { -1, -1, -1, -1 };
}
}
......@@ -64,13 +64,13 @@ public class PCalTLAGenerator
* Note that this requires RemoveNameConflicts to be called first *
* because of the grotty use of the class variable st. *
********************************************************************/
public Vector translate() throws RemoveNameConflictsException
public Vector<String> translate() throws RemoveNameConflictsException
{
Vector result = new Vector();
Vector<String> result = new Vector<String>();
AST xast = null; // Set to the exploded AST
for (int i = 0; i < st.disambiguateReport.size(); i++)
result.addElement(st.disambiguateReport.elementAt(i));
result.addElement((String) st.disambiguateReport.elementAt(i));
// System.out.println("Before: " + ast.toString());
// System.out.println("After renaming: " + ast.toString());
try
......
......@@ -151,11 +151,11 @@ public final class PcalParams
* Default initial value changed to "defaultInitValue" *
* by LL on 22 Aug 2007 *
*********************************************************************/
{ Vector line = new Vector() ;
{ Vector<TLAToken> line = new Vector<TLAToken>() ;
// line.addElement(new TLAToken("{", 0, 0)) ;
// line.addElement(new TLAToken("}", 0, 0)) ;
line.addElement(new TLAToken("defaultInitValue", 0, 0));
Vector vec = new Vector() ;
Vector<Vector<TLAToken>> vec = new Vector<Vector<TLAToken>>() ;
vec.addElement(line) ;
TLAExpr exp = new TLAExpr(vec) ;
exp.normalize() ;
......
......@@ -47,12 +47,12 @@ public class PcalResourceFileReader
inputReader = new BufferedReader(new InputStreamReader(input)) ;
};
public static Vector ResourceFileToStringVector(String fileName) throws PcalResourceFileReaderException
public static Vector<String> ResourceFileToStringVector(String fileName) throws PcalResourceFileReaderException
/***********************************************************************
* Reads file fileName into a StringVector, a vector in which each *
* element is a line of the file. *
***********************************************************************/
{ Vector inputVec = new Vector(100) ;
{ Vector<String> inputVec = new Vector<String>(100) ;
PcalResourceFileReader wordFileReader
= new PcalResourceFileReader(fileName);
......
......@@ -120,10 +120,10 @@ public class PcalTLAGen
* @return A vector of strings.
* @throws PcalTLAGenException
*/
public Vector generate(AST ast, PcalSymTab symtab, Vector report) throws PcalTLAGenException
public Vector<String> generate(AST ast, PcalSymTab symtab, Vector report) throws PcalTLAGenException
{
TLAtoPCalMapping map = PcalParams.tlaPcalMapping;
mappingVector = new Vector(50);
mappingVector = new Vector<String>(50);
/*
* Add the reports of renaming to the output.
*/
......
......@@ -8,7 +8,6 @@ import util.ToolIO;
/**
* Launcher for the PCal Translator for running out-of-the-tool
* @author Simon Zambrovski
* @version $Id$
*/
public class Translator
{
......@@ -38,10 +37,10 @@ public class Translator
* Retrieves the errors recorded during the execution
* @return
*/
public List getErrorMessages()
public List<String> getErrorMessages()
{
String[] messages = ToolIO.getAllMessages();
Vector errorMessages = new Vector();
Vector<String> errorMessages = new Vector<String>();
System.out.println("Found " + messages.length + " messages");
int position;
String cleanMessage = null;
......
......@@ -10,7 +10,6 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;
import pcal.MappingObject.Break;
import pcal.exception.FileToStringVectorException;
import pcal.exception.ParseAlgorithmException;
import pcal.exception.PcalResourceFileReaderException;
......@@ -18,7 +17,6 @@ import pcal.exception.RemoveNameConflictsException;
import pcal.exception.StringVectorToFileException;
import pcal.exception.TLCTranslationException;
import pcal.exception.UnrecoverableException;
import tla2tex.Debug;
import util.ToolIO;
/***************************************************************************
......@@ -358,7 +356,7 @@ class trans
* contents, where inputVec[i] is the string containing the contents *
* of line i+1 of the input file. *
*********************************************************************/
Vector inputVec = null;
Vector<String> inputVec = null;
try
{
inputVec = fileToStringVector(PcalParams.TLAInputFile + /* (PcalParams.fromPcalFile ? ".pcal" : */".tla" /*)*/);
......@@ -374,7 +372,7 @@ class trans
* which was not always the case in the aborted version 1.31. *
*********************************************************************/
// Vector outputVec = PcalParams.fromPcalFile ? new Vector() : inputVec;
Vector outputVec = inputVec;
Vector<String> outputVec = inputVec;
/*********************************************************************
* Set untabInputVec to be the vector of strings obtained from *
......@@ -393,7 +391,7 @@ class trans
* translator are copied from inputVec, so any tabs the user wants *
* are kept. *
*********************************************************************/
Vector untabInputVec = removeTabs(inputVec);
Vector<String> untabInputVec = removeTabs(inputVec);
/**
* Look through the file for PlusCal options. They are put anywhere
......@@ -750,7 +748,7 @@ class trans
* do the translation by calling TLC. Otherwise, call the ordinary *
* Translate method. *
*********************************************************************/
Vector translation = null;
Vector<String> translation = null;
boolean tlcTranslation = PcalParams.SpecOption || PcalParams.MyspecOption || PcalParams.Spec2Option
|| PcalParams.Myspec2Option;
......@@ -864,7 +862,7 @@ class trans
* Write the cfg file, unless the -nocfg option is used. *
*********************************************************************/
File cfgFile = new File(PcalParams.TLAInputFile + ".cfg");
Vector cfg = null;
Vector<String> cfg = null;
boolean writeCfg = !PcalParams.Nocfg;
if (writeCfg && cfgFile.exists())
{
......@@ -889,7 +887,7 @@ class trans
}
} else
{
cfg = new Vector();
cfg = new Vector<String>();
cfg.addElement(PcalParams.CfgFileDelimiter);
}
;
......@@ -1000,6 +998,7 @@ class trans
* If run in the system mode, exits the program, in tool mode returns the status
* @param status
*/
@SuppressWarnings("unused")
private static int exitWithStatus(int status)
{
if (ToolIO.getMode() == ToolIO.SYSTEM)
......@@ -1015,7 +1014,7 @@ class trans
/********************** Writing the AST ************************************/
private static boolean WriteAST(AST ast)
{
Vector astFile = new Vector();
Vector<String> astFile = new Vector<String>();
astFile.addElement("------ MODULE AST -------");
astFile.addElement("EXTENDS TLC");
astFile.addElement("fairness == \"" + PcalParams.FairnessOption + "\"");
......@@ -1037,7 +1036,7 @@ class trans
/************************* THE TLC TRANSLATION *****************************/
private static Vector TLCTranslate(AST ast) throws TLCTranslationException
private static Vector<String> TLCTranslate(AST ast) throws TLCTranslationException
/***********************************************************************
* The result is a translation of the algorithm represented by ast *
* obtained by using TLC to execute the definition of Translation(ast) *
......@@ -1079,7 +1078,7 @@ class trans
{
try
{
Vector parseFile = PcalResourceFileReader.ResourceFileToStringVector(PcalParams.SpecFile + ".tla");
Vector<String> parseFile = PcalResourceFileReader.ResourceFileToStringVector(PcalParams.SpecFile + ".tla");
WriteStringVectorToFile(parseFile, PcalParams.SpecFile + ".tla");
parseFile = PcalResourceFileReader.ResourceFileToStringVector(PcalParams.SpecFile + ".cfg");
......@@ -1235,14 +1234,14 @@ class trans
* Wrap the translated string into approximately 80 character lines *
*******************************************************************/
transl = WrapString(transl, 78);
Vector result = new Vector();
Vector<String> result = new Vector<String>();
result.addElement(transl);
return result;
}
/***************** METHODS FOR READING AND WRITING FILES *****************/
private static void WriteStringVectorToFile(Vector inputVec, String fileName) throws StringVectorToFileException
private static void WriteStringVectorToFile(Vector<String> inputVec, String fileName) throws StringVectorToFileException
/***********************************************************************
* Writes the Vector of strings inputVec to file named fileName, with *
* each element of inputVec written on a new line. *
......@@ -1283,13 +1282,13 @@ class trans
}
private static Vector fileToStringVector(String fileName) throws FileToStringVectorException
private static Vector<String> fileToStringVector(String fileName) throws FileToStringVectorException
/***********************************************************************
* Reads file fileName into a StringVector, a vector in which each *
* element is a line of the file. *
***********************************************************************/
{
Vector inputVec = new Vector(100);
Vector<String> inputVec = new Vector<String>(100);
try
{
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
......@@ -1813,7 +1812,7 @@ class trans
*/
private static boolean OutputHelpMessage()
{
Vector helpVec = null;
Vector<String> helpVec = null;
try
{
helpVec = PcalResourceFileReader.ResourceFileToStringVector("help.txt");
......@@ -1860,7 +1859,7 @@ class trans
return STATUS_EXIT_WITH_ERRORS;
}
private static int findTokenPair(Vector vec, int lineNum, String tok1, String tok2)
private static int findTokenPair(Vector<String> vec, int lineNum, String tok1, String tok2)
/*********************************************************************
* Returns the number of the first line at or after lineNum in the *
* vector of strings vec containing tok1 followed by 1 or more *
......@@ -1870,7 +1869,7 @@ class trans
int i = lineNum;
while (i < vec.size())
{
String line = (String) vec.elementAt(i);
String line = vec.elementAt(i);
int col = line.indexOf(tok1);
int nextcol = col + tok1.length();
if (col != -1)
......@@ -1894,7 +1893,7 @@ class trans
/************************** RemoveTabs *********************************/
public static Vector removeTabs(Vector vec)
public static Vector<String> removeTabs(Vector<String> vec)
{
/********************************************************************
* Returns a string vector obtained from the string vector vec by *
......@@ -1905,7 +1904,7 @@ class trans
* Emacs does when told to remove tabs, which makes it good enough *
* for me. *
********************************************************************/
Vector newVec = new Vector();
Vector<String> newVec = new Vector<String>();
int i = 0;
while (i < vec.size())
{
......
......@@ -198,7 +198,7 @@ public class FileUtil
}
/**
* Atomically replaced the file targetName with the file sourceName.
* Atomically replaces the file targetName with the file sourceName.
* @param sourceName
* @param targetName
* @throws IOException
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment