Skip to content

[lldb] DRAFT - Add Status::Detail type to hold information from diagnostics #80936

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PortalPete
Copy link
Contributor

@PortalPete PortalPete commented Feb 7, 2024

This is a work in progress that lets Status instances separately store multiple messages such as errors, warnings, and/or notes. This approach can help break the anti-pattern where code that creates or modifies a Status object has no choice but to merge multiple messages (e.g. errors and warnings) together into one, long string to store all the information in the status object.

By keeping messages separate, the codebase has more opportunities to give developers a richer and more pleasant experiences. For example, the codebase would have the ability to individually colorize the text of each error, warning, note, etc., as I've done for PR #80938.

Changes:

    • Type struct Status::Detail type in Status.cpp
    • Member std::vector<Status::Detail> m_status_details in class Status
        • Related methods
    • Member std::vector<Status::Detail> m_status_details in class CommandReturnObject
  • Types moved from DiagnosticManager.h -> lldb-private-enumerations.h
    • enum DiagnosticOrigin
    • enum DiagnosticSeverity
  • The UserExpression::Evaluate method:
    • Creates Status::Detail for Diagnostic in a DiagnosticManager instance.
      • And adds it to its Status &error parameter.
    • No longer appends the diagnostic manager's string (of its diagnostics) to its &error parameter.
  • The CommandReturnObject::SetError method:
    • Saves a copy of an error (Status).
    • Appends each status detail (diagnostic) into its own separate error messages.
    • This lets CommandReturnObject individually colorize each "error:", "warning:", or "note:".
    • Before, only the first entry got the colorization because the remaining entries were just concatenated onto the first entry.

…etail vector.

Changes:
* + Type `struct Status::Detail` type in `Status.cpp`
* + Member `std::vector<Status::Detail> m_status_details` in `class Status`
	* + Related methods
* + Member `std::vector<Status::Detail> m_status_details` in `class CommandReturnObject`
* Types moved from `DiagnosticManager.h` -> `lldb-private-enumerations.h`
	* `enum DiagnosticOrigin`
	* `enum DiagnosticSeverity`
* The `UserExpression::Evaluate` method:
	* Creates `Status::Detail` for `Diagnostic` in a `DiagnosticManager` instance.
		* And adds it to its `Status &error` parameter.
	* No longer appends the diagnostic manager's string (of its diagnostics) to its `&error` parameter.
* The `CommandReturnObject::SetError` method:
	* Saves a copy of an error (Status).
	* Appends each status detail (diagnostic) into its own separate error messages.
	* This lets `CommandReturnObject` individually colorize each "error:", "warning:", or "note:".
	* Before, only the first entry got the colorization because the remaining entries were just concatenated onto the first entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant