Skip to content

Commit

Permalink
Reverted problematic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel1464 committed Nov 27, 2024
1 parent 844d498 commit 0bc9627
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,13 @@ private void processEpilogue(RoundEnvironment roundEnv) {
for (TypeElement clazz : classes) {
try {
warnOfNonLoggableElements(clazz);
boolean isMainRobotClass = false;
if (processingEnv.getTypeUtils().isAssignable(clazz.getSuperclass(), robotBaseClass)) {
mainRobotClasses.add(clazz);
isMainRobotClass = true;
}
boolean canBeLogged = m_loggerGenerator.writeLoggerFile(clazz, isMainRobotClass);
boolean canBeLogged = m_loggerGenerator.writeLoggerFile(clazz);
if (canBeLogged) {
loggerClassNames.add(StringUtils.loggerClassName(clazz));
}
if (processingEnv.getTypeUtils().isAssignable(clazz.getSuperclass(), robotBaseClass)) {
mainRobotClasses.add(clazz);
}
} catch (IOException e) {
processingEnv
.getMessager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static boolean isBuiltInJavaMethod(ExecutableElement e) {
* @param clazz the data type that the logger should support.
* @throws IOException if the file could not be written
*/
public boolean writeLoggerFile(TypeElement clazz, boolean isMainRobotClass) throws IOException {
public boolean writeLoggerFile(TypeElement clazz) throws IOException {
var config = clazz.getAnnotation(Logged.class);
if (config == null) { config = kDefaultConfig; }
boolean requireExplicitOptIn = config.strategy() == Logged.Strategy.OPT_IN;
Expand Down Expand Up @@ -119,9 +119,9 @@ public boolean writeLoggerFile(TypeElement clazz, boolean isMainRobotClass) thro
.filter(e -> !isSimpleGetterMethodForLoggedField(e, fieldsToLog))
.toList();

// Nothing to log; continue
// Robot classes must have a generated logger
if (fieldsToLog.isEmpty() && methodsToLog.isEmpty() && !isMainRobotClass) {
// If there is no log annotation and no fields to log, don't generate a logger
// logger is still generated for @Logged classes for compatibility reasons
if (fieldsToLog.isEmpty() && methodsToLog.isEmpty() && clazz.getAnnotation(Logged.class) == null) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Example {
public final class Epilogue {
private static final EpilogueConfiguration config = new EpilogueConfiguration();
public static final ExampleLogger exampleLogger = new ExampleLogger();
public static void configure(java.util.function.Consumer<EpilogueConfiguration> configurator) {
configurator.accept(config);
Expand Down Expand Up @@ -190,14 +192,10 @@ void multipleRobots() {
package edu.wpi.first.epilogue;
@Logged
class AlphaBot extends edu.wpi.first.wpilibj.TimedRobot {
double x = 0.0;
}
class AlphaBot extends edu.wpi.first.wpilibj.TimedRobot { }
@Logged
class BetaBot extends edu.wpi.first.wpilibj.TimedRobot {
double x = 0.0;
}
class BetaBot extends edu.wpi.first.wpilibj.TimedRobot { }
""";

String expected =
Expand Down

0 comments on commit 0bc9627

Please sign in to comment.