@cparra/apexdocs 1.13.4 → 2.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/.eslintrc.js +12 -0
  2. package/.prettierrc.js +7 -0
  3. package/README.md +344 -277
  4. package/ROADMAP.md +18 -0
  5. package/docs/Gemfile.lock +1 -1
  6. package/docs/Sample-Classes/SampleClass.md +138 -30
  7. package/docs/Sample-Interfaces/SampleInterface.md +21 -4
  8. package/docs/index.md +1 -9
  9. package/examples/apex/SampleClass.cls +31 -6
  10. package/examples/apex/SampleInterface.cls +3 -2
  11. package/lib/application/Apexdocs.d.ts +11 -0
  12. package/lib/application/Apexdocs.js +41 -0
  13. package/lib/application/Apexdocs.js.map +1 -0
  14. package/lib/cli/generate.js +17 -21
  15. package/lib/cli/generate.js.map +1 -0
  16. package/lib/index.d.ts +1 -1
  17. package/lib/index.js +2 -1
  18. package/lib/index.js.map +1 -0
  19. package/lib/model/file.d.ts +10 -0
  20. package/lib/model/file.js +23 -0
  21. package/lib/model/file.js.map +1 -0
  22. package/lib/model/manifest.d.ts +22 -0
  23. package/lib/model/manifest.js +41 -0
  24. package/lib/model/manifest.js.map +1 -0
  25. package/lib/model/markdown-file.d.ts +10 -0
  26. package/lib/model/markdown-file.js +52 -0
  27. package/lib/model/markdown-file.js.map +1 -0
  28. package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -0
  29. package/lib/model/markdown-generation-util/field-declaration-util.js +33 -0
  30. package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -0
  31. package/lib/model/markdown-generation-util/index.d.ts +3 -0
  32. package/lib/model/markdown-generation-util/index.js +9 -0
  33. package/lib/model/markdown-generation-util/index.js.map +1 -0
  34. package/lib/model/markdown-generation-util/method-declaration-util.d.ts +3 -0
  35. package/lib/model/markdown-generation-util/method-declaration-util.js +97 -0
  36. package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -0
  37. package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -0
  38. package/lib/model/markdown-generation-util/type-declaration-util.js +25 -0
  39. package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -0
  40. package/lib/model/markdown-home-file.d.ts +11 -0
  41. package/lib/model/markdown-home-file.js +50 -0
  42. package/lib/model/markdown-home-file.js.map +1 -0
  43. package/lib/model/markdown-type-file.d.ts +17 -0
  44. package/lib/model/markdown-type-file.js +62 -0
  45. package/lib/model/markdown-type-file.js.map +1 -0
  46. package/lib/service/apex-file-reader.d.ts +13 -0
  47. package/lib/service/apex-file-reader.js +39 -0
  48. package/lib/service/apex-file-reader.js.map +1 -0
  49. package/lib/service/file-system.d.ts +12 -0
  50. package/lib/service/file-system.js +21 -0
  51. package/lib/service/file-system.js.map +1 -0
  52. package/lib/service/file-writer.d.ts +4 -0
  53. package/lib/service/file-writer.js +25 -0
  54. package/lib/service/file-writer.js.map +1 -0
  55. package/lib/service/manifest-factory.d.ts +9 -0
  56. package/lib/service/manifest-factory.js +13 -0
  57. package/lib/service/manifest-factory.js.map +1 -0
  58. package/lib/service/parser.d.ts +9 -0
  59. package/lib/service/parser.js +17 -0
  60. package/lib/service/parser.js.map +1 -0
  61. package/lib/service/walkers/class-walker.d.ts +4 -0
  62. package/lib/service/walkers/class-walker.js +32 -0
  63. package/lib/service/walkers/class-walker.js.map +1 -0
  64. package/lib/service/walkers/enum-walker.d.ts +4 -0
  65. package/lib/service/walkers/enum-walker.js +10 -0
  66. package/lib/service/walkers/enum-walker.js.map +1 -0
  67. package/lib/service/walkers/interface-walker.d.ts +4 -0
  68. package/lib/service/walkers/interface-walker.js +14 -0
  69. package/lib/service/walkers/interface-walker.js.map +1 -0
  70. package/lib/service/walkers/walker-factory.d.ts +5 -0
  71. package/lib/service/walkers/walker-factory.js +19 -0
  72. package/lib/service/walkers/walker-factory.js.map +1 -0
  73. package/lib/service/walkers/walker.d.ts +16 -0
  74. package/lib/service/walkers/walker.js +9 -0
  75. package/lib/service/walkers/walker.js.map +1 -0
  76. package/lib/settings.d.ts +21 -0
  77. package/lib/settings.js +42 -0
  78. package/lib/settings.js.map +1 -0
  79. package/lib/transpiler/file-container.d.ts +6 -0
  80. package/lib/transpiler/file-container.js +15 -0
  81. package/lib/transpiler/file-container.js.map +1 -0
  82. package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +6 -0
  83. package/lib/transpiler/markdown/class-file-generatorHelper.js +17 -0
  84. package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -0
  85. package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +4 -0
  86. package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +10 -0
  87. package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +1 -0
  88. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +8 -0
  89. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +24 -0
  90. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -0
  91. package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -0
  92. package/lib/transpiler/markdown/markdown-transpiler-base.js +23 -0
  93. package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -0
  94. package/lib/transpiler/processor-type-transpiler.d.ts +8 -0
  95. package/lib/transpiler/processor-type-transpiler.js +6 -0
  96. package/lib/transpiler/processor-type-transpiler.js.map +1 -0
  97. package/lib/transpiler/transpiler.d.ts +5 -0
  98. package/lib/transpiler/transpiler.js +21 -0
  99. package/lib/transpiler/transpiler.js.map +1 -0
  100. package/lib/util/logger.d.ts +18 -0
  101. package/lib/util/logger.js +32 -0
  102. package/lib/util/logger.js.map +1 -0
  103. package/package.json +22 -11
  104. package/src/application/Apexdocs.ts +41 -0
  105. package/src/cli/generate.ts +52 -64
  106. package/src/index.ts +1 -1
  107. package/src/model/__tests__/manifest.spec.ts +15 -0
  108. package/src/model/file.ts +23 -0
  109. package/src/model/manifest.ts +60 -0
  110. package/src/model/markdown-file.ts +56 -0
  111. package/src/model/markdown-generation-util/field-declaration-util.ts +42 -0
  112. package/src/model/markdown-generation-util/index.ts +3 -0
  113. package/src/model/markdown-generation-util/method-declaration-util.ts +128 -0
  114. package/src/model/markdown-generation-util/type-declaration-util.ts +29 -0
  115. package/src/model/markdown-home-file.ts +48 -0
  116. package/src/model/markdown-type-file.ts +75 -0
  117. package/src/service/__tests__/apex-file-reader.spec.ts +79 -0
  118. package/src/service/__tests__/manifest-factory.spec.ts +16 -0
  119. package/src/service/apex-file-reader.ts +45 -0
  120. package/src/service/file-system.ts +28 -0
  121. package/src/service/file-writer.ts +25 -0
  122. package/src/service/manifest-factory.ts +12 -0
  123. package/src/service/parser.ts +18 -0
  124. package/src/service/walkers/class-walker.ts +31 -0
  125. package/src/service/walkers/enum-walker.ts +8 -0
  126. package/src/service/walkers/interface-walker.ts +12 -0
  127. package/src/service/walkers/walker-factory.ts +18 -0
  128. package/src/service/walkers/walker.ts +35 -0
  129. package/src/settings.ts +57 -0
  130. package/src/transpiler/file-container.ts +13 -0
  131. package/src/transpiler/markdown/class-file-generatorHelper.ts +16 -0
  132. package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +7 -0
  133. package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +22 -0
  134. package/src/transpiler/markdown/markdown-transpiler-base.ts +28 -0
  135. package/src/transpiler/processor-type-transpiler.ts +12 -0
  136. package/src/transpiler/transpiler.ts +18 -0
  137. package/src/util/logger.ts +31 -0
  138. package/tsconfig.json +9 -3
  139. package/.prettierrc +0 -5
  140. package/examples/config/config.json +0 -5
  141. package/lib/AsJsDocsProcessor.d.ts +0 -9
  142. package/lib/AsJsDocsProcessor.js +0 -61
  143. package/lib/ClassFileGeneratorHelper.d.ts +0 -5
  144. package/lib/ClassFileGeneratorHelper.js +0 -25
  145. package/lib/ClassFileGeneratorHelper.test.d.ts +0 -1
  146. package/lib/ClassFileGeneratorHelper.test.js +0 -32
  147. package/lib/Configuration.d.ts +0 -34
  148. package/lib/Configuration.js +0 -37
  149. package/lib/DocsProcessor.d.ts +0 -6
  150. package/lib/DocsProcessor.js +0 -9
  151. package/lib/DocsifyDocsProcessor.d.ts +0 -4
  152. package/lib/DocsifyDocsProcessor.js +0 -9
  153. package/lib/DocsifyDocsProcessor.test.d.ts +0 -1
  154. package/lib/DocsifyDocsProcessor.test.js +0 -7
  155. package/lib/FileManager.d.ts +0 -6
  156. package/lib/FileManager.js +0 -28
  157. package/lib/JekyllDocsProcessor.d.ts +0 -8
  158. package/lib/JekyllDocsProcessor.js +0 -20
  159. package/lib/JekyllDocsProcessor.test.d.ts +0 -1
  160. package/lib/JekyllDocsProcessor.test.js +0 -21
  161. package/lib/JsHelper.d.ts +0 -12
  162. package/lib/JsHelper.js +0 -72
  163. package/lib/MarkdownDocsProcessor.d.ts +0 -22
  164. package/lib/MarkdownDocsProcessor.js +0 -358
  165. package/lib/MarkdownHelper.d.ts +0 -13
  166. package/lib/MarkdownHelper.js +0 -78
  167. package/lib/Settings.d.ts +0 -22
  168. package/lib/Settings.js +0 -51
  169. package/lib/Settings.test.d.ts +0 -1
  170. package/lib/Settings.test.js +0 -38
  171. package/lib/command/Generate.d.ts +0 -2
  172. package/lib/command/Generate.js +0 -54
  173. package/lib/command/__test__/Generte.test.d.ts +0 -1
  174. package/lib/command/__test__/Generte.test.js +0 -30
  175. package/lib/model/ApexModel.d.ts +0 -30
  176. package/lib/model/ApexModel.js +0 -85
  177. package/lib/model/ClassModel.d.ts +0 -39
  178. package/lib/model/ClassModel.js +0 -125
  179. package/lib/model/EnumModel.d.ts +0 -6
  180. package/lib/model/EnumModel.js +0 -28
  181. package/lib/model/MethodModel.d.ts +0 -18
  182. package/lib/model/MethodModel.js +0 -74
  183. package/lib/model/PropertyModel.d.ts +0 -6
  184. package/lib/model/PropertyModel.js +0 -40
  185. package/lib/model/__test__/ClassModel.test.d.ts +0 -1
  186. package/lib/model/__test__/ClassModel.test.js +0 -79
  187. package/lib/model/__test__/MethodModel.test.d.ts +0 -1
  188. package/lib/model/__test__/MethodModel.test.js +0 -55
  189. package/lib/model/__test__/PropertyModel.test.d.ts +0 -1
  190. package/lib/model/__test__/PropertyModel.test.js +0 -25
  191. package/lib/parser/ClassParser.d.ts +0 -5
  192. package/lib/parser/ClassParser.js +0 -79
  193. package/lib/parser/EnumParser.d.ts +0 -5
  194. package/lib/parser/EnumParser.js +0 -45
  195. package/lib/parser/FileParser.d.ts +0 -8
  196. package/lib/parser/FileParser.js +0 -210
  197. package/lib/parser/MethodParser.d.ts +0 -5
  198. package/lib/parser/MethodParser.js +0 -109
  199. package/lib/parser/PropertyParser.d.ts +0 -5
  200. package/lib/parser/PropertyParser.js +0 -46
  201. package/lib/parser/__test__/ClassParser.test.d.ts +0 -1
  202. package/lib/parser/__test__/ClassParser.test.js +0 -52
  203. package/lib/parser/__test__/FileParser.test.d.ts +0 -1
  204. package/lib/parser/__test__/FileParser.test.js +0 -12
  205. package/lib/parser/__test__/MethodParser.test.d.ts +0 -1
  206. package/lib/parser/__test__/MethodParser.test.js +0 -69
  207. package/lib/parser/__test__/PropertyParser.test.d.ts +0 -1
  208. package/lib/parser/__test__/PropertyParser.test.js +0 -14
  209. package/lib/parser/__test__/testFileContents.d.ts +0 -1
  210. package/lib/parser/__test__/testFileContents.js +0 -82
  211. package/lib/utils.d.ts +0 -12
  212. package/lib/utils.js +0 -49
  213. package/lib/utils.test.d.ts +0 -1
  214. package/lib/utils.test.js +0 -35
  215. package/src/AsJsDocsProcessor.ts +0 -67
  216. package/src/ClassFileGeneratorHelper.test.ts +0 -44
  217. package/src/ClassFileGeneratorHelper.ts +0 -26
  218. package/src/Configuration.ts +0 -69
  219. package/src/DocsProcessor.ts +0 -9
  220. package/src/DocsifyDocsProcessor.test.ts +0 -6
  221. package/src/DocsifyDocsProcessor.ts +0 -7
  222. package/src/FileManager.ts +0 -32
  223. package/src/JekyllDocsProcessor.test.ts +0 -28
  224. package/src/JekyllDocsProcessor.ts +0 -22
  225. package/src/JsHelper.ts +0 -78
  226. package/src/MarkdownDocsProcessor.ts +0 -420
  227. package/src/MarkdownHelper.ts +0 -91
  228. package/src/Settings.test.ts +0 -54
  229. package/src/Settings.ts +0 -65
  230. package/src/command/Generate.ts +0 -69
  231. package/src/command/__test__/Generte.test.ts +0 -39
  232. package/src/model/ApexModel.ts +0 -102
  233. package/src/model/ClassModel.ts +0 -140
  234. package/src/model/EnumModel.ts +0 -27
  235. package/src/model/MethodModel.ts +0 -80
  236. package/src/model/PropertyModel.ts +0 -37
  237. package/src/model/__test__/ClassModel.test.ts +0 -100
  238. package/src/model/__test__/MethodModel.test.ts +0 -70
  239. package/src/model/__test__/PropertyModel.test.ts +0 -34
  240. package/src/parser/ClassParser.ts +0 -83
  241. package/src/parser/EnumParser.ts +0 -47
  242. package/src/parser/FileParser.ts +0 -250
  243. package/src/parser/MethodParser.ts +0 -119
  244. package/src/parser/PropertyParser.ts +0 -46
  245. package/src/parser/__test__/ClassParser.test.ts +0 -70
  246. package/src/parser/__test__/FileParser.test.ts +0 -14
  247. package/src/parser/__test__/MethodParser.test.ts +0 -90
  248. package/src/parser/__test__/PropertyParser.test.ts +0 -18
  249. package/src/parser/__test__/testFileContents.ts +0 -81
  250. package/src/utils.test.ts +0 -40
  251. package/src/utils.ts +0 -52
