[apex] Disable logging of jorje apex lexer

Fixes #500
This commit is contained in:
Andreas Dangel
2017-07-16 21:00:40 +02:00
parent c408dc3ba9
commit fba00843bb
4 changed files with 33 additions and 0 deletions

View File

@@ -11,12 +11,17 @@ import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.Lexer;
import org.antlr.runtime.Token;
import net.sourceforge.pmd.lang.apex.ApexJorjeLogging;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
import apex.jorje.parser.impl.ApexLexer;
public class ApexTokenizer implements Tokenizer {
public ApexTokenizer() {
ApexJorjeLogging.disableLogging();
}
/**
* If the properties is <code>false</code> (default), then the case of any token
* is ignored.

View File

@@ -0,0 +1,25 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex;
import java.util.logging.Level;
import java.util.logging.Logger;
import apex.jorje.parser.impl.BaseApexLexer;
public final class ApexJorjeLogging {
private ApexJorjeLogging() {
// this is a utility class
}
public static void disableLogging() {
// Disable the logging of the ApexLexer, e.g.
// Jul 16, 2017 8:49:56 PM apex.jorje.parser.impl.BaseApexLexer dedupe
// INFORMATION: Deduped array ApexLexer.DFA23_transition. Found 7927114 shorts which is 15MB not
// including array overhead. Removed 7204963 shorts which is 13MB not counting array overhead. Took 18ms.
Logger log = Logger.getLogger(BaseApexLexer.class.getSimpleName());
log.setLevel(Level.WARNING);
}
}

View File

@@ -11,6 +11,7 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import net.sourceforge.pmd.lang.apex.ApexJorjeLogging;
import net.sourceforge.pmd.lang.apex.ApexParserOptions;
import net.sourceforge.pmd.lang.ast.ParseException;
@@ -29,6 +30,7 @@ public class ApexParser {
private String suppressMarker = "NOPMD";
public ApexParser(ApexParserOptions parserOptions) {
ApexJorjeLogging.disableLogging();
this.parserOptions = parserOptions;
if (parserOptions.getSuppressMarker() != null) {

View File

@@ -61,6 +61,7 @@ Based on those metrics, rules like "GodClass" detection can be implemented more
* apex
* [#488](https://github.com/pmd/pmd/pull/488): \[apex] Use Apex lexer for CPD
* [#500](https://github.com/pmd/pmd/issues/500): \[apex] Running through CLI shows jorje optimization messages
* cpp
* [#448](https://github.com/pmd/pmd/issues/448): \[cpp] Write custom CharStream to handle continuation characters
* java