release: WRNexusJS 0.3.5
This commit is contained in:
@@ -84,7 +84,62 @@ function lineDiagnostic(
|
||||
}
|
||||
|
||||
function stripComments(source) {
|
||||
return source.replace(/<!--[\s\S]*?-->/g, (comment) => comment.replace(/[^\n]/g, " "));
|
||||
const masked = [...source];
|
||||
let quote = null;
|
||||
let escaped = false;
|
||||
|
||||
const maskRange = (start, end) => {
|
||||
for (let index = start; index < end; index += 1) {
|
||||
if (source[index] !== "\n" && source[index] !== "\r") {
|
||||
masked[index] = " ";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (let index = 0; index < source.length; index += 1) {
|
||||
const character = source[index];
|
||||
|
||||
if (quote !== null) {
|
||||
if (escaped) {
|
||||
escaped = false;
|
||||
} else if (character === "\\") {
|
||||
escaped = true;
|
||||
} else if (character === quote) {
|
||||
quote = null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character === '"' || character === "'" || character === "`") {
|
||||
quote = character;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (source.startsWith("//", index)) {
|
||||
const lineEnd = source.indexOf("\n", index + 2);
|
||||
const end = lineEnd === -1 ? source.length : lineEnd;
|
||||
maskRange(index, end);
|
||||
index = end - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (source.startsWith("/*", index)) {
|
||||
const commentEnd = source.indexOf("*/", index + 2);
|
||||
const end = commentEnd === -1 ? source.length : commentEnd + 2;
|
||||
maskRange(index, end);
|
||||
index = end - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (source.startsWith("<!--", index)) {
|
||||
const commentEnd = source.indexOf("-->", index + 4);
|
||||
const end = commentEnd === -1 ? source.length : commentEnd + 3;
|
||||
maskRange(index, end);
|
||||
index = end - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return masked.join("");
|
||||
}
|
||||
|
||||
function maskLeadingTrivia(source) {
|
||||
@@ -509,6 +564,17 @@ function findRootMembers(source, bodyStart, bodyEnd) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (source.startsWith("//", index)) {
|
||||
skipLine();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (source.startsWith("/*", index)) {
|
||||
const end = source.indexOf("*/", index + 2);
|
||||
index = end === -1 ? bodyEnd : end + 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (source.startsWith("<!--", index)) {
|
||||
const end = source.indexOf("-->", index + 4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user