From bd2cf6c26aaf8c36f8edeaf8e786bd7f77c94525 Mon Sep 17 00:00:00 2001 From: jeffcheasey88 <66554203+jeffcheasey88@users.noreply.github.com> Date: Fri, 26 May 2023 18:36:04 +0200 Subject: [PATCH] Simple Comment Case --- .../peeratcode/parser/java/Function.java | 1 + .../peeratcode/parser/java/Import.java | 2 ++ .../peeratcode/parser/java/JavaParser.java | 14 ++++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Function.java b/src/be/jeffcheasey88/peeratcode/parser/java/Function.java index be61179..da22e69 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Function.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Function.java @@ -91,6 +91,7 @@ public class Function { } private void body(String content, CleanerPool cleaner) throws Exception{ + System.out.println("BODY "+content); } public void show(int tab){ diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/Import.java b/src/be/jeffcheasey88/peeratcode/parser/java/Import.java index 283accd..5533700 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/Import.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/Import.java @@ -21,6 +21,8 @@ public class Import { this.name = matcher.group(2); return matcher.group(1).length(); } + +// public int DoYouSeeMe(){ return false; } public String getName(){ return this.name; diff --git a/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java b/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java index fecb634..e73e695 100644 --- a/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java +++ b/src/be/jeffcheasey88/peeratcode/parser/java/JavaParser.java @@ -81,8 +81,16 @@ public class JavaParser{ String content = ""; int index; + CleanerPool cleaner = new CleanerPool( + new Cleaner("CONSTANT_STRING",'"','"'), + new Cleaner("CONSTANT_CHAR",'\'','\'')); + String line; - while((line = reader.readLine()) != null) content+=line; + while((line = reader.readLine()) != null){ + index = line.indexOf("//"); + if(index >= 0) line = line.substring(0, index); + content+=line; + } // content = CleanerPool.getterToDelete.clean(content); @@ -99,9 +107,7 @@ public class JavaParser{ } this.clazz = new Class(); - index = this.clazz.parse(content, new CleanerPool( - new Cleaner("CONSTANT_STRING",'"','"'), - new Cleaner("CONSTANT_CHAR",'\'','\''))); + index = this.clazz.parse(content, cleaner); content = content.substring(index); }