Skip to content

Commit d8c45e2

Browse files
committed
fixes
1 parent a32626d commit d8c45e2

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ protected File runJassHotCodeReload(File mapScript) throws IOException, Interrup
244244
private void purgeUnimportedFiles(WurstModel model) {
245245

246246
Set<CompilationUnit> imported = model.stream()
247-
.filter(cu -> isInProjectWurstFolder(cu.getCuInfo().getFile()) || isProjectWar3MapScript(cu.getCuInfo().getFile()))
247+
.filter(cu -> isInProjectWurstFolder(cu.getCuInfo().getFile())
248+
|| isProjectWar3MapScript(cu.getCuInfo().getFile())
249+
|| isRequiredBuildJass(cu.getCuInfo().getFile()))
248250
.collect(Collectors.toSet());
249251
addImports(imported, imported);
250252

@@ -278,6 +280,21 @@ private boolean isInProjectWurstFolder(String file) {
278280
&& Utils.isWurstFile(file);
279281
}
280282

283+
private boolean isRequiredBuildJass(String file) {
284+
Path p = Paths.get(file).toAbsolutePath().normalize();
285+
Path buildDir;
286+
try {
287+
buildDir = workspaceRoot.getPath().resolve("_build").toAbsolutePath().normalize();
288+
} catch (FileNotFoundException e) {
289+
return false;
290+
}
291+
if (!p.startsWith(buildDir)) {
292+
return false;
293+
}
294+
String name = p.getFileName().toString();
295+
return name.equals("common.j") || name.equals("blizzard.j");
296+
}
297+
281298
protected File getBuildDir() {
282299
File buildDir;
283300
try {

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/ModelManagerTests.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ public void runmapPurge_onlyKeepsWar3MapFromProjectWurstFolder() throws Exceptio
885885
private void purgeUnimportedFiles_likeRunMap(WurstModel model, ModelManagerImpl manager) {
886886
java.util.Set<CompilationUnit> keep = model.stream()
887887
.filter(cu -> isInProjectWurstFolder_likeRunMap(cu.getCuInfo().getFile(), manager)
888-
|| isProjectWar3Map_likeRunMap(cu.getCuInfo().getFile(), manager))
888+
|| isProjectWar3Map_likeRunMap(cu.getCuInfo().getFile(), manager)
889+
|| isRequiredBuildJass_likeRunMap(cu.getCuInfo().getFile(), manager))
889890
.collect(java.util.stream.Collectors.toSet());
890891

891892
// Recursively add imported packages’ CUs (uses attrImportedPackage like RunMap)
@@ -910,6 +911,16 @@ private boolean isProjectWar3Map_likeRunMap(String file, ModelManagerImpl manage
910911
return p.startsWith(w) && java.nio.file.Files.exists(p);
911912
}
912913

914+
private boolean isRequiredBuildJass_likeRunMap(String file, ModelManagerImpl manager) {
915+
java.nio.file.Path p = java.nio.file.Paths.get(file).toAbsolutePath().normalize();
916+
java.nio.file.Path buildDir = manager.getProjectPath().toPath().resolve("_build").toAbsolutePath().normalize();
917+
if (!p.startsWith(buildDir) || !java.nio.file.Files.exists(p)) {
918+
return false;
919+
}
920+
String name = p.getFileName().toString();
921+
return name.equals("common.j") || name.equals("blizzard.j");
922+
}
923+
913924
private void addImports_likeRunMap(java.util.Set<CompilationUnit> result, java.util.Set<CompilationUnit> toAdd) {
914925
java.util.Set<CompilationUnit> imported =
915926
toAdd.stream()

0 commit comments

Comments
 (0)