Skip to content

Message not interpolated in "Show details..." dialog #178

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
harbulot opened this issue May 11, 2023 · 0 comments · Fixed by #179
Closed

Message not interpolated in "Show details..." dialog #178

harbulot opened this issue May 11, 2023 · 0 comments · Fixed by #179
Milestone

Comments

@harbulot
Copy link

(This is using version PMD 7.0.0.v20230502-1028-rc2)

The message regarding a specific marker/violation only shows placeholders in the "Show details..." dialog.

image

image

The message is rendered properly (with placeholders filled in) when hovering on the marker in the editor and in the "Violation Outline" table, but not in the "Show details..." dialog.


I've tried to track the problem as follows:

The interpolated message seems to be in the actual IMarker, which is why the ViolationOutlinePageBR and the markers in general seem to work.

However, I think the problem is that the dialog uses Rule, instead of using the IMarker. See ShowRuleAction.getSelectedViolationRule():

    @Override
    public void run() {
        Rule selectedRule = getSelectedViolationRule();
        if (selectedRule != null) {
            RuleDialog ruleDialog = new RuleDialog(shell, selectedRule, false);
            ruleDialog.open();
        }
    }

    /**
     * Returns the rule from the first selected violation.
     */
    public Rule getSelectedViolationRule() {
        Rule rule = null;
        try {
            IMarker[] markers = getSelectedViolations();
            if (markers != null) {
                rule = PMDPlugin.getDefault().getPreferencesManager().getRuleSet()
                        .getRuleByName(MarkerUtil.ruleNameFor(markers[0]));
            }
        } catch (RuntimeException e) {
            logErrorByKey(StringKeys.ERROR_RUNTIME_EXCEPTION, e);
        }

        return rule;
    }

The information in the dialog is based uses the general Rule, not the specific IMarker. I get the impressing the RuleDialog was meant for another purpose: the rule editor, and that it's now deprecated anyway.

A workaround to fix this might be to create a fake Rule that has the actual message from the specific marker (similar to what FakeRuleViolation seems to do).

adangel added a commit to adangel/pmd-eclipse-plugin that referenced this issue May 13, 2023
This dialog can be opened from the problem view context menu.
The same dialog is used for the marker properties view.
The same dialog is opened from the outline view.

Fixes pmd#178
adangel added a commit to adangel/pmd-eclipse-plugin that referenced this issue May 13, 2023
adangel added a commit to adangel/pmd-eclipse-plugin that referenced this issue May 13, 2023
@adangel adangel added this to the 7.0.0 milestone May 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants