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

wurstscript / WurstScript / 203

18 Oct 2023 02:20PM UTC coverage: 63.758% (+0.3%) from 63.447%
203

push

circleci

web-flow
Update deps, improve performance, JHCR fixes (#1080)

- update dependencies
- update stdlib verison for unit tests
- only apply nullsetting when `-opt` is enabled to save some build time for testing
- minor performance improvements
- make build deterministic
- apply build map config before compilation
- hot code reload now more reliable

17246 of 27049 relevant lines covered (63.76%)

0.64 hits per line

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

0.0
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/BuildMap.java
1
package de.peeeq.wurstio.languageserver.requests;
2

3
import config.WurstProjectConfig;
4
import config.WurstProjectConfigData;
5
import de.peeeq.wurstio.gui.WurstGuiImpl;
6
import de.peeeq.wurstio.languageserver.ConfigProvider;
7
import de.peeeq.wurstio.languageserver.ModelManager;
8
import de.peeeq.wurstio.languageserver.ProjectConfigBuilder;
9
import de.peeeq.wurstio.languageserver.WFile;
10
import de.peeeq.wurstscript.WLogger;
11
import de.peeeq.wurstscript.attributes.CompileError;
12
import de.peeeq.wurstscript.gui.WurstGui;
13
import org.eclipse.lsp4j.MessageType;
14
import systems.crigges.jmpq3.JMpqEditor;
15
import systems.crigges.jmpq3.MPQOpenOption;
16

17
import java.io.File;
18
import java.io.IOException;
19
import java.util.List;
20
import java.util.Optional;
21

22
import static de.peeeq.wurstio.languageserver.ProjectConfigBuilder.FILE_NAME;
23

24
/**
25
 * Created by peter on 16.05.16.
26
 */
27
public class BuildMap extends MapRequest {
28

29
    public BuildMap(ConfigProvider configProvider, WFile workspaceRoot, Optional<String> wc3Path, Optional<File> map,
30
            List<String> compileArgs) {
31
        super(configProvider, map, compileArgs, workspaceRoot, wc3Path);
×
32
    }
×
33

34
    @Override
35
    public Object execute(ModelManager modelManager) throws IOException {
36
        if (modelManager.hasErrors()) {
×
37
            throw new RequestFailedException(MessageType.Error, "Fix errors in your code before building a release.\n" + modelManager.getFirstErrorDescription());
×
38
        }
39

40
        WurstProjectConfigData projectConfig = WurstProjectConfig.INSTANCE.loadProject(workspaceRoot.getFile().toPath().resolve(FILE_NAME));
×
41
        if (projectConfig == null) {
×
42
            throw new RequestFailedException(MessageType.Error, FILE_NAME + " file doesn't exist or is invalid. " +
×
43
                "Please install your project using grill or the wurst setup tool.");
44
        }
45

46
        WLogger.info("buildMap " + map + " " + compileArgs);
×
47
        WurstGui gui = new WurstGuiImpl(workspaceRoot.getFile().getAbsolutePath());
×
48
        try {
49
            if (!map.isPresent()) {
×
50
                throw new RequestFailedException(MessageType.Error, "Map is null");
×
51
            }
52
            if (!map.get().exists()) {
×
53
                throw new RequestFailedException(MessageType.Error, map.get().getAbsolutePath() + " does not exist.");
×
54
            }
55

56
            gui.sendProgress("Copying map");
×
57

58
            // first we copy in same location to ensure validity
59
            File buildDir = getBuildDir();
×
60
            String fileName = projectConfig.getBuildMapData().getFileName();
×
61
            Optional<File> targetMap = Optional.of(
×
62
                new File(buildDir, fileName.isEmpty() ? projectConfig.getProjectName() + ".w3x" : fileName + ".w3x"));
×
63
            CompilationResult result = compileScript(modelManager, gui, targetMap, projectConfig, buildDir, true);
×
64

65
            injectMapData(gui, targetMap, result);
×
66

67
            JMpqEditor finalizer = new JMpqEditor(targetMap.get(), MPQOpenOption.FORCE_V0);
×
68
            finalizer.close();
×
69

70
            gui.sendProgress("Done.");
×
71
        } catch (CompileError e) {
×
72
            WLogger.info(e);
×
73
            throw new RequestFailedException(MessageType.Error, "A compilation error occurred when building the map:\n" + e);
×
74
        } catch (Exception e) {
×
75
            WLogger.warning("Exception occurred", e);
×
76
            throw new RequestFailedException(MessageType.Error, "An exception was thrown when building the map:\n" + e);
×
77
        } finally {
78
            if (gui.getErrorCount() == 0) {
×
79
                gui.sendFinished();
×
80
            }
81
        }
82
        return "ok"; // TODO
×
83
    }
84
}
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

© 2025 Coveralls, Inc