-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring debts #32
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#Compiled files | ||
dist | ||
*.js | ||
!*.spec.js | ||
|
||
#IDE | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as os from 'os'; | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for an Enum within a typescript file. | ||
*/ | ||
export class Enum implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.ENUM; | ||
public readonly name: string; | ||
public values: IComponentComposite[] = []; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
const result: string[] = []; | ||
let declaration: string = `enum ${this.name}`; | ||
if (this.values.length > 0) { | ||
declaration += ' {'; | ||
} | ||
result.push(declaration); | ||
this.values.forEach((enumValue: IComponentComposite): void => { | ||
result.push(` ${enumValue.toPUML()}`); | ||
}); | ||
if (this.values.length > 0) { | ||
result.push('}'); | ||
} | ||
|
||
return result.join(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for the value or member of an enum within typescript | ||
*/ | ||
export class EnumValue implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.PROPERTY; | ||
public readonly name: string; | ||
public value: string | undefined; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
return this.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as os from 'os'; | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for an interface within typescript | ||
*/ | ||
export class Interface implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.INTERFACE; | ||
public readonly name: string; | ||
public members: IComponentComposite[] = []; | ||
public extendsInterface: string[] = []; | ||
public typeParameters: IComponentComposite[] = []; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
const result: string[] = []; | ||
const firstLine: string[] = []; | ||
firstLine.push(`interface ${this.name}`); | ||
if (this.typeParameters.length > 0) { | ||
firstLine.push('<'); | ||
firstLine.push(this.typeParameters | ||
.map((typeParameter: IComponentComposite): string => typeParameter.toPUML()) | ||
.join(', ')); | ||
firstLine.push('>'); | ||
} | ||
if (this.extendsInterface.length > 0) { | ||
firstLine.push(` extends ${this.extendsInterface.join(', ')}`); | ||
} | ||
if (this.members.length > 0) { | ||
firstLine.push(' {'); | ||
} | ||
result.push(firstLine.join('')); | ||
this.members.forEach((member: IComponentComposite): void => { | ||
result.push(` ${member.toPUML()}`); | ||
}); | ||
if (this.members.length > 0) { | ||
result.push('}'); | ||
} | ||
|
||
return result.join(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as os from 'os'; | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for a namespace within typescript | ||
*/ | ||
export class Namespace implements IComponentComposite { | ||
public readonly name: string; | ||
public readonly componentKind: ComponentKind = ComponentKind.NAMESPACE; | ||
public parts: IComponentComposite[] = []; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
const result: string[] = []; | ||
const declaration: string[] = []; | ||
declaration.push(`namespace ${this.name}`); | ||
if (this.parts.length > 0) { | ||
declaration.push(' {'); | ||
} | ||
result.push(declaration.join('')); | ||
this.parts.forEach((part: IComponentComposite): void => { | ||
result.push( | ||
part.toPUML() | ||
.replace(/^(?!\s*$)/gm, ' ') | ||
); | ||
}); | ||
if (this.parts.length > 0) { | ||
result.push('}'); | ||
} | ||
|
||
return result.join(os.EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
|
||
/** | ||
* Represents the metadata for a parameter within typescript | ||
*/ | ||
export class Parameter implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.PARAMETER; | ||
public readonly name: string; | ||
public hasInitializer: boolean = false; | ||
public isOptional: boolean = false; | ||
public parameterType: string = 'any'; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
return `${this.name}${this.isOptional || this.hasInitializer ? '?' : ''}: ${this.parameterType}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentKind } from '../Models/ComponentKind'; | ||
import { IComponentComposite } from '../Models/IComponentComposite'; | ||
import { Modifier } from '../Models/Modifier'; | ||
|
||
/** | ||
* Represents the metadata for a property within typescript | ||
*/ | ||
export class Property implements IComponentComposite { | ||
public readonly componentKind: ComponentKind = ComponentKind.PROPERTY; | ||
public readonly name: string; | ||
public modifier: Modifier = 'public'; | ||
public returnType: string = 'any'; | ||
public isOptional: boolean = false; | ||
public isStatic: boolean = false; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
public toPUML(): string { | ||
return `${{ public: '+', private: '-', protected: '#' }[this.modifier]}${(this.isStatic ? '{static} ' : '') | ||
}${this.name}${(this.isOptional ? '?' : '')}: ${this.returnType}`; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this regular expression attempting to replace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting of line except empty lines. To add indentation.