forked from erlang/otp
-
Notifications
You must be signed in to change notification settings - Fork 1
Lukas/stdlib/error index #383
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
Open
garazdawi
wants to merge
15
commits into
lukas/stdlib/io_ansi
Choose a base branch
from
lukas/stdlib/error-index
base: lukas/stdlib/io_ansi
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or 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
Reviewer's GuideThis PR introduces a unified diagnostics subsystem (erl_diagnostic) and refactors the linting and compilation toolchain to use structured diagnostic state instead of ad-hoc error/warning lists, adds user-facing explanation commands and documentation integration, and wires the new diagnostics into the CLI, application controller, and build scripts. Sequence Diagram for Compilation Diagnostics FlowsequenceDiagram
participant CLI as erlc/User
participant Compile as compile_module
participant Lint as erl_lint_module
participant Diag as erl_diagnostic_subsystem
CLI->>+Compile: compile_source(File, Options)
Compile->>+Diag: init(Options) # diagnostics_state
Note over Compile,Diag: Diagnostics state created
Compile->>+Lint: module(Forms, File, Opts, diagnostics_state)
Lint->>Lint: Perform linting checks
alt Issue found
Lint->>+Diag: emit(diagnostics_state, key, location, args, opts)
Diag-->>-Lint: updated_diagnostics_state
end
Lint-->>-Compile: updated_diagnostics_state
Compile->>+Diag: get_errors(updated_diagnostics_state)
Diag-->>-Compile: errors_list
Compile->>+Diag: get_warnings(updated_diagnostics_state)
Diag-->>-Compile: warnings_list
alt report_errors or report_warnings enabled
Compile->>+Diag: report(output_device, updated_diagnostics_state, format, report_opts)
Diag-->>-Compile: status
end
Compile-->>-CLI: Compilation result (ok/error with diags)
ER Diagram for Core Data Structure ChangeserDiagram
"erl_diagnostic_state" {
opaque state "Centralized diagnostic data"
}
"compile_record (#compile)" {
erl_diagnostic_state diagnostics "Replaces errors, warnings lists"
list options
atom module
string ifile
string ofile
}
"lint_record (#lint)" {
erl_diagnostic_state diagnostics "Replaces errors, warnings, enabled_warnings"
string file
list compile_options
gb_sets defined_functions
}
"application_controller_record (#appl)" {
string documentation_url "New field for diagnostic doc URL"
atom name
list appl_data
list inc_apps
}
"DiagnosticInfoMap (application:get_diagnostic)" {
atom application
string filename
string url
string short_code
string long_code
binary diagnostic_doc_content
}
"compile_record (#compile)" o|--|| "erl_diagnostic_state" : uses
"lint_record (#lint)" o|--|| "erl_diagnostic_state" : uses
Class Diagram for erl_lint Module ChangesclassDiagram
class erl_lint {
-diagnostics: erl_diagnostic_state
-errors: list (removed)
-warnings: list (removed)
-enabled_warnings: list (removed)
-warn_format: int (removed)
+module(Forms, FileName, Opts, DiagnosticsState): NewDiagnosticsState
+diagnostics(): list_of_diagnostic_definitions
+start1(File, Opts, InitialDiag): lint_state (modified from start/2)
+parse_options(Opts, DiagnosticsState): DiagnosticsState (modified)
+is_warn_enabled(Type, lint_state): boolean (modified)
+return_status(lint_state): result (modified)
+add_lint_diag(ErrorOrWarning, Anno, lint_state): lint_state (new, replaces add_error/add_warning)
+form(Form, lint_state): lint_state (modified)
-bool_options() (removed)
-pack_errors(Errors) (removed)
-pack_warnings(Warnings) (removed)
}
note for erl_lint "Error/warning handling refactored to use erl_diagnostic_state."
Class Diagram for compile Module ChangesclassDiagram
class compile {
-diagnostics: erl_diagnostic_state (replaces errors, warnings in #compile record)
+emit_errors(state, Errors): new_state
+emit_error(state, Location, Module, Reason): new_state
+emit_warnings(state, Warnings): new_state
+internal_comp(Passes, Code, File, Suffix, state): result (modified)
+fold_comp(PassList, Run, Code, state): result (modified)
+comp_ret_ok(Code, state): tuple_result (modified)
+comp_ret_err(state): error_result (modified)
+werror(state): boolean (modified)
+select_passes(PassSpecList, Opts): PassList (modified for module/3 passes)
+lint_module(Code, state): result (modified to use erl_lint:module/4)
+core_lint_module(Code, state): result (modified)
-messages_per_file(Messages) (removed)
-report_errors(state) (removed)
-report_warnings(state) (removed)
}
note for compile "Error/warning lists in #compile record replaced by erl_diagnostic_state. Reporting uses erl_diagnostic."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
b17ffb1 to
a6e4754
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary by Sourcery
Introduce a unified diagnostics framework to replace and modernize error and warning handling across the compiler, standard library, and tools.
New Features:
Enhancements:
Documentation: