Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using WarningsLibrary to query for warnings #6751

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4552,10 +4552,19 @@ class RuntimeServerTest
)
)
context.receiveNIgnoreStdLib(4) should contain theSameElementsAs Seq(
Api.Response(Api.BackgroundJobsStartedNotification()),
Api.Response(requestId, Api.PushContextResponse(contextId)),
TestMessages.update(contextId, idMain, ConstantsGen.VECTOR),
context.executionComplete(contextId)
TestMessages.update(
contextId,
idMain,
ConstantsGen.VECTOR,
payload = Api.ExpressionUpdate.Payload.Value(
Some(
Api.ExpressionUpdate.Payload.Value.Warnings(1, Some("'y'"), false)
)
)
),
context.executionComplete(contextId),
Api.Response(Api.BackgroundJobsStartedNotification())
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2967,10 +2967,19 @@ class RuntimeVisualizationsTest
context.receiveNIgnorePendingExpressionUpdates(
4
) should contain theSameElementsAs Seq(
Api.Response(Api.BackgroundJobsStartedNotification()),
Api.Response(requestId, Api.PushContextResponse(contextId)),
TestMessages.update(contextId, idMain, ConstantsGen.VECTOR),
context.executionComplete(contextId)
TestMessages.update(
contextId,
idMain,
ConstantsGen.VECTOR,
payload = Api.ExpressionUpdate.Payload.Value(
Some(
Api.ExpressionUpdate.Payload.Value.Warnings(1, Some("'y'"), false)
)
)
),
context.executionComplete(contextId),
Api.Response(Api.BackgroundJobsStartedNotification())
)

// attach visualisation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.enso.interpreter.runtime.control.ThreadInterruptedException
import org.enso.interpreter.runtime.error.{
DataflowError,
PanicSentinel,
WithWarnings
WarningsLibrary
}
import org.enso.interpreter.service.error._
import org.enso.polyglot.LanguageInfo
Expand Down Expand Up @@ -351,27 +351,32 @@ object ProgramExecutionSupport {
VisualizationResult.findExceptionMessage(panic),
ErrorResolver.getStackTrace(panic).flatMap(_.expressionId)
)
case withWarnings: WithWarnings =>
val warningsCount = withWarnings.getWarningsCount
val warning =
if (warningsCount == 1) {
val warnings = withWarnings.getWarningsArray(null)
Option(ctx.executionService.toDisplayString(warnings(0).getValue))
} else {
None
}
Api.ExpressionUpdate.Payload.Value(
Some(
Api.ExpressionUpdate.Payload.Value
.Warnings(
warningsCount,
warning,
withWarnings.isLimitReached()
case _ =>
if (WarningsLibrary.getUncached.hasWarnings(value.getValue)) {
val warnings =
WarningsLibrary.getUncached.getWarnings(value.getValue, null)
val warningsCount = warnings.length
val warning =
if (warningsCount == 1) {
Option(
ctx.executionService.toDisplayString(warnings(0).getValue)
)
} else {
None
}
Api.ExpressionUpdate.Payload.Value(
Some(
Api.ExpressionUpdate.Payload.Value
.Warnings(
warningsCount,
warning,
WarningsLibrary.getUncached.isLimitReached(value.getValue)
)
)
)
)
case _ =>
Api.ExpressionUpdate.Payload.Value()
} else {
Api.ExpressionUpdate.Payload.Value()
}
}
ctx.endpoint.sendToClient(
Api.Response(
Expand Down