Skip to content

Commit 20e1312

Browse files
committed
fix: update
1 parent 5bbaaed commit 20e1312

File tree

1 file changed

+8
-122
lines changed

1 file changed

+8
-122
lines changed

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java

Lines changed: 8 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,8 +1049,8 @@ private static String convertHtmlEntities(String text) {
10491049
}
10501050

10511051
/**
1052-
* Extract detailed JavaDoc summary from method including @param, @return, and @throws tags.
1053-
* Returns a formatted string with the method description and parameter/return information.
1052+
* Extract method JavaDoc content directly for LLM consumption.
1053+
* Returns cleaned JavaDoc without artificial truncation - let LLM understand the full context.
10541054
*/
10551055
private static String extractMethodJavaDocSummary(IMethod method) {
10561056
try {
@@ -1066,122 +1066,15 @@ private static String extractMethodJavaDocSummary(IMethod method) {
10661066
return "";
10671067
}
10681068

1069+
// Just clean and return - let LLM understand the full context
10691070
String cleaned = cleanJavadocComment(rawJavadoc);
1070-
StringBuilder result = new StringBuilder();
1071-
1072-
// Extract main description (first sentence)
1073-
String description = extractJavadocDescription(cleaned);
1074-
String firstSentence = getFirstSentenceOrLimit(description, 120);
1075-
if (isNotEmpty(firstSentence)) {
1076-
result.append(firstSentence);
1077-
}
1078-
1079-
// === Medium Priority: Parse @param tags ===
1080-
List<String> params = extractJavadocTag(cleaned, "@param");
1081-
if (!params.isEmpty()) {
1082-
result.append(" | Params: ");
1083-
for (int i = 0; i < params.size() && i < 3; i++) { // Limit to 3 params
1084-
if (i > 0) result.append(", ");
1085-
result.append(params.get(i));
1086-
}
1087-
if (params.size() > 3) {
1088-
result.append("...");
1089-
}
1090-
}
1091-
1092-
// === Medium Priority: Parse @return tag ===
1093-
List<String> returns = extractJavadocTag(cleaned, "@return");
1094-
if (!returns.isEmpty()) {
1095-
String returnDesc = returns.get(0);
1096-
// Limit return description to 60 chars
1097-
if (returnDesc.length() > 60) {
1098-
returnDesc = returnDesc.substring(0, 57) + "...";
1099-
}
1100-
result.append(" | Returns: ").append(returnDesc);
1101-
}
1102-
1103-
// === Medium Priority: Parse @throws tags ===
1104-
List<String> throwsTags = extractJavadocTag(cleaned, "@throws");
1105-
if (throwsTags.isEmpty()) {
1106-
throwsTags = extractJavadocTag(cleaned, "@exception");
1107-
}
1108-
if (!throwsTags.isEmpty()) {
1109-
result.append(" | Throws: ");
1110-
for (int i = 0; i < Math.min(throwsTags.size(), 2); i++) {
1111-
if (i > 0) result.append(", ");
1112-
String exceptionInfo = throwsTags.get(i);
1113-
int spaceIndex = exceptionInfo.indexOf(' ');
1114-
result.append(spaceIndex != -1 ? exceptionInfo.substring(0, spaceIndex) : exceptionInfo);
1115-
}
1116-
if (throwsTags.size() > 2) {
1117-
result.append("...");
1118-
}
1119-
}
1120-
1121-
// === High Priority: Mark deprecated methods ===
1122-
if (cleaned.contains("@deprecated")) {
1123-
result.append(result.length() > 0 ? " " : "").append("[DEPRECATED]");
1124-
}
1125-
1126-
return result.toString();
1071+
return convertHtmlEntities(cleaned);
11271072

11281073
} catch (Exception e) {
11291074
return "";
11301075
}
11311076
}
11321077

1133-
/**
1134-
* Extract JavaDoc tags of a specific type (e.g., @param, @return, @throws).
1135-
* Returns a list of tag values (without the tag name itself).
1136-
*
1137-
* @param cleanedJavadoc Cleaned JavaDoc text
1138-
* @param tagName Tag name to search for (e.g., "@param")
1139-
* @return List of tag values
1140-
*/
1141-
private static List<String> extractJavadocTag(String cleanedJavadoc, String tagName) {
1142-
List<String> results = new ArrayList<>();
1143-
1144-
if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) {
1145-
return results;
1146-
}
1147-
1148-
String[] lines = cleanedJavadoc.split("\\n");
1149-
StringBuilder currentTag = null;
1150-
1151-
for (String line : lines) {
1152-
String trimmed = line.trim();
1153-
1154-
// Check if this line starts with the target tag
1155-
if (trimmed.startsWith(tagName + " ")) {
1156-
// Save previous tag if exists
1157-
if (currentTag != null) {
1158-
results.add(currentTag.toString().trim());
1159-
}
1160-
// Start new tag (remove tag name)
1161-
currentTag = new StringBuilder(trimmed.substring(tagName.length() + 1).trim());
1162-
}
1163-
// Check if this line starts with any other tag
1164-
else if (trimmed.startsWith("@")) {
1165-
// Save previous tag if exists
1166-
if (currentTag != null) {
1167-
results.add(currentTag.toString().trim());
1168-
currentTag = null;
1169-
}
1170-
}
1171-
// Continuation of current tag
1172-
else if (currentTag != null && isNotEmpty(trimmed)) {
1173-
currentTag.append(" ").append(trimmed);
1174-
}
1175-
}
1176-
1177-
// Don't forget the last tag
1178-
if (currentTag != null) {
1179-
results.add(currentTag.toString().trim());
1180-
}
1181-
1182-
return results;
1183-
}
1184-
11851078
/**
11861079
* Extract the main description part from JavaDoc (before @tags)
11871080
*/
@@ -1276,7 +1169,8 @@ private static int findBestBreakpoint(String text, int minPos, int maxPos) {
12761169
}
12771170

12781171
/**
1279-
* Extract summary description from field JavaDoc, including @deprecated marking.
1172+
* Extract field JavaDoc content directly for LLM consumption.
1173+
* Returns cleaned JavaDoc without artificial truncation - let LLM understand the full context.
12801174
*/
12811175
private static String extractFieldJavaDocSummary(org.eclipse.jdt.core.IField field) {
12821176
try {
@@ -1292,16 +1186,10 @@ private static String extractFieldJavaDocSummary(org.eclipse.jdt.core.IField fie
12921186
return "";
12931187
}
12941188

1189+
// Just clean and return - let LLM understand the full context
12951190
String cleaned = cleanJavadocComment(rawJavadoc);
1296-
String description = extractJavadocDescription(cleaned);
1297-
String summary = getFirstSentenceOrLimit(description, 120);
1298-
1299-
// === High Priority: Mark deprecated fields ===
1300-
if (cleaned.contains("@deprecated")) {
1301-
summary = summary.isEmpty() ? "[DEPRECATED]" : summary + " [DEPRECATED]";
1302-
}
1191+
return convertHtmlEntities(cleaned);
13031192

1304-
return summary;
13051193
} catch (Exception e) {
13061194
return "";
13071195
}
@@ -1321,8 +1209,6 @@ public static String generateFieldSignature(org.eclipse.jdt.core.IField field) {
13211209
return generateFieldSignatureInternal(field, false);
13221210
}
13231211

1324-
1325-
13261212
/**
13271213
* Convert JDT type signature to human-readable format
13281214
*/

0 commit comments

Comments
 (0)