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

devonfw / IDEasy / 25362807967

05 May 2026 07:09AM UTC coverage: 70.716% (+0.06%) from 70.657%
25362807967

Pull #1832

github

web-flow
Merge 9a27bd7a6 into 84fe4e9bf
Pull Request #1832: #1754: Add support for VS Code plugin versions

4417 of 6890 branches covered (64.11%)

Branch coverage included in aggregate %.

11337 of 15388 relevant lines covered (73.67%)

3.12 hits per line

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

80.36
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.Path;
4
import java.util.ArrayList;
5
import java.util.Collection;
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.io.IdeProgressBar;
15
import com.devonfw.tools.ide.log.IdeLogLevel;
16
import com.devonfw.tools.ide.process.ProcessContext;
17
import com.devonfw.tools.ide.process.ProcessMode;
18
import com.devonfw.tools.ide.process.ProcessResult;
19
import com.devonfw.tools.ide.step.Step;
20
import com.devonfw.tools.ide.tool.ToolCommandlet;
21
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
22
import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor;
23

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

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

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

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

41
  @Override
42
  protected String getBinaryName() {
43

44
    return "code";
2✔
45
  }
46

47
  @Override
48
  protected void installPlugins(Collection<ToolPluginDescriptor> plugins, ProcessContext pc) {
49
    this.context.runWithoutLogging(() -> {
7✔
50
      IdeProgressBar pb = this.context.newProgressBarForPlugins(plugins.size());
7✔
51
      pc.setOutputListener((msg, err) -> {
4✔
52
        if (msg.contains("Installing extension ")) {
4!
53
          pb.stepBy(1);
×
54
        }
55
      });
1✔
56
      super.installPlugins(plugins, pc);
4✔
57
      pb.close();
2✔
58
    });
1✔
59
  }
1✔
60

61
  @Override
62
  public boolean installPlugin(ToolPluginDescriptor plugin, Step step, ProcessContext pc) {
63

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

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

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

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