aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/utils/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/utils/diagnostics')
-rw-r--r--editors/code/src/utils/diagnostics/SuggestedFix.ts4
-rw-r--r--editors/code/src/utils/diagnostics/SuggestedFixCollection.ts6
-rw-r--r--editors/code/src/utils/diagnostics/rust.ts20
-rw-r--r--editors/code/src/utils/diagnostics/vscode.ts2
4 files changed, 16 insertions, 16 deletions
diff --git a/editors/code/src/utils/diagnostics/SuggestedFix.ts b/editors/code/src/utils/diagnostics/SuggestedFix.ts
index b1be2a225..6e660bb61 100644
--- a/editors/code/src/utils/diagnostics/SuggestedFix.ts
+++ b/editors/code/src/utils/diagnostics/SuggestedFix.ts
@@ -24,7 +24,7 @@ export default class SuggestedFix {
24 title: string, 24 title: string,
25 location: vscode.Location, 25 location: vscode.Location,
26 replacement: string, 26 replacement: string,
27 applicability: SuggestionApplicability = SuggestionApplicability.Unspecified 27 applicability: SuggestionApplicability = SuggestionApplicability.Unspecified,
28 ) { 28 ) {
29 this.title = title; 29 this.title = title;
30 this.location = location; 30 this.location = location;
@@ -51,7 +51,7 @@ export default class SuggestedFix {
51 public toCodeAction(): vscode.CodeAction { 51 public toCodeAction(): vscode.CodeAction {
52 const codeAction = new vscode.CodeAction( 52 const codeAction = new vscode.CodeAction(
53 this.title, 53 this.title,
54 vscode.CodeActionKind.QuickFix 54 vscode.CodeActionKind.QuickFix,
55 ); 55 );
56 56
57 const edit = new vscode.WorkspaceEdit(); 57 const edit = new vscode.WorkspaceEdit();
diff --git a/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts b/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts
index 132ce12f8..57c9856cf 100644
--- a/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts
+++ b/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts
@@ -38,13 +38,13 @@ export default class SuggestedFixCollection
38 */ 38 */
39 public addSuggestedFixForDiagnostic( 39 public addSuggestedFixForDiagnostic(
40 suggestedFix: SuggestedFix, 40 suggestedFix: SuggestedFix,
41 diagnostic: vscode.Diagnostic 41 diagnostic: vscode.Diagnostic,
42 ): void { 42 ): void {
43 const fileUriString = suggestedFix.location.uri.toString(); 43 const fileUriString = suggestedFix.location.uri.toString();
44 const fileSuggestions = this.suggestedFixes.get(fileUriString) || []; 44 const fileSuggestions = this.suggestedFixes.get(fileUriString) || [];
45 45
46 const existingSuggestion = fileSuggestions.find(s => 46 const existingSuggestion = fileSuggestions.find(s =>
47 s.isEqual(suggestedFix) 47 s.isEqual(suggestedFix),
48 ); 48 );
49 49
50 if (existingSuggestion) { 50 if (existingSuggestion) {
@@ -65,7 +65,7 @@ export default class SuggestedFixCollection
65 */ 65 */
66 public provideCodeActions( 66 public provideCodeActions(
67 document: vscode.TextDocument, 67 document: vscode.TextDocument,
68 range: vscode.Range 68 range: vscode.Range,
69 ): vscode.CodeAction[] { 69 ): vscode.CodeAction[] {
70 const documentUriString = document.uri.toString(); 70 const documentUriString = document.uri.toString();
71 71
diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts
index 0550d0372..b6efc0f56 100644
--- a/editors/code/src/utils/diagnostics/rust.ts
+++ b/editors/code/src/utils/diagnostics/rust.ts
@@ -7,7 +7,7 @@ export enum SuggestionApplicability {
7 MachineApplicable = 'MachineApplicable', 7 MachineApplicable = 'MachineApplicable',
8 HasPlaceholders = 'HasPlaceholders', 8 HasPlaceholders = 'HasPlaceholders',
9 MaybeIncorrect = 'MaybeIncorrect', 9 MaybeIncorrect = 'MaybeIncorrect',
10 Unspecified = 'Unspecified' 10 Unspecified = 'Unspecified',
11} 11}
12 12
13// Reference: 13// Reference:
@@ -69,7 +69,7 @@ function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
69 69
70 const range = new vscode.Range( 70 const range = new vscode.Range(
71 new vscode.Position(span.line_start - 1, span.column_start - 1), 71 new vscode.Position(span.line_start - 1, span.column_start - 1),
72 new vscode.Position(span.line_end - 1, span.column_end - 1) 72 new vscode.Position(span.line_end - 1, span.column_end - 1),
73 ); 73 );
74 74
75 return new vscode.Location(fileUri, range); 75 return new vscode.Location(fileUri, range);
@@ -81,7 +81,7 @@ function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
81 * If the span is unlabelled this will return `undefined`. 81 * If the span is unlabelled this will return `undefined`.
82 */ 82 */
83function mapSecondarySpanToRelated( 83function mapSecondarySpanToRelated(
84 span: RustDiagnosticSpan 84 span: RustDiagnosticSpan,
85): vscode.DiagnosticRelatedInformation | undefined { 85): vscode.DiagnosticRelatedInformation | undefined {
86 if (!span.label) { 86 if (!span.label) {
87 // Nothing to label this with 87 // Nothing to label this with
@@ -107,7 +107,7 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean {
107 'unused_attributes', 107 'unused_attributes',
108 'unused_imports', 108 'unused_imports',
109 'unused_macros', 109 'unused_macros',
110 'unused_variables' 110 'unused_variables',
111 ].includes(rd.code.code); 111 ].includes(rd.code.code);
112} 112}
113 113
@@ -157,13 +157,13 @@ function mapRustChildDiagnostic(rd: RustDiagnostic): MappedRustChildDiagnostic {
157 title, 157 title,
158 location, 158 location,
159 span.suggested_replacement, 159 span.suggested_replacement,
160 span.suggestion_applicability 160 span.suggestion_applicability,
161 ) 161 ),
162 }; 162 };
163 } else { 163 } else {
164 const related = new vscode.DiagnosticRelatedInformation( 164 const related = new vscode.DiagnosticRelatedInformation(
165 location, 165 location,
166 rd.message 166 rd.message,
167 ); 167 );
168 168
169 return { related }; 169 return { related };
@@ -183,7 +183,7 @@ function mapRustChildDiagnostic(rd: RustDiagnostic): MappedRustChildDiagnostic {
183 * If the diagnostic has no primary span this will return `undefined` 183 * If the diagnostic has no primary span this will return `undefined`
184 */ 184 */
185export function mapRustDiagnosticToVsCode( 185export function mapRustDiagnosticToVsCode(
186 rd: RustDiagnostic 186 rd: RustDiagnostic,
187): MappedRustDiagnostic | undefined { 187): MappedRustDiagnostic | undefined {
188 const primarySpan = rd.spans.find(s => s.is_primary); 188 const primarySpan = rd.spans.find(s => s.is_primary);
189 if (!primarySpan) { 189 if (!primarySpan) {
@@ -223,7 +223,7 @@ export function mapRustDiagnosticToVsCode(
223 const suggestedFixes = []; 223 const suggestedFixes = [];
224 for (const child of rd.children) { 224 for (const child of rd.children) {
225 const { related, suggestedFix, messageLine } = mapRustChildDiagnostic( 225 const { related, suggestedFix, messageLine } = mapRustChildDiagnostic(
226 child 226 child,
227 ); 227 );
228 228
229 if (related) { 229 if (related) {
@@ -256,6 +256,6 @@ export function mapRustDiagnosticToVsCode(
256 return { 256 return {
257 location, 257 location,
258 diagnostic: vd, 258 diagnostic: vd,
259 suggestedFixes 259 suggestedFixes,
260 }; 260 };
261} 261}
diff --git a/editors/code/src/utils/diagnostics/vscode.ts b/editors/code/src/utils/diagnostics/vscode.ts
index d8b85b720..f4a5450e2 100644
--- a/editors/code/src/utils/diagnostics/vscode.ts
+++ b/editors/code/src/utils/diagnostics/vscode.ts
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
3/** Compares two `vscode.Diagnostic`s for equality */ 3/** Compares two `vscode.Diagnostic`s for equality */
4export function areDiagnosticsEqual( 4export function areDiagnosticsEqual(
5 left: vscode.Diagnostic, 5 left: vscode.Diagnostic,
6 right: vscode.Diagnostic 6 right: vscode.Diagnostic,
7): boolean { 7): boolean {
8 return ( 8 return (
9 left.source === right.source && 9 left.source === right.source &&