Diagnostics¶
Problem reporting and language server features.
Languages
¶
Language-related operations for VS Code.
Source code in vscode_sockpuppet/diagnostics.py
create_diagnostic_collection
¶
Create a diagnostic collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the collection (default: 'default') |
'default'
|
Returns:
| Type | Description |
|---|---|
DiagnosticCollection
|
A new diagnostic collection |
Source code in vscode_sockpuppet/diagnostics.py
Diagnostic¶
Diagnostic
¶
Diagnostic(range: dict, message: str, severity: Union[int, str] = DiagnosticSeverity.Error, source: Optional[str] = None, code: Optional[Union[str, int]] = None)
Represents a diagnostic, such as a compiler error or warning.
Create a diagnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
range
|
dict
|
Range dict with start and end positions |
required |
message
|
str
|
Diagnostic message |
required |
severity
|
Union[int, str]
|
Severity level (Error, Warning, Information, Hint) |
Error
|
source
|
Optional[str]
|
Source of the diagnostic (e.g., 'python', 'mypy') |
None
|
code
|
Optional[Union[str, int]]
|
Diagnostic code |
None
|
Source code in vscode_sockpuppet/diagnostics.py
add_related_information
¶
Add related information to this diagnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
dict
|
Location dict with uri and range |
required |
message
|
str
|
Related message |
required |
Returns:
| Type | Description |
|---|---|
Diagnostic
|
Self for chaining |
Source code in vscode_sockpuppet/diagnostics.py
to_dict
¶
Convert to dictionary for JSON serialization.
Source code in vscode_sockpuppet/diagnostics.py
DiagnosticSeverity¶
DiagnosticSeverity
¶
Diagnostic severity levels.
DiagnosticCollection¶
DiagnosticCollection
¶
A collection of diagnostics for a specific source.
Create a diagnostic collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
VSCodeClient
|
The VS Code client |
required |
name
|
str
|
Name of the collection |
required |
Source code in vscode_sockpuppet/diagnostics.py
set
¶
Set diagnostics for a URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI to set diagnostics for |
required |
diagnostics
|
Optional[List[Diagnostic]]
|
List of diagnostics (None or [] clears) |
None
|
Source code in vscode_sockpuppet/diagnostics.py
delete
¶
Delete diagnostics for a URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI to clear diagnostics for |
required |
clear
¶
DiagnosticRelatedInformation¶
DiagnosticRelatedInformation
¶
Related information for a diagnostic.
Create diagnostic related information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
dict
|
Location dict with uri and range |
required |
message
|
str
|
Related message |
required |
Source code in vscode_sockpuppet/diagnostics.py
Utility Functions¶
create_position
¶
Create a position object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
int
|
Line number (0-based) |
required |
character
|
int
|
Character position (0-based) |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Position dictionary |
Source code in vscode_sockpuppet/diagnostics.py
create_range
¶
Create a range object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_line
|
int
|
Start line (0-based) |
required |
start_char
|
int
|
Start character (0-based) |
required |
end_line
|
int
|
End line (0-based) |
required |
end_char
|
int
|
End character (0-based) |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Range dictionary |
Source code in vscode_sockpuppet/diagnostics.py
create_location
¶
Create a location object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the location |
required |
range
|
dict
|
The range in the document |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Location dictionary |