Closed sailingKieler closed 4 months ago
Thought: shall the template method also include the call to scope.getAllElements()? That means it would return a Stream, making it very easy to filter elements from the scope without the need to manipulate the scope hierarchy.
Hmm ... I don't have strong opinion here, we could do that yes.
In my case I only manipulated the ReferenceInfo
depending on some conditions wrt. the CompetionContext
, and then delegated to the scope provider and returned its result.
We could also take { getAllElements: () => Stream<AstNodeDescription> }
as return type.
Then a Scope
would be a valid result, but something like the following is also possible.
const scope = this.scopeProvider.getScope(refInfo);
.
.
.
return {
getAllElements: () => scope.getAllElements().filter(e => ... ),
};
Hmm ... I don't have strong opinion here, we could do that yes.
Imagine cases where you want elements to be linkable, but hide them from completion because they would cause a validation error (e.g. type checking indicates that they don't match).
We could also take
{ getAllElements: () => Stream<AstNodeDescription> }
as return type.
I think just returning the stream is a bit simpler than wrapping it in an object.
You may be right, but then we need a better template method name.
… allowing to add the completion-specific scope computation refinements.