Skip to content

Commit c21a33c

Browse files
committed
revert: "lsp-test: advisor now extends DiskCompilerAdvisor (with some bug)"
This reverts commit b9d49e5.
1 parent b9d49e5 commit c21a33c

File tree

3 files changed

+6
-44
lines changed

3 files changed

+6
-44
lines changed

Diff for: ide-lsp/src/test/java/org/aya/lsp/LspTest.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
1+
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
22
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
33
package org.aya.lsp;
44

@@ -15,16 +15,13 @@
1515
import org.aya.syntax.concrete.stmt.decl.FnDecl;
1616
import org.aya.syntax.core.term.MetaPatTerm;
1717
import org.aya.syntax.core.term.call.DataCall;
18-
import org.aya.util.FileUtil;
1918
import org.javacs.lsp.InitializeParams;
2019
import org.javacs.lsp.Position;
2120
import org.javacs.lsp.TextDocumentIdentifier;
2221
import org.javacs.lsp.TextDocumentPositionParams;
2322
import org.jetbrains.annotations.NotNull;
24-
import org.junit.jupiter.api.BeforeEach;
2523
import org.junit.jupiter.api.Test;
2624

27-
import java.io.IOException;
2825
import java.nio.file.Path;
2926

3027
import static org.aya.lsp.tester.TestCommand.compile;
@@ -40,11 +37,6 @@ public class LspTest {
4037
return client;
4138
}
4239

43-
// FIXME: remove this after fixing the prim factory problem
44-
@BeforeEach public void clearCore() throws IOException {
45-
FileUtil.deleteRecursively(TEST_LIB.resolve("build"));
46-
}
47-
4840
@Test public void testJustLoad() {
4941
launch(TEST_LIB).execute(compile((_, _) -> {}));
5042
}

Diff for: ide-lsp/src/test/java/org/aya/lsp/tester/LspTestCompilerAdvisor.java

+4-34
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
1+
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
22
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
33
package org.aya.lsp.tester;
44

55
import kala.collection.SeqView;
66
import kala.collection.immutable.ImmutableSeq;
77
import kala.collection.mutable.MutableList;
8-
import kala.collection.mutable.MutableMap;
9-
import org.aya.cli.library.incremental.DiskCompilerAdvisor;
108
import org.aya.cli.library.incremental.InMemoryCompilerAdvisor;
119
import org.aya.cli.library.source.LibrarySource;
1210
import org.aya.resolve.ResolveInfo;
@@ -15,16 +13,10 @@
1513
import org.jetbrains.annotations.NotNull;
1614
import org.jetbrains.annotations.Nullable;
1715

18-
import java.io.IOException;
19-
import java.nio.file.Files;
20-
import java.nio.file.Path;
21-
import java.nio.file.attribute.FileTime;
22-
import java.time.Instant;
2316
import java.util.function.Function;
2417

25-
public class LspTestCompilerAdvisor extends DiskCompilerAdvisor {
18+
public class LspTestCompilerAdvisor extends InMemoryCompilerAdvisor {
2619
public @Nullable ImmutableSeq<ImmutableSeq<LibrarySource>> lastJob;
27-
public final @NotNull MutableMap<Path, FileTime> newlyModified = MutableMap.create();
2820
public final @NotNull MutableList<ResolveInfo> newlyCompiled = MutableList.create();
2921

3022
public @NotNull SeqView<LibrarySource> lastCompiled() {
@@ -34,24 +26,7 @@ public class LspTestCompilerAdvisor extends DiskCompilerAdvisor {
3426
}
3527

3628
public void mutate(@NotNull LibrarySource source) {
37-
newlyModified.put(source.underlyingFile(), FileTime.from(Instant.now()));
38-
}
39-
40-
@Override
41-
public boolean isSourceModified(@NotNull LibrarySource source) {
42-
var tempFileTime = newlyModified.getOrNull(source.underlyingFile());
43-
if (tempFileTime != null) {
44-
try {
45-
// TODO: duplicate code as in [InMemoryCompilerAdvisor] and [DiskCompilerAdvisor]
46-
var core = source.compiledCorePath();
47-
if (!Files.exists(core)) return true;
48-
return tempFileTime.compareTo(Files.getLastModifiedTime(core)) > 0;
49-
} catch (IOException e) {
50-
return true;
51-
}
52-
}
53-
54-
return super.isSourceModified(source);
29+
coreTimestamp.remove(timestampKey(source));
5530
}
5631

5732
public void prepareCompile() {
@@ -65,12 +40,7 @@ public void prepareCompile() {
6540
}
6641

6742
@Override public @NotNull ResolveInfo
68-
doSaveCompiledCore(
69-
@NotNull LibrarySource file,
70-
@NotNull ResolveInfo resolveInfo,
71-
@NotNull ImmutableSeq<TyckDef> defs,
72-
@NotNull ModuleLoader recurseLoader
73-
) throws IOException, ClassNotFoundException {
43+
doSaveCompiledCore(@NotNull LibrarySource file, @NotNull ResolveInfo resolveInfo, @NotNull ImmutableSeq<TyckDef> defs, @NotNull ModuleLoader recurseLoader) {
7444
var info = super.doSaveCompiledCore(file, resolveInfo, defs, recurseLoader);
7545
newlyCompiled.append(resolveInfo);
7646
return info;

Diff for: syntax/src/main/java/org/aya/syntax/compile/JitUnit.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.aya.util.error.Panic;
1010
import org.jetbrains.annotations.NotNull;
1111

12-
public abstract class JitUnit {
12+
public abstract sealed class JitUnit permits JitDef, JitMatchy {
1313
private CompiledAya metadata;
1414

1515
public @NotNull final CompiledAya metadata() {

0 commit comments

Comments
 (0)