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

wurstscript / WurstScript / 228

29 Nov 2023 05:00PM UTC coverage: 62.48% (-0.09%) from 62.574%
228

push

circleci

web-flow
Show dialog for choosing game path, cleanup (#1083)

* show dialog for choosing game path

* cleanup code

* remove logs and refactor

* remove confusing mpq error, make some mpq loads readonly

17295 of 27681 relevant lines covered (62.48%)

0.62 hits per line

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

45.83
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ModelManager.java
1
package de.peeeq.wurstio.languageserver;
2

3
import de.peeeq.wurstscript.ast.CompilationUnit;
4
import de.peeeq.wurstscript.ast.ModuleInstanciations;
5
import de.peeeq.wurstscript.ast.WurstModel;
6
import de.peeeq.wurstscript.attributes.CompileError;
7
import io.vavr.collection.HashSet;
8
import org.eclipse.jdt.annotation.Nullable;
9
import org.eclipse.lsp4j.PublishDiagnosticsParams;
10

11
import java.io.File;
12
import java.util.List;
13
import java.util.Set;
14
import java.util.function.Consumer;
15
import java.util.stream.Stream;
16

17
public interface ModelManager {
18

19
    Changes removeCompilationUnit(WFile filename);
20

21
    /**
22
     * cleans the model
23
     */
24
    void clean();
25

26
    List<CompileError> getParseErrors();
27

28
    void onCompilationResult(Consumer<PublishDiagnosticsParams> f);
29

30
    void buildProject();
31

32
    Changes syncCompilationUnit(WFile changedFilePath);
33

34
    Changes syncCompilationUnitContent(WFile filename, String contents);
35

36
    CompilationUnit replaceCompilationUnitContent(WFile filename, String buffer, boolean reportErrors);
37

38
    /**
39
     * get all wurst files in dependency folders
40
     */
41
    Set<File> getDependencyWurstFiles();
42

43
    @Nullable CompilationUnit getCompilationUnit(WFile filename);
44

45
    WurstModel getModel();
46

47
    boolean hasErrors();
48

49
    static WurstModel copy(WurstModel model) {
50
        WurstModel m = model.copy();
×
51
        // clear all module instantiations, since they might include old stuff
52
        m.accept(new WurstModel.DefaultVisitor() {
×
53
            @Override
54
            public void visit(ModuleInstanciations mis) {
55
                super.visit(mis);
×
56
                mis.clear();
×
57
            }
×
58
        });
59
        return m;
×
60
    }
61

62
    File getProjectPath();
63

64
    String getFirstErrorDescription();
65

66
    /** clean and typecheck the given files */
67
    void reconcile(Changes changes);
68

69
    class Changes {
70
        private static final Changes EMPTY = new Changes(HashSet.empty(), HashSet.empty());
1✔
71
        private final HashSet<WFile> affectedFiles;
72
        private final HashSet<String> affectedPackageNames;
73

74
        public Changes(Iterable<WFile> affectedFiles, Iterable<String> affectedPackageNames) {
1✔
75
            this.affectedFiles = HashSet.ofAll(affectedFiles);
1✔
76
            this.affectedPackageNames = HashSet.ofAll(affectedPackageNames);
1✔
77
        }
1✔
78

79
        public Changes(Stream<WFile> affectedFiles, Stream<String> affectedPackageNames) {
1✔
80
            this.affectedFiles = HashSet.ofAll(affectedFiles);
1✔
81
            this.affectedPackageNames = HashSet.ofAll(affectedPackageNames);
1✔
82
        }
1✔
83

84
        public static Changes empty() {
85
            return EMPTY;
×
86
        }
87

88
        public HashSet<WFile> getAffectedFiles() {
89
            return affectedFiles;
1✔
90
        }
91

92
        public HashSet<String> getAffectedPackageNames() {
93
            return affectedPackageNames;
1✔
94
        }
95

96
        public Changes mergeWith(Changes affected) {
97
            HashSet<WFile> newF = affectedFiles.addAll(affected.affectedFiles);
×
98
            HashSet<String> newP = affectedPackageNames.addAll(affected.affectedPackageNames);
×
99
            if (newF == affectedFiles && newP == affectedPackageNames) {
×
100
                return this;
×
101
            }
102
            return new Changes(newF, newP);
×
103
        }
104

105
        public boolean isEmpty() {
106
            return affectedFiles.isEmpty() && affectedPackageNames.isEmpty();
×
107
        }
108
    }
109

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