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

devonfw / IDEasy / 15271391656

27 May 2025 09:15AM UTC coverage: 67.76% (+0.04%) from 67.716%
15271391656

push

github

web-flow
#716 Add VSCode extension installation visualization (#1308)

Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com>

3164 of 5072 branches covered (62.38%)

Branch coverage included in aggregate %.

8114 of 11572 relevant lines covered (70.12%)

3.07 hits per line

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

86.11
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 com.devonfw.tools.ide.common.Tag;
10
import com.devonfw.tools.ide.context.IdeContext;
11
import com.devonfw.tools.ide.io.IdeProgressBar;
12
import com.devonfw.tools.ide.process.ProcessContext;
13
import com.devonfw.tools.ide.process.ProcessErrorHandling;
14
import com.devonfw.tools.ide.process.ProcessMode;
15
import com.devonfw.tools.ide.process.ProcessResult;
16
import com.devonfw.tools.ide.step.Step;
17
import com.devonfw.tools.ide.tool.ToolCommandlet;
18
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
19
import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor;
20

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

26
  /**
27
   * The constructor.
28
   *
29
   * @param context the {@link IdeContext}.
30
   */
31
  public Vscode(IdeContext context) {
32

33
    super(context, "vscode", Set.of(Tag.VS_CODE));
6✔
34
  }
1✔
35

36
  @Override
37
  protected String getBinaryName() {
38

39
    return "code";
2✔
40
  }
41

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

56
  @Override
57
  public boolean installPlugin(ToolPluginDescriptor plugin, Step step, ProcessContext pc) {
58

59
    List<String> extensionsCommands = new ArrayList<>();
4✔
60
    extensionsCommands.add("--force");
4✔
61
    extensionsCommands.add("--install-extension");
4✔
62
    extensionsCommands.add(plugin.id());
5✔
63
    ProcessResult result = runTool(ProcessMode.DEFAULT_CAPTURE, ProcessErrorHandling.THROW_ERR, pc, extensionsCommands.toArray(String[]::new));
13✔
64
    if (result.isSuccessful()) {
3!
65
      this.context.success("Successfully installed plugin: {}", plugin.name());
11✔
66
      step.success();
2✔
67
      return true;
2✔
68
    } else {
69
      this.context.warning("An error occurred while installing plugin: {}", plugin.name());
×
70
      return false;
×
71
    }
72
  }
73

74
  @Override
75
  protected void configureToolArgs(ProcessContext pc, ProcessMode processMode, ProcessErrorHandling errorHandling, String... args) {
76

77
    Path vsCodeConf = this.context.getWorkspacePath().resolve(".vscode/.userdata");
6✔
78
    pc.addArg("--new-window");
4✔
79
    pc.addArg("--user-data-dir=" + vsCodeConf);
6✔
80
    Path vsCodeExtensionFolder = this.context.getIdeHome().resolve("plugins/vscode");
6✔
81
    pc.addArg("--extensions-dir=" + vsCodeExtensionFolder);
6✔
82
    pc.addArg(this.context.getWorkspacePath());
6✔
83
    super.configureToolArgs(pc, processMode, errorHandling, args);
6✔
84
  }
1✔
85

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