Skip to content

Commit ae78e09

Browse files
committedOct 23, 2021
Parser interface: remove redundant variable initializer and field modifiers
1 parent 44cddcf commit ae78e09

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎reader/src/main/java/org/jline/reader/Parser.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002-2020, the original author or authors.
2+
* Copyright (c) 2002-2021, the original author or authors.
33
*
44
* This software is distributable under the BSD license. See the terms of the
55
* BSD license in the documentation provided with this software.
@@ -12,8 +12,8 @@
1212
import java.util.regex.Pattern;
1313

1414
public interface Parser {
15-
static final String REGEX_VARIABLE = "[a-zA-Z_]{1,}[a-zA-Z0-9_-]*";
16-
static final String REGEX_COMMAND = "[:]{0,1}[a-zA-Z]{1,}[a-zA-Z0-9_-]*";
15+
String REGEX_VARIABLE = "[a-zA-Z_]+[a-zA-Z0-9_-]*";
16+
String REGEX_COMMAND = "[:]?[a-zA-Z]+[a-zA-Z0-9_-]*";
1717

1818
ParsedLine parse(String line, int cursor, ParseContext context) throws SyntaxError;
1919

@@ -34,7 +34,7 @@ default boolean validVariableName(String name) {
3434
}
3535

3636
default String getCommand(final String line) {
37-
String out = "";
37+
String out;
3838
Pattern patternCommand = Pattern.compile("^\\s*" + REGEX_VARIABLE + "=(" + REGEX_COMMAND + ")(\\s+|$)");
3939
Matcher matcher = patternCommand.matcher(line);
4040
if (matcher.find()) {

0 commit comments

Comments
 (0)
Please sign in to comment.