Search in sources :

Example 1 with DefaultServerFlow

use of org.sonarsource.sonarlint.core.container.model.DefaultServerFlow in project sonarlint-core by SonarSource.

the class IssueStorePaths method toApiIssue.

public static ServerIssue toApiIssue(Sonarlint.ServerIssue pbIssue, String idePath) {
    var issue = new DefaultServerIssue();
    issue.setAssigneeLogin(pbIssue.getAssigneeLogin());
    issue.setLineHash(pbIssue.getLineHash());
    if (pbIssue.getPrimaryLocation().hasTextRange()) {
        var textRange = pbIssue.getPrimaryLocation().getTextRange();
        issue.setTextRange(new TextRange(textRange.getStartLine(), textRange.getStartLineOffset(), textRange.getEndLine(), textRange.getEndLineOffset()));
        issue.setCodeSnippet(trimToNull(pbIssue.getPrimaryLocation().getCodeSnippet()));
    }
    issue.setFilePath(idePath);
    issue.setMessage(pbIssue.getPrimaryLocation().getMsg());
    issue.setSeverity(pbIssue.getSeverity());
    issue.setType(pbIssue.getType());
    issue.setCreationDate(Instant.ofEpochMilli(pbIssue.getCreationDate()));
    issue.setResolution(pbIssue.getResolution());
    issue.setKey(pbIssue.getKey());
    issue.setRuleKey(pbIssue.getRuleRepository() + ":" + pbIssue.getRuleKey());
    for (Sonarlint.ServerIssue.Flow f : pbIssue.getFlowList()) {
        issue.getFlows().add(new DefaultServerFlow(f.getLocationList()));
    }
    return issue;
}
Also used : DefaultServerIssue(org.sonarsource.sonarlint.core.container.model.DefaultServerIssue) TextRange(org.sonarsource.sonarlint.core.analysis.api.TextRange) DefaultServerIssue(org.sonarsource.sonarlint.core.container.model.DefaultServerIssue) ServerIssue(org.sonarsource.sonarlint.core.client.api.connected.ServerIssue) DefaultServerFlow(org.sonarsource.sonarlint.core.container.model.DefaultServerFlow)

Aggregations

TextRange (org.sonarsource.sonarlint.core.analysis.api.TextRange)1 ServerIssue (org.sonarsource.sonarlint.core.client.api.connected.ServerIssue)1 DefaultServerFlow (org.sonarsource.sonarlint.core.container.model.DefaultServerFlow)1 DefaultServerIssue (org.sonarsource.sonarlint.core.container.model.DefaultServerIssue)1