File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
server/src/main/kotlin/org/javacs/kt Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class CompilerClassPath(private val config: CompilerConfiguration) : Closeable {
46
46
}
47
47
48
48
if (refreshCompiler) {
49
+ LOG .info(" Reinstantiating compiler" )
49
50
compiler.close()
50
51
compiler = Compiler (javaSourcePath, classPath, buildScriptClassPath)
51
52
updateCompilerConfiguration()
Original file line number Diff line number Diff line change @@ -45,6 +45,13 @@ class SourcePath(
45
45
content = newContent
46
46
}
47
47
48
+ fun clean () {
49
+ parsed = null
50
+ compiledFile = null
51
+ compiledContext = null
52
+ compiledContainer = null
53
+ }
54
+
48
55
fun parse () {
49
56
// TODO: Create PsiFile using the stored language instead
50
57
parsed = cp.compiler.createKtFile(content, path ? : Paths .get(" sourceFile.virtual.$extension " ), kind)
@@ -68,12 +75,6 @@ class SourcePath(
68
75
69
76
fun compile () = parse().apply { doCompile() }
70
77
71
- fun compileIfInitialized () {
72
- if (parsed != null ) {
73
- compile()
74
- }
75
- }
76
-
77
78
private fun doCompile () {
78
79
LOG .debug(" Compiling {}" , path?.fileName)
79
80
@@ -205,8 +206,12 @@ class SourcePath(
205
206
* Recompiles all source files that are initialized.
206
207
*/
207
208
fun refresh () {
208
- LOG .info(" Refreshing source path" )
209
- files.values.forEach { it.compileIfInitialized() }
209
+ val initialized = files.values.any { it.parsed != null }
210
+ if (initialized) {
211
+ LOG .info(" Refreshing source path" )
212
+ files.values.forEach { it.clean() }
213
+ files.values.forEach { it.compile() }
214
+ }
210
215
}
211
216
212
217
/* *
You can’t perform that action at this time.
0 commit comments