Skip to content

Commit

Permalink
refactor: use EMPTY_STREAM instead of creating a new empty stream
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Oct 22, 2023
1 parent 7416645 commit c03f637
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/language/helpers/safe-ds-node-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import {
SdsYield,
} from '../generated/ast.js';
import { CallableType, StaticType } from '../typing/model.js';
import { findLocalReferences, getContainerOfType, Stream, stream } from 'langium';
import { EMPTY_STREAM, findLocalReferences, getContainerOfType, Stream } from 'langium';
import {
getAbstractResults,
getArguments,
isNamedArgument,
isNamedTypeArgument,
getParameters,
getTypeArguments,
getTypeParameters,
isNamedArgument,
isNamedTypeArgument,
} from './nodeProperties.js';

export class SafeDsNodeMapper {
Expand Down Expand Up @@ -155,13 +155,13 @@ export class SafeDsNodeMapper {
*/
parameterToReferences(node: SdsParameter | undefined): Stream<SdsReference> {
if (!node) {
return stream();
return EMPTY_STREAM;
}

const containingCallable = getContainerOfType(node, isSdsCallable);
/* c8 ignore start */
if (!containingCallable) {
return stream();
return EMPTY_STREAM;
}
/* c8 ignore stop */

Expand All @@ -175,13 +175,13 @@ export class SafeDsNodeMapper {
*/
placeholderToReferences(node: SdsPlaceholder | undefined): Stream<SdsReference> {
if (!node) {
return stream();
return EMPTY_STREAM;
}

const containingBlock = getContainerOfType(node, isSdsBlock);
/* c8 ignore start */
if (!containingBlock) {
return stream();
return EMPTY_STREAM;
}
/* c8 ignore stop */

Expand All @@ -195,12 +195,12 @@ export class SafeDsNodeMapper {
*/
resultToYields(node: SdsResult | undefined): Stream<SdsYield> {
if (!node) {
return stream();
return EMPTY_STREAM;
}

const containingSegment = getContainerOfType(node, isSdsSegment);
if (!containingSegment) {
return stream();
return EMPTY_STREAM;
}

return findLocalReferences(node, containingSegment)
Expand Down
4 changes: 2 additions & 2 deletions src/language/typing/safe-ds-class-hierarchy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SafeDsServices } from '../safe-ds-module.js';
import { SafeDsClasses } from '../builtins/safe-ds-classes.js';
import { SdsClass } from '../generated/ast.js';
import { stream, Stream } from 'langium';
import { EMPTY_STREAM, stream, Stream } from 'langium';
import { getParentTypes } from '../helpers/nodeProperties.js';
import { SafeDsTypeComputer } from './safe-ds-type-computer.js';
import { ClassType } from './model.js';
Expand Down Expand Up @@ -39,7 +39,7 @@ export class SafeDsClassHierarchy {
*/
streamSuperclasses(node: SdsClass | undefined): Stream<SdsClass> {
if (!node) {
return stream();
return EMPTY_STREAM;
}

return stream(this.superclassesGenerator(node));
Expand Down

0 comments on commit c03f637

Please sign in to comment.