Skip to content

Commit

Permalink
Merge pull request #92 from georgejecook/notification-annotation
Browse files Browse the repository at this point in the history
Notification annotation support
  • Loading branch information
georgejecook authored Jul 11, 2024
2 parents 46a334d + 4cc1cf6 commit 364f0b2
Show file tree
Hide file tree
Showing 7 changed files with 1,048 additions and 411 deletions.
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

0 comments on commit 364f0b2

Please sign in to comment.