Skip to content

Commit

Permalink
SLVSCODE-966 apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Jan 6, 2025
1 parent 58ca923 commit 5f8d265
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scripts/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"groupId": "org.sonarsource.sonarlint.ls",
"artifactId": "sonarlint-language-server",
"version": "3.15.0.75823",
"version": "3.15.0.75834",
"output": "server/sonarlint-ls.jar"
},
{
Expand Down
14 changes: 7 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as ChildProcess from 'child_process';
import { DateTime } from 'luxon';
import * as Path from 'path';
import * as VSCode from 'vscode';
import { DiagnosticSeverity, LanguageClientOptions, StreamInfo } from 'vscode-languageclient/node';
import { LanguageClientOptions, StreamInfo } from 'vscode-languageclient/node';
import { configureCompilationDatabase, notifyMissingCompileCommands } from './cfamily/cfamily';
import { AutoBindingService } from './connected/autobinding';
import { assistCreatingConnection } from './connected/assistCreatingConnection';
Expand Down Expand Up @@ -60,7 +60,7 @@ import { getPlatform } from './util/platform';
import { installManagedJre, JAVA_HOME_CONFIG, resolveRequirements } from './util/requirements';
import { code2ProtocolConverter, protocol2CodeConverter } from './util/uri';
import * as util from './util/util';
import { filterOutFilesIgnoredForAnalysis, shouldAnalyseFile } from './util/util';
import { filterOutFilesIgnoredForAnalysis, getSeverity, shouldAnalyseFile } from './util/util';
import { resolveIssueMultiStepInput } from './issue/resolveIssue';
import { IssueService } from './issue/issue';
import { CAN_SHOW_MISSING_REQUIREMENT_NOTIF, showSslCertificateConfirmationDialog } from './util/showMessage';
Expand Down Expand Up @@ -92,7 +92,7 @@ let hotspotsTreeDataProvider: AllHotspotsTreeDataProvider;
let allHotspotsView: VSCode.TreeView<HotspotTreeViewItem>;
let helpAndFeedbackTreeDataProvider: HelpAndFeedbackTreeDataProvider;
let helpAndFeedbackView: VSCode.TreeView<HelpAndFeedbackLink>;
let diagnosticCollection: VSCode.DiagnosticCollection;
let taintVulnerabilityCollection: VSCode.DiagnosticCollection;

function runJavaServer(context: VSCode.ExtensionContext): Promise<StreamInfo> {
return resolveRequirements(context)
Expand Down Expand Up @@ -222,8 +222,8 @@ export async function activate(context: VSCode.ExtensionContext) {

await languageClient.start();

diagnosticCollection = VSCode.languages.createDiagnosticCollection('SonarQube Taint Vulnerabilities');
context.subscriptions.push(diagnosticCollection);
taintVulnerabilityCollection = VSCode.languages.createDiagnosticCollection('SonarQube Taint Vulnerabilities');
context.subscriptions.push(taintVulnerabilityCollection);

ConnectionSettingsService.init(context, languageClient);
NewCodeDefinitionService.init(context);
Expand Down Expand Up @@ -635,14 +635,14 @@ function installCustomRequestHandlers(context: VSCode.ExtensionContext) {
new VSCode.Position(diagnostic.range.end.line, diagnostic.range.end.character)
),
diagnostic.message,
DiagnosticSeverity.Error
getSeverity(diagnostic.severity)
);
d.source = diagnostic.source;
d.code = diagnostic.code;
d['data'] = diagnostic.data;
return d;
});
diagnosticCollection.set(VSCode.Uri.parse(taintVulnerabilitiesPerFile.uri), diagnostics);
taintVulnerabilityCollection.set(VSCode.Uri.parse(taintVulnerabilitiesPerFile.uri), diagnostics);
});

languageClient.onRequest(
Expand Down
19 changes: 19 additions & 0 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,22 @@ function isOpenInEditor(fileUri: string) {
const notebookDocumentIsOpen = vscode.workspace.notebookDocuments.some(d => d.uri.toString(false) === codeFileUri);
return textDocumentIsOpen || notebookDocumentIsOpen;
}

export function getSeverity(severity: number): vscode.DiagnosticSeverity {
const SEVERITY_ERROR = 1;
const SEVERITY_WARNING = 2;
const SEVERITY_INFORMATION = 3;
const SEVERITY_HINT = 4;
switch (severity) {
case SEVERITY_ERROR:
return vscode.DiagnosticSeverity.Error;
case SEVERITY_WARNING:
return vscode.DiagnosticSeverity.Warning;
case SEVERITY_INFORMATION:
return vscode.DiagnosticSeverity.Information;
case SEVERITY_HINT:
return vscode.DiagnosticSeverity.Hint;
default:
return vscode.DiagnosticSeverity.Warning;
}
}

0 comments on commit 5f8d265

Please sign in to comment.