Skip to content

Commit

Permalink
Merge pull request #18 from cesarParra/enum-values
Browse files Browse the repository at this point in the history
Support for enum values
  • Loading branch information
cesarParra authored Jun 7, 2024
2 parents 5b5883d + ba01e77 commit 752833b
Show file tree
Hide file tree
Showing 15 changed files with 620 additions and 318 deletions.
6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 29 additions & 1 deletion js/apex-reflection-node/__tests__/end-to-end.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ClassMirror, InterfaceMirror, reflect} from '../index';
import {ClassMirror, EnumMirror, InterfaceMirror, reflect} from '../index';

describe('Enum Reflection', () => {
test('Simple, single line declaration', () => {
Expand Down Expand Up @@ -33,6 +33,34 @@ describe('Enum Reflection', () => {
const result = reflect(enumBody).typeMirror;
expect(result.docComment.description).toBe('My enum description');
});

test('Enums can have values', () => {
const enumBody = `
enum MyEnumName {
VALUE_1,
VALUE2
}
`;
const result = reflect(enumBody).typeMirror as EnumMirror;
expect(result.values.length).toBe(2);
expect(result.values[0].name).toBe('VALUE_1');
expect(result.values[1].name).toBe('VALUE2');
});

test('Enum values can have descriptions', () => {
const enumBody = `
enum MyEnumName {
/**
* Value 1 description
*/
VALUE_1,
VALUE2
}
`;
const result = reflect(enumBody).typeMirror as EnumMirror;
expect(result.values.length).toBe(2);
expect(result.values[0].docComment.description).toBe('Value 1 description');
});
});

describe('Interface Reflection', () => {
Expand Down
11 changes: 8 additions & 3 deletions js/apex-reflection-node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface Annotation {
type: string;
elementValues?: AnnotationElementValue[];
}
export declare type ReferencedType = ReferenceObjectType | ListObjectType | SetObjectType | MapObjectType;
export type ReferencedType = ReferenceObjectType | ListObjectType | SetObjectType | MapObjectType;
export interface ReferenceObjectType {
type: string;
rawDeclaration: string;
Expand All @@ -54,6 +54,10 @@ export interface MapObjectType extends ReferenceObjectType {
keyType: ReferenceObjectType;
valueType: ReferenceObjectType;
}
export interface EnumValue {
name: string;
docComment?: DocComment;
}
export interface ParameterMirror {
memberModifiers: string[];
name: string;
Expand Down Expand Up @@ -106,8 +110,8 @@ export interface ReflectionResult {
export interface ParsingError {
message: string;
}
declare type TypeName = 'class' | 'interface' | 'enum';
export declare type Type = InterfaceMirror | ClassMirror | EnumMirror;
type TypeName = 'class' | 'interface' | 'enum';
export type Type = InterfaceMirror | ClassMirror | EnumMirror;
export interface EnumMirror {
annotations: Annotation[];
name: string;
Expand All @@ -116,6 +120,7 @@ export interface EnumMirror {
docComment?: DocComment;
group?: string;
groupDescription?: string;
values: EnumValue[];
}
export interface InterfaceMirror {
annotations: Annotation[];
Expand Down
6 changes: 6 additions & 0 deletions js/apex-reflection-node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export interface MapObjectType extends ReferenceObjectType {
valueType: ReferenceObjectType;
}

export interface EnumValue {
name: string;
docComment?: DocComment;
}

export interface ParameterMirror {
memberModifiers: string[];
name: string;
Expand Down Expand Up @@ -144,6 +149,7 @@ export interface EnumMirror {
docComment?: DocComment;
group?: string;
groupDescription?: string;
values: EnumValue[];
}

export interface InterfaceMirror {
Expand Down
Loading

0 comments on commit 752833b

Please sign in to comment.