Skip to content

Commit 3282201

Browse files
committed
fix: update
1 parent 95f7844 commit 3282201

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ProjectCommand.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public String getMessage() {
155155
* Error context information for operations
156156
*/
157157
public static class ErrorContext {
158-
public final String errorValue; // The value that caused the error (e.g., invalid URI, null parsedPath, etc.)
158+
public final String errorValue; // The value that caused the error (e.g., invalid URI, null parsedPath, etc.)
159159

160160
public ErrorContext(String errorValue) {
161161
this.errorValue = errorValue;
@@ -491,7 +491,7 @@ public static ImportClassContentResult getImportClassContent(List<Object> argume
491491
// Record start time for timeout control
492492
long startTime = System.currentTimeMillis();
493493
final long TIMEOUT_MS = 80; // 80ms timeout
494-
494+
495495
if (arguments == null || arguments.isEmpty()) {
496496
return new ImportClassContentResult(ImportClassContentErrorReason.NULL_ARGUMENTS);
497497
}
@@ -505,15 +505,17 @@ public static ImportClassContentResult getImportClassContent(List<Object> argume
505505
// Directly resolve compilation unit from URI using JDTUtils
506506
java.net.URI uri = JDTUtils.toURI(fileUri);
507507
org.eclipse.jdt.core.ICompilationUnit compilationUnit = JDTUtils.resolveCompilationUnit(uri);
508-
508+
509509
if (compilationUnit == null || !compilationUnit.exists()) {
510510
return new ImportClassContentResult(ImportClassContentErrorReason.FILE_NOT_FOUND, fileUri);
511511
}
512512

513513
// Get the Java project from the compilation unit
514514
IJavaProject javaProject = compilationUnit.getJavaProject();
515515
if (javaProject == null || !javaProject.exists()) {
516-
String projectName = javaProject != null ? javaProject.getProject().getName() : "unknown";
516+
String projectName = javaProject != null && javaProject.getProject() != null
517+
? javaProject.getProject().getName()
518+
: "unknown";
517519
return new ImportClassContentResult(ImportClassContentErrorReason.PROJECT_NOT_EXISTS, projectName);
518520
}
519521

@@ -559,28 +561,30 @@ public static ImportClassContentResult getImportClassContent(List<Object> argume
559561
// Check if we have exceeded the timeout before starting external resolution
560562
long currentTime = System.currentTimeMillis();
561563
long elapsedTime = currentTime - startTime;
562-
564+
563565
if (elapsedTime >= TIMEOUT_MS) {
564566
// Return early due to timeout, but still return what we have collected so far
565567
if (classInfoList.isEmpty()) {
566-
return new ImportClassContentResult(ImportClassContentErrorReason.TIME_LIMIT_EXCEEDED, String.valueOf(elapsedTime) + "ms");
568+
return new ImportClassContentResult(ImportClassContentErrorReason.TIME_LIMIT_EXCEEDED,
569+
String.valueOf(elapsedTime) + "ms");
567570
}
568571
return new ImportClassContentResult(classInfoList);
569572
}
570-
573+
571574
List<ImportClassInfo> externalClasses = new ArrayList<>();
572575

573576
for (org.eclipse.jdt.core.IImportDeclaration importDecl : imports) {
574577
// Check cancellation before each external resolution
575578
if (monitor.isCanceled()) {
576579
break;
577580
}
578-
581+
579582
// Check timeout before each external resolution
580583
currentTime = System.currentTimeMillis();
581584
elapsedTime = currentTime - startTime;
582585
if (elapsedTime >= TIMEOUT_MS) {
583-
// Timeout reached, stop processing external dependencies but keep existing results
586+
// Timeout reached, stop processing external dependencies but keep existing
587+
// results
584588
break;
585589
}
586590

@@ -652,8 +656,9 @@ private static String getSeverityString(int severity) {
652656
* Get project dependencies information including JDK version.
653657
*
654658
* @param arguments List containing the file URI as the first element
655-
* @param monitor Progress monitor for cancellation support
656-
* @return List of DependencyInfo containing key-value pairs of project information
659+
* @param monitor Progress monitor for cancellation support
660+
* @return List of DependencyInfo containing key-value pairs of project
661+
* information
657662
*/
658663
public static ProjectDependenciesResult getProjectDependencies(List<Object> arguments,
659664
IProgressMonitor monitor) {

0 commit comments

Comments
 (0)