Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
yesamer committed Dec 16, 2024
1 parent ea6f438 commit 1b86f15
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
12 changes: 4 additions & 8 deletions packages/extended-services-vscode-extension/src/Validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile):
);
return createBPMNDiagnostics(validationResponses);
} catch (error) {
console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
throw new Error(
"An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
);
console.error(`An error occured while trying to validate DMN file: ${bpmnFile} with error: ${error.message}`);
throw new Error(`An error occured while trying to validate DMN file: ${bpmnFile} with error: ${error.message}`);
}
}

Expand All @@ -72,9 +70,7 @@ export async function validateDMN(serviceURL: URL, dmnFile: kieFile.KieFile): Pr
);
return createDMNDiagnostics(validationResponses);
} catch (error) {
console.error("An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message);
throw new Error(
"An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message
);
console.error(`An error occured while trying to validate DMN file: ${dmnFile} with error: ${error.message}`);
throw new Error(`An error occured while trying to validate DMN file: ${dmnFile} with error: ${error.message}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ function fetchExtendedServicesURL(): URL {
try {
return new URL(extendedServicesURL);
} catch (error) {
throw new Error("URL configuration " + extendedServicesURL + " is invalid: " + error.message);
throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
}
}

const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
const value = vscode.workspace.getConfiguration().get(property) as T;
if (value == null) {
console.warn("Property: " + property + " is missing, using the default: " + defaultValue);
console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
value == defaultValue;
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,24 @@ function startExtendedServices(): void {
try {
configuration = fetchConfiguration();
} catch (error) {
console.error("[Extended Services Extension] Extension configuration is wrong: " + error.message);
console.error(`[Extended Services Extension] Extension configuration is wrong: ${error.message}`);
vscode.window.showErrorMessage(
"Extension configuration is wrong: " + error.message + " Please fix your local extension's setting"
`Extension configuration is wrong: ${error.message}. Please fix your local extension's setting`
);
return;
}

try {
console.debug(
"[Extended Services Extension] Connecting with the Extended Service located: " + configuration.extendedServicesURL
`[Extended Services Extension] Connecting with the Extended Services located: ${configuration.extendedServicesURL}`
);
connection.start(configuration.extendedServicesURL, configuration.connectionHeartbeatIntervalinSecs);
} catch (error) {
stopExtendedServices();
console.error(
"[Extended Services Extension] An error happened while trying to start the local service:" + error.message
`[Extended Services Extension] An error happened while trying to start the local service: ${error.message}`
);
vscode.window.showErrorMessage("An error happened while trying to start the local service:" + error.message);
vscode.window.showErrorMessage(`An error happened while trying to start the local service: ${error.message}`);
}
}

Expand All @@ -111,36 +111,30 @@ async function validate(extendedServicesURL: URL) {

for (const bpmnFile of bpmnFiles) {
try {
console.debug("[Extended Services Extension] Validating BPMN file: " + bpmnFile.uri.path);
console.debug(`[Extended Services Extension] Validating DMN file: ${bpmnFile.uri.path}`);
const bpmnDiagnostics: vscode.Diagnostic[] = await validator.validateBPMN(extendedServicesURL, bpmnFile);
diagnosticCollection.set(bpmnFile.uri, bpmnDiagnostics);
} catch (error) {
console.error(
"[Extended Services Extension] An error happened while trying to validate " +
bpmnFile.uri.path +
": " +
error.message
`[Extended Services Extension] An error happened while trying to validate ${bpmnFile.uri.path}: ${error.message}`
);
vscode.window.showErrorMessage(
"An error happened while trying to validate " + bpmnFile.uri.path + ": " + error.message
`An error happened while trying to validate ${bpmnFile.uri.path}: ${error.message}`
);
}
}

for (const dmnFile of dmnFiles) {
try {
console.debug("[Extended Services Extension] Validating DMN file: " + dmnFile.uri.path);
console.debug(`[Extended Services Extension] Validating DMN file: ${dmnFile.uri.path}`);
const dmnDiagnostics: vscode.Diagnostic[] = await validator.validateDMN(extendedServicesURL, dmnFile);
diagnosticCollection.set(dmnFile.uri, dmnDiagnostics);
} catch (error) {
console.error(
"[Extended Services Extension] An error happened while trying to validate " +
dmnFile.uri.path +
": " +
error.message
`[Extended Services Extension] An error happened while trying to validate ${dmnFile.uri.path}: ${error.message}`
);
vscode.window.showErrorMessage(
"An error happened while trying to validate " + dmnFile.uri.path + ": " + error.message
`An error happened while trying to validate ${dmnFile.uri.path}: ${error.message}`
);
}
}
Expand All @@ -160,8 +154,9 @@ export function activate(context: vscode.ExtensionContext) {

kieFilesWatcher.subscribeKieFilesOpened(() => {
console.debug(
"[Extended Services Extension] A KIE file has been opened. Current opened KIE files: " +
`[Extended Services Extension] A KIE file has been opened. Current opened KIE files: ${
kieFilesWatcher.watchedKieFiles.length
}`
);
if (!disconnectedByUser && isConnected && configuration) {
validate(configuration.extendedServicesURL);
Expand Down Expand Up @@ -203,7 +198,7 @@ export function activate(context: vscode.ExtensionContext) {
stopExtendedServices();
isConnected = false;
console.error("[Extended Services Extension] Connection lost with Extended Services");
vscode.window.showErrorMessage("Connection error: " + errorMessage);
vscode.window.showErrorMessage(`Connection error: ${errorMessage}`);
});

connection.subscribeDisconnected(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let configurationWatcher: ConfigurationWatcher;
let connection: Connection;
let localService: LocalExtendedServices;

/* Determines if the extension is corrected with the Extended Services Backend */
/* Determines if the extension is connected with the Extended Services Backend */
let isConnected = false;
/* Determines the user explicitely disconnected the Extension from the Extended Services Backend */
let disconnectedByUser: boolean = false;
Expand Down Expand Up @@ -107,24 +107,24 @@ function stopExtendedServices(configuration: Configuration | null) {
}

function startLocalExtendedServices(configuration: Configuration, context: vscode.ExtensionContext): void {
console.debug("[Extended Services Extension] Starting a Local Extended Service process");
console.debug("[Extended Services Extension] Starting a Local Extended Services process");
try {
localService.start(configuration.extendedServicesURL, context.extensionPath);
} catch (error) {
stopExtendedServices(configuration);
console.error(
"[Extended Services Extension] An error happened while trying to start the Local Extended Service process:" +
"[Extended Services Extension] An error happened while trying to start the Local Extended Services process:" +
error.message
);
vscode.window.showErrorMessage(
"An error happened while trying to start the Local Extended Service process:" + error.message
"An error happened while trying to start the Local Extended Services process:" + error.message
);
}
}

function startConnection(configuration: Configuration) {
console.debug(
"[Extended Services Extension] Connecting with the Extended Service located: " + configuration.extendedServicesURL
"[Extended Services Extension] Connecting with the Extended Services located: " + configuration.extendedServicesURL
);
try {
connection.start(configuration.extendedServicesURL, configuration.connectionHeartbeatIntervalinSecs);
Expand Down

0 comments on commit 1b86f15

Please sign in to comment.