mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 23:45:17 -04:00
added test for unused language keys and removed 4 unused language keys
This commit is contained in:
parent
c7a8c9a1ad
commit
03c447b3ee
@ -253,7 +253,6 @@ public class ObservableValue extends Observable implements PinDescription {
|
||||
return bidirectional;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
if (description != null)
|
||||
@ -262,16 +261,6 @@ public class ObservableValue extends Observable implements PinDescription {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of this value.
|
||||
*
|
||||
* @param descriptionKey the descriptions key
|
||||
* @return this for call chaining
|
||||
*/
|
||||
public ObservableValue setDescriptionKey(String descriptionKey) {
|
||||
return setDescription(Lang.get(descriptionKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description of this value.
|
||||
*
|
||||
|
@ -47,8 +47,8 @@ public class Add extends Node implements Element {
|
||||
bits = attributes.get(Keys.BITS);
|
||||
this.mask = 1 << bits;
|
||||
|
||||
this.sum = new ObservableValue("s", bits).setDescriptionKey("elem_Add_output");
|
||||
this.cOut = new ObservableValue("c_o", 1).setDescriptionKey("elem_Add_carryOut");
|
||||
this.sum = new ObservableValue("s", bits).setDescription(Lang.get("elem_Add_output"));
|
||||
this.cOut = new ObservableValue("c_o", 1).setDescription(Lang.get("elem_Add_carryOut"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,6 +63,7 @@ public class ElementTypeDescription {
|
||||
public ElementTypeDescription(String name, ElementFactory elementFactory, PinDescription... inputPins) {
|
||||
this.name = name;
|
||||
this.shortName = null;
|
||||
this.description = Lang.getNull("elem_" + name + "_tt");
|
||||
String n = Lang.getNull("elem_" + name);
|
||||
if (n != null) this.translatedName = n;
|
||||
else this.translatedName = name;
|
||||
|
@ -16,7 +16,6 @@
|
||||
<string name="btn_create_tt">Erzeugt eine Schaltung in einem eigenen Fenster.</string>
|
||||
<string name="btn_editDetached">Permanent Bearbeiten</string>
|
||||
<string name="btn_editDetached_tt">Öffnet den Bearbeitendialog nicht modal.</string>
|
||||
<string name="apply">Übernehmen</string>
|
||||
<string name="cancel">Abbrechen</string>
|
||||
<string name="digital">Digital</string>
|
||||
<string name="expression">Ausdruck</string>
|
||||
@ -139,7 +138,6 @@ in der Stabilisierungsphase befindet. Hat sich die Schaltung stabilisiert wird d
|
||||
<string name="err_burnError">Es sind mehrere zusammengeschaltete Ausgänge gleichzeitig aktiv</string>
|
||||
<string name="err_cannotAnalyse_N">Element {0} kann nicht analysiert werden.</string>
|
||||
<string name="err_containsVarAndNotVar">Enthält [var] und [nicht var]</string>
|
||||
<string name="err_duplicateElement_N">Doppeltes Element {0}</string>
|
||||
<string name="err_duplicatePinLabel">Pin {0} in Element {1} exitiert mehrfach</string>
|
||||
<string name="err_element_N_notFound">Element {0} nicht gefunden</string>
|
||||
<string name="err_exact_N0_valuesNecessaryNot_N1">Es sind {0} Variablen erforderlich, nicht {1}</string>
|
||||
@ -185,7 +183,6 @@ Zur Analyse können Sie die Schaltung im Gatterschrittmodus ausführen.</string>
|
||||
<string name="err_varNotDefined_N">Variable {0} ist nicht definiert.</string>
|
||||
<string name="err_parserUnexpectedToken_N">Unerwartetes Zeichen {0}</string>
|
||||
<string name="err_parserMissingClosedParenthesis">Fehlende schließende Klammer</string>
|
||||
<string name="err_parserUnexpectedEndOfExpression">Unerwartetes Ende des Ausdrucks</string>
|
||||
<string name="err_notANumber_N0_inLine_N1">Wert {0} in Zeile {1} ist keine Zahl!</string>
|
||||
<string name="err_testDataExpected_N0_found_N1_numbersInLine_N2">Erwarte {0} anstelle von {1} Werten in Zeile {2}!</string>
|
||||
<string name="err_signal_N_notInTestVector">Signal {0} ist im Testvektor nicht vorhanden!</string>
|
||||
@ -382,7 +379,6 @@ Die Icons stammen aus dem Tango Desktop Project.</string>
|
||||
<string name="msg_errorEditingValue">Fehler bei der Eingabe eines Wertes</string>
|
||||
<string name="msg_errorImportingModel">Fehler beim Import einer Schaltung</string>
|
||||
<string name="msg_errorReadingFile">Fehler beim Lesen einer Datei</string>
|
||||
<string name="msg_errorFileNotFound">Die Datei {0} wurde nicht gefunden!</string>
|
||||
<string name="msg_remoteUnknownCommand">Das Kommando {0} ist unbekannt!</string>
|
||||
<string name="msg_errorReadingListing_N0">Fehler beim Laden des Listings {0}</string>
|
||||
<string name="msg_errorWritingFile">Fehler beim Schreiben einer Datei</string>
|
||||
|
@ -16,7 +16,6 @@
|
||||
<string name="btn_create_tt">Create a circuit in a seperate window</string>
|
||||
<string name="btn_editDetached">Edit detached</string>
|
||||
<string name="btn_editDetached_tt">Opens the dialog as a non modal dialog</string>
|
||||
<string name="apply">apply</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="digital">Digital</string>
|
||||
<string name="expression">Expression</string>
|
||||
@ -139,7 +138,6 @@ The terminal opens its own window.</string>
|
||||
<string name="err_burnError">More then one output is active on a wire</string>
|
||||
<string name="err_cannotAnalyse_N">Cannot analyse Node {0}</string>
|
||||
<string name="err_containsVarAndNotVar">Contains [var] and [not var]</string>
|
||||
<string name="err_duplicateElement_N">Duplicate component {0}</string>
|
||||
<string name="err_duplicatePinLabel">Pin {0} in component {1} exists twice</string>
|
||||
<string name="err_element_N_notFound">Component {0} not found</string>
|
||||
<string name="err_exact_N0_valuesNecessaryNot_N1">Exact {0} variables necessary, not {1}</string>
|
||||
@ -185,7 +183,6 @@ To analyse you can run the circuit in single gate step mode.</string>
|
||||
<string name="err_varNotDefined_N">Variable {0} not defined</string>
|
||||
<string name="err_parserUnexpectedToken_N">Unexpected Token {0}</string>
|
||||
<string name="err_parserMissingClosedParenthesis">Missing closed parenthesis</string>
|
||||
<string name="err_parserUnexpectedEndOfExpression">Unexpected end of expression</string>
|
||||
<string name="err_notANumber_N0_inLine_N1">Value {0} in line {1} is not a number!</string>
|
||||
<string name="err_testDataExpected_N0_found_N1_numbersInLine_N2">Expected {0} but found {1} values in line {2}!</string>
|
||||
<string name="err_signal_N_notInTestVector">Signal {0} is not present in test vector!</string>
|
||||
@ -395,7 +392,6 @@ The icons are taken from the Tango Desktop Project.</string>
|
||||
<string name="msg_restartNeeded">Change needs a restart to take effect!</string>
|
||||
<string name="msg_noRomFound">No ROM found! ROM needs to be set to be program memory.</string>
|
||||
<string name="msg_moreThenOneRomFound">More then one ROM found! Only one ROM must be set to be program memory.</string>
|
||||
<string name="msg_errorFileNotFound">Could not find file: {0}</string>
|
||||
<string name="msg_remoteUnknownCommand">Command {0} unknown!</string>
|
||||
<string name="msg_enterAnExpression">Enter an expression:</string>
|
||||
<string name="msg_runningTestError">Error running the tests:</string>
|
||||
|
@ -48,19 +48,32 @@ public class TestLang extends TestCase {
|
||||
System.out.println("Try to use hardcoded " + SOURCEPATH);
|
||||
sources = SOURCEPATH;
|
||||
}
|
||||
HashSet<String> keys = new HashSet<>();
|
||||
parseTree(new File(sources), keys);
|
||||
|
||||
parseTree(new File(sources));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String key : map.keySet()) {
|
||||
if (!keys.contains(key)) {
|
||||
if (!(key.startsWith("key_") || key.startsWith("elem_"))) {
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
sb.append('"').append(key).append('"');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sb.length()>0)
|
||||
fail("there are unused language keys: "+sb.toString());
|
||||
}
|
||||
|
||||
private void parseTree(File file) throws IOException {
|
||||
private void parseTree(File file, HashSet<String> keys) throws IOException {
|
||||
File[] files = file.listFiles();
|
||||
if (files != null)
|
||||
for (File f : files) {
|
||||
if (f.isDirectory() && f.getName().charAt(0) != '.')
|
||||
parseTree(f);
|
||||
parseTree(f, keys);
|
||||
if (f.isFile() && f.getName().endsWith(".java")) {
|
||||
try {
|
||||
checkSourceFile(f);
|
||||
checkSourceFile(f, keys);
|
||||
} catch (AssertionFailedError e) {
|
||||
throw new AssertionFailedError(e.getMessage() + " in file " + f);
|
||||
}
|
||||
@ -68,14 +81,14 @@ public class TestLang extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSourceFile(File f) throws IOException {
|
||||
private void checkSourceFile(File f, HashSet<String> keys) throws IOException {
|
||||
try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f), "utf-8"))) {
|
||||
int linecount = 0;
|
||||
String line;
|
||||
while ((line = r.readLine()) != null) {
|
||||
linecount++;
|
||||
try {
|
||||
checkSourceLine(line);
|
||||
checkSourceLine(line, keys);
|
||||
} catch (AssertionFailedError e) {
|
||||
throw new AssertionFailedError(e.getMessage() + " in line " + linecount);
|
||||
}
|
||||
@ -85,7 +98,7 @@ public class TestLang extends TestCase {
|
||||
|
||||
private static final String PATTERN = "Lang.get(\"";
|
||||
|
||||
private void checkSourceLine(String line) {
|
||||
private void checkSourceLine(String line, HashSet<String> keys) {
|
||||
if (line.contains(PATTERN)) {
|
||||
int pos = line.indexOf(PATTERN, 0);
|
||||
while (pos >= 0) {
|
||||
@ -100,8 +113,11 @@ public class TestLang extends TestCase {
|
||||
while (line.charAt(pos) == ' ') pos++;
|
||||
char nextChar = line.charAt(pos);
|
||||
|
||||
if (nextChar != '+')
|
||||
checkSourceKey(sb.toString());
|
||||
if (nextChar != '+') {
|
||||
final String key = sb.toString();
|
||||
keys.add(key);
|
||||
checkSourceKey(key);
|
||||
}
|
||||
pos = line.indexOf(PATTERN, pos);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user