Skip to content
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

Notification annotation support #92

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"files.trimTrailingWhitespace": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"cSpell.words": ["MSTO", "undent"]
// "eslint.format.enable": true
Expand Down
887 changes: 479 additions & 408 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lib/files/MaestroConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum MaestroLogLevel {

export interface MaestroConfig {
updateObserveCalls?: boolean;
allowNotificationAnnotations?: boolean;
updateAsFunctionCalls?: boolean;
validateAnnotations?: boolean;
defaultAnnotations?: Set<string>;
Expand Down
45 changes: 44 additions & 1 deletion src/lib/utils/Diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,55 @@ export function addNodeClassDoesNotOverrideNewError(file: BrsFile, name: string,

export function addNodeTaskMustExtendTaskComponent(file: BrsFile, name: string, line = 0, col = 0) {
file.addDiagnostics([createDiagnostic(file, 1029, `Task "${name}" does not extend Task. Ensure that the node, or one of it'a ancestors extends Task`, line, col)]);

}

export function addWrongAnnotation(file: BrsFile, name: string, line = 0, col = 0) {
file.addDiagnostics([createDiagnostic(file, 1065, `Annotation "${name}" does not exist`, line, col)]);
}

export function noNameForNotification() {
return {
message: `@onNotification tag requires only 1 string argument to indicate what notification to listen for. e.g @onNotification("userChanged")`,
code: `MSTO${1066}`,
severity: DiagnosticSeverity.Error
};
}

export function onNotificationFieldError() {
return {
message: `@onNotification can only be used on methods, not fields`,
code: `MSTO${1067}`,
severity: DiagnosticSeverity.Error
};
}

export function notificationAnnotationDisabled() {
return {
message: `@onNotification are disabled. To enable them, set the 'allowNotificationAnnotations' flag in your maestro config to true`,
code: `MSTO${1068}`,
severity: DiagnosticSeverity.Error
};
}
export function onNotificationWrongParameter() {
return {
message: `@onNotification methods must have 1 parameter type mc.notification, which is the notification payload`,
code: `MSTO${1069}`,
severity: DiagnosticSeverity.Error
};
}

export function onNotificationConstructorError() {
return {
message: `@onNotification cannot be set on a constructor`,
code: `MSTO${1070}`,
severity: DiagnosticSeverity.Error
};
}

export function onNotificationNotSupported() {
return {
message: `@onNotification is only supported on methods in a node class`,
code: `MSTO${1071}`,
severity: DiagnosticSeverity.Error
};
}
1 change: 1 addition & 0 deletions src/lib/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export let defaultAnnotations = new Set<string>([
'rootOnly',
'node',
'observersWaitInitialize',
'onNotification',
'observeField',
'task',
'inject',
Expand Down
Loading
Loading