You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Logging message(s) from a single-thread queue to keep the correct order.
99
-
logExecutor.submit {
100
-
logger.infoRich("Successfully loaded <yellow>${loadedScripts.size} <reset>out of total <yellow>${scriptHolders.size}<reset> scripts.")
77
+
logger.infoRich("Successfully compiled <yellow>${compiledScripts.size} <reset>out of total <yellow>${scriptHolders.size}<reset> scripts. Loading them now...")
78
+
// Loading compiled scripts.
79
+
val elapsedExecutionTime = measureTime {
80
+
for (script in compiledScripts) try {
81
+
loadedScripts[script.name] = script
82
+
script.runOnLoad()
83
+
} catch (e:Exception) {
84
+
e.printStackTrace()
85
+
}
101
86
}
87
+
logger.infoRich("Successfully loaded <yellow>${loadedScripts.size} <reset>out of total <yellow>${compiledScripts.size}<reset> scripts.")
// Logging diagnostics from a single-thread queue. Otherwise, messages can be displayed in wrong order due to parallel compilation.
156
-
logExecutor.submit {
142
+
// Logging message after *failed* compilation, but before diagnostics.
143
+
if (compiledScript isResultWithDiagnostics.Failure) {
144
+
val errorCount = compiledScript.reports.count { it.severity ==Severity.FATAL|| it.severity ==Severity.ERROR }
145
+
logger.errorRich("Script <yellow>${holder.name}</yellow> reported <yellow>$errorCount</yellow> error(s) during compilation:")
146
+
}
147
+
// Logging diagnostics to the console.
148
+
compiledScript.reports.forEach {
149
+
val message ="<yellow>(${script.name}, ${it.sourcePath?.substringAfterLast("/")}, line ${it.location?.start?.line ?:"???"}, col ${it.location?.start?.col ?:"???"})</yellow> ${it.message}"
150
+
when (it.severity) {
151
+
Severity.INFO-> logger.infoRich(message)
152
+
Severity.WARNING-> logger.warnRich(message)
153
+
Severity.ERROR,
154
+
Severity.FATAL-> logger.errorRich(message)
155
+
else-> {}
156
+
}
157
+
}
158
+
// Logging message after *successful* compilation, and after diagnostics.
159
+
if (compiledScript isResultWithDiagnostics.Success) {
157
160
if (cacheFile !=null&& cacheFile.lastModified() == cacheLastModified) {
158
161
logger.infoRich("Compiled <yellow>${holder.name}</yellow> from cache in <yellow>${elapsedTime.inWholeMilliseconds}ms</yellow>.")
159
162
} else {
160
163
logger.infoRich("Compiled <yellow>${holder.name}</yellow> in <yellow>${elapsedTime.inWholeMilliseconds}ms</yellow>.")
if (compiledScript isResultWithDiagnostics.Failure)
164
-
logger.errorRich("Script <yellow>${holder.name}</yellow> reported <yellow>$errorCount</yellow> error(s) during compilation:")
165
-
compiledScript.reports.forEach {
166
-
val message ="<yellow>(${script.name}, ${it.sourcePath?.substringAfterLast("/")}, line ${it.location?.start?.line ?:"???"}, col ${it.location?.start?.col ?:"???"})</yellow> ${it.message}"
167
-
when (it.severity) {
168
-
Severity.INFO-> logger.infoRich(message)
169
-
Severity.WARNING-> logger.warnRich(message)
170
-
Severity.ERROR,
171
-
Severity.FATAL-> logger.errorRich(message)
172
-
else-> {}
173
-
}
174
-
}
175
165
}
176
166
// Returning ScriptContext instance if compilation was successful, or null otherwise.
177
167
return@withContext if (compiledScript !isResultWithDiagnostics.Failure) script elsenull
@@ -191,11 +181,10 @@ internal class ScriptManager(val plugin: Kite) {
0 commit comments