Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sfge/src/main/java/com/salesforce/apex/jorje/JorjeUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.salesforce.apex.jorje;

import apex.jorje.data.Locations;
import apex.jorje.parser.impl.BaseApexLexer;
import apex.jorje.parser.impl.HiddenToken;
import apex.jorje.semantic.ast.AstNode;
import apex.jorje.semantic.ast.visitor.NoopScope;
Expand All @@ -22,13 +23,17 @@
import java.util.Collections;
import java.util.List;
import java.util.NavigableMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

/** Converts string source code into a node that can be imported into the graph. */
public final class JorjeUtil {
static {
// Inform Jorje to track locations
Locations.useIndexFactory();
// Increment log level to avoid printing info lines
incrementLogLevel();
}

public static AstNodeWrapper<?> compileApexFromString(String sourceCode) {
Expand Down Expand Up @@ -130,5 +135,14 @@ public static class JorjeCompilationException extends SfgeRuntimeException {
}
}

/**
* Increments log level of BaseApexLexer class from jorje jar
* to avoid printing info logs.
*/
private static void incrementLogLevel() {
Logger jorjeLogger = Logger.getLogger(BaseApexLexer.class.getName());
jorjeLogger.setLevel(Level.WARNING);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to repro the info log line consistently and hence don't have a unit test.

}

private JorjeUtil() {}
}