Skip to content

Commit 533b80f

Browse files
authored
(feat) update dependencies and add a filename to the BaseFileException (#41)
* (feat) update dependencies and add a filename to the BaseFileException Signed-off-by: Dan Selman <[email protected]> * (fix) merge issues Signed-off-by: Dan Selman <[email protected]>
1 parent bde4353 commit 533b80f

File tree

8 files changed

+1445
-1090
lines changed

8 files changed

+1445
-1090
lines changed

lib/basefileexception.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ const BaseException = require('./baseexception');
2727
class BaseFileException extends BaseException {
2828

2929
/**
30-
* Create an IllegalModelException
30+
* Create an BaseFileException
3131
* @param {string} message - the message for the exception
3232
* @param {string} fileLocation - the optional file location associated with the exception
3333
* @param {string} fullMessage - the optional full message text
34-
* @param {string} component - the optional component which throws this error
34+
* @param {string} fileName - the optional file name
35+
* @param {string} component - the optional component which throws this error
3536
*/
36-
constructor(message, fileLocation, fullMessage, component) {
37+
constructor(message, fileLocation, fullMessage, fileName, component) {
3738
super(fullMessage ? fullMessage : message, component);
3839
this.fileLocation = fileLocation;
3940
this.shortMessage = message;
41+
this.fileName = fileName;
4042
}
4143

4244
/**
@@ -54,6 +56,14 @@ class BaseFileException extends BaseException {
5456
getShortMessage() {
5557
return this.shortMessage;
5658
}
59+
60+
/**
61+
* Returns the fileName for the error
62+
* @returns {string} the file name or null
63+
*/
64+
getFileName() {
65+
return this.fileName;
66+
}
5767
}
5868

5969
module.exports = BaseFileException;

lib/codegen/parsejs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'use strict';
1616

1717
const fs = require('fs-extra');
18+
const klaw = require('klaw');
1819
const path = require('path');
1920
const program = require('commander');
2021
const PlantUMLGenerator = require('./fromjs/plantumlgenerator');
@@ -48,7 +49,7 @@ function processFile(file, fileProcessor) {
4849
*/
4950
function processDirectory(path, fileProcessor) {
5051
let items = [];
51-
fs.walk(path)
52+
klaw(path)
5253
.on('readable', function (item) {
5354
while ((item = this.read())) {
5455
if (item.stats.isFile()) {

lib/introspect/illegalmodelexception.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class IllegalModelException extends BaseFileException {
4040
constructor(message, modelFile, fileLocation, component) {
4141

4242
let messageSuffix = '';
43+
let fileName = null;
4344
if(modelFile && modelFile.getName()) {
45+
fileName = modelFile.getName();
4446
messageSuffix = 'File \'' + modelFile.getName() + '\': ' ;
4547
}
4648

@@ -53,7 +55,7 @@ class IllegalModelException extends BaseFileException {
5355
// First character to be uppercase
5456
messageSuffix = messageSuffix.charAt(0).toUpperCase() + messageSuffix.slice(1);
5557

56-
super(message, fileLocation, message + ' ' + messageSuffix, component);
58+
super(message, fileLocation, message + ' ' + messageSuffix, fileName, component);
5759
this.modelFile = modelFile;
5860
}
5961

lib/introspect/parseexception.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ParseException extends BaseFileException {
4343
}
4444

4545
// The parser does not give us back the end location of an invalid token.
46-
// Making the end column equal to the end column makes use of
46+
// Making the end column equal to the start column makes use of
4747
// vscodes default behaviour of selecting an entire word
4848
if (fileLocation) {
4949
if (fileLocation.end && fileLocation.start) {
@@ -65,9 +65,8 @@ class ParseException extends BaseFileException {
6565
}
6666

6767
fullMessage += suffix;
68-
super(message, fileLocation, fullMessage, component);
68+
super(message, fileLocation, fullMessage, fileName, component);
6969
}
70-
7170
}
7271

7372
module.exports = ParseException;

0 commit comments

Comments
 (0)