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

devonfw / IDEasy / 11783304870

11 Nov 2024 05:26PM UTC coverage: 67.136% (+0.2%) from 66.902%
11783304870

push

github

web-flow
#632: added .editorconfig  to settings-workspaces (#731)

2430 of 3960 branches covered (61.36%)

Branch coverage included in aggregate %.

6336 of 9097 relevant lines covered (69.65%)

3.07 hits per line

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

72.22
cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java
1
package com.devonfw.tools.ide.tool.ide;
2

3
import java.nio.file.Path;
4
import java.util.Set;
5

6
import com.devonfw.tools.ide.common.Tag;
7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.io.FileAccess;
9
import com.devonfw.tools.ide.process.ProcessMode;
10
import com.devonfw.tools.ide.step.Step;
11
import com.devonfw.tools.ide.tool.ToolCommandlet;
12
import com.devonfw.tools.ide.tool.eclipse.Eclipse;
13
import com.devonfw.tools.ide.tool.intellij.Intellij;
14
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
15
import com.devonfw.tools.ide.tool.vscode.Vscode;
16

17
/**
18
 * {@link ToolCommandlet} for an IDE (integrated development environment) such as {@link Eclipse}, {@link Vscode}, or {@link Intellij}.
19
 */
20
public abstract class IdeToolCommandlet extends PluginBasedCommandlet {
1✔
21

22
  /**
23
   * The constructor.
24
   *
25
   * @param context the {@link IdeContext}.
26
   * @param tool the {@link #getName() tool name}.
27
   * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method.
28
   */
29
  public IdeToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {
30

31
    super(context, tool, tags);
5✔
32
    assert (hasIde(tags));
5!
33
  }
1✔
34

35
  private boolean hasIde(Set<Tag> tags) {
36

37
    for (Tag tag : tags) {
10!
38
      if (tag.isAncestorOf(Tag.IDE)) {
4!
39
        return true;
2✔
40
      }
41
    }
×
42
    throw new IllegalStateException("Tags of IdeTool hat to be connected with tag IDE: " + tags);
×
43
  }
44

45
  @Override
46
  public final void run() {
47

48
    configureWorkspace();
2✔
49
    super.run();
2✔
50
  }
1✔
51

52
  @Override
53
  public void runTool(String... args) {
54

55
    runTool(ProcessMode.BACKGROUND, null, args);
5✔
56
  }
1✔
57

58
  /**
59
   * Configure the workspace for this IDE using the templates from the settings.
60
   */
61
  protected void configureWorkspace() {
62

63
    Path settingsWorkspaceFolder = this.context.getSettingsPath().resolve(this.tool)
7✔
64
        .resolve(IdeContext.FOLDER_WORKSPACE);
2✔
65
    Path genericWorkspaceFolder = this.context.getSettingsPath().resolve(IdeContext.FOLDER_WORKSPACE); 
6✔
66
    Path workspaceUpdateFolder = genericWorkspaceFolder.resolve(IdeContext.FOLDER_UPDATE);
4✔
67
    Path workspaceSetupFolder = genericWorkspaceFolder.resolve(IdeContext.FOLDER_SETUP);
4✔
68
    FileAccess fileAccess = this.context.getFileAccess();
4✔
69
    if (!fileAccess.isExpectedFolder(settingsWorkspaceFolder)) {
4✔
70
      return;
1✔
71
    }
72
    Path setupFolder = settingsWorkspaceFolder.resolve(IdeContext.FOLDER_SETUP);
4✔
73
    Path updateFolder = settingsWorkspaceFolder.resolve(IdeContext.FOLDER_UPDATE);
4✔
74
    if (!fileAccess.isExpectedFolder(setupFolder) && !fileAccess.isExpectedFolder(updateFolder)) {
4!
75
      return;
×
76
    }
77
    Path ideWorkspacePath = this.context.getWorkspacePath();
4✔
78
    if (!fileAccess.isExpectedFolder(ideWorkspacePath)) {
4!
79
      return; // should actually never happen...
×
80
    }
81
    try (Step step = this.context.newStep("Configuring workspace " + ideWorkspacePath.getFileName() + " for IDE " + this.tool)) {
9✔
82
      int errors = this.context.getWorkspaceMerger().merge(workspaceSetupFolder, workspaceUpdateFolder, this.context.getVariables(), ideWorkspacePath);
11✔
83
      errors += this.context.getWorkspaceMerger().merge(setupFolder, updateFolder, this.context.getVariables(), ideWorkspacePath);
13✔
84
      if (errors == 0) {
2!
85
        step.success();
3✔
86
      } else {
87
        step.error("Your workspace configuration failed with {} error(s) - see log above.\n"
×
88
            + "This is either a configuration error in your settings git repository or a bug in IDEasy.\n"
89
            + "Please analyze the above errors with your team or IDE-admin and try to fix the problem.", errors);
×
90
        this.context.askToContinue(
×
91
            "In order to prevent you from being blocked, you can start your IDE anyhow but some configuration may not be in sync.");
92
      }
93
    }
94
  }
1✔
95
}
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