Skip to content

Commit

Permalink
fix: fix SourceSpan and History not being properly exported
Browse files Browse the repository at this point in the history
Some modules where not being exported properly. This commit fixes the exports while at the same time
orginizing some elements in the source code.
  • Loading branch information
alanrodas committed Sep 6, 2024
1 parent 8296a22 commit fe56f73
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 55 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## <small>0.5.6 (2024-09-06)</small>

## <small>0.5.5 (2024-09-05)</small>

- build: bump gobstones-scripts version to 0.9.3 ([f9e850a](https://github.com/gobstones/gobstones-core/commit/f9e850a))
Expand Down
144 changes: 143 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,149 @@ const config = eslintTs.config(
'@typescript-eslint/member-ordering': [
'error',
{
default: ['signature', 'field', 'constructor', ['get', 'set'], 'method']
default: {
memberTypes: [
// Static
// ======
// fields
'public-static-field',
'protected-static-field',
'private-static-field',
'#private-static-field',
'static-field',
// accessors
'public-static-accessor',
'protected-static-accessor',
'private-static-accessor',
'#private-static-accessor',
'static-accessor',
// initialization
'static-initialization',
// Getter and setter
['public-static-get', 'public-static-set'],
['protected-static-get', 'protected-static-set'],
['private-static-get', 'private-static-set'],
['#private-static-get', '#private-static-set'],
['static-get', 'static-set'],
// Methods
'public-static-method',
'protected-static-method',
'private-static-method',
'#private-static-method',
'static-method',

// Instance
// ========
// Index signature
'signature',
'call-signature',

// Fields
'public-abstract-field',
'protected-abstract-field',

'public-decorated-field',
'protected-decorated-field',
'private-decorated-field',

'public-instance-field',
'protected-instance-field',
'private-instance-field',
'#private-instance-field',

'public-field',
'protected-field',
'private-field',
'#private-field',

'abstract-field',
'instance-field',

'decorated-field',

'field',

// Constructors
'public-constructor',
'protected-constructor',
'private-constructor',
'constructor',

// Accessors
'public-abstract-accessor',
'protected-abstract-accessor',

'public-decorated-accessor',
'protected-decorated-accessor',
'private-decorated-accessor',

'public-instance-accessor',
'protected-instance-accessor',
'private-instance-accessor',
'#private-instance-accessor',

'public-accessor',
'protected-accessor',
'private-accessor',
'#private-accessor',

'abstract-accessor',
'instance-accessor',

'decorated-accessor',

'accessor',

// Getters and Setter
['public-abstract-get', 'public-abstract-set'],
['protected-abstract-get', 'protected-abstract-set'],

['public-decorated-get', 'public-decorated-set'],
['protected-decorated-get', 'protected-decorated-set'],
['private-decorated-get', 'private-decorated-set'],

['public-instance-get', 'public-instance-set'],
['protected-instance-get', 'protected-instance-set'],
['private-instance-get', 'private-instance-set'],
['#private-instance-get', '#private-instance-set'],

['public-get', 'public-set'],
['protected-get', 'protected-set'],
['private-get', 'private-set'],
['#private-get', '#private-set'],

['abstract-get', 'abstract-set'],
['decorated-get', 'decorated-set'],
['instance-get', 'instance-set'],

['get', 'set'],

// Methods
'public-abstract-method',
'protected-abstract-method',

'public-decorated-method',
'protected-decorated-method',
'private-decorated-method',

'public-instance-method',
'protected-instance-method',
'private-instance-method',
'#private-instance-method',

'public-method',
'protected-method',
'private-method',
'#private-method',

'abstract-method',
'instance-method',

'decorated-method',

'method'
]
}
}
],
'@typescript-eslint/no-unused-vars': [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gobstones/gobstones-core",
"version": "0.5.5",
"version": "0.5.6",
"description": "A set of utility types, interfaces and classes that are used through all the Gobstones Platform repositories.",
"repository": "https://github.com/gobstones/gobstones-core",
"homepage": "https://gobstones.github.io/gobstones-core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

/**
* @module SourceReader/SourcePositions
* @module SourceReader
* @author Alan Rodas Bonjour <[email protected]>
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/

import { AbstractSourcePosition } from './AbstractSourcePosition';
import { SourcePosition } from './SourcePosition';

import { expect } from '../../Expectations';
import { SourcePosition } from '../SourcePosition';
import { SourceReader } from '../SourceReader';
import { InvalidOperationAtUnknownPositionError, MismatchedInputsError } from '../SourceReaderErrors';

Expand Down
2 changes: 1 addition & 1 deletion src/SourceReader/SourcePositions/AbstractSourcePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @author Alan Rodas Bonjour <[email protected]>
*/

import { SourcePosition } from './SourcePosition';
import { SourcePosition } from '../SourcePosition';

/**
* This is the abstract implementation of the interface {@link SourcePosition}, and
Expand Down
2 changes: 1 addition & 1 deletion src/SourceReader/SourcePositions/DocumentSourcePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

import { AbstractDocumentSourcePosition } from './AbstractDocumentSourcePosition';
import { SourcePosition } from './SourcePosition';

import { SourcePosition } from '../SourcePosition';
import { SourceReader } from '../SourceReader';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* @author Alan Rodas Bonjour <[email protected]>
*/
import { AbstractDocumentSourcePosition } from './AbstractDocumentSourcePosition';
import { SourcePosition } from './SourcePosition';

import { SourcePosition } from '../SourcePosition';
import { SourceReader } from '../SourceReader';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

import { AbstractKnownSourcePosition } from './AbstractKnownSourcePosition';
import { SourcePosition } from './SourcePosition';

import { SourcePosition } from '../SourcePosition';
import { SourceReader } from '../SourceReader';
import { InvalidOperationAtEOIError } from '../SourceReaderErrors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { SourceReader } from '../SourceReader';
/**
* The constant implementing the
* [Abstract Factory Pattern](https://en.wikipedia.org/wiki/Abstract_factory_pattern)
* for {@link SourcePosition}s.
* for {@link SourceReader.SourcePosition}s.
*/
export const SourcePositions = {
export const SourcePositionFactory = {
Unknown: () => UnknownSourcePosition.instance,
EndOfInput: (_sr: SourceReader) => new EndOfInputSourcePosition(_sr),
EndOfDocument: (
Expand Down
2 changes: 1 addition & 1 deletion src/SourceReader/SourcePositions/UnknownSourcePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

import { AbstractSourcePosition } from './AbstractSourcePosition';
import { SourcePosition } from './SourcePosition';

import { SourcePosition } from '../SourcePosition';
import { InvalidOperationAtUnknownPositionError } from '../SourceReaderErrors';

/**
Expand Down
9 changes: 4 additions & 5 deletions src/SourceReader/SourcePositions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/

/**
* This module exposes the source position elements that are used by the
* {@link SourceReader}. This module is internal, thus, the user should not
* instantiate the classes here but through the {@link SourcePositions} factory.
* {@link SourceReader}, that can be created and accessed through the
* SourcePositionsFactory.
*
* @module SourceReader/SourcePositions
* @author Alan Rodas Bonjour <[email protected]>
*
* @internal
*/
export * from './SourceSpan';
export * from './SourcePosition';
export * from './SourcePositions';
export * from './SourcePositionFactory';
29 changes: 15 additions & 14 deletions src/SourceReader/SourceReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* @module SourceReader
* @author Pablo E. --Fidel-- Martínez López, <[email protected]>
*/
import { SourcePosition, SourcePositions } from './SourcePositions';
import { SourcePosition } from './SourcePosition';
import { SourcePositionFactory } from './SourcePositions';
import { InvalidOperationAtEODError, InvalidOperationAtEOIError, NoInputError } from './SourceReaderErrors';

import { and, expect } from '../Expectations';
Expand Down Expand Up @@ -80,13 +81,13 @@ export type SourceInput = string | Record<string, string> | string[];
* parts with ease.
*
* A {@link SourceReader} is created using a {@link SourceInput} and then
* {@link SourceReader/SourcePositions.SourcePosition}s can be read from it.
* {@link SourcePosition}s can be read from it.
* Possible interactions with a {@link SourceReader} include:
* - peek a character, with {@link SourceReader.peek | peek},
* - check if a given strings occurs at the beginning of the text in the
* current document, without skipping it, with
* {@link SourceReader.startsWith | startsWith},
* - get the current position as a {@link SourceReader/SourcePositions.SourcePosition}, with
* - get the current position as a {@link SourcePosition}, with
* {@link SourceReader.getPosition | getPosition},
* - detect if the end of input was reached, with
* {@link SourceReader.atEndOfInput | atEndOfInput},
Expand Down Expand Up @@ -254,7 +255,7 @@ export type SourceInput = string | Record<string, string> | string[];
* that have been processed as visible; unprocessed characters do not appear
* (yet) on visible inputs.
*
* This class is tightly coupled with {@link SourceReader/SourcePositions.SourcePosition}'s implementations,
* This class is tightly coupled with {@link SourcePosition}'s implementations,
* because of instances of that class represent different positions in the source
* inputs kept by a {@link SourceReader}.
* The operations
Expand All @@ -264,7 +265,7 @@ export type SourceInput = string | Record<string, string> | string[];
* {@link SourceReader._inputFromToIn | _inputFromToIn},
* {@link SourceReader._documentContextBeforeOf | _fullInputFromTo} and
* {@link SourceReader._documentContextAfterOf | _fullDocumentContentsAt}
* are meant to be used only by {@link SourceReader/SourcePositions.SourcePosition}, to complete
* are meant to be used only by {@link SourcePosition}, to complete
* their operations, and so they are grouped as Protected.
*
* The remaining auxiliary operations are meant for internal usage, to
Expand All @@ -283,7 +284,7 @@ export class SourceReader {
*
* @group Properties (Static)
*/
public static readonly UnknownPosition: SourcePosition = SourcePositions.Unknown();
public static readonly UnknownPosition: SourcePosition = SourcePositionFactory.Unknown();

/**
* The string to use as a name for unnamed input documents.
Expand Down Expand Up @@ -554,7 +555,7 @@ export class SourceReader {
}

/**
* Gives the current position as a {@link SourceReader/SourcePositions.SourcePosition}.
* Gives the current position as a {@link SourcePosition}.
* See {@link SourceReader} documentation for an example.
*
* **NOTE:**
Expand All @@ -566,9 +567,9 @@ export class SourceReader {
public getPosition(): SourcePosition {
/* istanbul ignore next */
if (!this._hasMoreDocuments()) {
return SourcePositions.EndOfInput(this);
return SourcePositionFactory.EndOfInput(this);
} else if (!this._hasMoreCharsAtCurrentDocument()) {
return SourcePositions.EndOfDocument(
return SourcePositionFactory.EndOfDocument(
this,
this._line,
this._column,
Expand All @@ -578,7 +579,7 @@ export class SourceReader {
this._visibleDocumentContents[this.documentsNames[this._documentIndex]].length
);
} else {
return SourcePositions.Document(
return SourcePositionFactory.Document(
this,
this._line,
this._column,
Expand Down Expand Up @@ -703,7 +704,7 @@ export class SourceReader {
// -----------------------------------------------
/**
* Gives the name of the input document at the given index.
* It is intended to be used only by {@linkSourceReader/SourcePositions.SourcePosition}s.
* It is intended to be used only by {@link SourcePosition}s.
*
* **PRECONDITION:**
* `index <= this._documentsNames.length` (not verified)
Expand All @@ -721,7 +722,7 @@ export class SourceReader {
/**
* Gives the contents of the input document at the given index, both visible
* and non-visible.
* It is intended to be used only by {@link SourceReader/SourcePositions.SourcePosition}s.
* It is intended to be used only by {@link SourcePosition}s.
*
* **PRECONDITION:**
* `index < this._documentsNames.length` (not verified)
Expand All @@ -738,7 +739,7 @@ export class SourceReader {

/**
* Gives the contents of the visible input document at the given index. It
* is intended to be used only by {@link SourceReader/SourcePositions.SourcePosition}s.
* is intended to be used only by {@link SourcePosition}s.
*
* **PRECONDITION:**
* `index < this._documentsNames.length` (not verified).
Expand Down Expand Up @@ -974,7 +975,7 @@ export class SourceReader {
/**
* Gives a clone of the stack of regions.
* Auxiliary for {@link SourceReader/SourcePositions.SourceReader.getPosition | getPosition}.
* It is necessary because regions of {@link SourceReader/SourcePositions.SourcePosition} must correspond
* It is necessary because regions of {@link SourcePosition} must correspond
* to those at that position and do not change with changes in reader state.
*
* @group Function: Auxiliaries
Expand Down
Loading

0 comments on commit fe56f73

Please sign in to comment.