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

devonfw / IDEasy / 28658329500

03 Jul 2026 11:43AM UTC coverage: 71.312% (-0.04%) from 71.351%
28658329500

Pull #2105

github

web-flow
Merge 23a524516 into 2504d944a
Pull Request #2105: #2056 Replaced progress bar with progress information for plugin installation

4699 of 7284 branches covered (64.51%)

Branch coverage included in aggregate %.

12097 of 16269 relevant lines covered (74.36%)

3.15 hits per line

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

86.67
cli/src/main/java/com/devonfw/tools/ide/tool/vscode/Vscode.java
1
package com.devonfw.tools.ide.tool.vscode;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.ArrayList;
6
import java.util.List;
7
import java.util.Set;
8

9
import org.slf4j.Logger;
10
import org.slf4j.LoggerFactory;
11

12
import com.devonfw.tools.ide.common.Tag;
13
import com.devonfw.tools.ide.context.IdeContext;
14
import com.devonfw.tools.ide.log.IdeLogLevel;
15
import com.devonfw.tools.ide.process.ProcessContext;
16
import com.devonfw.tools.ide.process.ProcessMode;
17
import com.devonfw.tools.ide.process.ProcessResult;
18
import com.devonfw.tools.ide.step.Step;
19
import com.devonfw.tools.ide.tool.ToolCommandlet;
20
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
21
import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor;
22

23
/**
24
 * {@link ToolCommandlet} for <a href="https://code.visualstudio.com/">vscode</a>.
25
 */
26
public class Vscode extends IdeToolCommandlet {
27

28
  private static final Logger LOG = LoggerFactory.getLogger(Vscode.class);
4✔
29

30
  /** The {@link #getConfiguredEdition() edition} for VSCodium. */
31
  private static final String EDITION_VSCODIUM = "vscodium";
32

33
  /**
34
   * The constructor.
35
   *
36
   * @param context the {@link IdeContext}.
37
   */
38
  public Vscode(IdeContext context) {
39

40
    super(context, "vscode", Set.of(Tag.VS_CODE));
6✔
41
  }
1✔
42

43
  @Override
44
  protected String getBinaryName() {
45

46
    if (EDITION_VSCODIUM.equals(getConfiguredEdition())) {
5✔
47
      return "codium";
2✔
48
    }
49
    return "code";
2✔
50
  }
51

52
  @Override
53
  protected Path getPluginsConfigPath() {
54

55
    if (EDITION_VSCODIUM.equals(getConfiguredEdition())) {
5✔
56
      Path vscodiumPluginsPath = this.context.getSettingsPath().resolve(EDITION_VSCODIUM).resolve(IdeContext.FOLDER_PLUGINS);
8✔
57
      if (Files.isDirectory(vscodiumPluginsPath)) {
5✔
58
        return vscodiumPluginsPath;
2✔
59
      }
60
    }
61
    return super.getPluginsConfigPath();
3✔
62
  }
63

64
  @Override
65
  public boolean installPlugin(ToolPluginDescriptor plugin, Step step, ProcessContext pc) {
66

67
    List<String> extensionsCommands = new ArrayList<>();
4✔
68
    extensionsCommands.add("--force");
4✔
69
    extensionsCommands.add("--install-extension");
4✔
70
    String extensionInstallTarget = plugin.id();
3✔
71
    // If a version number was specified, add it to the extension identifier with the format "extensionId@version"
72
    boolean versionSpecified = (plugin.version() != null) && !plugin.version().isBlank();
11!
73
    if (versionSpecified) {
2✔
74
      extensionInstallTarget = extensionInstallTarget + "@" + plugin.version();
5✔
75
    }
76
    extensionsCommands.add(extensionInstallTarget);
4✔
77
    ProcessResult result = runTool(pc, ProcessMode.DEFAULT_CAPTURE, extensionsCommands);
6✔
78
    if (result.isSuccessful()) {
3!
79
      if (versionSpecified) {
2✔
80
        IdeLogLevel.SUCCESS.log(LOG, "Successfully installed plugin: {} with version: {}", plugin.name(), plugin.version());
17✔
81
      } else {
82
        IdeLogLevel.SUCCESS.log(LOG, "Successfully installed plugin: {}", plugin.name());
11✔
83
      }
84
      step.success();
2✔
85
      return true;
2✔
86
    }
87
    if (versionSpecified) {
×
88
      IdeLogLevel.ERROR.log(LOG, "Failed to install plugin: {} with version: {}", plugin.name(), plugin.version());
×
89
    } else {
90
      IdeLogLevel.ERROR.log(LOG, "Failed to install plugin: {}", plugin.name());
×
91
    }
92
    return false;
×
93
  }
94

95
  @Override
96
  protected void configureToolArgs(ProcessContext pc, ProcessMode processMode, List<String> args) {
97

98
    if (this.context.getSystemInfo().isWsl()) {
5✔
99
      pc.withEnvVar("DONT_PROMPT_WSL_INSTALL", "1");
5✔
100
    }
101
    Path vsCodeConf = this.context.getWorkspacePath().resolve(".vscode/.userdata");
6✔
102
    pc.addArg("--new-window");
4✔
103
    pc.addArg("--user-data-dir=" + vsCodeConf);
6✔
104
    Path vsCodeExtensionFolder = this.context.getIdeHome().resolve("plugins/vscode");
6✔
105
    pc.addArg("--extensions-dir=" + vsCodeExtensionFolder);
6✔
106
    pc.addArg(this.context.getWorkspacePath());
6✔
107
    super.configureToolArgs(pc, processMode, args);
5✔
108
  }
1✔
109

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