Skip to content

Commit

Permalink
Shutdown raises exception
Browse files Browse the repository at this point in the history
Fixes eclipse#1132

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Dec 7, 2021
1 parent fceb4c3 commit e1f82e2
Show file tree
Hide file tree
Showing 5 changed files with 1,249 additions and 1,133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
* XML language server.
*
*/
public class XMLLanguageServer
implements ProcessLanguageServer, XMLLanguageServerAPI, IXMLDocumentProvider,
public class XMLLanguageServer implements ProcessLanguageServer, XMLLanguageServerAPI, IXMLDocumentProvider,
IXMLNotificationService, IXMLValidationService {

private static final Logger LOGGER = Logger.getLogger(XMLLanguageServer.class.getName());
Expand Down Expand Up @@ -109,7 +108,7 @@ public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
Object xmlSettings = AllXMLSettings.getAllXMLSettings(initOptions);
XMLGeneralClientSettings settings = XMLGeneralClientSettings.getGeneralXMLSettings(xmlSettings);

LogHelper.initializeRootLogger(languageClient, settings == null? null : settings.getLogs());
LogHelper.initializeRootLogger(languageClient, settings == null ? null : settings.getLogs());

LOGGER.info("Initializing XML Language server" + System.lineSeparator() + Platform.details());

Expand All @@ -126,7 +125,7 @@ public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
xmlTextDocumentService.updateClientCapabilities(capabilityManager.getClientCapabilities().capabilities,
capabilityManager.getClientCapabilities().getExtendedCapabilities());

updateSettings(initOptions, false /* already configured logging*/ );
updateSettings(initOptions, false /* already configured logging */ );

ServerCapabilities nonDynamicServerCapabilities = ServerCapabilitiesInitializer.getNonDynamicServerCapabilities(
capabilityManager.getClientCapabilities(), xmlTextDocumentService.isIncrementalSupport());
Expand Down Expand Up @@ -162,7 +161,7 @@ public synchronized void updateSettings(Object initOptions) {
* Update XML settings configured from the client.
*
* @param initOptions Settings the XML settings
* @param initLogs whether to initialize the log handlers
* @param initLogs whether to initialize the log handlers
*/
private synchronized void updateSettings(Object initOptions, boolean initLogs) {
if (initOptions == null) {
Expand Down Expand Up @@ -227,10 +226,15 @@ private synchronized void updateSettings(Object initOptions, boolean initLogs) {
@Override
public CompletableFuture<Object> shutdown() {
xmlLanguageService.dispose();
if (capabilityManager.getClientCapabilities().getExtendedCapabilities().shouldLanguageServerExitOnShutdown()) {
delayer.schedule(() -> exit(0) , 1, TimeUnit.SECONDS);
if (capabilityManager != null) {
if (capabilityManager.getClientCapabilities().getExtendedCapabilities()
.shouldLanguageServerExitOnShutdown()) {
delayer.schedule(() -> exit(0), 1, TimeUnit.SECONDS);
}
}
if (telemetryManager != null) {
getTelemetryManager().shutdown();
}
getTelemetryManager().shutdown();
return computeAsync(cc -> new Object());
}

Expand Down Expand Up @@ -285,7 +289,8 @@ public long getParentProcessId() {
@Override
public CompletableFuture<AutoCloseTagResponse> closeTag(TextDocumentPositionParams params) {
return xmlTextDocumentService.computeDOMAsync(params.getTextDocument(), (cancelChecker, xmlDocument) -> {
return getXMLLanguageService().doAutoClose(xmlDocument, params.getPosition(), getSettings().getCompletionSettings(), cancelChecker);
return getXMLLanguageService().doAutoClose(xmlDocument, params.getPosition(),
getSettings().getCompletionSettings(), cancelChecker);
});
}

Expand Down Expand Up @@ -323,9 +328,9 @@ public SharedSettings getSharedSettings() {

@Override
public Collection<DOMDocument> getAllDocuments() {
return xmlTextDocumentService.allDocuments().stream()
.map(m -> m.getModel().getNow(null))
.filter(Objects::nonNull)
return xmlTextDocumentService.allDocuments().stream() //
.map(m -> m.getModel().getNow(null)) //
.filter(Objects::nonNull) //
.collect(Collectors.toList());
}

Expand Down
Loading

0 comments on commit e1f82e2

Please sign in to comment.