Class RegexErrorPattern

java.lang.Object
org.eclipse.cdt.core.errorparsers.RegexErrorPattern
All Implemented Interfaces:
Cloneable

public class RegexErrorPattern extends Object implements Cloneable

RegexErrorPattern specifies a regular expression and rules how to create markers for Problems View. It is used by RegexErrorParser to process build output.

Regex pattern used by this class is Java regular expression and defines capturing groups. Those capturing groups are used in file, line, description expressions to get the values.

For example: pattern "(../../..) (.*):(\d*): (Error:.*)" could go along with file-expression "$2", line-expression "$3" and description-expression "$1 $4".

Note: variable name is being stored in marker tag. However currently it is not being used.

Severity could be one of:
- IMarkerGenerator.SEVERITY_INFO,
- IMarkerGenerator.SEVERITY_WARNING,
- IMarkerGenerator.SEVERITY_ERROR_RESOURCE,
- IMarkerGenerator.SEVERITY_ERROR_BUILD
- SEVERITY_SKIP
SEVERITY_SKIP means that output line is checked to match the pattern but won't be parsed to create a marker. It is useful with conjunction with eatProcessedLine=true to filter out certain lines.

eatProcessedLine specifies if the current output line is being passed to the rest of patterns for further processing or consumed by the pattern.

Clients may extend this class. As it implements Cloneable interface those clients must implement Object.clone() and Object.equals(java.lang.Object) methods to avoid slicing.

Since:
5.2
  • Field Details

    • SEVERITY_SKIP

      public static final int SEVERITY_SKIP
      Additional "severity" flag which tells if qualified output line should be ignored.
      See Also:
  • Constructor Details

  • Method Details

    • getPattern

      public String getPattern()
      Returns:
      regular expression pattern
    • getFileExpression

      public String getFileExpression()
      Returns:
      expression defining file name
    • getLineExpression

      public String getLineExpression()
      Returns:
      expression defining line number
    • getDescriptionExpression

      public String getDescriptionExpression()
      Returns:
      expression defining description
    • getVarNameExpression

      public String getVarNameExpression()
      Returns:
      expression defining variable name
    • getSeverity

      public int getSeverity()
      Returns:
      severity of the marker, one of:
      IMarkerGenerator.SEVERITY_INFO,
      IMarkerGenerator.SEVERITY_WARNING,
      IMarkerGenerator.SEVERITY_ERROR_RESOURCE,
      IMarkerGenerator.SEVERITY_ERROR_BUILD
    • isEatProcessedLine

      public boolean isEatProcessedLine()
      Returns:
      whether output line is consumed and not processed further by other patterns
    • setPattern

      public void setPattern(String pattern)
      Parameters:
      pattern - - regular expression pattern describing the capturing groups
    • setFileExpression

      public void setFileExpression(String fileExpression)
      Parameters:
      fileExpression - - capturing group expression defining file name
    • setLineExpression

      public void setLineExpression(String lineExpression)
      Parameters:
      lineExpression - - capturing group expression defining line number
    • setDescriptionExpression

      public void setDescriptionExpression(String descriptionExpression)
      Parameters:
      descriptionExpression - - capturing group expression defining description
    • setVarNameExpression

      public void setVarNameExpression(String varNameExpression)
      Parameters:
      varNameExpression - -capturing group expression defining variable name
    • setSeverity

      public void setSeverity(int severity)
      Parameters:
      severity - - severity, one of
      IMarkerGenerator.SEVERITY_INFO,
      IMarkerGenerator.SEVERITY_WARNING,
      IMarkerGenerator.SEVERITY_ERROR_RESOURCE,
      IMarkerGenerator.SEVERITY_ERROR_BUILD
      SEVERITY_SKIP
    • setEatProcessedLine

      public void setEatProcessedLine(boolean eatProcessedLine)
      Parameters:
      eatProcessedLine - - whether to consume output line avoiding further processing by other patterns
    • getFileName

      protected String getFileName(Matcher matcher)
      Parameters:
      matcher - - matcher to parse the input line.
      Returns:
      parsed file name or null.
    • getLineNum

      protected int getLineNum(Matcher matcher)
      Parameters:
      matcher - - matcher to parse the input line.
      Returns:
      parsed line number or 0.
    • getDesc

      protected String getDesc(Matcher matcher)
      Parameters:
      matcher - - matcher to parse the input line.
      Returns:
      parsed description or null.
    • getVarName

      protected String getVarName(Matcher matcher)
      Parameters:
      matcher - - matcher to parse the input line.
      Returns:
      parsed variable name or null.
    • getSeverity

      protected int getSeverity(Matcher matcher)
      Parameters:
      matcher - - matcher to parse the input line.
      Returns:
      severity of the problem.
    • processLine

      public boolean processLine(String line, ErrorParserManager eoParser)
      Parse a line of build output and register error/warning for Problems view.
      Parameters:
      line - - one line of output.
      eoParser - - ErrorParserManager.
      Returns:
      true if error/warning/info problem was found.
    • recordError

      protected boolean recordError(Matcher matcher, ErrorParserManager eoParser)
      Register the error in ErrorParserManager.
      Parameters:
      matcher - - matcher to parse the input line.
      eoParser - - ErrorParserManager.
      Returns:
      true indicating that error was found.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException