Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.eclipse.lsp4e.test.utils.CloseIntroExtension
org.eclipse.lsp4e.test.utils.MockLanguageServerExtension
org.eclipse.lsp4e.test.utils.CloseIntroExtension
19 changes: 1 addition & 18 deletions org.eclipse.lsp4e.test/fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
id="org.eclipse.lsp4e.test.server-with-exception"
lastDocumentDisconnectedTimeout="0"
label="Test LS With Exception">
</server>
<server
class="org.eclipse.lsp4e.tests.mock.MockConnectionProviderMultiRootFolders"
id="org.eclipse.lsp4e.test.server-with-multi-root-support"
lastDocumentDisconnectedTimeout="0"
label="Test LS With Multi-Root Support">
</server>
<server
class="org.eclipse.lsp4e.tests.mock.MockConnectionProvider"
Expand Down Expand Up @@ -72,10 +66,6 @@
contentType="org.eclipse.lsp4e.test.content-type-server-with-exception"
id="org.eclipse.lsp4e.test.server-with-exception">
</contentTypeMapping>
<contentTypeMapping
contentType="org.eclipse.lsp4e.test.content-type-server-with-multi-root"
id="org.eclipse.lsp4e.test.server-with-multi-root-support">
</contentTypeMapping>
<contentTypeMapping
contentType="org.eclipse.lsp4e.test.content-type-server-with-last-document-disconnected-timeout"
id="org.eclipse.lsp4e.test.server-with-last-document-disconnected-timeout">
Expand Down Expand Up @@ -130,7 +120,7 @@
base-type="org.eclipse.core.runtime.text"
file-extensions="lsptmultils"
id="org.eclipse.lsp4e.test.content-type-multi-ls"
name="Test Content Type"
name="Test Content Type which is picked up by two different LS"
priority="normal">
</content-type>
<content-type
Expand All @@ -147,13 +137,6 @@
name="Test Content Type Server with Exception"
priority="normal">
</content-type>
<content-type
base-type="org.eclipse.core.runtime.text"
file-extensions="lsptWithMultiRoot"
id="org.eclipse.lsp4e.test.content-type-server-with-multi-root"
name="Test Content Type Server with Multi-Root Support"
priority="normal">
</content-type>
<content-type
base-type="org.eclipse.core.runtime.text"
file-extensions="lsptWithLastDocumentDisconnectedTimeout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
import org.eclipse.lsp4e.ContentTypeToLanguageServerDefinition;
import org.eclipse.lsp4e.LanguageServerPlugin;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.test.utils.AbstractTest;
import org.eclipse.lsp4e.test.utils.TestUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class ContentTypeToLanguageServerDefinitionTest extends AbstractTest {
public class ContentTypeToLanguageServerDefinitionTest {

public static final String SERVER_TO_DISABLE = "org.eclipse.lsp4e.test.server.disable";
public static final String DISABLED_CONTENT_TYPE = "org.eclipse.lsp4e.test.content-type-disabled";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.test.utils.AbstractTestWithProject;
import org.eclipse.lsp4e.test.utils.TestUtils;
import org.eclipse.lsp4e.tests.mock.MockConnectionProviderMultiRootFolders;
import org.eclipse.lsp4e.tests.mock.MockLanguageServer;
import org.eclipse.lsp4e.tests.mock.MockLanguageServerFactory;
import org.eclipse.ui.IEditorPart;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -45,9 +46,10 @@ public void setUp() throws Exception {
}

@Test
public void testConnect() throws Exception {
IFile testFile1 = TestUtils.createFile(project, "shouldUseExtension.lsptWithMultiRoot", "");
IFile testFile2 = TestUtils.createFile(project2, "shouldUseExtension.lsptWithMultiRoot", "");
public void testConnect(MockLanguageServerFactory factory) throws Exception {
factory.withCapabilities(MockLanguageServer::multiRootCapabilities);
IFile testFile1 = TestUtils.createFile(project, "shouldUseExtension.lspt", "");
IFile testFile2 = TestUtils.createFile(project2, "shouldUseExtension.lspt", "");

IEditorPart editor1 = TestUtils.openEditor(testFile1);
IEditorPart editor2 = TestUtils.openEditor(testFile2);
Expand All @@ -60,7 +62,7 @@ public void testConnect() throws Exception {
waitForAndAssertCondition(2_000, wrapper::isActive);

// e.g. LanguageServerWrapper@69fe8c75 [serverId=org.eclipse.lsp4e.test.server-with-multi-root-support, initialPath=null, initialProject=P/LanguageServerWrapperTest_testConnect_11691664858710, isActive=true]
assertThat(wrapper.toString(), matchesPattern("LanguageServerWrapper@[0-9a-f]+ \\[serverId=org.eclipse.lsp4e.test.server-with-multi-root-support, initialPath=null, initialProject=P\\/LanguageServerWrapperTest_testConnect_[0-9]+, isActive=true, pid=(null|[0-9])+\\]"));
assertThat(wrapper.toString(), matchesPattern("LanguageServerWrapper@[0-9a-f]+ \\[serverId=org.eclipse.lsp4e.test.server, initialPath=null, initialProject=P\\/LanguageServerWrapperTest_testConnect_[0-9]+, isActive=true, pid=(null|[0-9])+\\]"));

assertTrue(wrapper.isConnectedTo(testFile1.getLocationURI()));
assertTrue(wrapper.isConnectedTo(testFile2.getLocationURI()));
Expand All @@ -74,12 +76,11 @@ public void testConnect() throws Exception {
* @see <a href="https://github.com/eclipse-lsp4e/lsp4e/pull/688">GitHub Pull Request #688</a>
*/
@Test
public void testStartStopAndActive() throws CoreException, AssertionError {
public void testStartStopAndActive(MockLanguageServerFactory factory) throws CoreException, AssertionError {
factory.withCapabilities(MockLanguageServer::multiRootCapabilities);
final int testCount= 100;

MockConnectionProviderMultiRootFolders.resetCounts();

IFile testFile1 = TestUtils.createFile(project, "shouldUseExtension.lsptWithMultiRoot", "");
IFile testFile1 = TestUtils.createFile(project, "shouldUseExtension.lspt", "");
IEditorPart editor1 = TestUtils.openEditor(testFile1);
@NonNull Collection<LanguageServerWrapper> wrappers = LanguageServiceAccessor.getLSWrappers(testFile1, request -> true);
assertEquals(1, wrappers.size());
Expand Down Expand Up @@ -132,10 +133,7 @@ public void testStartStopAndActive() throws CoreException, AssertionError {
if (ForkJoinPool.commonPool().getActiveThreadCount() > startingActiveThreads)
throw new AssertionError("timeout waiting for ForkJoinPool.commonPool to go quiet");

Integer cpStartCount= MockConnectionProviderMultiRootFolders.getStartCount();
Integer cpStopCount= MockConnectionProviderMultiRootFolders.getStopCount();

assertEquals(cpStartCount, cpStopCount, "startCount == stopCount");
assertEquals(factory.connectionProviderStartCounter.get(), factory.connectionProviderStopCounter.get());
}

}
Loading
Loading