• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 29803149984

21 Jul 2026 05:08AM UTC coverage: 72.439% (-0.04%) from 72.476%
29803149984

Pull #2179

github

web-flow
Merge c6c1d1813 into 3221b7580
Pull Request #2179: Feature/2165 interactive template variables

4961 of 7574 branches covered (65.5%)

Branch coverage included in aggregate %.

12804 of 16950 relevant lines covered (75.54%)

3.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
cli/src/main/java/com/devonfw/tools/ide/variable/VariableSyntax.java
1
package com.devonfw.tools.ide.variable;
2

3
import java.util.regex.Matcher;
4
import java.util.regex.Pattern;
5

6
/**
7
 * Enum with the available syntax for variables.
8
 *
9
 * @see com.devonfw.tools.ide.environment.EnvironmentVariables#resolve(String, Object, boolean)
10
 */
11
public enum VariableSyntax {
3✔
12

13
  /**
14
   * Syntax using curly braces ("${...}"). Considered legacy in IDEasy and only supported for devonfw-ide backward compatibility.
15
   *
16
   * @see IdeVariables#IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED
17
   */
18
  CURLY("\\$\\{([a-zA-Z0-9_-]+)\\}") {
13✔
19
    @Override
20
    public String create(String variableName) {
21
      return "${" + variableName + "}";
3✔
22
    }
23
  },
24

25
  /**
26
   * Syntax using square brackets ("$[...]"). Additionally to plain variables ("$[MY_VARIABLE]") this syntax supports the function expression
27
   * "$[ask:MY_VARIABLE]" or "$[secret:MY_VARIABLE]" that will interactively ask the user for the value if the variable is undefined.
28
   */
29
  SQUARE("\\$\\[(?:([a-zA-Z0-9_-]+)|(ask|secret):([a-zA-Z0-9_-]+))\\]") {
13✔
30
    @Override
31
    public String create(String variableName) {
32
      return "$[" + variableName + "]";
3✔
33
    }
34

35
    @Override
36
    public String getAskVariable(Matcher matcher) {
37
      return matcher.group(3);
4✔
38
    }
39

40
    @Override
41
    public boolean isSecret(Matcher matcher) {
42
      return "secret".equals(matcher.group(2));
6✔
43
    }
44
  };
45

46
  private final Pattern pattern;
47

48
  VariableSyntax(String regex) {
4✔
49

50
    this.pattern = Pattern.compile(regex);
4✔
51
  }
1✔
52

53
  /**
54
   * @return the regular expression {@link Pattern} for this {@link VariableSyntax}.
55
   */
56
  public Pattern getPattern() {
57

58
    return this.pattern;
3✔
59
  }
60

61
  /**
62
   * @param matcher the current {@link Matcher}.
63
   * @return the variable name.
64
   */
65
  public String getVariable(Matcher matcher) {
66
    return matcher.group(1);
4✔
67
  }
68

69
  /**
70
   * @param matcher the current {@link Matcher}.
71
   * @return the name of the variable to interactively ask the user for in case the current match is an ask expression (e.g. "$[ask:MY_VARIABLE]") or
72
   *     {@code null} if the current match is a plain {@link #getVariable(Matcher) variable}.
73
   */
74
  public String getAskVariable(Matcher matcher) {
75
    return null;
×
76
  }
77

78
  /**
79
   * @param matcher the current {@link Matcher}.
80
   * @return {@code true} if the current match is an {@link #getAskVariable(Matcher) ask expression} for a secret value (e.g. "$[secret:MY_TOKEN]")
81
   *     that shall not be echoed while typing, {@code false} otherwise.
82
   */
83
  public boolean isSecret(Matcher matcher) {
84
    return false;
×
85
  }
86

87
  /**
88
   * @param variableName the variable name.
89
   * @return the variable syntax for the given {@code variableName}. E.g. for {@link #CURLY} and the given {@link String} "JAVA_HOME" this method would return
90
   * "${JAVA_HOME}".
91
   */
92
  public abstract String create(String variableName);
93

94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc