From a535ab1b0b8ce6614ef7d99ef506b013861e80ee Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Mon, 17 Nov 2025 14:55:12 +0800 Subject: [PATCH 1/4] fix: use jdtutils to parse uri --- .../jdtls/ext/core/ProjectCommand.java | 12 +++--- .../ext/core/parser/ContextResolver.java | 41 ++++++++----------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ProjectCommand.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ProjectCommand.java index 9d0009fb..75c8b4b5 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ProjectCommand.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ProjectCommand.java @@ -672,15 +672,13 @@ public static ProjectDependenciesResult getProjectDependencies(List argu return new ProjectDependenciesResult(ProjectDependenciesErrorReason.INVALID_URI, fileUri); } - // Validate URI format - String parsedPath = null; + // Validate URI format using JDTUtils try { - java.net.URI uri = new java.net.URI(fileUri); - parsedPath = uri.getPath(); - if (parsedPath == null) { - return new ProjectDependenciesResult(ProjectDependenciesErrorReason.URI_PARSE_FAILED, parsedPath); + java.net.URI uri = JDTUtils.toURI(fileUri); + if (uri == null) { + return new ProjectDependenciesResult(ProjectDependenciesErrorReason.URI_PARSE_FAILED, fileUri); } - } catch (java.net.URISyntaxException e) { + } catch (Exception e) { return new ProjectDependenciesResult(ProjectDependenciesErrorReason.MALFORMED_URI, fileUri); } diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java index 4adcef08..24bac65f 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java @@ -18,6 +18,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageFragmentRoot; @@ -232,7 +233,7 @@ public static void resolveSingleType(IJavaProject javaProject, String typeName, * @return true if the type is from a common JDK package */ private static boolean isCommonJdkType(String typeName) { - if (typeName == null || typeName.isEmpty()) { + if (StringUtils.isBlank(typeName)) { return false; } @@ -789,7 +790,7 @@ public static String generateClassDescription(org.eclipse.jdt.core.IType type, S description.append("Signature: ").append(signature).append("\n\n"); // === 2. JavaDoc (inserted after signature) === - if (isNotEmpty(javadoc)) { + if (StringUtils.isNotBlank(javadoc)) { description.append("JavaDoc:\n").append(javadoc).append("\n\n"); } @@ -897,7 +898,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t } rawJavadoc = type.getCompilationUnit().getSource().substring(javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength()); - if (!isNotEmpty(rawJavadoc)) { + if (StringUtils.isBlank(rawJavadoc)) { return ""; } @@ -911,7 +912,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t // === High Priority: Extract class description text (first paragraph) === String description = extractClassDescription(cleanedJavadoc); - if (isNotEmpty(description)) { + if (StringUtils.isNotBlank(description)) { result.append("Description:\n").append(description).append("\n\n"); } @@ -920,7 +921,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t Matcher markdownMatcher = MARKDOWN_CODE_PATTERN.matcher(rawJavadoc); while (markdownMatcher.find()) { String code = markdownMatcher.group(1).trim(); - if (isNotEmpty(code) && seenCodeSnippets.add(code)) { + if (StringUtils.isNotBlank(code) && seenCodeSnippets.add(code)) { result.append("```java\n").append(code).append("\n```\n\n"); } } @@ -930,7 +931,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t Matcher preMatcher = HTML_PRE_PATTERN.matcher(cleanedJavadoc); while (preMatcher.find()) { String code = preMatcher.group(1).replaceAll("(?i)]*>", "").replaceAll("(?i)", "").trim(); - if (isNotEmpty(code) && seenCodeSnippets.add(code)) { + if (StringUtils.isNotBlank(code) && seenCodeSnippets.add(code)) { result.append("```java\n").append(code).append("\n```\n\n"); } } @@ -940,7 +941,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t while (codeMatcher.find()) { String code = codeMatcher.group(1).trim(); // Use HashSet for O(1) duplicate checking - if (isNotEmpty(code) && seenCodeSnippets.add(code)) { + if (StringUtils.isNotBlank(code) && seenCodeSnippets.add(code)) { result.append("```java\n").append(code).append("\n```\n\n"); } } @@ -958,7 +959,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t * Returns the first paragraph of descriptive text, limited to reasonable length. */ private static String extractClassDescription(String cleanedJavadoc) { - if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { + if (StringUtils.isBlank(cleanedJavadoc)) { return ""; } @@ -989,7 +990,7 @@ private static String extractClassDescription(String cleanedJavadoc) { * Clean up raw JavaDoc comment by removing comment markers and asterisks */ private static String cleanJavadocComment(String rawJavadoc) { - if (rawJavadoc == null || rawJavadoc.isEmpty()) { + if (StringUtils.isBlank(rawJavadoc)) { return ""; } @@ -1029,7 +1030,7 @@ private static String cleanJavadocComment(String rawJavadoc) { * Convert HTML entities to their plain text equivalents */ private static String convertHtmlEntities(String text) { - if (text == null || text.isEmpty()) { + if (StringUtils.isBlank(text)) { return text; } return text.replace(" ", " ") @@ -1048,7 +1049,7 @@ private static String convertHtmlEntities(String text) { * Preserves line breaks for block-level tags like

