Skip to content

Commit 80ee8fa

Browse files
committed
feat: support for multiline comment for languages that use default regex
1 parent aba4a0b commit 80ee8fa

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

example-project/src-client/auth/actions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import {
1010

1111
function authenticate(provider) {
1212
return dispatch => {
13-
//cc:signin#1;firebase sign in;+1;call to firebase with auth provider, proceed if success response
13+
/*
14+
* cc:signin#1;firebase sign in;+1;call to firebase with auth provider, proceed if success response
15+
*/
1416
firebaseAuth.signInWithPopup(provider)
1517
.then(result => dispatch(signInSuccess(result)))
1618
.catch(error => dispatch(signInError(error)));

src/server/code-parse/language/default/codecrumbs.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const lineNumber = require('line-number');
21
const compact = require('lodash/compact');
32
const { CC_NODE_TYPE, NO_TRAIL_FLOW } = require('../../../shared-constants');
43

@@ -61,20 +60,13 @@ const setupGetCommentsFromCode = regex => fileCode => {
6160
const result = compact(regex.exec(fileCode)) || [];
6261

6362
return result.reduce((comments, value) => {
64-
const matchLineNumber = lineNumber(fileCode, regex);
65-
66-
const parseRes = matchLineNumber.filter((val) => val.match == value)[0]
67-
68-
if(parseRes) {
69-
const number = parseRes["number"]
70-
71-
const nodeLines = [number, number];
72-
73-
return [...comments, { value, nodeLines }];
74-
} else {
75-
return comments;
76-
}
63+
const index = fileCode.indexOf(value);
64+
const tempString = fileCode.substring(0, index);
65+
const matchLineNumber = tempString.split('\n').length;
7766

67+
const commentStringCount = value.split('\n').length
68+
const nodeLines = [matchLineNumber, matchLineNumber + commentStringCount - 1];
69+
return [...comments, { value, nodeLines }]
7870
}, []);
7971
};
8072

src/server/utils/logger.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ const logAdapter = (msg, force) => (isDebugModeEnabled || force) && console.log(
66
module.exports = {
77
getText: e => {
88
try {
9-
return typeof e === 'object' ? JSON.stringify(e) : e;
9+
if (typeof e === 'object') {
10+
const stringifiedError = JSON.stringify(e);
11+
return stringifiedError === '{}' ? e : stringifiedError;
12+
} else {
13+
return e;
14+
}
1015
} catch (e) {
1116
return `COULD NOT PARSE ERROR ${e}`;
1217
}

0 commit comments

Comments
 (0)