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

devonfw / IDEasy / 27349193662

11 Jun 2026 01:10PM UTC coverage: 71.031% (-0.02%) from 71.052%
27349193662

Pull #2017

github

web-flow
Merge 114318b2a into 8b8989cb3
Pull Request #2017: 1966: Support separate VSCodium plugins folder

4523 of 7062 branches covered (64.05%)

Branch coverage included in aggregate %.

11729 of 15818 relevant lines covered (74.15%)

3.14 hits per line

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

78.21
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.Collection;
7
import java.util.List;
8
import java.util.Set;
9

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

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

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

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

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

35
  /** Plugin IDs collected during {@link #installPlugins} that VSCodium was unable to install. */
36
  private final List<String> vscodiumUnavailablePlugins = new ArrayList<>();
5✔
37

38
  /**
39
   * The constructor.
40
   *
41
   * @param context the {@link IdeContext}.
42
   */
43
  public Vscode(IdeContext context) {
44

45
    super(context, "vscode", Set.of(Tag.VS_CODE));
6✔
46
  }
1✔
47

48
  @Override
49
  protected String getBinaryName() {
50

51
    if (EDITION_VSCODIUM.equals(getConfiguredEdition())) {
5✔
52
      return "codium";
2✔
53
    }
54
    return "code";
2✔
55
  }
56

57
  @Override
58
  protected Path getPluginsConfigPath() {
59

60
    if (EDITION_VSCODIUM.equals(getConfiguredEdition())) {
5✔
61
      Path vscodiumPluginsPath = this.context.getSettingsPath().resolve(EDITION_VSCODIUM).resolve(IdeContext.FOLDER_PLUGINS);
8✔
62
      if (Files.isDirectory(vscodiumPluginsPath)) {
5!
63
        return vscodiumPluginsPath;
×
64
      }
65
    }
66
    return super.getPluginsConfigPath();
3✔
67
  }
68

69
  @Override
70
  protected void installPlugins(Collection<ToolPluginDescriptor> plugins, ProcessContext pc) {
71

72
    this.context.runWithoutLogging(() -> {
7✔
73
      IdeProgressBar pb = this.context.newProgressBarForPlugins(plugins.size());
7✔
74
      pc.setOutputListener((msg, err) -> {
4✔
75
        if (msg.contains("Installing extension ")) {
4!
76
          pb.stepBy(1);
×
77
        }
78
      });
1✔
79
      super.installPlugins(plugins, pc);
4✔
80
      pb.close();
2✔
81
  });
1✔
82
}
1✔
83

84
  @Override
85
  public boolean installPlugin(ToolPluginDescriptor plugin, Step step, ProcessContext pc) {
86

87
    List<String> extensionsCommands = new ArrayList<>();
4✔
88
    extensionsCommands.add("--force");
4✔
89
    extensionsCommands.add("--install-extension");
4✔
90
    String extensionInstallTarget = plugin.id();
3✔
91
    // If a version number was specified, add it to the extension identifier with the format "extensionId@version"
92
    boolean versionSpecified = (plugin.version() != null) && !plugin.version().isBlank();
11!
93
    if (versionSpecified) {
2✔
94
      extensionInstallTarget = extensionInstallTarget + "@" + plugin.version();
5✔
95
    }
96
    extensionsCommands.add(extensionInstallTarget);
4✔
97
    ProcessResult result = runTool(pc, ProcessMode.DEFAULT_CAPTURE, extensionsCommands);
6✔
98
    if (result.isSuccessful()) {
3!
99
      if (versionSpecified) {
2✔
100
        IdeLogLevel.SUCCESS.log(LOG, "Successfully installed plugin: {} with version: {}", plugin.name(), plugin.version());
17✔
101
      } else {
102
        IdeLogLevel.SUCCESS.log(LOG, "Successfully installed plugin: {}", plugin.name());
11✔
103
      }
104
      step.success();
2✔
105
      return true;
2✔
106
    }
107
    if (EDITION_VSCODIUM.equals(getConfiguredEdition())) {
×
108
      this.vscodiumUnavailablePlugins.add(plugin.id());
×
109
      return false;
×
110
    } else {
111
      if (versionSpecified) {
×
112
        IdeLogLevel.ERROR.log(LOG, "Failed to install plugin: {} with version: {}", plugin.name(), plugin.version());
×
113
      } else {
114
        IdeLogLevel.ERROR.log(LOG, "Failed to install plugin: {}", plugin.name());
×
115
      }
116
      return false;
×
117
    }
118
  }
119

120
  @Override
121
  protected void configureToolArgs(ProcessContext pc, ProcessMode processMode, List<String> args) {
122

123
    if (this.context.getSystemInfo().isWsl()) {
5✔
124
      pc.withEnvVar("DONT_PROMPT_WSL_INSTALL", "1");
5✔
125
    }
126
    Path vsCodeConf = this.context.getWorkspacePath().resolve(".vscode/.userdata");
6✔
127
    pc.addArg("--new-window");
4✔
128
    pc.addArg("--user-data-dir=" + vsCodeConf);
6✔
129
    Path vsCodeExtensionFolder = this.context.getIdeHome().resolve("plugins/vscode");
6✔
130
    pc.addArg("--extensions-dir=" + vsCodeExtensionFolder);
6✔
131
    pc.addArg(this.context.getWorkspacePath());
6✔
132
    super.configureToolArgs(pc, processMode, args);
5✔
133
  }
1✔
134

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