Skip to content

Commit

Permalink
100% CPU Usage since version 0.18.3
Browse files Browse the repository at this point in the history
Fixes eclipse-lemminx#1175

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Feb 15, 2022
1 parent 953af82 commit 23fcbe3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ public List<Diagnostic> doDiagnostics(DOMDocument xmlDocument, XMLValidationSett
public CompletableFuture<Path> publishDiagnostics(DOMDocument xmlDocument,
Consumer<PublishDiagnosticsParams> publishDiagnostics, Consumer<TextDocument> triggerValidation,
XMLValidationSettings validationSettings, CancelChecker cancelChecker) {
if (validationSettings != null && !validationSettings.isEnabled()) {
// Validation is disabled
return null;
}
// Process validation
String uri = xmlDocument.getDocumentURI();
TextDocument document = xmlDocument.getTextDocument();

Expand All @@ -177,7 +182,7 @@ public CompletableFuture<Path> publishDiagnostics(DOMDocument xmlDocument,
publishDiagnostics.accept(new PublishDiagnosticsParams(uri, diagnostics));

List<CompletableFuture<?>> futures = diagnostics.getFutures();
if (futures != null) {
if (!futures.isEmpty()) {
CompletableFuture<Void> allFutures = CompletableFuture
.allOf(futures.toArray(new CompletableFuture[futures.size()]));
allFutures.thenAccept(Void -> {
Expand Down Expand Up @@ -271,7 +276,7 @@ public Position getMatchingTagPosition(DOMDocument xmlDocument, Position positio
/**
* Returns the linked editing ranges for the given <code>xmlDocument</code> at
* the given <code>position</code> and null otherwise.
*
*
* @param xmlDocument the DOM document.
* @param position the position.
* @param cancelChecker the cancel checker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

/**
* This class is the result of a diagnostic process. It contains:
*
*
* <ul>
* <li>list of diagnostics.</li>
* <li>list of completable future which are not done(ex : download some external
* resources XSD, DTD). This list of future gives the capability to refresh
* again the diagnostics once all completable futures are finished (ex : all
* download are finished).</li>
* </ul>
*
*
* @author Angelo ZERR
*
*/
Expand All @@ -55,12 +55,16 @@ public void addFuture(CompletableFuture<?> future) {

/**
* Returns the completable futures used in a diagnostics (ex : completeable
* future to download external resources XSD, DTD) and null otherwise.
*
* future to download external resources XSD, DTD) and an empty list otherwise.
*
* @return the completable futures used in a diagnostics (ex : completeable
* future to download external resources XSD, DTD) and null otherwise.
* future to download external resources XSD, DTD) and an empty list
* otherwise.
*/
public List<CompletableFuture<?>> getFutures() {
if (futures == null) {
return Collections.emptyList();
}
return futures;
}

Expand Down

0 comments on commit 23fcbe3

Please sign in to comment.