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] An error handling kit: CompilerBase-Error #115

Closed
zong-zhe opened this issue Jul 21, 2022 · 1 comment
Closed

[Feature] An error handling kit: CompilerBase-Error #115

zong-zhe opened this issue Jul 21, 2022 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request error-handling Issues or PRs related to kcl error handling long-term refactor

Comments

@zong-zhe
Copy link
Contributor

zong-zhe commented Jul 21, 2022

CompilerBase-Error is an error handling kit, whose goal is to help compiler developers build the error handling of their own compiler during the development.

google docs:
[WIP] https://docs.google.com/document/d/1oXZr_T76DkL9tkU2RT5anNr615xpLperOghKWdG79NE/edit?usp=sharing
[WIP] https://docs.google.com/document/d/1xFwBOkwD2cJYdb6L-JLKgRMYCy_xfLKgU9-kdPZtqas/edit?usp=sharing

yuque docs:
[WIP] https://www.yuque.com/docs/share/64c4e739-9cbf-4946-8659-5b35b86f5956?# 《CompilerBase-Error》

@zong-zhe zong-zhe added documentation Improvements or additions to documentation enhancement New feature or request error-handling Issues or PRs related to kcl error handling refactor labels Jul 21, 2022
@zong-zhe zong-zhe added this to the v0.4.3 Release milestone Jul 21, 2022
@zong-zhe zong-zhe self-assigned this Jul 21, 2022
@zong-zhe
Copy link
Contributor Author

zong-zhe commented Aug 4, 2022

RoadMap

1. Compiler-Base

2. One-Sentence

3. Landing

Prepare
KCLVM
  • [WIP] Complete and fix the work flow of an exception from throwing to outputing.
  • [WIP] All errors/warnings whose message texts is simple and no interpolation strings.
  • All errors/warnings.
  • Lint Warning.
Other
  • Accumulates predefined error/warning types.

4. Problems

