Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-21569] Expose current line in groovy.
Browse files Browse the repository at this point in the history
Added getCurrentLine() method for line based parsers.
  • Loading branch information
uhafner committed Jan 31, 2014
1 parent 4605175 commit fb9924a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -41,6 +41,8 @@ public DynamicParser(final String name, final String regexp, final String script
*/
@Override
protected Warning createWarning(final Matcher matcher) {
expressionMatcher.setCurrentLine(getCurrentLine());

return expressionMatcher.createWarning(matcher);
}
}
Expand Down
Expand Up @@ -23,9 +23,11 @@ public class GroovyExpressionMatcher implements Serializable {

private final Warning falsePositive;
private final String script;
private int currentLine;

private transient Script compiled;


/**
* Creates a new instance of {@link GroovyExpressionMatcher}.
*
Expand Down Expand Up @@ -53,6 +55,24 @@ private void compileScriptIfNotYetDone() {
}
}

/**
* Returns the current line number that is handled by the parser.
*
* @return the current line number
*/
public int getCurrentLine() {
return currentLine;
}

/**
* Sets the current line number to the specified value.
*
* @param currentLine the new line number
*/
void setCurrentLine(int currentLine) {
this.currentLine = currentLine;
}

/**
* Creates a new annotation for the specified match.
*
Expand Down

0 comments on commit fb9924a

Please sign in to comment.