apply suggesitons

This commit is contained in:
Justin Greywolf
2023-07-03 09:40:25 -07:00
parent 1d391d9408
commit e29d2b29a9
3 changed files with 55 additions and 2 deletions

View File

@@ -43,7 +43,7 @@
} }
class Zebra{ class Zebra{
+bool is_wild +bool is_wild
+run() +run(List~T~, List~OT~)
} }
</pre> </pre>

View File

@@ -377,6 +377,59 @@ describe('given text representing a method, ', function () {
}); });
}); });
describe('when method parameter contains two generic', function () {
it('should parse correctly', function () {
const str = `getTimes(List~T~, List~OT~)`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('getTimes(List<T>, List<OT>');
});
it('should handle public visibility', function () {
const str = `+getTimes(List~T~, List~OT~)`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('+getTimes(List<T>, List<OT>');
});
it('should handle private visibility', function () {
const str = `-getTimes(List~T~, List~OT~)`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('-getTimes(List<T>, List<OT>');
});
it('should handle protected visibility', function () {
const str = `#getTimes(List~T~, List~OT~)`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('#getTimes(List<T>, List<OT>');
});
it('should handle internal visibility', function () {
const str = `~getTimes(List~T~, List~OT~)`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('~getTimes(List<T>, List<OT>');
});
it('should return correct css for static classifier', function () {
const str = `getTimes(List~T~, List~OT~)$`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('getTimes(List<T>, List<OT>');
expect(classMember.getDisplayDetails().cssStyle).toBe(staticCssStyle);
});
it('should return correct css for abstract classifier', function () {
const str = `getTimes(List~T~, List~OT~)*`;
const classMember = new ClassMember(str, 'method');
expect(classMember.getDisplayDetails().displayText).toBe('getTimes(List<T>, List<OT>)');
expect(classMember.getDisplayDetails().cssStyle).toBe(abstractCssStyle);
});
});
describe('when method parameter is a nested generic', function () { describe('when method parameter is a nested generic', function () {
it('should parse correctly', function () { it('should parse correctly', function () {
const str = `getTimetableList(List~List~T~~)`; const str = `getTimetableList(List~List~T~~)`;

View File

@@ -189,7 +189,7 @@ export const parseGenericTypes = function (text: string): string {
do { do {
cleanedText = newCleanedText; cleanedText = newCleanedText;
newCleanedText = cleanedText.replace(/~([^:;]+)~/, '<$1>'); newCleanedText = cleanedText.replace(/~([^\s:;]+)~/, '<$1>');
} while (newCleanedText != cleanedText); } while (newCleanedText != cleanedText);
return parseGenericTypes(newCleanedText); return parseGenericTypes(newCleanedText);