,
,

. */ private static String removeHtmlTags(String text) { - if (text == null || text.isEmpty()) { + if (StringUtils.isBlank(text)) { return text; } @@ -1080,7 +1081,7 @@ private static String extractMethodJavaDocSummary(IMethod method) { String rawJavadoc = method.getCompilationUnit().getSource() .substring(javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength()); - if (!isNotEmpty(rawJavadoc)) { + if (StringUtils.isBlank(rawJavadoc)) { return ""; } @@ -1098,7 +1099,7 @@ private static String extractMethodJavaDocSummary(IMethod method) { * Extract the main description part from JavaDoc (before @tags) */ private static String extractJavadocDescription(String cleanedJavadoc) { - if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { + if (StringUtils.isBlank(cleanedJavadoc)) { return ""; } @@ -1131,7 +1132,7 @@ private static String extractJavadocDescription(String cleanedJavadoc) { * Get the first sentence or limit the text to maxLength characters */ private static String getFirstSentenceOrLimit(String text, int maxLength) { - if (text == null || text.isEmpty()) { + if (StringUtils.isBlank(text)) { return ""; } @@ -1201,7 +1202,7 @@ private static String extractFieldJavaDocSummary(org.eclipse.jdt.core.IField fie String rawJavadoc = field.getCompilationUnit().getSource() .substring(javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength()); - if (!isNotEmpty(rawJavadoc)) { + if (StringUtils.isBlank(rawJavadoc)) { return ""; } @@ -1439,7 +1440,7 @@ private static String generateMethodSignatureInternal(IMethod method, boolean si // Add JavaDoc if requested if (includeJavadoc) { String javadocSummary = extractMethodJavaDocSummary(method); - if (javadocSummary != null && !javadocSummary.isEmpty()) { + if (StringUtils.isNotBlank(javadocSummary)) { return "// " + javadocSummary + "\n " + sb.toString(); } } @@ -1494,7 +1495,7 @@ private static String generateFieldSignatureInternal(org.eclipse.jdt.core.IField // Add JavaDoc if not simplified if (!simplified) { String javadocSummary = extractFieldJavaDocSummary(field); - if (javadocSummary != null && !javadocSummary.isEmpty()) { + if (StringUtils.isNotBlank(javadocSummary)) { return "// " + javadocSummary + "\n " + sb.toString(); } } @@ -1505,10 +1506,4 @@ private static String generateFieldSignatureInternal(org.eclipse.jdt.core.IField } } - /** - * Utility method to check if a string is not empty or null - */ - private static boolean isNotEmpty(String value) { - return value != null && !value.isEmpty(); - } } From fd0f2720247d931997a51dd01382a65b7ff9c1d4 Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Mon, 17 Nov 2025 15:13:40 +0800 Subject: [PATCH 2/4] fix: fix copilot comments --- .../jdtls/ext/core/parser/ContextResolver.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java index 24bac65f..ab57c7be 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java @@ -959,7 +959,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t * Returns the first paragraph of descriptive text, limited to reasonable length. */ private static String extractClassDescription(String cleanedJavadoc) { - if (StringUtils.isBlank(cleanedJavadoc)) { + if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { return ""; } @@ -990,7 +990,7 @@ private static String extractClassDescription(String cleanedJavadoc) { * Clean up raw JavaDoc comment by removing comment markers and asterisks */ private static String cleanJavadocComment(String rawJavadoc) { - if (StringUtils.isBlank(rawJavadoc)) { + if (rawJavadoc == null || rawJavadoc.isEmpty()) { return ""; } @@ -1030,7 +1030,7 @@ private static String cleanJavadocComment(String rawJavadoc) { * Convert HTML entities to their plain text equivalents */ private static String convertHtmlEntities(String text) { - if (StringUtils.isBlank(text)) { + if (text == null || text.isEmpty()) { return text; } return text.replace(" ", " ") @@ -1049,7 +1049,7 @@ private static String convertHtmlEntities(String text) { * Preserves line breaks for block-level tags like

,
,

. */ private static String removeHtmlTags(String text) { - if (StringUtils.isBlank(text)) { + if (text == null || text.isEmpty()) { return text; } @@ -1099,7 +1099,7 @@ private static String extractMethodJavaDocSummary(IMethod method) { * Extract the main description part from JavaDoc (before @tags) */ private static String extractJavadocDescription(String cleanedJavadoc) { - if (StringUtils.isBlank(cleanedJavadoc)) { + if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { return ""; } @@ -1132,7 +1132,7 @@ private static String extractJavadocDescription(String cleanedJavadoc) { * Get the first sentence or limit the text to maxLength characters */ private static String getFirstSentenceOrLimit(String text, int maxLength) { - if (StringUtils.isBlank(text)) { + if (text == null || text.isEmpty()) { return ""; } From 17d4e0bed0a5c47f4e4b5e8d731d7fc300f7344e Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Mon, 17 Nov 2025 15:19:24 +0800 Subject: [PATCH 3/4] fix: update --- .../ext/core/parser/ContextResolver.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java index ab57c7be..eb5eb740 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java @@ -225,6 +225,18 @@ public static void resolveSingleType(IJavaProject javaProject, String typeName, } } + /** + * Helper method to check if a string is not empty (null or zero-length). + * Note: This does NOT trim or check for whitespace-only strings. + * Use this instead of StringUtils.isNotBlank() when you want to preserve whitespace. + * + * @param str the string to check + * @return true if the string is not null and not empty + */ + private static boolean isNotEmpty(String str) { + return str != null && !str.isEmpty(); + } + /** * Check if a type belongs to a common JDK package that should be skipped. * Uses package-level matching for efficient filtering. @@ -660,7 +672,7 @@ private static String extractBriefJavaDoc(org.eclipse.jdt.core.IType type) { try { String javadoc = type.getAttachedJavadoc(null); - if (javadoc == null || javadoc.isEmpty()) { + if (!isNotEmpty(javadoc)) { return null; } return getFirstSentenceOrLimit(javadoc, 120); @@ -898,7 +910,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t } rawJavadoc = type.getCompilationUnit().getSource().substring(javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength()); - if (StringUtils.isBlank(rawJavadoc)) { + if (!isNotEmpty(rawJavadoc)) { return ""; } @@ -959,7 +971,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t * Returns the first paragraph of descriptive text, limited to reasonable length. */ private static String extractClassDescription(String cleanedJavadoc) { - if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { + if (!isNotEmpty(cleanedJavadoc)) { return ""; } @@ -990,7 +1002,7 @@ private static String extractClassDescription(String cleanedJavadoc) { * Clean up raw JavaDoc comment by removing comment markers and asterisks */ private static String cleanJavadocComment(String rawJavadoc) { - if (rawJavadoc == null || rawJavadoc.isEmpty()) { + if (!isNotEmpty(rawJavadoc)) { return ""; } @@ -1030,7 +1042,7 @@ private static String cleanJavadocComment(String rawJavadoc) { * Convert HTML entities to their plain text equivalents */ private static String convertHtmlEntities(String text) { - if (text == null || text.isEmpty()) { + if (!isNotEmpty(text)) { return text; } return text.replace(" ", " ") @@ -1049,7 +1061,7 @@ private static String convertHtmlEntities(String text) { * Preserves line breaks for block-level tags like

,
,

. */ private static String removeHtmlTags(String text) { - if (text == null || text.isEmpty()) { + if (!isNotEmpty(text)) { return text; } @@ -1081,7 +1093,7 @@ private static String extractMethodJavaDocSummary(IMethod method) { String rawJavadoc = method.getCompilationUnit().getSource() .substring(javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength()); - if (StringUtils.isBlank(rawJavadoc)) { + if (!isNotEmpty(rawJavadoc)) { return ""; } @@ -1099,7 +1111,7 @@ private static String extractMethodJavaDocSummary(IMethod method) { * Extract the main description part from JavaDoc (before @tags) */ private static String extractJavadocDescription(String cleanedJavadoc) { - if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { + if (!isNotEmpty(cleanedJavadoc)) { return ""; } @@ -1132,7 +1144,7 @@ private static String extractJavadocDescription(String cleanedJavadoc) { * Get the first sentence or limit the text to maxLength characters */ private static String getFirstSentenceOrLimit(String text, int maxLength) { - if (text == null || text.isEmpty()) { + if (!isNotEmpty(text)) { return ""; } @@ -1202,7 +1214,7 @@ private static String extractFieldJavaDocSummary(org.eclipse.jdt.core.IField fie String rawJavadoc = field.getCompilationUnit().getSource() .substring(javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength()); - if (StringUtils.isBlank(rawJavadoc)) { + if (!isNotEmpty(rawJavadoc)) { return ""; } @@ -1234,7 +1246,7 @@ public static String generateFieldSignature(org.eclipse.jdt.core.IField field) { * Convert JDT type signature to human-readable format */ public static String convertTypeSignature(String jdtSignature) { - if (jdtSignature == null || jdtSignature.isEmpty()) { + if (!isNotEmpty(jdtSignature)) { return "void"; } From 915ad8f5e6ca40567ce993c7a14822346b7c8282 Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Mon, 17 Nov 2025 15:20:49 +0800 Subject: [PATCH 4/4] fix: update --- .../ext/core/parser/ContextResolver.java | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java index eb5eb740..77c04010 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/parser/ContextResolver.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2018 Microsoft Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -18,7 +18,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IPackageFragmentRoot; @@ -225,18 +224,6 @@ public static void resolveSingleType(IJavaProject javaProject, String typeName, } } - /** - * Helper method to check if a string is not empty (null or zero-length). - * Note: This does NOT trim or check for whitespace-only strings. - * Use this instead of StringUtils.isNotBlank() when you want to preserve whitespace. - * - * @param str the string to check - * @return true if the string is not null and not empty - */ - private static boolean isNotEmpty(String str) { - return str != null && !str.isEmpty(); - } - /** * Check if a type belongs to a common JDK package that should be skipped. * Uses package-level matching for efficient filtering. @@ -245,7 +232,7 @@ private static boolean isNotEmpty(String str) { * @return true if the type is from a common JDK package */ private static boolean isCommonJdkType(String typeName) { - if (StringUtils.isBlank(typeName)) { + if (typeName == null || typeName.isEmpty()) { return false; } @@ -672,7 +659,7 @@ private static String extractBriefJavaDoc(org.eclipse.jdt.core.IType type) { try { String javadoc = type.getAttachedJavadoc(null); - if (!isNotEmpty(javadoc)) { + if (javadoc == null || javadoc.isEmpty()) { return null; } return getFirstSentenceOrLimit(javadoc, 120); @@ -802,7 +789,7 @@ public static String generateClassDescription(org.eclipse.jdt.core.IType type, S description.append("Signature: ").append(signature).append("\n\n"); // === 2. JavaDoc (inserted after signature) === - if (StringUtils.isNotBlank(javadoc)) { + if (isNotEmpty(javadoc)) { description.append("JavaDoc:\n").append(javadoc).append("\n\n"); } @@ -924,7 +911,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t // === High Priority: Extract class description text (first paragraph) === String description = extractClassDescription(cleanedJavadoc); - if (StringUtils.isNotBlank(description)) { + if (isNotEmpty(description)) { result.append("Description:\n").append(description).append("\n\n"); } @@ -933,7 +920,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t Matcher markdownMatcher = MARKDOWN_CODE_PATTERN.matcher(rawJavadoc); while (markdownMatcher.find()) { String code = markdownMatcher.group(1).trim(); - if (StringUtils.isNotBlank(code) && seenCodeSnippets.add(code)) { + if (isNotEmpty(code) && seenCodeSnippets.add(code)) { result.append("```java\n").append(code).append("\n```\n\n"); } } @@ -943,7 +930,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t Matcher preMatcher = HTML_PRE_PATTERN.matcher(cleanedJavadoc); while (preMatcher.find()) { String code = preMatcher.group(1).replaceAll("(?i)]*>", "").replaceAll("(?i)", "").trim(); - if (StringUtils.isNotBlank(code) && seenCodeSnippets.add(code)) { + if (isNotEmpty(code) && seenCodeSnippets.add(code)) { result.append("```java\n").append(code).append("\n```\n\n"); } } @@ -953,7 +940,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t while (codeMatcher.find()) { String code = codeMatcher.group(1).trim(); // Use HashSet for O(1) duplicate checking - if (StringUtils.isNotBlank(code) && seenCodeSnippets.add(code)) { + if (isNotEmpty(code) && seenCodeSnippets.add(code)) { result.append("```java\n").append(code).append("\n```\n\n"); } } @@ -971,7 +958,7 @@ private static String extractRelevantJavaDocContent(org.eclipse.jdt.core.IType t * Returns the first paragraph of descriptive text, limited to reasonable length. */ private static String extractClassDescription(String cleanedJavadoc) { - if (!isNotEmpty(cleanedJavadoc)) { + if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { return ""; } @@ -1002,7 +989,7 @@ private static String extractClassDescription(String cleanedJavadoc) { * Clean up raw JavaDoc comment by removing comment markers and asterisks */ private static String cleanJavadocComment(String rawJavadoc) { - if (!isNotEmpty(rawJavadoc)) { + if (rawJavadoc == null || rawJavadoc.isEmpty()) { return ""; } @@ -1042,7 +1029,7 @@ private static String cleanJavadocComment(String rawJavadoc) { * Convert HTML entities to their plain text equivalents */ private static String convertHtmlEntities(String text) { - if (!isNotEmpty(text)) { + if (text == null || text.isEmpty()) { return text; } return text.replace(" ", " ") @@ -1061,7 +1048,7 @@ private static String convertHtmlEntities(String text) { * Preserves line breaks for block-level tags like

,
,

. */ private static String removeHtmlTags(String text) { - if (!isNotEmpty(text)) { + if (text == null || text.isEmpty()) { return text; } @@ -1111,7 +1098,7 @@ private static String extractMethodJavaDocSummary(IMethod method) { * Extract the main description part from JavaDoc (before @tags) */ private static String extractJavadocDescription(String cleanedJavadoc) { - if (!isNotEmpty(cleanedJavadoc)) { + if (cleanedJavadoc == null || cleanedJavadoc.isEmpty()) { return ""; } @@ -1144,7 +1131,7 @@ private static String extractJavadocDescription(String cleanedJavadoc) { * Get the first sentence or limit the text to maxLength characters */ private static String getFirstSentenceOrLimit(String text, int maxLength) { - if (!isNotEmpty(text)) { + if (text == null || text.isEmpty()) { return ""; } @@ -1246,7 +1233,7 @@ public static String generateFieldSignature(org.eclipse.jdt.core.IField field) { * Convert JDT type signature to human-readable format */ public static String convertTypeSignature(String jdtSignature) { - if (!isNotEmpty(jdtSignature)) { + if (jdtSignature == null || jdtSignature.isEmpty()) { return "void"; } @@ -1452,7 +1439,7 @@ private static String generateMethodSignatureInternal(IMethod method, boolean si // Add JavaDoc if requested if (includeJavadoc) { String javadocSummary = extractMethodJavaDocSummary(method); - if (StringUtils.isNotBlank(javadocSummary)) { + if (javadocSummary != null && !javadocSummary.isEmpty()) { return "// " + javadocSummary + "\n " + sb.toString(); } } @@ -1507,7 +1494,7 @@ private static String generateFieldSignatureInternal(org.eclipse.jdt.core.IField // Add JavaDoc if not simplified if (!simplified) { String javadocSummary = extractFieldJavaDocSummary(field); - if (StringUtils.isNotBlank(javadocSummary)) { + if (javadocSummary != null && !javadocSummary.isEmpty()) { return "// " + javadocSummary + "\n " + sb.toString(); } } @@ -1518,4 +1505,10 @@ private static String generateFieldSignatureInternal(org.eclipse.jdt.core.IField } } + /** + * Utility method to check if a string is not empty or null + */ + private static boolean isNotEmpty(String value) { + return value != null && !value.isEmpty(); + } }