Skip to content

Commit 4072dc6

Browse files
ryan-storeyRyan Storeygkwan-ibm
authored
Uppercase fix (#162)
* Fix uppercase lettering after commas for Replace keyword * Remove random println statement * Fix uppercase lettering for Update and Create keywords Co-authored-by: Ryan Storey <[email protected]> Co-authored-by: Gilbert Kwan <[email protected]>
1 parent 63378b3 commit 4072dc6

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/main/java/Functions.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
*******************************************************************************/
1111

1212
import java.io.IOException;
13+
import java.net.PasswordAuthentication;
1314
import java.net.URL;
1415
import java.util.ArrayList;
1516
import java.util.Properties;
1617
import java.util.Scanner;
1718
import java.util.regex.Matcher;
1819
import java.util.regex.Pattern;
20+
import java.util.Arrays;
1921

2022
class LinkSets {
2123
String linkName;
@@ -304,6 +306,25 @@ public static void replaceDashes(ArrayList<String> listOfLines, int i) {
304306
}
305307
}
306308

309+
public static void lowercaseKeyword(String keyword, ArrayList<String> listOfLines, int i){
310+
String lowerCase = keyword.toLowerCase();
311+
String prohibited = "[]-=";
312+
int v = i-2;
313+
char lastChar = 0;
314+
do{
315+
if(listOfLines.get(v).isBlank()){
316+
lastChar = 0;
317+
}else{
318+
lastChar = listOfLines.get(v).charAt(listOfLines.get(v).length()-2);
319+
}
320+
if(lastChar == ','){
321+
listOfLines.set(i-1, listOfLines.get(i-1).replaceAll(keyword, lowerCase));
322+
}
323+
v--;
324+
} while (prohibited.indexOf(lastChar) != -1 || lastChar == 0);
325+
}
326+
327+
307328
// Inserts code snippets
308329
public static void codeInsert(String atIndex, ArrayList<String> listOfLines, String guideName, String branch, int i, String position) {
309330
listOfLines.set(i, listOfLines.get(i).replaceAll("#", ""));
@@ -597,7 +618,6 @@ public static void end(ArrayList<String> listOfLines, String guideName, String G
597618
//configures instructions to replace file
598619
public static String replace(ArrayList<String> listOfLines, String guideName, String branch, int i, String
599620
position, ArrayList<String> hideList) {
600-
601621
String str = null;
602622
for (int x = i; x <= i + 10; x++) {
603623
if (listOfLines.get(x).startsWith("include") && !listOfLines.get(x).startsWith("include::{common-includes}")) {
@@ -608,6 +628,9 @@ public static String replace(ArrayList<String> listOfLines, String guideName, St
608628
if (str == null) {
609629
str = "finish/" + listOfLines.get(i).replaceAll("`", "");
610630
}
631+
632+
lowercaseKeyword("Replace", listOfLines, i);
633+
611634
listOfLines.set(i, listOfLines.get(i).replaceAll("#", ""));
612635
listOfLines.set(i, listOfLines.get(i).replaceAll("`", "**"));
613636
listOfLines.set(i, "\n> From the menu of the IDE, select \n **File** > **Open** > " + guideName + "/start/" + listOfLines.get(i).replaceAll("\\*\\*", "") + "\n\n\n");
@@ -629,6 +652,9 @@ public static String update(ArrayList<String> listOfLines, String guideName, Str
629652

630653
}
631654
}
655+
656+
lowercaseKeyword("Update", listOfLines, i);
657+
632658
if (str == null) {
633659
str = "finish/" + listOfLines.get(i).replaceAll("`", "");
634660
}
@@ -652,6 +678,9 @@ public static String updateFinish(ArrayList<String> listOfLines, String guideNam
652678

653679
}
654680
}
681+
682+
lowercaseKeyword("Update", listOfLines, i);
683+
655684
if (str == null) {
656685
str = "finish/" + listOfLines.get(i).replaceAll("`", "");
657686
}
@@ -675,6 +704,9 @@ public static String touch(ArrayList<String> listOfLines, String guideName, Stri
675704
str = str.substring(9, str.length() - 3);
676705
}
677706
}
707+
708+
lowercaseKeyword("Create", listOfLines, i);
709+
678710
if (str == null) {
679711
str = "finish/" + listOfLines.get(i).replaceAll("`", "");
680712
}

0 commit comments

Comments
 (0)