-
Notifications
You must be signed in to change notification settings - Fork 323
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
Deliver full intersection type of a value to the IDE #11583
Changes from all commits
de884a4
58fbc9c
6cdeeb2
cfd2dff
386f402
86bfb98
fead15c
d4a56cb
99cca04
8b9e1eb
8f4c728
f63b1b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,8 +366,14 @@ An update about the computed expression. | |
interface ExpressionUpdate { | ||
/** The id of updated expression. */ | ||
expressionId: ExpressionId; | ||
/** The updated type of the expression. */ | ||
type?: string; | ||
/** The updated type of the expression. | ||
* | ||
* Possible values: | ||
* - empty array indicates no type information for this expression | ||
* - array with a single value contains a value of this expression | ||
* - array with multiple values represents an intersetion type | ||
*/ | ||
type: string[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel incompatible changes should be versioned and documented. We should:
Sure, I know we have no version of the protocol. However I asked for it a year ago. Moreover recently there were complains about incompatibilities between cloud/IDE and the conclusion was: we should at least detect the incompatibilities by versioning our protocols. |
||
/** The updated method call info. */ | ||
methodCall?: MethodCall; | ||
/** Profiling information about the expression. */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,8 +97,6 @@ final class SuggestionsHandler( | |
config, | ||
suggestionsRepo | ||
) | ||
context.system.eventStream | ||
.subscribe(self, classOf[Api.ExpressionUpdates]) | ||
context.system.eventStream | ||
.subscribe(self, classOf[Api.SuggestionsDatabaseModuleUpdateNotification]) | ||
context.system.eventStream.subscribe( | ||
|
@@ -264,54 +262,6 @@ final class SuggestionsHandler( | |
) | ||
) | ||
|
||
case msg: Api.ExpressionUpdates if state.isSuggestionUpdatesRunning => | ||
state.suggestionUpdatesQueue.enqueue(msg) | ||
|
||
case Api.ExpressionUpdates(_, updates) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? Seems rather unrelated. Or is that feature no longer used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, after the component browser is finished, and GUI can handle suggestions itself, we don't need to do this logic anymore |
||
logger.debug( | ||
"Received expression updates [{}]", | ||
updates.map(u => (u.expressionId, u.expressionType)) | ||
) | ||
val types = updates.toSeq | ||
.filter(_.typeChanged) | ||
.flatMap(update => update.expressionType.map(update.expressionId -> _)) | ||
suggestionsRepo | ||
.updateAll(types) | ||
.map { case (version, updatedIds) => | ||
val updates = types.zip(updatedIds).collect { | ||
case ((_, typeValue), Some(suggestionId)) => | ||
SuggestionsDatabaseUpdate.Modify( | ||
id = suggestionId, | ||
returnType = Some(fieldUpdate(typeValue)) | ||
) | ||
} | ||
SuggestionsDatabaseUpdateNotification(version, updates) | ||
} | ||
.onComplete { | ||
case Success(notification) => | ||
if (notification.updates.nonEmpty) { | ||
clients.foreach { clientId => | ||
sessionRouter ! DeliverToJsonController(clientId, notification) | ||
} | ||
} | ||
self ! SuggestionsHandler.SuggestionUpdatesCompleted | ||
case Failure(ex) => | ||
logger.error( | ||
"Error applying changes from computed values [{}]", | ||
updates.map(_.expressionId), | ||
ex | ||
) | ||
self ! SuggestionsHandler.SuggestionUpdatesCompleted | ||
} | ||
context.become( | ||
initialized( | ||
projectName, | ||
graph, | ||
clients, | ||
state.suggestionUpdatesRunning() | ||
) | ||
) | ||
|
||
case Api.BackgroundJobsStartedNotification() => | ||
self ! SuggestionLoadingCompleted | ||
context.become( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,16 +98,16 @@ public Object findCachedResult(IdExecutionService.Info info) { | |
@Override | ||
public void updateCachedResult(IdExecutionService.Info info) { | ||
Object result = info.getResult(); | ||
String resultType = typeOf(result); | ||
String[] resultTypes = typeOf(result); | ||
UUID nodeId = info.getId(); | ||
String cachedType = cache.getType(nodeId); | ||
String[] cachedTypes = cache.getType(nodeId); | ||
FunctionCallInfo call = functionCallInfoById(nodeId); | ||
FunctionCallInfo cachedCall = cache.getCall(nodeId); | ||
ProfilingInfo[] profilingInfo = new ProfilingInfo[] {new ExecutionTime(info.getElapsedTime())}; | ||
|
||
ExpressionValue expressionValue = | ||
new ExpressionValue( | ||
nodeId, result, resultType, cachedType, call, cachedCall, profilingInfo, false); | ||
nodeId, result, resultTypes, cachedTypes, call, cachedCall, profilingInfo, false); | ||
syncState.setExpressionUnsync(nodeId); | ||
syncState.setVisualizationUnsync(nodeId); | ||
|
||
|
@@ -119,7 +119,7 @@ public void updateCachedResult(IdExecutionService.Info info) { | |
cache.offer(nodeId, result); | ||
cache.putCall(nodeId, call); | ||
} | ||
cache.putType(nodeId, resultType); | ||
cache.putType(nodeId, resultTypes); | ||
|
||
callOnComputedCallback(expressionValue); | ||
executeOneshotExpressions(nodeId, result, info); | ||
|
@@ -214,20 +214,22 @@ private FunctionCallInfo functionCallInfoById(UUID nodeId) { | |
return calls.get(nodeId); | ||
} | ||
|
||
private String typeOf(Object value) { | ||
String resultType; | ||
private String[] typeOf(Object value) { | ||
if (value instanceof UnresolvedSymbol) { | ||
resultType = Constants.UNRESOLVED_SYMBOL; | ||
} else { | ||
var typeOfNode = TypeOfNode.getUncached(); | ||
Object typeResult = value == null ? null : typeOfNode.findTypeOrError(value); | ||
if (typeResult instanceof Type t) { | ||
resultType = getTypeQualifiedName(t); | ||
} else { | ||
resultType = null; | ||
return new String[] {Constants.UNRESOLVED_SYMBOL}; | ||
} | ||
|
||
var typeOfNode = TypeOfNode.getUncached(); | ||
Type[] allTypes = value == null ? null : typeOfNode.findAllTypesOrNull(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. |
||
if (allTypes != null) { | ||
String[] result = new String[allTypes.length]; | ||
for (var i = 0; i < allTypes.length; i++) { | ||
result[i] = getTypeQualifiedName(allTypes[i]); | ||
} | ||
return result; | ||
} | ||
return resultType; | ||
|
||
return null; | ||
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an incompatible message change. Single values used to be represented as
"string"
and now they will be[ "string" ]
. Are we sure we don't need compatibility?