Skip to content

Commit 73925cc

Browse files
committed
decent state
1 parent 228f778 commit 73925cc

55 files changed

Lines changed: 668 additions & 298 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

de.peeeq.wurstscript/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ dependencies {
9090

9191
// Libs
9292
implementation 'com.google.guava:guava:32.1.3-jre'
93-
implementation 'io.vavr:vavr:0.10.4'
93+
implementation 'io.vavr:vavr:0.10.7'
9494
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.21.1'
9595
implementation 'org.eclipse.jdt:org.eclipse.jdt.annotation:2.1.0'
9696
implementation 'com.google.code.gson:gson:2.10.1'
@@ -193,7 +193,7 @@ tasks.named('compileJava') { it.dependsOn('gen') }
193193
/** -------- Tests -------- */
194194

195195
test {
196-
jvmArgs = ['-Xms256m']
196+
jvmArgs = ['-Xms2g', '-Xmx8g', '-XX:+UseG1GC']
197197
useTestNG()
198198
}
199199

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/CompiletimeFunctionRunner.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,11 @@ public ImVar initFor(ILconstObject obj) {
286286
for (Map.Entry<List<Integer>, ILconst> entry2 : value1.entrySet()) {
287287
List<Integer> indexes = entry2.getKey();
288288
ILconst attrValue = entry2.getValue();
289-
ImExprs indexesT = indexes.stream()
290-
.map(i -> constantToExpr(trace, ILconstInt.create(i)))
291-
.collect(Collectors.toCollection(JassIm::ImExprs));
289+
ImExprs indexesT = JassIm.ImExprs();
290+
for (Integer i : indexes) {
291+
ImExpr imExpr = constantToExpr(trace, ILconstInt.create(i));
292+
indexesT.add(imExpr);
293+
}
292294
ImExpr value2 = constantToExpr(trace, attrValue);
293295
if(translator.isLuaTarget() && value2.toString().equals("0")) {
294296
ImType varType = var.getType();
@@ -345,11 +347,14 @@ private ImExpr constantToExpr(Element trace, ILconst value) {
345347
} else if (value instanceof ILconstString) {
346348
return JassIm.ImStringVal(((ILconstString) value).getVal());
347349
} else if (value instanceof ILconstTuple) {
350+
List<ImExpr> list = new ArrayList<>();
351+
for (ILconst e : ((ILconstTuple) value).values()) {
352+
ImExpr imExpr = constantToExpr(trace, e);
353+
list.add(imExpr);
354+
}
348355
return JassIm.ImTupleExpr(
349356
JassIm.ImExprs(
350-
((ILconstTuple) value).values().stream()
351-
.map(e -> constantToExpr(trace, e))
352-
.collect(Collectors.toList())
357+
list
353358
)
354359
);
355360
} else if (value instanceof IlConstHandle) {
@@ -469,14 +474,18 @@ private ImExpr constantToExprHashtable(Element trace, ImVar htVar, IlConstHandle
469474

470475
@NotNull
471476
private ImFunction findNative(String funcName, WPos trace) {
472-
return imProg.getFunctions()
473-
.stream()
474-
.filter(ImFunction::isNative)
475-
.filter(func -> func.getName().equals(funcName))
476-
.findFirst()
477-
.orElseGet(() -> {
478-
throw new CompileError(trace, "Could not find native 'InitHashtable'");
479-
});
477+
for (ImFunction func : imProg.getFunctions()) {
478+
if (func.isNative()) {
479+
if (func.getName().equals(funcName)) {
480+
return Optional.of(func)
481+
.orElseGet(() -> {
482+
throw new CompileError(trace, "Could not find native 'InitHashtable'");
483+
});
484+
}
485+
}
486+
}
487+
return Optional.<ImFunction>empty()
488+
.orElseThrow(() -> new CompileError(trace, "Could not find native 'InitHashtable'"));
480489
}
481490

482491

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/WurstCompilerJassImpl.java

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,17 @@ public static void addDependenciesFromFolder(File projectFolder, Collection<File
290290
File[] depProjects = dependencyFolder.listFiles();
291291
if (depProjects != null) {
292292
for (File depFile : depProjects) {
293-
if (depFile.isDirectory()
294-
&& dependencies.stream().noneMatch(f -> FileUtils.sameFile(f, depFile))) {
295-
dependencies.add(depFile);
293+
if (depFile.isDirectory()) {
294+
boolean b = true;
295+
for (File f : dependencies) {
296+
if (FileUtils.sameFile(f, depFile)) {
297+
b = false;
298+
break;
299+
}
300+
}
301+
if (b) {
302+
dependencies.add(depFile);
303+
}
296304
}
297305
}
298306
}
@@ -608,25 +616,32 @@ private void addJassHotCodeReloadCode() {
608616

609617
@NotNull
610618
private ImFunction findNative(String funcName, WPos trace) {
611-
return imProg.getFunctions()
612-
.stream()
613-
.filter(ImFunction::isNative)
614-
.filter(func -> func.getName().equals(funcName))
615-
.findFirst()
616-
.orElseGet(() -> {
617-
throw new CompileError(trace, "Could not find native " + funcName);
618-
});
619+
for (ImFunction func : imProg.getFunctions()) {
620+
if (func.isNative()) {
621+
if (func.getName().equals(funcName)) {
622+
return Optional.of(func)
623+
.orElseGet(() -> {
624+
throw new CompileError(trace, "Could not find native " + funcName);
625+
});
626+
}
627+
}
628+
}
629+
return Optional.<ImFunction>empty()
630+
.orElseThrow(() -> new CompileError(trace, "Could not find native " + funcName));
619631
}
620632

621633
@NotNull
622634
private ImFunction findFunction(String funcName, WPos trace) {
623-
return imProg.getFunctions()
624-
.stream()
625-
.filter(func -> func.getName().equals(funcName))
626-
.findFirst()
627-
.orElseGet(() -> {
628-
throw new CompileError(trace, "Could not find native " + funcName);
629-
});
635+
for (ImFunction func : imProg.getFunctions()) {
636+
if (func.getName().equals(funcName)) {
637+
return Optional.of(func)
638+
.orElseGet(() -> {
639+
throw new CompileError(trace, "Could not find native " + funcName);
640+
});
641+
}
642+
}
643+
return Optional.<ImFunction>empty()
644+
.orElseThrow(() -> new CompileError(trace, "Could not find native " + funcName));
630645
}
631646

632647
@NotNull
@@ -671,10 +686,11 @@ private void beginPhase(int phase, String description) {
671686
}
672687

673688
private void printDebugImProg(String debugFile) {
674-
if (!errorHandler.isUnitTestMode()) {
689+
if (!errorHandler.isUnitTestMode() || !errorHandler.isOutputTestSource()) {
675690
// output only in unit test mode
676691
return;
677692
}
693+
678694
try {
679695
// TODO remove test output
680696
File file = new File(debugFile);

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/jassinterpreter/JassArray.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import de.peeeq.wurstscript.intermediatelang.ILconstAbstract;
66
import de.peeeq.wurstscript.types.WurstType;
77

8+
import java.util.ArrayList;
9+
import java.util.List;
810
import java.util.Map;
911

1012
public class JassArray extends ILconstAbstract {
@@ -38,15 +40,20 @@ public String print() {
3840
}
3941

4042
int finalI = i;
41-
values.keySet().stream().sorted().filter(x -> x < 0 || x >= finalI).forEach(k -> {
42-
ILconst v = values.get(k);
43-
if (res.length() > 0) {
44-
res.append(", ");
43+
List<Integer> toSort = new ArrayList<>();
44+
toSort.addAll(values.keySet());
45+
toSort.sort(null);
46+
for (Integer x : toSort) {
47+
if (x < 0 || x >= finalI) {
48+
ILconst v = values.get(x);
49+
if (!res.isEmpty()) {
50+
res.append(", ");
51+
}
52+
res.append(x);
53+
res.append(" -> ");
54+
res.append(v);
4555
}
46-
res.append(k);
47-
res.append(" -> ");
48-
res.append(v);
49-
});
56+
}
5057

5158
return "[" + res + "]";
5259
}

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/jassinterpreter/providers/WurstflectionProvider.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
import de.peeeq.wurstscript.intermediatelang.ILconstInt;
55
import de.peeeq.wurstscript.intermediatelang.ILconstString;
66
import de.peeeq.wurstscript.intermediatelang.interpreter.AbstractInterpreter;
7+
import de.peeeq.wurstscript.jassIm.ImClass;
78
import de.peeeq.wurstscript.jassIm.ImProg;
89

10+
import java.util.Map;
11+
import java.util.Optional;
12+
913
import static de.peeeq.wurstscript.translation.imtranslation.EliminateClasses.calculateClassName;
1014
import static de.peeeq.wurstscript.translation.imtranslation.EliminateClasses.calculateMaxTypeId;
1115

@@ -19,11 +23,16 @@ public WurstflectionProvider(AbstractInterpreter interpreter) {
1923
public ILconstString typeIdToTypeName(ILconstInt typeId) {
2024
ImProg prog = interpreter.getImProg();
2125
int typeIdInt = typeId.getVal();
22-
return prog.attrTypeId().entrySet()
23-
.stream()
24-
.filter(e -> e.getValue() == typeIdInt)
25-
.map(e -> new ILconstString(calculateClassName(e.getKey())))
26-
.findFirst()
26+
for (Map.Entry<ImClass, Integer> e : prog.attrTypeId().entrySet()) {
27+
if (e.getValue() == typeIdInt) {
28+
ILconstString iLconstString = new ILconstString(calculateClassName(e.getKey()));
29+
return Optional.of(iLconstString)
30+
.orElseGet(() -> {
31+
throw new InterpreterException("Could not determine type name for id " + typeId);
32+
});
33+
}
34+
}
35+
return Optional.<ILconstString>empty()
2736
.orElseGet(() -> {
2837
throw new InterpreterException("Could not determine type name for id " + typeId);
2938
});

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ModelManagerImpl.java

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ public Changes removeCompilationUnit(WFile resource) {
9393
}
9494

9595
syncCompilationUnitContent(resource, "");
96-
List<CompilationUnit> toRemove = model2.stream()
97-
.filter(cu -> wFile(cu).equals(resource))
98-
.collect(Collectors.toList());
96+
List<CompilationUnit> toRemove = new ArrayList<>();
97+
for (CompilationUnit compilationUnit : model2) {
98+
if (wFile(compilationUnit).equals(resource)) {
99+
toRemove.add(compilationUnit);
100+
}
101+
}
99102
model2.removeAll(toRemove);
100103
return new Changes(toRemove.stream()
101104
.map(this::wFile),
@@ -191,13 +194,22 @@ private List<CompilationUnit> getCompilationUnits(List<WFile> fileNames) {
191194
if (model2 == null) {
192195
return Collections.emptyList();
193196
}
194-
return model2.stream().filter(cu -> fileNames.contains(wFile(cu))).collect(Collectors.toList());
197+
List<CompilationUnit> list = new ArrayList<>();
198+
for (CompilationUnit cu : model2) {
199+
if (fileNames.contains(wFile(cu))) {
200+
list.add(cu);
201+
}
202+
}
203+
return list;
195204
}
196205

197206
private List<WFile> getfileNames(Collection<CompilationUnit> compilationUnits) {
198-
return compilationUnits.stream()
199-
.map(this::wFile)
200-
.collect(Collectors.toList());
207+
List<WFile> list = new ArrayList<>();
208+
for (CompilationUnit compilationUnit : compilationUnits) {
209+
WFile wFile = wFile(compilationUnit);
210+
list.add(wFile);
211+
}
212+
return list;
201213
}
202214

203215
/**
@@ -384,10 +396,12 @@ private void updateModel(CompilationUnit cu, WurstGui gui) {
384396
}
385397

386398
private Set<String> providedPackages(CompilationUnit c) {
387-
return c.getPackages()
388-
.stream()
389-
.map(WPackage::getName)
390-
.collect(Collectors.toSet());
399+
Set<String> set = new HashSet<>();
400+
for (WPackage wPackage : c.getPackages()) {
401+
String name = wPackage.getName();
402+
set.add(name);
403+
}
404+
return set;
391405
}
392406

393407
private CompilationUnit compileFromJar(WurstGui gui, String filename) throws IOException {
@@ -477,10 +491,12 @@ private Set<String> declaredPackages(WFile f) {
477491
}
478492
for (CompilationUnit cu : model) {
479493
if (wFile(cu).equals(f)) {
480-
return cu.getPackages()
481-
.stream()
482-
.map(WPackage::getName)
483-
.collect(Collectors.toSet());
494+
Set<String> set = new HashSet<>();
495+
for (WPackage wPackage : cu.getPackages()) {
496+
String name = wPackage.getName();
497+
set.add(name);
498+
}
499+
return set;
484500
}
485501
}
486502
return Collections.emptySet();
@@ -617,9 +633,12 @@ public void reconcile(Changes changes) {
617633
if (model2 == null) {
618634
return;
619635
}
620-
Collection<CompilationUnit> toCheck1 = model2.stream()
621-
.filter(cu -> changes.getAffectedFiles().contains(WFile.create(cu.getCuInfo().getFile())))
622-
.collect(Collectors.toSet());
636+
Collection<CompilationUnit> toCheck1 = new HashSet<>();
637+
for (CompilationUnit cu : model2) {
638+
if (changes.getAffectedFiles().contains(WFile.create(cu.getCuInfo().getFile()))) {
639+
toCheck1.add(cu);
640+
}
641+
}
623642
Set<String> oldPackageNames = changes.getAffectedPackageNames().toJavaSet();
624643
Collection<CompilationUnit> toCheckRec = calculateCUsToUpdate(toCheck1, oldPackageNames, model2);
625644
WurstGui gui = new WurstGuiLogger();
@@ -657,7 +676,14 @@ private Set<CompilationUnit> calculateCUsToUpdate(Collection<CompilationUnit> ch
657676
Set<CompilationUnit> result = new TreeSet<>(Comparator.comparing(cu -> cu.getCuInfo().getFile()));
658677
result.addAll(changed);
659678

660-
if (changed.stream().anyMatch(cu -> cu.getCuInfo().getFile().endsWith(".j"))) {
679+
boolean b = false;
680+
for (CompilationUnit compilationUnit : changed) {
681+
if (compilationUnit.getCuInfo().getFile().endsWith(".j")) {
682+
b = true;
683+
break;
684+
}
685+
}
686+
if (b) {
661687
// when plain Jass files are changed, everything must be checked again:
662688
result.addAll(model);
663689
return result;

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/ProjectConfigBuilder.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ private static void applyPlayers(WurstProjectConfigData projectConfig, W3I w3I)
164164
w3I.getPlayers().clear();
165165
ArrayList<WurstProjectBuildPlayer> players = projectConfig.getBuildMapData().getPlayers();
166166
for (WurstProjectBuildPlayer wplayer : players) {
167-
Optional<W3I.Player> old = existing.stream().filter(player -> player.getNum() == wplayer.getId()).findFirst();
167+
Optional<Player> old = Optional.empty();
168+
for (Player player2 : existing) {
169+
if (player2.getNum() == wplayer.getId()) {
170+
old = Optional.of(player2);
171+
break;
172+
}
173+
}
168174
W3I.Player player = new Player();
169175
player.setNum(wplayer.getId());
170176
w3I.addPlayer(player);

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/WurstTextDocumentService.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,29 @@ public CompletableFuture<List<? extends Location>> references(ReferenceParams pa
5858
WLogger.info("references");
5959
return worker.handle(new GetUsages(params, worker.getBufferManager(), true))
6060
.thenApply((List<GetUsages.UsagesData> udList) ->
61-
udList.stream()
62-
.map(GetUsages.UsagesData::getLocation)
63-
.collect(Collectors.toList()));
61+
{
62+
List<Location> list = new ArrayList<>();
63+
for (GetUsages.UsagesData usagesData : udList) {
64+
Location location = usagesData.getLocation();
65+
list.add(location);
66+
}
67+
return list;
68+
});
6469
}
6570

6671
@Override
6772
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(DocumentHighlightParams highlightParams) {
6873
WLogger.info("documentHighlight");
6974
return worker.handle(new GetUsages(highlightParams, worker.getBufferManager(), false))
7075
.thenApply((List<GetUsages.UsagesData> udList) ->
71-
udList.stream()
72-
.map(GetUsages.UsagesData::toDocumentHighlight)
73-
.collect(Collectors.toList()));
76+
{
77+
List<DocumentHighlight> list = new ArrayList<>();
78+
for (GetUsages.UsagesData usagesData : udList) {
79+
DocumentHighlight documentHighlight = usagesData.toDocumentHighlight();
80+
list.add(documentHighlight);
81+
}
82+
return list;
83+
});
7484
}
7585

7686
@Override

0 commit comments

Comments
 (0)