Permalink
Browse files

[JENKINS-10319] Eat your own dogfood: use extension point to register

all parsers.
  • Loading branch information...
uhafner committed Mar 26, 2012
1 parent 69d3dbb commit b416ca53c57a8bab3f4e5e5bb61279f030d3da20
Showing with 111 additions and 70 deletions.
  1. +3 −0 src/main/java/hudson/plugins/warnings/parser/AcuCobolParser.java
  2. +3 −0 src/main/java/hudson/plugins/warnings/parser/AntJavacParser.java
  3. +2 −0 src/main/java/hudson/plugins/warnings/parser/ArmccCompilerParser.java
  4. +2 −0 src/main/java/hudson/plugins/warnings/parser/BuckminsterParser.java
  5. +2 −0 src/main/java/hudson/plugins/warnings/parser/CoolfluxChessccParser.java
  6. +2 −0 src/main/java/hudson/plugins/warnings/parser/DoxygenParser.java
  7. +2 −0 src/main/java/hudson/plugins/warnings/parser/EclipseParser.java
  8. +2 −0 src/main/java/hudson/plugins/warnings/parser/ErlcParser.java
  9. +3 −0 src/main/java/hudson/plugins/warnings/parser/FlexSDKParser.java
  10. +2 −0 src/main/java/hudson/plugins/warnings/parser/Gcc4CompilerParser.java
  11. +2 −0 src/main/java/hudson/plugins/warnings/parser/Gcc4LinkerParser.java
  12. +2 −0 src/main/java/hudson/plugins/warnings/parser/GccParser.java
  13. +2 −0 src/main/java/hudson/plugins/warnings/parser/GhsMultiParser.java
  14. +2 −0 src/main/java/hudson/plugins/warnings/parser/GnatParser.java
  15. +2 −0 src/main/java/hudson/plugins/warnings/parser/IarParser.java
  16. +2 −0 src/main/java/hudson/plugins/warnings/parser/IntelCParser.java
  17. +2 −0 src/main/java/hudson/plugins/warnings/parser/InvalidsParser.java
  18. +0 −1 src/main/java/hudson/plugins/warnings/parser/JavacParser.java
  19. +2 −0 src/main/java/hudson/plugins/warnings/parser/MsBuildParser.java
  20. +2 −0 src/main/java/hudson/plugins/warnings/parser/P4Parser.java
  21. +6 −34 src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
  22. +2 −0 src/main/java/hudson/plugins/warnings/parser/PhpParser.java
  23. +2 −0 src/main/java/hudson/plugins/warnings/parser/PuppetLintParser.java
  24. +2 −0 src/main/java/hudson/plugins/warnings/parser/RobocopyParser.java
  25. +2 −0 src/main/java/hudson/plugins/warnings/parser/SunCParser.java
  26. +2 −0 src/main/java/hudson/plugins/warnings/parser/TiCcsParser.java
  27. +2 −0 src/main/java/hudson/plugins/warnings/parser/TnsdlParser.java
  28. +2 −0 src/main/java/hudson/plugins/warnings/parser/YuiCompressorParser.java
  29. +46 −0 src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java
  30. +4 −35 src/test/java/hudson/plugins/warnings/parser/ParserRegistryTest.java
