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

devonfw / IDEasy / 34780871777

13 Sep 2026 08:28PM UTC coverage: 73.934% (+0.02%) from 73.91%
34780871777

Pull #2429

github

web-flow
Merge d19417117 into 09c20b869
Pull Request #2429: #2409: cleanup of expression functions

5600 of 8419 branches covered (66.52%)

Branch coverage included in aggregate %.

14541 of 18823 relevant lines covered (77.25%)

3.29 hits per line

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

90.0
cli/src/main/java/com/devonfw/tools/ide/expression/function/PathFunction.java
1
package com.devonfw.tools.ide.expression.function;
2

3
import com.devonfw.tools.ide.cli.CliException;
4
import com.devonfw.tools.ide.expression.BinaryExpressionFunction;
5
import com.devonfw.tools.ide.expression.ExpressionContext;
6
import com.devonfw.tools.ide.expression.ExpressionFunction;
7
import com.devonfw.tools.ide.os.WindowsPathSyntax;
8

9
/**
10
 * {@link ExpressionFunction} {@code @path} that normalises a path.
11
 * <ol>
12
 * <li>the path to normalise. By default backslashes are replaced with slashes.</li>
13
 * <li>optional: the literal value {@code unix} (default) or {@code native}.</li>
14
 * </ol>
15
 * Example: {@code @path('$[IDE_HOME]/software/node/node.exe')}
16
 */
17
public class PathFunction extends BinaryExpressionFunction {
18

19
  /** The literal value for the second argument to normalise to unix syntax (default). */
20
  public static final String MODE_UNIX = "unix";
21

22
  /** The literal value for the second argument to normalise to the syntax native to the current operating system. */
23
  public static final String MODE_NATIVE = "native";
24

25
  /**
26
   * The constructor.
27
   */
28
  public PathFunction() {
29

30
    super(1);
3✔
31
  }
1✔
32

33
  @Override
34
  public String getName() {
35

36
    return "path";
2✔
37
  }
38

39
  @Override
40
  protected String apply(String path, String mode, ExpressionContext context) {
41

42
    if (mode == null) {
2✔
43
      mode = MODE_UNIX;
2✔
44
    }
45
    if (MODE_UNIX.equals(mode)) {
4✔
46
      return path.replace('\\', '/');
5✔
47
    } else if (MODE_NATIVE.equals(mode)) {
4✔
48
      if (context.getIdeContext().getSystemInfo().isWindows()) {
5!
49
        return WindowsPathSyntax.WINDOWS.normalize(path).replace('/', '\\');
7✔
50
      }
51
      return path.replace('\\', '/');
×
52
    }
53
    throw new CliException(
6✔
54
        "Invalid template expression: invalid mode '" + mode + "' for function @path - expected '" + MODE_UNIX + "' or '" + MODE_NATIVE + "'.");
55
  }
56

57
}
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