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

devonfw / IDEasy / 39756774067

22 Oct 2026 09:36AM UTC coverage: 74.929% (-0.02%) from 74.951%
39756774067

push

github

web-flow
#2409: cleanup of expression functions (#2429)

Co-authored-by: quando632 <quang-hieu.do@capgemini.com>
Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>

5892 of 8727 branches covered (67.51%)

Branch coverage included in aggregate %.

15375 of 19656 relevant lines covered (78.22%)

3.36 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