Skip to content

Commit

Permalink
feat: show "print" code lens for some nullable types (#1248)
Browse files Browse the repository at this point in the history
### Summary of Changes

The "print" code lens now also appears for selected nullable types like
`Int?`.
  • Loading branch information
lars-reimann authored Oct 31, 2024
1 parent 2930357 commit 492120c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,14 @@ export class SafeDsTypeChecker {
canBePrinted = (type: Type): boolean => {
return (
!type.equals(this.coreTypes.Nothing) &&
!type.equals(this.coreTypes.NothingOrNull) &&
[
this.coreTypes.Boolean,
this.coreTypes.Float,
this.coreTypes.Int,
this.coreTypes.List(UnknownType),
this.coreTypes.Map(UnknownType, UnknownType),
this.coreTypes.String,
].some((it) => this.isSubtypeOf(type, it, { ignoreTypeParameters: true }))
].some((it) => this.isSubtypeOf(type.withExplicitNullability(false), it, { ignoreTypeParameters: true }))
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('SafeDsCodeLensProvider', () => {
code: `pipeline myPipeline {
val a = null;
}`,
expectedCodeLensTitles: ['Run myPipeline'],
expectedCodeLensTitles: ['Run myPipeline', 'Print a'],
},
{
testName: 'pipeline with Image placeholder',
Expand Down

0 comments on commit 492120c

Please sign in to comment.