@@ -231,16 +231,14 @@ private static boolean isCommonJdkType(String typeName) {
231231 return false ;
232232 }
233233
234- // Extract package name from fully qualified type name
235234 int lastDotIndex = typeName .lastIndexOf ('.' );
236235 if (lastDotIndex == -1 ) {
237- return false ; // No package (default package)
236+ return false ;
238237 }
239238
240239 String packageName = typeName .substring (0 , lastDotIndex );
241240
242- // Check if package matches any common JDK package
243- // This includes both exact matches and sub-packages
241+ // Check exact match or sub-package match
244242 return SKIP_COMMON_JDK_PACKAGES .contains (packageName ) ||
245243 SKIP_COMMON_JDK_PACKAGES .stream ().anyMatch (pkg -> packageName .startsWith (pkg + "." ));
246244 }
@@ -958,7 +956,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t
958956 * Returns the first paragraph of descriptive text, limited to reasonable length.
959957 */
960958 private static String extractClassDescription (String cleanedJavadoc ) {
961- if (! isNotEmpty ( cleanedJavadoc )) {
959+ if (cleanedJavadoc == null || cleanedJavadoc . isEmpty ( )) {
962960 return "" ;
963961 }
964962
@@ -973,25 +971,10 @@ private static String extractClassDescription(String cleanedJavadoc) {
973971
974972 // Limit to first 2-3 sentences or ~200 characters
975973 if (description .length () > 200 ) {
976- // Try to find a good break point (., !, ?)
977- int [] boundaries = {
978- description .indexOf (". " , 100 ),
979- description .indexOf (".\n " , 100 ),
980- description .indexOf ("! " , 100 ),
981- description .indexOf ("? " , 100 )
982- };
983-
984- int breakPoint = -1 ;
985- for (int boundary : boundaries ) {
986- if (boundary != -1 && boundary < 250 && (breakPoint == -1 || boundary < breakPoint )) {
987- breakPoint = boundary ;
988- }
989- }
990-
974+ int breakPoint = findBestBreakpoint (description , 100 , 250 );
991975 if (breakPoint != -1 ) {
992976 description = description .substring (0 , breakPoint + 1 ).trim ();
993977 } else {
994- // No good break point, just truncate with ellipsis
995978 int lastSpace = description .lastIndexOf (' ' , 200 );
996979 description = description .substring (0 , lastSpace > 100 ? lastSpace : 200 ).trim () + "..." ;
997980 }
@@ -1004,10 +987,7 @@ private static String extractClassDescription(String cleanedJavadoc) {
1004987 * Check if the JavaDoc contains @deprecated tag.
1005988 */
1006989 private static boolean isDeprecated (String cleanedJavadoc ) {
1007- if (!isNotEmpty (cleanedJavadoc )) {
1008- return false ;
1009- }
1010- return cleanedJavadoc .contains ("@deprecated" );
990+ return cleanedJavadoc != null && cleanedJavadoc .contains ("@deprecated" );
1011991 }
1012992
1013993 /**
@@ -1057,17 +1037,15 @@ private static String convertHtmlEntities(String text) {
10571037 if (text == null || text .isEmpty ()) {
10581038 return text ;
10591039 }
1060- String result = text ;
1061- result = result .replace (" " , " " );
1062- result = result .replace ("<" , "<" );
1063- result = result .replace (">" , ">" );
1064- result = result .replace ("&" , "&" );
1065- result = result .replace (""" , "\" " );
1066- result = result .replace ("'" , "'" );
1067- result = result .replace ("'" , "'" );
1068- result = result .replace ("—" , "-" );
1069- result = result .replace ("–" , "-" );
1070- return result ;
1040+ return text .replace (" " , " " )
1041+ .replace ("<" , "<" )
1042+ .replace (">" , ">" )
1043+ .replace ("&" , "&" )
1044+ .replace (""" , "\" " )
1045+ .replace ("'" , "'" )
1046+ .replace ("'" , "'" )
1047+ .replace ("—" , "-" )
1048+ .replace ("–" , "-" );
10711049 }
10721050
10731051 /**
@@ -1129,16 +1107,11 @@ private static String extractMethodJavaDocSummary(IMethod method) {
11291107 }
11301108 if (!throwsTags .isEmpty ()) {
11311109 result .append (" | Throws: " );
1132- for (int i = 0 ; i < throwsTags .size () && i < 2 ; i ++) { // Limit to 2 exceptions
1110+ for (int i = 0 ; i < Math . min ( throwsTags .size (), 2 ) ; i ++) {
11331111 if (i > 0 ) result .append (", " );
1134- // Extract just the exception class name (first word)
11351112 String exceptionInfo = throwsTags .get (i );
11361113 int spaceIndex = exceptionInfo .indexOf (' ' );
1137- if (spaceIndex != -1 ) {
1138- result .append (exceptionInfo .substring (0 , spaceIndex ));
1139- } else {
1140- result .append (exceptionInfo );
1141- }
1114+ result .append (spaceIndex != -1 ? exceptionInfo .substring (0 , spaceIndex ) : exceptionInfo );
11421115 }
11431116 if (throwsTags .size () > 2 ) {
11441117 result .append ("..." );
@@ -1168,7 +1141,7 @@ private static String extractMethodJavaDocSummary(IMethod method) {
11681141 private static List <String > extractJavadocTag (String cleanedJavadoc , String tagName ) {
11691142 List <String > results = new ArrayList <>();
11701143
1171- if (! isNotEmpty ( cleanedJavadoc )) {
1144+ if (cleanedJavadoc == null || cleanedJavadoc . isEmpty ( )) {
11721145 return results ;
11731146 }
11741147
@@ -1251,13 +1224,7 @@ private static String getFirstSentenceOrLimit(String text, int maxLength) {
12511224 }
12521225
12531226 // Find first sentence boundary (., !, ?)
1254- int [] boundaries = {text .indexOf (". " ), text .indexOf (".\n " ), text .indexOf ("! " ), text .indexOf ("? " )};
1255- int firstSentenceEnd = -1 ;
1256- for (int boundary : boundaries ) {
1257- if (boundary != -1 && (firstSentenceEnd == -1 || boundary < firstSentenceEnd )) {
1258- firstSentenceEnd = boundary ;
1259- }
1260- }
1227+ int firstSentenceEnd = findFirstSentenceBoundary (text );
12611228
12621229 // Return first sentence if within reasonable length
12631230 if (firstSentenceEnd != -1 && firstSentenceEnd < maxLength ) {
@@ -1273,6 +1240,40 @@ private static String getFirstSentenceOrLimit(String text, int maxLength) {
12731240
12741241 return text .trim ();
12751242 }
1243+
1244+ /**
1245+ * Find the first sentence boundary in text
1246+ */
1247+ private static int findFirstSentenceBoundary (String text ) {
1248+ int [] boundaries = {text .indexOf (". " ), text .indexOf (".\n " ), text .indexOf ("! " ), text .indexOf ("? " )};
1249+ int result = -1 ;
1250+ for (int boundary : boundaries ) {
1251+ if (boundary != -1 && (result == -1 || boundary < result )) {
1252+ result = boundary ;
1253+ }
1254+ }
1255+ return result ;
1256+ }
1257+
1258+ /**
1259+ * Find the best breakpoint for truncating text within a range
1260+ */
1261+ private static int findBestBreakpoint (String text , int minPos , int maxPos ) {
1262+ int [] boundaries = {
1263+ text .indexOf (". " , minPos ),
1264+ text .indexOf (".\n " , minPos ),
1265+ text .indexOf ("! " , minPos ),
1266+ text .indexOf ("? " , minPos )
1267+ };
1268+
1269+ int result = -1 ;
1270+ for (int boundary : boundaries ) {
1271+ if (boundary != -1 && boundary < maxPos && (result == -1 || boundary < result )) {
1272+ result = boundary ;
1273+ }
1274+ }
1275+ return result ;
1276+ }
12761277
12771278 /**
12781279 * Extract summary description from field JavaDoc, including @deprecated marking.
0 commit comments