-
Notifications
You must be signed in to change notification settings - Fork 1
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
NEW (Extension) @W-16442046@ Apex guru fixer logic - to show and insert apex guru suggestions #116
Changes from 6 commits
5cb3946
0e56474
97362ca
fa4a36c
622cb8e
70890fc
fc7b915
3f1c22a
d5bf863
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { PathlessRuleViolation, RuleResult, RuleViolation } from '../types'; | ||
import { ApexGuruViolation, PathlessRuleViolation, RuleResult, RuleViolation } from '../types'; | ||
import {messages} from './messages'; | ||
import * as vscode from 'vscode'; | ||
|
||
|
@@ -89,6 +89,23 @@ export class DiagnosticManager { | |
target: vscode.Uri.parse(violation.url), | ||
value: violation.ruleName | ||
} : violation.ruleName; | ||
if (engine === 'apexguru') { | ||
const apexGuruViolation = violation as ApexGuruViolation; | ||
|
||
if (apexGuruViolation.suggestedCode?.trim()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the suggestedCode is empty... maybe that is because we are suggesting to replace it. Can we instead just explicitly check if the suggestedCode is undefined as a way of determining this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! this is a super-edge case. But valid point. Let me take care of this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
diagnostic.relatedInformation = [ | ||
new vscode.DiagnosticRelatedInformation( | ||
new vscode.Location(vscode.Uri.parse('Current Code'), range), | ||
`${apexGuruViolation.currentCode}` | ||
), | ||
new vscode.DiagnosticRelatedInformation( | ||
new vscode.Location(vscode.Uri.parse('ApexGuru Suggestions'), range), | ||
`${apexGuruViolation.suggestedCode}` | ||
) | ||
]; | ||
} | ||
|
||
} | ||
return diagnostic; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If currentCode and suggestedCode is equal to `` (i.e. empty)… does it show this in the popup box still?
I ask because I would have assumed that to trigger whether it shows up or not would be based on undefined or null instead. Because maybe the after code is indeed empty and we want to show that instead of hide it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As explained in slack, this doesn't show up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not today. But it could in the future.
Instead of
Why not just send in the value always even if it is undefined.
Then your line
code could just switch to
or maybe just
so that it allows for empty strings.