@@ -130,6 +130,18 @@ else if (c=='*' && n=='/'){
130
130
131
131
}
132
132
133
+ else if (c =='"' || c =='\'' ){
134
+
135
+ if (insideComment ){
136
+ currComment .append (c );
137
+ }
138
+ else {
139
+ String quote = readQuote (s , i , c );
140
+ code .append (quote );
141
+ i = i +quote .length ();
142
+ }
143
+ }
144
+
133
145
else {
134
146
if (insideComment ){
135
147
currComment .append (c );
@@ -167,7 +179,7 @@ else if (c=='*' && n=='/'){
167
179
if (word !=null && !word .isBlank ()){
168
180
169
181
if (ext .equals ("java" )){
170
-
182
+
171
183
if (word .equals ("package" )){
172
184
String [] arr = readFunction (s , i );
173
185
String fn = arr [0 ].replace (" " , "" );
@@ -261,7 +273,16 @@ else if (word.equals("public")){
261
273
String raw = arr [1 ];
262
274
char lastChar = s .charAt (i +raw .length ());
263
275
if (lastChar =='{' ){
276
+ //console.log(fn);
277
+
278
+ //Parse method and add to class
264
279
currClass .addMember (parseMethod (fn , comment , ext ));
280
+
281
+ //Move past the function
282
+ int end = getEndBacket (s , i );
283
+ //console.log(s.substring(i, end));
284
+
285
+ if (end >-1 ) i = end ;
265
286
}
266
287
267
288
}
@@ -521,6 +542,41 @@ private static String readLine(String s, int offset){
521
542
}
522
543
523
544
545
+ //**************************************************************************
546
+ //** readQuote
547
+ //**************************************************************************
548
+ /** Returns a string encapsulated by either a single or double quote,
549
+ * starting at a given index
550
+ */
551
+ private static String readQuote (String s , int i , char t ){
552
+
553
+ StringBuilder str = new StringBuilder ();
554
+ str .append (s .charAt (i ));
555
+ boolean escaped = false ;
556
+ for (int x =i +1 ; x <s .length (); x ++){
557
+ char q = s .charAt (x );
558
+ str .append (q );
559
+
560
+ if (q ==t ){
561
+ if (!escaped ){
562
+ break ;
563
+ }
564
+ else {
565
+ escaped = false ;
566
+ }
567
+ }
568
+ else if (q =='\\' ){
569
+ escaped = !escaped ;
570
+ }
571
+ else {
572
+ escaped = false ;
573
+ }
574
+ }
575
+
576
+ return str .toString ();
577
+ }
578
+
579
+
524
580
//**************************************************************************
525
581
//** readFunction
526
582
//**************************************************************************
@@ -610,6 +666,14 @@ else if (c=='*' && n=='/'){
610
666
}
611
667
}
612
668
669
+ else if (c =='"' || c =='\'' ){
670
+
671
+ if (!insideComment ){
672
+ String quote = readQuote (s , i , c );
673
+ i = i +quote .length ();
674
+ }
675
+ }
676
+
613
677
else {
614
678
if (!insideComment ){
615
679
@@ -699,6 +763,7 @@ else if (c=='*' && n=='/'){
699
763
700
764
701
765
private static LinkedHashSet <String > getModifiers (String s , int offset ) {
766
+ //console.log(s);
702
767
int idx = offset ;
703
768
for (int i =offset ; i >-1 ; i --){
704
769
char c = s .charAt (i );
@@ -867,7 +932,36 @@ private static Method parseMethod(String fn, String comments, String ext){
867
932
868
933
//Add parameters
869
934
if (!parameters .isEmpty ()){
870
- for (String param : parameters .split ("," )){
935
+
936
+ ArrayList <String > params = new ArrayList <>();
937
+ StringBuilder str = new StringBuilder ();
938
+ int numBrackets = 0 ;
939
+ for (int i =0 ; i <parameters .length (); i ++){
940
+ char c = parameters .charAt (i );
941
+ if (c ==',' ){
942
+ if (numBrackets ==0 ){
943
+ params .add (str .toString ());
944
+ str = new StringBuilder ();
945
+ }
946
+ else {
947
+ str .append (c );
948
+ }
949
+ }
950
+ else {
951
+ if (c =='<' ){
952
+ numBrackets ++;
953
+ }
954
+ else if (c =='>' ){
955
+ numBrackets --;
956
+ }
957
+ str .append (c );
958
+ }
959
+ }
960
+ params .add (str .toString ());
961
+
962
+
963
+
964
+ for (String param : params ){
871
965
param = param .trim ();
872
966
873
967
idx = param .lastIndexOf (" " );
0 commit comments