From cd35e15f58088bc74bd798918b7a4ef70235b35a Mon Sep 17 00:00:00 2001 From: Will Eand Date: Tue, 12 Mar 2024 18:24:11 -0700 Subject: [PATCH] This code prints exported line information with error code at indicated line --- src/findCapitalizedPrimitiveTypes.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/findCapitalizedPrimitiveTypes.ts b/src/findCapitalizedPrimitiveTypes.ts index 440ad6b..ff14f21 100644 --- a/src/findCapitalizedPrimitiveTypes.ts +++ b/src/findCapitalizedPrimitiveTypes.ts @@ -26,14 +26,18 @@ export function findCapitalizedPrimitiveTypes() { const pattern = /\b(?:int|double|Boolean|char|byte|long|String)\s+([A-Z])(\w*)\b/g; - const errorLines = []; // Array to store line numbers with errors + const errorLines: string[] = []; + // Array to store line numbers with errors // Find matches let match; while ((match = pattern.exec(text)) !== null) { // Get the matched variable name - const lineNumber = document.positionAt(match.index).line; - errorLines.push(lineNumber+1); + let lineNumber = document.positionAt(match.index).line; + lineNumber = lineNumber+1; + let myString: string = lineNumber.toString(); + myString = "Improper Capitalized Primitive Type on line: " + myString; + errorLines.push(myString); const variableName = match[0]; // Entire matched variable name const firstLetterIndex = match.index + match[0].indexOf(match[1]); // Index of the first letter after the primitive data type