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

devonfw / IDEasy / 19168407473

07 Nov 2025 12:30PM UTC coverage: 68.878% (+0.002%) from 68.876%
19168407473

Pull #1578

github

web-flow
Merge 91cb3363d into 6cb666c38
Pull Request #1578: #536: Fix duplicate completion candidates

3489 of 5549 branches covered (62.88%)

Branch coverage included in aggregate %.

9124 of 12763 relevant lines covered (71.49%)

3.14 hits per line

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

88.46
cli/src/main/java/com/devonfw/tools/ide/completion/CompletionCandidateCollectorDefault.java
1
package com.devonfw.tools.ide.completion;
2

3
import java.util.ArrayList;
4
import java.util.Collections;
5
import java.util.List;
6

7
import com.devonfw.tools.ide.commandlet.Commandlet;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.property.Property;
10

11
/**
12
 * Collects the {@link CompletionCandidate}s for auto-completion.
13
 */
14
public class CompletionCandidateCollectorDefault implements CompletionCandidateCollector {
15

16
  private final List<CompletionCandidate> candidates;
17

18
  private final IdeContext context;
19

20
  private boolean sortCandidates;
21

22
  /**
23
   * The constructor.
24
   *
25
   * @param context the {@link IdeContext}.
26
   */
27
  public CompletionCandidateCollectorDefault(IdeContext context) {
28

29
    super();
2✔
30
    this.candidates = new ArrayList<>();
5✔
31
    this.context = context;
3✔
32
    this.sortCandidates = true;
3✔
33
  }
1✔
34

35
  @Override
36
  public void add(String text, String description, Property<?> property, Commandlet commandlet) {
37

38
    // Check if this candidate already exists to avoid duplicates
39
    for (CompletionCandidate existing : this.candidates) {
11✔
40
      if (existing.text().equals(text)) {
5!
41
        // Duplicate candidate found, do not add
42
        return;
×
43
      }
44
    }
1✔
45

46
    CompletionCandidate candidate = createCandidate(text, description, property, commandlet);
7✔
47
    this.candidates.add(candidate);
5✔
48
    this.context.trace("Added {} for auto-completion of property {}.{}", candidate, commandlet, property);
18✔
49
  }
1✔
50

51
  @Override
52
  public List<CompletionCandidate> getCandidates() {
53

54
    return this.candidates;
3✔
55
  }
56

57
  @Override
58
  public List<CompletionCandidate> getSortedCandidates() {
59

60
    if (this.sortCandidates) {
3✔
61
      Collections.sort(this.candidates);
3✔
62
    }
63
    return this.candidates;
3✔
64
  }
65

66
  @Override
67
  public void disableSorting() {
68

69
    this.sortCandidates = false;
3✔
70
  }
1✔
71

72
  @Override
73
  public String toString() {
74

75
    return this.candidates.toString();
×
76
  }
77

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

© 2025 Coveralls, Inc