refactor folders to move "/state" (IApplicationState) inside "/context" (IApplicationContext)
This commit is contained in:
24
src/application/Context/State/Code/Position/CodePosition.ts
Normal file
24
src/application/Context/State/Code/Position/CodePosition.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ICodePosition } from './ICodePosition';
|
||||
export class CodePosition implements ICodePosition {
|
||||
|
||||
public get totalLines(): number {
|
||||
return this.endLine - this.startLine;
|
||||
}
|
||||
|
||||
constructor(
|
||||
public readonly startLine: number,
|
||||
public readonly endLine: number) {
|
||||
if (startLine < 0) {
|
||||
throw new Error('Code cannot start in a negative line');
|
||||
}
|
||||
if (endLine < 0) {
|
||||
throw new Error('Code cannot end in a negative line');
|
||||
}
|
||||
if (endLine === startLine) {
|
||||
throw new Error('Empty code');
|
||||
}
|
||||
if (endLine < startLine) {
|
||||
throw new Error('End line cannot be less than start line');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user