better API

This commit is contained in:
rusefillc 2023-01-02 13:20:58 -05:00
parent 6b4794eee1
commit afa7e9b36e
5 changed files with 11 additions and 9 deletions

View File

@ -85,8 +85,12 @@ public class DataLogConsumer implements ConfigurationConsumer {
String comment = configField.getCommentTemplated();
comment = getFirstLine(comment);
if (comment.isEmpty())
if (comment.isEmpty()) {
/**
* @see ConfigField#getCommentOrName()
*/
comment = prefix + unquote(configField.getName());
}
if (comment.charAt(0) != '"')
comment = quote(comment);

View File

@ -32,7 +32,7 @@ public class TSProjectConsumer implements ConfigurationConsumer {
}
// also known as TS tooltips
public StringBuilder getSettingContextHelp() {
public String getSettingContextHelpForUnitTest() {
return tsOutput.getSettingContextHelp();
}
@ -56,7 +56,7 @@ public class TSProjectConsumer implements ConfigurationConsumer {
tsHeader.write(fieldsSection);
if (tsOutput.getSettingContextHelp().length() > 0) {
tsHeader.write("[" + SETTING_CONTEXT_HELP + "]" + ToolUtil.EOL);
tsHeader.write(tsOutput.getSettingContextHelp().toString() + ToolUtil.EOL + ToolUtil.EOL);
tsHeader.write(tsOutput.getSettingContextHelp() + ToolUtil.EOL + ToolUtil.EOL);
tsHeader.write("; " + SETTING_CONTEXT_HELP_END + ToolUtil.EOL);
}
tsHeader.write("; " + CONFIG_DEFINITION_END + ToolUtil.EOL);

View File

@ -32,8 +32,8 @@ public class TsOutput {
return tsHeader.toString();
}
public StringBuilder getSettingContextHelp() {
return settingContextHelp;
public String getSettingContextHelp() {
return settingContextHelp.toString();
}
public int run(ReaderState state, ConfigStructure structure, int sensorTsPosition) {

View File

@ -10,8 +10,6 @@ import com.rusefi.output.JavaFieldsConsumer;
import com.rusefi.output.TSProjectConsumer;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.*;
/**
@ -690,7 +688,7 @@ public class ConfigFieldParserTest {
assertEquals(
"\tpid_afr_type = \"PID dTime\"\n" +
"\tpid_isForcedInduction = \"Does the vehicle have a turbo or supercharger?\"\n" +
"\tpid_enableFan1WithAc = \"Turn on this fan when AC is on.\"\n", tsProjectConsumer.getSettingContextHelp().toString());
"\tpid_enableFan1WithAc = \"Turn on this fan when AC is on.\"\n", tsProjectConsumer.getSettingContextHelpForUnitTest());
}
@Test

View File

@ -201,7 +201,7 @@ public class OutputsTest {
assertEquals(
"\ttriggerSimulatorPins1 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n" +
"\ttriggerSimulatorPins2 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n" +
"\ttriggerSimulatorPins3 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n", tsProjectConsumer.getSettingContextHelp().toString());
"\ttriggerSimulatorPins3 = \"Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\"\n", tsProjectConsumer.getSettingContextHelpForUnitTest());
}
@Test(expected = IllegalStateException.class)