@@ -1,12 +1,15 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import java.util.regex.Matcher;
/**
* A parser for the Acu Cobol compile.
*
* @author jerryshea
*/
@Extension
public class AcuCobolParser extends RegexpLineParser {
private static final long serialVersionUID = -894639209290549425L;
private static final String ACUCOBOL_WARNING_PATTERN = "^\\s*(\\[.*\\])?\\s*?(.*), line ([0-9]*): Warning: (.*)$";
@@ -1,5 +1,7 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import java.util.regex.Matcher;
import org.apache.commons.lang.StringUtils;
@@ -9,6 +11,7 @@
*
* @author Ulli Hafner
*/
@Extension
public class AntJavacParser extends RegexpLineParser {
private static final long serialVersionUID = 1737791073711198075L;
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Emanuele Zattin
*/
@Extension
public class ArmccCompilerParser extends RegexpLineParser {
private static final long serialVersionUID = -2677728927938443703L;
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Johannes Utzig
*/
@Extension
public class BuckminsterParser extends RegexpLineParser {
private static final long serialVersionUID = -3723799140297979579L;
private static final String BUCKMINSTER_WARNING_PATTERN = "^.*(Warning|Error): file (.*?)(, line )?(\\d*): (.*)$";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Vangelis Livadiotis
*/
@Extension
public class CoolfluxChessccParser extends RegexpLineParser {
private static final long serialVersionUID = 4742509996511002391L;
private static final String CHESSCC_PATTERN = "^.*?Warning in \"([^\"]+)\", line (\\d+),.*?:\\s*(.*)$";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -12,6 +13,7 @@
* @author Frederic Chateau
* @author Bruno Matos
*/
@Extension
public class DoxygenParser extends RegexpDocumentParser {
private static final long serialVersionUID = -6770174143703245309L;
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -11,6 +12,7 @@
*
* @author Ulli Hafner
*/
@Extension
public class EclipseParser extends RegexpDocumentParser {
private static final long serialVersionUID = 425883472788422955L;
private static final String ANT_ECLIPSE_WARNING_PATTERN = "(WARNING|ERROR)\\s*in\\s*(.*)\\(at line\\s*(\\d+)\\).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n(.*)([\\^]+).*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Stefan Brausch
*/
@Extension
public class ErlcParser extends RegexpLineParser {
private static final long serialVersionUID = 8986478184830773892L;
/** Pattern of erlc compiler warnings. */
@@ -1,12 +1,15 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import java.util.regex.Matcher;
/**
* A parser for Flex SDK compiler warnings.
*
* @author Vivien Tintillier
*/
@Extension
public class FlexSDKParser extends RegexpLineParser {
private static final long serialVersionUID = -185055018399324311L;
private static final String FLEX_SDK_WARNING_PATTERN = "^\\s*(?:\\[.*\\])?\\s*(.*\\.as|.*\\.mxml)\\((\\d*)\\):\\s*(?:col:\\s*\\d*\\s*)?(?:Warning)\\s*:\\s*(.*)$";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Frederic Chateau
*/
@Extension
public class Gcc4CompilerParser extends RegexpLineParser {
private static final long serialVersionUID = 5490211629355204910L;
private static final String ERROR = "error";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -11,6 +12,7 @@
*
* @author Frederic Chateau
*/
@Extension
public class Gcc4LinkerParser extends RegexpLineParser {
private static final long serialVersionUID = -2792019431810134790L;
/** A GCC error. */
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -11,6 +12,7 @@
*
* @author Greg Roth
*/
@Extension
public class GccParser extends RegexpLineParser {
private static final long serialVersionUID = 2020182274225690532L;
static final String GCC_ERROR = "GCC error";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -11,6 +12,7 @@
*
* @author Joseph Boulos
*/
@Extension
public class GhsMultiParser extends RegexpDocumentParser {
private static final long serialVersionUID = 8149238560432255036L;
private static final String GHS_MULTI_WARNING_PATTERN = "\\.(.*)\\,\\s*line\\s*(\\d+):\\s*(warning|error)\\s*([^:]+):\\s*(?m)([^\\^]*)\\s*\\^";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Bernhard Berger
*/
@Extension
public class GnatParser extends RegexpLineParser {
private static final long serialVersionUID = -7139298560308123856L;
private static final String GNAT_WARNING_PATTERN = "^(.+.(?:ads|adb)):(\\d+):(\\d+): ((?:error:)|(?:warning:)|(?:\\(style\\))) (.+)$";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Claus Klein
*/
@Extension
public class IarParser extends RegexpDocumentParser {
private static final long serialVersionUID = 7695540852439013425L;
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -11,6 +12,7 @@
*
* @author Vangelis Livadiotis
*/
@Extension
public class IntelCParser extends RegexpLineParser {
private static final long serialVersionUID = 8409744276858003050L;
private static final String INTEL_PATTERN = "^(.*)\\((\\d*)\\)?:.*((?:remark|warning|error)\\s*#*\\d*)\\s*:\\s*(.*)$";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -11,6 +12,7 @@
*
* @author Ulli Hafner
*/
@Extension
public class InvalidsParser extends RegexpLineParser {
private static final long serialVersionUID = 440910718005095427L;
static final String WARNING_PREFIX = "Oracle ";
@@ -37,7 +37,6 @@ protected Warning createWarning(final Matcher matcher) {
return createWarning(matcher.group(1), getLineNumber(matcher.group(2)), category, message);
}
/** {@inheritDoc} */
@Override
protected String getId() {
return "Java Compiler"; // old ID in serialization
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -12,6 +13,7 @@
*
* @author Ulli Hafner
*/
@Extension
public class MsBuildParser extends RegexpLineParser {
private static final long serialVersionUID = -2141974437420906595L;
static final String WARNING_TYPE = "MSBuild";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Adrian Deccico
*/
@Extension
public class P4Parser extends RegexpLineParser {
private static final long serialVersionUID = -8106854254745366432L;
@@ -183,44 +183,16 @@ public static int getUrl(final String group) {
}
/**
* Returns all available parsers.
* Returns all available parsers. Parsers are automatically detected using
* the extension point mechanism.
*
* @return all available parsers
*/
private static List<AbstractWarningsParser> getAllParsers() {
List<AbstractWarningsParser> parsers = new ArrayList<AbstractWarningsParser>();
parsers.add(new JavacParser());
parsers.add(new AntJavacParser());
parsers.add(new JavaDocParser());
parsers.add(new EclipseParser());
parsers.add(new MsBuildParser());
parsers.add(new GccParser());
parsers.add(new Gcc4CompilerParser());
parsers.add(new Gcc4LinkerParser());
parsers.add(new InvalidsParser());
parsers.add(new SunCParser());
parsers.add(new GnatParser());
parsers.add(new ErlcParser());
parsers.add(new IntelCParser());
parsers.add(new IarParser());
MsBuildParser pclintParser = new MsBuildParser(Messages._Warnings_PCLint_ParserName(),
Messages._Warnings_PCLint_LinkName(),
Messages._Warnings_PCLint_TrendName());
parsers.add(pclintParser);
parsers.add(new BuckminsterParser());
parsers.add(new TiCcsParser());
parsers.add(new AcuCobolParser());
parsers.add(new FlexSDKParser());
parsers.add(new PhpParser());
parsers.add(new CoolfluxChessccParser());
parsers.add(new P4Parser());
parsers.add(new RobocopyParser());
parsers.add(new DoxygenParser());
parsers.add(new TnsdlParser());
parsers.add(new GhsMultiParser());
parsers.add(new ArmccCompilerParser());
parsers.add(new YuiCompressorParser());
parsers.add(new PuppetLintParser());
List<AbstractWarningsParser> parsers = Lists.newArrayList();
parsers.add(new MsBuildParser(Messages._Warnings_PCLint_ParserName(),
Messages._Warnings_PCLint_LinkName(),
Messages._Warnings_PCLint_TrendName()));

This comment has been minimized.

Show comment
Hide comment
@jglick

jglick Jan 29, 2013

Member

Why did you keep MsBuildParser explicitly registered here? You did add an @Extension for it.

(Noticed because rendering the index page of any job using warnings runs this code, and the regexp compilation for MsBuildParser appears as a top CPU contender.)

@jglick

jglick Jan 29, 2013

Member

Why did you keep MsBuildParser explicitly registered here? You did add an @Extension for it.

(Noticed because rendering the index page of any job using warnings runs this code, and the regexp compilation for MsBuildParser appears as a top CPU contender.)

This comment has been minimized.

Show comment
Hide comment
@uhafner

uhafner Jan 31, 2013

Member

Actually this additional parser instance increases the usability: PC Lint and MS Build use the same parser but are unrelated tools, the additional Parser instance thus has a different name and description. Otherwise it would not be clear for someone using PC Lint that he has to choose MS Build.

@uhafner

uhafner Jan 31, 2013

Member

Actually this additional parser instance increases the usability: PC Lint and MS Build use the same parser but are unrelated tools, the additional Parser instance thus has a different name and description. Otherwise it would not be clear for someone using PC Lint that he has to choose MS Build.

This comment has been minimized.

Show comment
Hide comment
@jglick

jglick Feb 1, 2013

Member

Then you should create a public static method (or final field) with the PC-Lint instance and mark it with @Extension, so that it will be a singleton and not incur this construction overhead each time.

@jglick

jglick Feb 1, 2013

Member

Then you should create a public static method (or final field) with the PC-Lint instance and mark it with @Extension, so that it will be a singleton and not incur this construction overhead each time.

Iterable<GroovyParser> parserDescriptions = getDynamicParserDescriptions();
parsers.addAll(getDynamicParsers(parserDescriptions));
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -9,6 +10,7 @@
*
* @author Shimi Kiviti
*/
@Extension
public class PhpParser extends RegexpLineParser {
private static final long serialVersionUID = -5154327854315791181L;
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -12,6 +13,7 @@
*
* @author Jan Vansteenkiste <jan@vstone.eu>
*/
@Extension
public class PuppetLintParser extends RegexpLineParser {
private static final long serialVersionUID = 7492869677427430346L;
private static final String SEPARATOR = "::";
@@ -1,5 +1,6 @@
package hudson.plugins.warnings.parser;
import hudson.Extension;
import hudson.plugins.analysis.util.model.Priority;
import java.util.regex.Matcher;
@@ -14,6 +15,7 @@
* 100% New File 0 a.log
* same 0 a.log
*/
@Extension
public class RobocopyParser extends RegexpLineParser {
private static final long serialVersionUID = -671744745118772873L;
/** Pattern of perforce compiler warnings. */
Oops, something went wrong.

0 comments on commit b416ca5

Please sign in to comment.