Skip to content
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

[feature request] Вынести создание координат в сервис ITextCoordinateSystemComputer #109

Closed
Stepami opened this issue Aug 19, 2024 · 0 comments · Fixed by #110
Labels
FrontEnd Working on frontend of the interpreter Good First Issue Good for newcomers
Milestone

Comments

@Stepami
Copy link
Owner

Stepami commented Aug 19, 2024

Is your feature request related to a problem? Please describe.
Конструктор класса Coordinate https://github.com/Stepami/hydrascript/blob/master/src/Domain/HydraScript.Domain.FrontEnd/Lexer/Token.cs#L42
Обладает слишком сложной реализацией с неположенной ответственностью:

public record Coordinates(int Line, int Column)
{
    public Coordinates(int absolutePos, IReadOnlyList<int> system) :
        this(0, 0)
    {
        for (var i = 0; i < system.Count; i++)
            if (absolutePos <= system[i])
            {
                var offset = i == 0 ? -1 : system[i - 1];
                (Line, Column) = (i + 1, absolutePos - offset);
                break;
            }

        if (Line == 0)
        {
            (Line, Column) = (system.Count + 1, 1);
        }
    }

    public override string ToString() => $"({Line}, {Column})";
}

Describe the solution you'd like
Необходимо перенести логику вычисления координаты (Строка, Столбец) из пары (индекс, переносы строк) внутрь сервиса ITextCoordinateSystemComputer

@Stepami Stepami added Good First Issue Good for newcomers FrontEnd Working on frontend of the interpreter labels Aug 19, 2024
@Stepami Stepami added this to the v2.1.0 milestone Aug 19, 2024
Stepami added a commit that referenced this issue Aug 20, 2024
Stepami added a commit that referenced this issue Aug 20, 2024
* #107 - оптимизация ITextCoordinateSystemComputer.GetLines

* #107 - правка тестов

* #109 - Вынос логики построения координат в сервис

* #109 - тесты
Stepami added a commit that referenced this issue Aug 25, 2024
* #103 - вернул префикс (#104)

* #105 - fix GitVersion.yml +semver:skip (#106)

* #105 - fix GitVersion.yml

* #105 - label->tag

* #97 - внедрение логгера (#108)

* #97 - rename logging -> dumping

* #97 - refactoring of writer entity

* #97 - реализация вывода с помощью логгера

* #97 - реализация форматтера для эквивалентного вывода

* #97 - работа с логгером в тестах

* Улучшения работы с текстовыми координатами (#110)

* #107 - оптимизация ITextCoordinateSystemComputer.GetLines

* #107 - правка тестов

* #109 - Вынос логики построения координат в сервис

* #109 - тесты

---------

Co-authored-by: StefanioHabrArticles <120809256+StefanioHabrArticles@users.noreply.github.com>
Stepami added a commit that referenced this issue Feb 2, 2025
* #107 - оптимизация ITextCoordinateSystemComputer.GetLines

* #107 - правка тестов

* #109 - Вынос логики построения координат в сервис

* #109 - тесты
Stepami added a commit that referenced this issue Feb 3, 2025
* #107 - оптимизация ITextCoordinateSystemComputer.GetLines

* #107 - правка тестов

* #109 - Вынос логики построения координат в сервис

* #109 - тесты
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FrontEnd Working on frontend of the interpreter Good First Issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant