Skip to content

Commit

Permalink
Merge pull request #19 from Senior-Capstone-2024/findLowercase2.0
Browse files Browse the repository at this point in the history
This adds the errors onto a single datastructure before JSON file
  • Loading branch information
chiouc authored May 6, 2024
2 parents b505dd0 + 26636b8 commit 2d46287
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion output/data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"3":["Improper Capitalized Primitive Type"],"4":["Improper Capitalized Primitive Type"],"11":["Improper Capitalized Primitive Type","Improper Capitalized Primitive Type"],"12":["Improper Capitalized Primitive Type","Improper Capitalized Primitive Type"],"13":["Improper Capitalized Primitive Type"],"24":["Improper Method Name"],"28":["Improper Method Name","Improper Capitalized Primitive Type"]}
{"3":["Improper Capitalized Primitive Type"],"4":["Improper Capitalized Primitive Type"],"11":["Improper Capitalized Primitive Type","Improper Capitalized Primitive Type"],"12":["Improper Capitalized Primitive Type","Improper Capitalized Primitive Type"],"13":["Improper Capitalized Primitive Type"],"28":["Improper Capitalized Primitive Type"],"33":["Improper Class Or Interface"]}
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export function activate(context: vscode.ExtensionContext) {
} );


const disposable1 = vscode.commands.registerCommand('extension.findLowercaseClassOrInterface', findLowercaseClassOrInterface);
const disposable1 = vscode.commands.registerCommand('extension.findLowercaseClassOrInterface', () => {
findLowercaseClassOrInterface(myMap);
} );

const disposable3 = vscode.commands.registerCommand('extension.singleStatementPerLineChecker', singleStatementPerLineChecker);
const disposable0 = vscode.commands.registerCommand('extension.findAllErrors', findAllErrors);

Expand Down
4 changes: 2 additions & 2 deletions src/findAllErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import { singleStatementPerLineChecker } from "./singleStatementPerLineChecker";
export function findAllErrors() {
// findCapitalizedMethodName();
// findCapitalizedPrimitiveTypes();
findLowercaseClassOrInterface();
singleStatementPerLineChecker();
// findLowercaseClassOrInterface();
// singleStatementPerLineChecker();
}
14 changes: 11 additions & 3 deletions src/findLowercaseClassOrInterface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';

export function findLowercaseClassOrInterface() {
export function findLowercaseClassOrInterface(myMap: Map<number, string[]>): Map<number, string[]> {
// activeTextEditor allows access to text inside opened document.
vscode.window.showInformationMessage('Naming Convention Mistake!! Highlighted in RED=');
const editor = vscode.window.activeTextEditor;
Expand All @@ -23,7 +23,7 @@ export function findLowercaseClassOrInterface() {
let match;
while ((match = pattern.exec(text)) !== null) {
// Get the matched variable name

const lineNumber = document.positionAt(match.index).line + 1; // Get the line number
const variableName = match[0]; // Entire matched variable name
const firstLetterIndex = match.index + match[0].indexOf(match[1]); // Index of the first letter after class
const firstLetterRange = new vscode.Range(document.positionAt(firstLetterIndex), document.positionAt(firstLetterIndex + 1));
Expand All @@ -44,10 +44,18 @@ export function findLowercaseClassOrInterface() {
backgroundColor: 'rgba(255, 0, 0, 0.4)'
}
}), [firstLetterRange]);


if (!myMap.has(lineNumber)) {
myMap.set(lineNumber, []);
}
const errorMessage = "Improper Class Or Interface";
const currentErrors = myMap.get(lineNumber) || [];
currentErrors.push(errorMessage);
myMap.set(lineNumber, currentErrors);
}

} else {
vscode.window.showErrorMessage('No active text editor.');
}
return myMap;
}

0 comments on commit 2d46287

Please sign in to comment.