From 9a6be8c390e9a9063a257f0c503860d7a2e63738 Mon Sep 17 00:00:00 2001 From: Reed Odeneal Date: Thu, 22 Feb 2018 09:27:50 -0600 Subject: [PATCH 1/2] using startsWith method for matching strings that are defined in the scope --- src/org/salesforce/apexdoc/ApexDoc.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/salesforce/apexdoc/ApexDoc.java b/src/org/salesforce/apexdoc/ApexDoc.java index 8da4f97..8f63dc5 100644 --- a/src/org/salesforce/apexdoc/ApexDoc.java +++ b/src/org/salesforce/apexdoc/ApexDoc.java @@ -348,7 +348,8 @@ public static ClassModel parseFileContents(String filePath) { public static String strContainsScope(String str) { str = str.toLowerCase(); for (int i = 0; i < rgstrScope.length; i++) { - if (str.toLowerCase().contains(rgstrScope[i].toLowerCase() + " ")) { + // prevent matching strings containing scope keywords that aren't class, method, or property definitions + if (str.toLowerCase().startsWith(rgstrScope[i].toLowerCase() + " ")) { return rgstrScope[i]; } } From 52386c00ece9476eb19cd4a7e6cfeb75e2dc29a6 Mon Sep 17 00:00:00 2001 From: Reed Odeneal Date: Thu, 22 Feb 2018 10:10:21 -0600 Subject: [PATCH 2/2] check for special keyword prefixes when scanning for scope keywords --- src/org/salesforce/apexdoc/ApexDoc.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/salesforce/apexdoc/ApexDoc.java b/src/org/salesforce/apexdoc/ApexDoc.java index 8f63dc5..c5ec930 100644 --- a/src/org/salesforce/apexdoc/ApexDoc.java +++ b/src/org/salesforce/apexdoc/ApexDoc.java @@ -20,6 +20,8 @@ public class ApexDoc { public static String[] rgstrScope; public static String[] rgstrArgs; + public static final String[] KEYWORDS = {"static ","final ","public ","private ","void ",""}; + public ApexDoc() { try { File file = new File("apex_doc_log.txt"); @@ -349,8 +351,10 @@ public static String strContainsScope(String str) { str = str.toLowerCase(); for (int i = 0; i < rgstrScope.length; i++) { // prevent matching strings containing scope keywords that aren't class, method, or property definitions - if (str.toLowerCase().startsWith(rgstrScope[i].toLowerCase() + " ")) { - return rgstrScope[i]; + for (String kw : KEYWORDS) { + if (str.toLowerCase().startsWith(kw + rgstrScope[i].toLowerCase() + " ")) { + return rgstrScope[i]; + } } } return null;