Skip to content

Commit

Permalink
add super keyword support
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegDokuka committed Nov 29, 2024
1 parent d0867a9 commit 74e44ce
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openrewrite/src/javascript/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,10 @@ export class JavaScriptParserVisitor {
)
}

visitSuperKeyword(node: ts.KeywordToken<ts.SyntaxKind.SuperKeyword>) {
return this.mapIdentifier(node, node.getText());
}

visitNewExpression(node: ts.NewExpression) {
return new J.NewClass(
randomId(),
Expand Down
29 changes: 29 additions & 0 deletions openrewrite/test/javascript/e2e/twenty.files.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {connect, disconnect, rewriteRun, rewriteRunWithOptions, typeScript} from '../testHarness';

describe('highlight.js files tests', () => {
beforeAll(() => connect());
afterAll(() => disconnect());

test('twenty/packages/twenty-server/src/modules/messaging/message-import-manager/exceptions/message-import.exception.ts', () => {
rewriteRun(
//language=typescript
typeScript(`
import { CustomException } from 'src/utils/custom-exception';
export class MessageImportException extends CustomException {
code: MessageImportExceptionCode;
constructor(message: string, code: MessageImportExceptionCode) {
super(message, code);
}
}
export enum MessageImportExceptionCode {
UNKNOWN = 'UNKNOWN',
PROVIDER_NOT_SUPPORTED = 'PROVIDER_NOT_SUPPORTED',
MESSAGE_CHANNEL_NOT_FOUND = 'MESSAGE_CHANNEL_NOT_FOUND',
}
`)
);
});

});
14 changes: 14 additions & 0 deletions openrewrite/test/javascript/parser/class.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,20 @@ describe('class mapping', () => {
);
});

test('class extends expression with constructor', () => {
rewriteRun(
//language=typescript
typeScript(`
class OuterClass extends (class extends Number {
}) {
constructor() {
/*1*/ super /*2*/ () /*3*/;
}
}
`)
);
});

test('class expressions inline', () => {
rewriteRun(
//language=typescript
Expand Down

0 comments on commit 74e44ce

Please sign in to comment.