@@ -1,39 +0,0 @@
1
- import * as fs from 'fs';
2
- import { generate } from '../Generate';
3
- import FileParser from '../../parser/FileParser';
4
-
5
- jest.mock('fs');
6
- jest.mock('../../parser/FileParser');
7
-
8
- beforeEach(() => {
9
- (FileParser as jest.Mock).mockClear();
10
- });
11
-
12
- it('returns an empty list when there are no files', () => {
13
- (fs.readdirSync as jest.Mock).mockReturnValue([]);
14
-
15
- const classes = generate('src');
16
-
17
- expect(classes.length).toBe(0);
18
- });
19
-
20
- it('returns an empty list when there are no files ending in .cls', () => {
21
- (fs.readdirSync as jest.Mock).mockReturnValue(['file.xml', 'README.md']);
22
-
23
- const classes = generate('src', false);
24
-
25
- expect(classes.length).toBe(0);
26
- });
27
-
28
- it('returns parsed files when there are .cls files', () => {
29
- (fs.readdirSync as jest.Mock).mockReturnValue(['TestClass.cls', 'README.md']);
30
- (fs.readFileSync as jest.Mock).mockReturnValue('Raw class data');
31
-
32
- generate('src', false);
33
-
34
- expect(FileParser).toHaveBeenCalledTimes(1);
35
- const mockFileParserInstance = (FileParser as jest.Mock).mock.instances[0];
36
- const mockParseFileContents = mockFileParserInstance.parseFileContents;
37
- expect(mockParseFileContents).toHaveBeenCalledTimes(1);
38
- expect(mockParseFileContents).toHaveBeenCalledWith('Raw class data');
39
- });
@@ -1,102 +0,0 @@
1
- import Settings from '../Settings';
2
-
3
- export default class ApexModel {
4
- protected nameLine: string = '';
5
- private nameLineIndex: number | undefined;
6
- private description: string = '';
7
- private author: string = '';
8
- private date: string = '';
9
- private returns: string = '';
10
- private example: string = '';
11
- private scope: string = '';
12
- private isNamespaceAccessible: boolean = false;
13
-
14
- getNameLine() {
15
- return this.nameLine;
16
- }
17
-
18
- getInameLine() {
19
- return this.nameLineIndex;
20
- }
21
-
22
- setNameLine(nameLine: string, iLine: number) {
23
- this.nameLine = nameLine.trim();
24
- this.nameLineIndex = iLine;
25
- this.parseScope();
26
- }
27
-
28
- getDescription() {
29
- return this.description == null ? '' : this.description;
30
- }
31
-
32
- setDescription(description: string) {
33
- this.description = description;
34
- }
35
-
36
- getAuthor() {
37
- return this.author == null ? '' : this.author;
38
- }
39
-
40
- setAuthor(author: string) {
41
- this.author = author;
42
- }
43
-
44
- getDate() {
45
- return this.date == null ? '' : this.date;
46
- }
47
-
48
- setDate(date: string) {
49
- this.date = date;
50
- }
51
-
52
- getReturns() {
53
- return this.returns == null ? '' : this.returns;
54
- }
55
-
56
- setReturns(returns: string) {
57
- this.returns = returns;
58
- }
59
-
60
- getExample() {
61
- return this.example == null ? '' : this.example;
62
- }
63
-
64
- setExample(example: string) {
65
- this.example = example;
66
- }
67
-
68
- getScope() {
69
- return this.scope == null ? '' : this.scope;
70
- }
71
-
72
- setScope(scope: string) {
73
- this.scope = scope;
74
- }
75
-
76
- setIsNamespaceAccessible(isNamespaceAccessible: boolean) {
77
- this.isNamespaceAccessible = isNamespaceAccessible;
78
- }
79
-
80
- getIsNamespaceAccessible() {
81
- return this.isNamespaceAccessible;
82
- }
83
-
84
- private parseScope() {
85
- this.scope = '';
86
- const str = this.getScopeFromSettings(this.nameLine);
87
- if (str != null) {
88
- this.scope = str;
89
- }
90
- }
91
-
92
- private getScopeFromSettings(str: string) {
93
- str = str.toLowerCase();
94
- for (const currentScope of Settings.getInstance().getScope()) {
95
- if (str.toLowerCase().includes(currentScope.toLowerCase() + ' ')) {
96
- return currentScope;
97
- }
98
- }
99
-
100
- return null;
101
- }
102
- }
@@ -1,140 +0,0 @@
1
- import ApexModel from './ApexModel';
2
- import MethodModel from './MethodModel';
3
- import PropertyModel from './PropertyModel';
4
- import EnumModel from './EnumModel';
5
- import Configuration from '../Configuration';
6
-
7
- export default class ClassModel extends ApexModel {
8
- methods: MethodModel[] = [];
9
- properties: PropertyModel[] = [];
10
- cmodelParent?: ClassModel;
11
- childClasses: ClassModel[] = [];
12
- childEnums: EnumModel[] = [];
13
- strClassGroup: string = Configuration.getConfig()?.defaultGroupName || 'Miscellaneous';
14
- strClassGroupContent: string = '';
15
- isInterface: boolean = false;
16
- isEnum: boolean = false;
17
- seeList: string[] = [];
18
- className: string = '';
19
-
20
- constructor(parent?: any) {
21
- super();
22
- if (parent) {
23
- this.cmodelParent = parent as ClassModel;
24
- }
25
- }
26
-
27
- getProperties() {
28
- return this.properties;
29
- }
30
-
31
- setProperties(properties: PropertyModel[]) {
32
- this.properties = properties;
33
- }
34
-
35
- getMethods() {
36
- return this.methods;
37
- }
38
-
39
- setMethods(methods: MethodModel[]) {
40
- this.methods = methods;
41
- }
42
-
43
- getChildClasses() {
44
- return this.childClasses;
45
- }
46
-
47
- addChildClass(child: ClassModel) {
48
- this.childClasses.push(child);
49
- }
50
-
51
- addChildEnum(childEnum: EnumModel) {
52
- this.childEnums.push(childEnum);
53
- }
54
-
55
- getChildEnums() {
56
- return this.childEnums;
57
- }
58
-
59
- getClassName(includeParent: boolean = true): string {
60
- if (this.className !== '') {
61
- return this.className;
62
- }
63
-
64
- let nameLine = this.getNameLine();
65
- let strParent = '';
66
- if (includeParent) {
67
- strParent = this.cmodelParent == null ? '' : this.cmodelParent.getClassName() + '.';
68
- }
69
- if (nameLine != null) nameLine = nameLine.trim();
70
- if (nameLine != null && nameLine.trim().length > 0) {
71
- let fFound = nameLine.toLowerCase().indexOf('class ');
72
- let cch = 6;
73
- if (fFound === -1) {
74
- fFound = nameLine.toLowerCase().indexOf('interface ');
75
- cch = 10;
76
- }
77
- if (fFound > -1) nameLine = nameLine.substring(fFound + cch).trim();
78
- const lFound = nameLine.indexOf(' ');
79
- if (lFound === -1) return strParent + nameLine;
80
- try {
81
- const name = nameLine.substring(0, lFound);
82
- return strParent + name;
83
- } catch (ex) {
84
- return strParent + nameLine.substring(nameLine.lastIndexOf(' ') + 1);
85
- }
86
- } else {
87
- return '';
88
- }
89
- }
90
-
91
- setClassName(className: string) {
92
- this.className = className;
93
- }
94
-
95
- getTopmostClassName() {
96
- if (this.cmodelParent != null) return this.cmodelParent.getClassName();
97
- else return this.getClassName();
98
- }
99
-
100
- getClassGroup(): string {
101
- if (this.cmodelParent != null) return this.cmodelParent.getClassGroup();
102
- else return this.strClassGroup;
103
- }
104
-
105
- setClassGroup(strGroup: string) {
106
- this.strClassGroup = strGroup;
107
- }
108
-
109
- getClassGroupContent() {
110
- return this.strClassGroupContent;
111
- }
112
-
113
- setClassGroupContent(strGroupContent: string) {
114
- this.strClassGroupContent = strGroupContent;
115
- }
116
-
117
- getIsInterface() {
118
- return this.isInterface;
119
- }
120
-
121
- setIsInterface(isInterface: boolean) {
122
- this.isInterface = isInterface;
123
- }
124
-
125
- getIsEnum() {
126
- return this.isEnum;
127
- }
128
-
129
- setIsEnum(isEnum: boolean) {
130
- this.isEnum = isEnum;
131
- }
132
-
133
- addSee(seeClassName: string) {
134
- this.seeList.push(seeClassName);
135
- }
136
-
137
- getSeeList() {
138
- return this.seeList;
139
- }
140
- }
@@ -1,27 +0,0 @@
1
- import ClassModel from './ClassModel';
2
-
3
- export default class EnumModel extends ClassModel {
4
- constructor() {
5
- super();
6
- this.setIsEnum(true);
7
- }
8
-
9
- setNameLine(nameLine: string, iLine: number) {
10
- // remove any trailing stuff after enum name.
11
- const i = nameLine.indexOf('{');
12
- if (i >= 0) nameLine = nameLine.substring(0, i);
13
- super.setNameLine(nameLine, iLine);
14
- }
15
-
16
- getClassName() {
17
- const nameLine = this.getNameLine().trim();
18
- if (nameLine != null && nameLine.length > 0) {
19
- const lastindex = nameLine.lastIndexOf(' ');
20
- if (lastindex >= 0) {
21
- const propertyName = nameLine.substring(lastindex + 1);
22
- return propertyName;
23
- }
24
- }
25
- return '';
26
- }
27
- }
@@ -1,80 +0,0 @@
1
- import ApexModel from './ApexModel';
2
- import { findPreviousWord } from '../utils';
3
-
4
- export default class MethodModel extends ApexModel {
5
- params: string[] = [];
6
- thrownExceptions: string[] = [];
7
- iLine: number | undefined;
8
- returnType: string = '';
9
- private isConstructor: boolean = false;
10
-
11
- setNameLine(nameLine: string, iLine: number) {
12
- // remove anything after the parameter list
13
- if (nameLine != null) {
14
- const i = nameLine.lastIndexOf(')');
15
- if (i >= 0) nameLine = nameLine.substring(0, i + 1);
16
- }
17
- super.setNameLine(nameLine, iLine);
18
- }
19
-
20
- getParams() {
21
- return this.params;
22
- }
23
-
24
- setParams(params: string[]) {
25
- this.params = params;
26
- }
27
-
28
- getThrownExceptions() {
29
- return this.thrownExceptions;
30
- }
31
-
32
- setThrownExceptions(thrownExceptions: string[]) {
33
- this.thrownExceptions = thrownExceptions;
34
- }
35
-
36
- getReturnType() {
37
- if (this.isConstructor) {
38
- // If the method is a constructor, then it return the same type as its name.
39
- return this.getMethodName();
40
- }
41
-
42
- const nameLine = this.getNameLine().trim();
43
- if (nameLine != null && nameLine.length > 0) {
44
- const lastindex = nameLine.indexOf(this.getMethodName());
45
- if (lastindex >= 0) {
46
- const returnType = findPreviousWord(nameLine, lastindex);
47
- return returnType ? returnType : '';
48
- }
49
- }
50
- return '';
51
- }
52
-
53
- getMethodName(): string {
54
- const nameLine = this.getNameLine().trim();
55
- if (nameLine != null && nameLine.length > 0) {
56
- const lastindex = nameLine.indexOf('(');
57
- if (lastindex >= 0) {
58
- const methodName = findPreviousWord(nameLine, lastindex);
59
- return methodName ? methodName : '';
60
- }
61
- }
62
- return '';
63
- }
64
-
65
- getSignature() {
66
- const nameLine = this.getNameLine().trim();
67
- if (nameLine != null && nameLine.length > 0) {
68
- const beginParen = nameLine.indexOf('(');
69
- return this.getMethodName() + nameLine.substring(beginParen);
70
- }
71
- }
72
-
73
- setIsConstructor(isConstructor: boolean) {
74
- this.isConstructor = isConstructor;
75
- }
76
-
77
- getIsConstructor() {
78
- return this.isConstructor;
79
- }
80
- }
@@ -1,37 +0,0 @@
1
- import ApexModel from './ApexModel';
2
- import { findPreviousWord } from '../utils';
3
-
4
- export default class PropertyModel extends ApexModel {
5
- setNameLine(nameLine: string, iLine: number) {
6
- // remove any trailing stuff after property name. { =
7
- let i = nameLine.indexOf('{');
8
- if (i === -1) i = nameLine.indexOf('=');
9
- if (i === -1) i = nameLine.indexOf(';');
10
- if (i >= 0) nameLine = nameLine.substring(0, i);
11
- super.setNameLine(nameLine, iLine);
12
- }
13
-
14
- getPropertyName() {
15
- const nameLine = this.getNameLine().trim();
16
- if (nameLine != null && nameLine.length > 0) {
17
- const lastindex = nameLine.lastIndexOf(' ');
18
- if (lastindex >= 0) {
19
- const propertyName = nameLine.substring(lastindex + 1);
20
- return propertyName;
21
- }
22
- }
23
- return '';
24
- }
25
-
26
- getReturnType() {
27
- const nameLine = this.getNameLine().trim();
28
- if (nameLine != null && nameLine.length > 0) {
29
- const lastindex = nameLine.indexOf(this.getPropertyName());
30
- if (lastindex >= 0) {
31
- const returnType = findPreviousWord(nameLine, lastindex);
32
- return returnType ? returnType : '';
33
- }
34
- }
35
- return '';
36
- }
37
- }
@@ -1,100 +0,0 @@
1
- import ClassModel from '../ClassModel';
2
- import PropertyModel from '../PropertyModel';
3
- import MethodModel from '../MethodModel';
4
-
5
- test('new class model initializes correctly', () => {
6
- const classModel = new ClassModel();
7
-
8
- expect(classModel.getProperties()).toHaveLength(0);
9
- expect(classModel.getMethods()).toHaveLength(0);
10
- expect(classModel.getChildClasses()).toHaveLength(0);
11
- expect(classModel.getClassName()).toBe('');
12
- expect(classModel.getTopmostClassName()).toBe('');
13
- expect(classModel.getClassGroup()).toBe('Miscellaneous');
14
- expect(classModel.getClassGroupContent()).toBe('');
15
- expect(classModel.getIsInterface()).toBe(false);
16
- });
17
-
18
- test('can set properties', () => {
19
- const classModel = new ClassModel();
20
- const properties = [new PropertyModel()];
21
-
22
- classModel.setProperties(properties);
23
- expect(classModel.getProperties()).toBe(properties);
24
- });
25
-
26
- test('can set methods', () => {
27
- const classModel = new ClassModel();
28
- const methods = [new MethodModel()];
29
-
30
- classModel.setMethods(methods);
31
- expect(classModel.getMethods()).toBe(methods);
32
- });
33
-
34
- test('can add children', () => {
35
- const classModel = new ClassModel();
36
- const childClass = new ClassModel();
37
-
38
- classModel.addChildClass(childClass);
39
- expect(classModel.getChildClasses().length).toBe(1);
40
- expect(classModel.getChildClasses()[0]).toBe(childClass);
41
- });
42
-
43
- test('class name can be set and retrieved correctly', () => {
44
- const classModel = new ClassModel();
45
- const nameLine = 'public with sharing class TestClassName {';
46
- classModel.setNameLine(nameLine, 1);
47
-
48
- expect(classModel.getClassName()).toBe('TestClassName');
49
- });
50
-
51
- test('interface name can be retrieved correctly', () => {
52
- const classModel = new ClassModel();
53
- const nameLine = 'public interface TestInterfaceName {';
54
- classModel.setNameLine(nameLine, 1);
55
-
56
- expect(classModel.getClassName()).toBe('TestInterfaceName');
57
- });
58
-
59
- test('topmost class name is the class name when it has no parent', () => {
60
- const classModel = new ClassModel();
61
- const nameLine = 'public abstract class TestClassName {';
62
- classModel.setNameLine(nameLine, 1);
63
-
64
- expect(classModel.getClassName()).toBe('TestClassName');
65
- });
66
-
67
- test('topmost class name is parent name', () => {
68
- const parentClass = new ClassModel();
69
- const nameLine = 'public abstract class TestClassName {';
70
- parentClass.setNameLine(nameLine, 1);
71
-
72
- const childClass = new ClassModel(parentClass);
73
- const nameLineChild = 'private class ChildClassName {';
74
- childClass.setNameLine(nameLineChild, 10);
75
-
76
- expect(childClass.getTopmostClassName()).toBe('TestClassName');
77
- });
78
-
79
- test('can add group', () => {
80
- const classModel = new ClassModel();
81
- const groupName = 'GroupName';
82
- classModel.setClassGroup(groupName);
83
-
84
- expect(classModel.getClassGroup()).toBe(groupName);
85
- });
86
-
87
- test('can add group content', () => {
88
- const classModel = new ClassModel();
89
- const groupContentName = 'GroupContentName';
90
- classModel.setClassGroupContent(groupContentName);
91
-
92
- expect(classModel.getClassGroupContent()).toBe(groupContentName);
93
- });
94
-
95
- test('can set as interface', () => {
96
- const classModel = new ClassModel();
97
- classModel.setIsInterface(true);
98
-
99
- expect(classModel.getIsInterface()).toBe(true);
100
- });
@@ -1,70 +0,0 @@
1
- import MethodModel from '../MethodModel';
2
-
3
- test('name line can be set', () => {
4
- const method = new MethodModel();
5
- const nameLine = 'public static void testMethod() {';
6
- method.setNameLine(nameLine, 1);
7
-
8
- // Expected everyhing after the parameter list to be removed
9
- const expected = 'public static void testMethod()';
10
- expect(method.getNameLine()).toBe(expected);
11
- });
12
-
13
- test('new method is empty', () => {
14
- const method = new MethodModel();
15
-
16
- expect(method.getParams()).toHaveLength(0);
17
- expect(method.getReturnType()).toBe('');
18
- expect(method.getMethodName()).toBe('');
19
- });
20
-
21
- test('params can be set', () => {
22
- const method = new MethodModel();
23
- const params = ['a', 'b', 'c'];
24
-
25
- method.setParams(params);
26
-
27
- expect(method.getParams()).toBe(params);
28
- });
29
-
30
- test('return type is method name when method is constructor', () => {
31
- const method = new MethodModel();
32
- const nameLine = 'public TestClass() {';
33
- method.setNameLine(nameLine, 10);
34
- method.setIsConstructor(true);
35
-
36
- expect(method.getReturnType()).toBe('TestClass');
37
- });
38
-
39
- test('return type returns previous word when method is not constructor', () => {
40
- const method = new MethodModel();
41
- const nameLine = 'public static void testMethod() {';
42
- method.setNameLine(nameLine, 10);
43
- method.setIsConstructor(false);
44
-
45
- expect(method.getReturnType()).toBe('void');
46
- });
47
-
48
- test('signature can be retrieved', () => {
49
- const method = new MethodModel();
50
- const nameLine = 'public static void testMethod() {';
51
- method.setNameLine(nameLine, 10);
52
- method.setIsConstructor(false);
53
-
54
- expect(method.getSignature()).toBe('testMethod()');
55
- });
56
-
57
- test('method name is retrieved correctly', () => {
58
- const method = new MethodModel();
59
- const nameLine = 'public static void testMethod() {';
60
- method.setNameLine(nameLine, 1);
61
-
62
- expect(method.getMethodName()).toBe('testMethod');
63
- });
64
-
65
- test('can get and set if the method is a constructor', () => {
66
- const method = new MethodModel();
67
- method.setIsConstructor(true);
68
-
69
- expect(method.getIsConstructor()).toBe(true);
70
- });
@@ -1,34 +0,0 @@
1
- import PropertyModel from '../PropertyModel';
2
-
3
- test('has no name by defaullt', () => {
4
- const property = new PropertyModel();
5
-
6
- expect(property.getPropertyName()).toBe('');
7
- });
8
-
9
- test('can set name line for property', () => {
10
- const nameLine = 'public PropertyName { get; set; }';
11
-
12
- const property = new PropertyModel();
13
- property.setNameLine(nameLine, 1);
14
-
15
- expect(property.getPropertyName()).toBe('PropertyName');
16
- });
17
-
18
- test('can set name line for null variable', () => {
19
- const nameLine = 'public PropertyName;';
20
-
21
- const property = new PropertyModel();
22
- property.setNameLine(nameLine, 1);
23
-
24
- expect(property.getPropertyName()).toBe('PropertyName');
25
- });
26
-
27
- test('can set name line for initialized variable', () => {
28
- const nameLine = 'public PropertyName;';
29
-
30
- const property = new PropertyModel();
31
- property.setNameLine(nameLine, 1);
32
-
33
- expect(property.getPropertyName()).toBe('PropertyName');
34
- });