forked from eclipse-lemminx/lemminx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unregister language server extension on LS shutdown
fix eclipse-lemminx#605 Signed-off-by: Andrew Obuchowicz <[email protected]>
- Loading branch information
Showing
3 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...l/src/test/java/org/eclipse/lsp4xml/services/extensions/ExtensionRegistryDisposeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lsp4xml.services.extensions; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.eclipse.lsp4j.InitializeParams; | ||
import org.eclipse.lsp4xml.services.extensions.save.ISaveContext; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Ensures XML LS extensions are correctly unregistered when | ||
* {@code XMLExtensionRegistry.dispose()} is called. During extension | ||
* unregistration, the {@code IXMLExtension.stop()} function is called. | ||
* | ||
* @author aobuchow | ||
* | ||
*/ | ||
public class ExtensionRegistryDisposeTest { | ||
|
||
@Test | ||
public void testExtensionRegistryDipose() { | ||
XMLExtensionsRegistry registry = new XMLExtensionsRegistry(); | ||
registry.initializeIfNeeded(); | ||
MockXMLExtension extension = new MockXMLExtension(); | ||
registry.registerExtension(extension); | ||
assertTrue(!extension.isStopped()); | ||
registry.dispose(); | ||
assertTrue(extension.isStopped()); | ||
assertTrue(registry.getExtensions().isEmpty()); | ||
} | ||
} | ||
|
||
class MockXMLExtension implements IXMLExtension { | ||
boolean stopped; | ||
|
||
@Override | ||
public void start(InitializeParams params, XMLExtensionsRegistry registry) { | ||
stopped = false; | ||
} | ||
|
||
@Override | ||
public void stop(XMLExtensionsRegistry registry) { | ||
stopped = true; | ||
} | ||
|
||
@Override | ||
public void doSave(ISaveContext context) { | ||
} | ||
|
||
public boolean isStopped() { | ||
return stopped; | ||
} | ||
|
||
} |