-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Assert creation of scope handlers #2684
base: main
Are you sure you want to change the base?
Changes from 3 commits
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 |
---|---|---|
|
@@ -45,10 +45,11 @@ import type { CustomScopeType, ScopeHandler } from "./scopeHandler.types"; | |
*/ | ||
export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory { | ||
constructor(private languageDefinitions: LanguageDefinitions) { | ||
this.tryCreate = this.tryCreate.bind(this); | ||
this.create = this.create.bind(this); | ||
} | ||
|
||
create( | ||
tryCreate( | ||
scopeType: ScopeType | CustomScopeType, | ||
languageId: string, | ||
): ScopeHandler | undefined { | ||
|
@@ -114,4 +115,15 @@ export class ScopeHandlerFactoryImpl implements ScopeHandlerFactory { | |
?.getScopeHandler(scopeType); | ||
} | ||
} | ||
|
||
create( | ||
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 would be tempted to call this 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 this shouldn't really throw. It's just there because I don't like doing |
||
scopeType: ScopeType | CustomScopeType, | ||
languageId: string, | ||
): ScopeHandler { | ||
const handler = this.tryCreate(scopeType, languageId); | ||
if (handler == null) { | ||
throw new Error(`Couldn't create scope handler for '${scopeType.type}'`); | ||
} | ||
return handler; | ||
} | ||
} |
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.
I believe we usually use
maybe
for things like this, egmaybeCreate
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.
Fixed