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

devonfw / IDEasy / 26101908636

19 May 2026 01:55PM UTC coverage: 70.982% (+0.003%) from 70.979%
26101908636

Pull #1859

github

web-flow
Merge cf4a7f717 into b4eeee25f
Pull Request #1859: #1392: Smart completions

4472 of 6964 branches covered (64.22%)

Branch coverage included in aggregate %.

11521 of 15567 relevant lines covered (74.01%)

3.14 hits per line

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

53.33
cli/src/main/java/com/devonfw/tools/ide/property/RepositoryProperty.java
1
package com.devonfw.tools.ide.property;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5

6
import com.devonfw.tools.ide.commandlet.Commandlet;
7
import com.devonfw.tools.ide.completion.CompletionCandidateCollector;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.validation.PropertyValidator;
10

11
/**
12
 * Extends {@link FileProperty} for repository properties config file with auto-completion.
13
 */
14
public class RepositoryProperty extends FileProperty {
15

16
  public static final String EXTENSION_PROPERTIES = ".properties";
17

18
  /**
19
   * The constructor.
20
   *
21
   * @param name the {@link #getName() property name}.
22
   * @param required the {@link #isRequired() required flag}.
23
   * @param alias the {@link #getAlias() property alias}.
24
   */
25
  public RepositoryProperty(String name, boolean required, String alias, boolean placeholder) {
26

27
    super(name, required, alias, true, placeholder);
7✔
28
  }
1✔
29

30
  /**
31
   * The constructor.
32
   *
33
   * @param name the {@link #getName() property name}.
34
   * @param required the {@link #isRequired() required flag}.
35
   * @param alias the {@link #getAlias() property alias}.
36
   * @param validator the {@link PropertyValidator} used to {@link #validate() validate} the {@link #getValue() value}.
37
   */
38
  public RepositoryProperty(String name, boolean required, String alias, PropertyValidator<Path> validator) {
39

40
    super(name, required, alias, true, false, validator);
×
41
  }
×
42

43
  @Override
44
  public Path parse(String valueAsString, IdeContext context) {
45

46
    if (valueAsString == null) {
2!
47
      return null;
×
48
    }
49
    Path repositoriesPath = null;
2✔
50
    Path repositoryFile = Path.of(valueAsString);
5✔
51
    if (!Files.exists(repositoryFile)) {
5!
52
      repositoryFile = null;
2✔
53
      repositoriesPath = context.getRepositoriesPath();
3✔
54
      if (repositoriesPath != null) {
2!
55
        String propertiesFileName = valueAsString;
2✔
56
        if (!valueAsString.endsWith(EXTENSION_PROPERTIES)) {
4✔
57
          propertiesFileName += EXTENSION_PROPERTIES;
3✔
58
        }
59
        Path resolvedRepositoriesFile = repositoriesPath.resolve(propertiesFileName);
4✔
60
        if (Files.exists(resolvedRepositoriesFile)) {
5!
61
          repositoryFile = resolvedRepositoriesFile;
2✔
62
        }
63
      }
64
    }
65
    if (repositoryFile == null) {
2!
66
      throw new IllegalStateException("Could not find properties file: " + valueAsString + " in " + repositoriesPath);
×
67
    }
68
    return repositoryFile;
2✔
69
  }
70

71
  @Override
72
  protected void completeValue(String arg, IdeContext context, Commandlet commandlet, CompletionCandidateCollector collector) {
73

74
    Path repositoriesPath = context.getRepositoriesPath();
×
75
    if (repositoriesPath != null) {
×
76
      completeValuesFromFolder(repositoriesPath, arg, context, commandlet, collector);
×
77
    }
78
  }
×
79

80
  @Override
81
  protected String getPathForCompletion(Path path, IdeContext context, Commandlet commandlet) {
82

83
    String filename = path.getFileName().toString();
×
84
    if (filename.endsWith(EXTENSION_PROPERTIES)) {
×
85
      filename = filename.substring(0, filename.length() - EXTENSION_PROPERTIES.length());
×
86
    }
87
    return filename;
×
88
  }
89

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

© 2026 Coveralls, Inc