zong-zhe added a commit that referenced this issue Aug 11, 2022
…er-base. (#142)

feat(compiler-base-error): add text rendering and related helper functions.

Reuse 'styled_buffer.rs' in 'rustc_errors', and 'styled_buffer.rs' has been modified to fit the feature of 'Compiler-Base'.
- add method 'appendl()' and 'pushs()' to 'StyledBuffer'.
- replaced the `enum Style` with generics `T: Clone + PartialEq + Eq + Style` to support extending more styles.
- add some test cases for 'StyledBuffer'.

issue #115

add comments for `putl()` and `appendl()`

add comments to trait Style

add more README

use generic to replace `dyn trait`

rename `putl` to `pushs`.
rename `appendl` to `append_last_line`.
rename `render_style` to `render_style_to_color_spec`.

fix comments mistake

rename `append_last_line` to `appendl`
zong-zhe added a commit that referenced this issue Aug 11, 2022
* fix rebase conflicts

* rename `putl` to `pushs`.
rename `appendl` to `append_last_line`.
rename `render_style` to `render_style_to_color_spec`.

* feat(compiler-base): reuse kclvm bug macro.

init crate 'macros' in compiler_base.
reuse bug macro 'bug!()' in compiler_base/macros/src/bug.rs.
add test cases for 'bug!()' in compiler_base/macros/src/tests.rs.

issue #115

* feat(compiler-base): add diagnostic style.

init the crate 'error' in compiler-base.
add `DiagnosticStyle` in compiler-base/error/src/style.rs.
add test cases in compiler-base/error/src/style.rs.

issue #115

* fmt function DiagnosticStyle.render_style_to_color_spec()
zong-zhe added a commit that referenced this issue Aug 15, 2022
* fix rebase conflicts

* rename `putl` to `pushs`.
rename `appendl` to `append_last_line`.
rename `render_style` to `render_style_to_color_spec`.

* fix rebase conflicts.

* fix rebase conflicts.

* fmt function DiagnosticStyle.render_style_to_color_spec()

* feat(compiler-base): add 'One-Sentence' to compiler_base/error

add pendant.rs in compiler_base/diagnostic/error/src/diagnostic.
add trait `Formatter` provides method `format()` to format pendant/sentence/sentence_message into `StyledString`.
add struct `LabelPendant` implemented trait `Pendant` to show label for diagnostic.
add struct `Sentence` implemented `Pendant`.
add test cases in compiler_base/error/src/tests.rs

issue #115

* add comments for field of LabelPendant

* replace 'One-Sentence' by 'Components'.

* fix pr comments and cargo fmt.

* fmt
zong-zhe added a commit that referenced this issue Aug 15, 2022
feat(compiler-base): reuse 'rustc_span' and 'rustc_data_structure'.

'Compiler-Base' decides to reuse 'rustc_span' and 'rustc_data_structure' to describe code snippets and the location of code elements in the file.
copy -r '3rdparty/rustc_span' and '3rdparty/rustc_data_structure' from 'kclvm' to 'kclvm/compiler_base'.
add 'span' in 'kclvm/compiler_base' to pub use some parts of '3rdparty/rustc_span' and '3rdparty/rustc_data_structure'.

issue #115
zong-zhe added a commit that referenced this issue Aug 15, 2022
feat(compiler-base): reuse kclvm bug macro.

init crate 'macros' in compiler_base.
reuse bug macro 'bug!()' in compiler_base/macros/src/bug.rs.
add test cases for 'bug!()' in compiler_base/macros/src/tests.rs.

issue #115
Peefy pushed a commit that referenced this issue Aug 15, 2022
…nt` with generic `T: Clone + PartialEq + Eq + Style`. (#152)

* Refactor(compiler-base): Replaced `DiagnosticStyle` in `trait Component` with generic `T: Clone + PartialEq + Eq + Style`.

Replaced `DiagnosticStyle` in `trait Component` with generic `T: Clone + PartialEq + Eq + Style`, So that `Components` can support more Styles.

issue #115

* move `Component String` from `components.rs` to `mod.rs`.
add some comments.

* add some comments

* add some comments.
zong-zhe added a commit that referenced this issue Aug 23, 2022
* Refactor(compiler-base): Replaced `DiagnosticStyle` in `trait Component` with generic `T: Clone + PartialEq + Eq + Style`.

Replaced `DiagnosticStyle` in `trait Component` with generic `T: Clone + PartialEq + Eq + Style`, So that `Components` can support more Styles.

issue #115

* init reuse kclvm emitter

* add some comments

* replace panic! by bug!

* reuse the lock.rs in rustc_errors

* remove unused dependencies

* rm pub for Destination

* rm unused pub

* rm Destination::Raw

* fix lock name mistake

* add some comments

* add more comments

* fix a bug and add some comments

* rm useless comments

* add some comments

* add some comments

* add some comments and rename `EmitterWriter` to `TerminalWriter`

* fix typo

* fix mistakes

Co-authored-by: zong-zhe <zongzhe1996@163.com>
@Peefy Peefy modified the milestones: v0.4.3 Release, v0.4.4 Release Aug 25, 2022
zong-zhe added a commit that referenced this issue Aug 29, 2022
* feat(compiler-base): add error message depends on fluent.

add error message loader based on fluent0.16.0.

issue #115

* make pub -> pub(crate)

* add walk dir

* fix typo

* a simpler template loader

* add error for template loader

* fix comments

* add some comments

* fmt

* remove useless import

* fix typo
zong-zhe added a commit that referenced this issue Sep 1, 2022
* init error handler

* feat(compiler-base): add diagnostic handler.

add diagnostic handler in compiler_base/error/lib.rs.

issue #115

* rm useless comments

* add some comments and fix import mistake

* try handler inner

* fix uncatched panic

* use match replace unwrap

* add some comments about mutex

* add docstring in comments

* fmt in docstring

* fix comments mistakes

* move comments to lib.rs

* add default() for DiagnosticHandler

* add inlines

* add note comments for add_diagnostic()

* add comments

* fix mistake

* fix mistake

* add comments for eager and lazy loading

* fix typo

* fix typo

* fix comments
ldxdl pushed a commit that referenced this issue Oct 18, 2022
* Refactor(compiler-base): refactor method in DiagnosticHandler.

make method 'add_err_diagnostic','add_warn_diagnostic','emit_error_diagnostic',
'emit_warn_diagnostic','emit_stashed_diagnostics' and 'abort_if_errors' return `&self`.

issue #115

* add test case
ldxdl pushed a commit that referenced this issue Oct 18, 2022
* Feat(compiler-base-session): Add some method for 'Session'.

add constructor `new_with_src_code()` to 'Session' for constructing by source code.
add method 'emit_err()' to 'Session' for displaying error diagnostic.

issue #115

* update compiler-base-error version

* refactor method `Session.emit_err`
amyXia1994 pushed a commit that referenced this issue Oct 20, 2022
#249)

* Fix(compiler-base-error): `CodeSnippet` component generates the line number plus one.

In `CodeSnippet` components, the line number plus one.

issue #115

* add some comments
amyXia1994 pushed a commit that referenced this issue Oct 24, 2022
#252)

Feat(compiler-base-error): remove the newline at the end of component `CodeSnippet`.

remove the newline at the end of component `CodeSnippet`.

issue #115
amyXia1994 pushed a commit that referenced this issue Oct 24, 2022
add new constructor `new_with_file_and_code` for `Session`.

issue #115
zong-zhe added a commit that referenced this issue Oct 25, 2022
…tyledString and StyledChar (#256)

* Feat(rustc_error): add trait Debug, PartialEq, Eq for StyledBuffer, StyledString and StyledChar.

add trait Debug, PartialEq, Eq for StyledBuffer, StyledString and StyledChar.

issue #115.

* update rustc_error version
amyXia1994 pushed a commit that referenced this issue Oct 25, 2022
…piler-base-error. (#257)

* Feat(rustc_error): add trait Debug, PartialEq, Eq for StyledBuffer, StyledString and StyledChar.

add trait Debug, PartialEq, Eq for StyledBuffer, StyledString and StyledChar.

issue #115.

* update rustc_error version

* Feat(compiler-base-error): make StyledBuffer, StyledString pub in compiler-base-error.

make StyledBuffer, StyledString pub in compiler-base-error.

issue #115
zong-zhe added a commit that referenced this issue Oct 25, 2022
…iagnostic. (#258)

Feat(compiler-base-error): Implement trait Debug and PartialEq for Diagnostic.

Implement trait Debug and PartialEq for Diagnostic.

issue #115
zong-zhe added a commit that referenced this issue Oct 25, 2022
… DiagnosticHandlerInner. (#259)

* Feat(compiler-base-error): impl trait Debug for DiagnosticHandler and DiagnosticHandlerInner.

impl trait Debug for DiagnosticHandler and DiagnosticHandlerInner.

issue #115

* cargo fmt
amyXia1994 pushed a commit that referenced this issue Oct 26, 2022
* update session version

* Feat(compiler-base-session): Add some methods for Session.

'emit_stashed_diagnostics_and_abort' to emit all the diagnostics and abort.
'emit_stashed_diagnostics' to emit all the diagnostics but not abort.
'add_err' to add error to diagnostics.
'add-warn' to add warning to diagnostics.
'diagnostic_count' to get the count of diagnostics.

issue #115.

* emit_stashed_diagnostics_and_abort return self
zong-zhe added a commit that referenced this issue Oct 28, 2022
The new default method does not need to load the template file, which solves the problem that the template file path may not be found.

issue #115.
zong-zhe added a commit that referenced this issue Oct 31, 2022
#269)

Feat(compiler-base-session): Update the new `compiler-base-error/DiagnosticHandler/default()` method in compiler-base-session.

Replace the old default method with the new default method in compiler-base-session,

The new default method will not return `Error`.
The new method will not load the file inside.

issue #115.
@Peefy Peefy modified the milestones: v0.4.4 Release, v0.4.5 Release Dec 4, 2022
@Peefy Peefy removed this from the v0.4.5 Release milestone Jan 29, 2023
@Peefy Peefy changed the title [WIP][Enhancement] an error handling kit: CompilerBase-Error [Feature] An error handling kit: CompilerBase-Error Jan 29, 2023
@Peefy Peefy closed this as completed Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request error-handling Issues or PRs related to kcl error handling long-term refactor
Projects
None yet
2 participants