1
- // Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
1
+ // Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
2
2
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
3
3
package org .aya .lsp .tester ;
4
4
5
5
import kala .collection .SeqView ;
6
6
import kala .collection .immutable .ImmutableSeq ;
7
7
import kala .collection .mutable .MutableList ;
8
- import kala .collection .mutable .MutableMap ;
9
- import org .aya .cli .library .incremental .DiskCompilerAdvisor ;
10
8
import org .aya .cli .library .incremental .InMemoryCompilerAdvisor ;
11
9
import org .aya .cli .library .source .LibrarySource ;
12
10
import org .aya .resolve .ResolveInfo ;
15
13
import org .jetbrains .annotations .NotNull ;
16
14
import org .jetbrains .annotations .Nullable ;
17
15
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 ;
23
16
import java .util .function .Function ;
24
17
25
- public class LspTestCompilerAdvisor extends DiskCompilerAdvisor {
18
+ public class LspTestCompilerAdvisor extends InMemoryCompilerAdvisor {
26
19
public @ Nullable ImmutableSeq <ImmutableSeq <LibrarySource >> lastJob ;
27
- public final @ NotNull MutableMap <Path , FileTime > newlyModified = MutableMap .create ();
28
20
public final @ NotNull MutableList <ResolveInfo > newlyCompiled = MutableList .create ();
29
21
30
22
public @ NotNull SeqView <LibrarySource > lastCompiled () {
@@ -34,24 +26,7 @@ public class LspTestCompilerAdvisor extends DiskCompilerAdvisor {
34
26
}
35
27
36
28
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 ));
55
30
}
56
31
57
32
public void prepareCompile () {
@@ -65,12 +40,7 @@ public void prepareCompile() {
65
40
}
66
41
67
42
@ 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 ) {
74
44
var info = super .doSaveCompiledCore (file , resolveInfo , defs , recurseLoader );
75
45
newlyCompiled .append (resolveInfo );
76
46
return info ;
0 commit comments