Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout #422

Merged
merged 5 commits into from
Nov 17, 2023
Merged
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
8 changes: 6 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
}
options {
buildDiscarder(logRotator(numToKeepStr:'10'))
timeout(time: 1, unit: 'HOURS')
timeout(time: 30, unit: 'MINUTES')
}
environment {
PATH = "$HOME/.local/bin:$HOME/.cargo/bin/:$PATH"
Expand All @@ -19,7 +19,7 @@ pipeline {
sh 'org.eclipse.corrosion/scripts/rustup-init.sh -y'
sh 'rustup install stable-x86_64-unknown-linux-gnu'
sh 'rustup default stable-x86_64-unknown-linux-gnu'
sh 'mkdir -p ~/.local/bin'
sh 'rustup component add rust-analyzer'
sh 'echo $PATH'
}
}
Expand All @@ -31,9 +31,13 @@ pipeline {
wrap([$class: 'Xvnc', useXauthority: true]) {
sh './mvnw -Dmaven.repo.local=$WORKSPACE/.m2 clean verify -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Dtycho.showEclipseLog=true -Psign -Dsurefire.timeout=1800'
}
sh 'rust-analyzer --version'
}
post {
always {
sh 'which rustup'
sh 'which rust-analyzer'
sh 'rust-analyzer --version'
junit '*/target/surefire-reports/TEST-*.xml'
archiveArtifacts artifacts: '*/target/work/data/.metadata/.log'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobManager;
Expand All @@ -24,13 +25,15 @@
import org.eclipse.corrosion.extensions.ProgressParams;
import org.eclipse.swt.widgets.Display;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

class TestLSPExtensions extends AbstractCorrosionTest {

private static final String PROGRESS_ID_1 = "progress_1";
private static final String PROGRESS_ID_2 = "progress_2";

@Test
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void testBuildingMessages() {
String jobType = "Building";
RLSClientImplementation clientImplementation = new RLSClientImplementation();
Expand All @@ -50,6 +53,7 @@ void testBuildingMessages() {
}

@Test
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void testIndexingMessages() {
String jobType = "Indexing";
RLSClientImplementation clientImplementation = new RLSClientImplementation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.IOException;
import java.time.Duration;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
Expand All @@ -29,10 +30,12 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

class TestLSPIntegration extends AbstractCorrosionTest {

@Test
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void testLSWorks() throws IOException, CoreException {
IProject project = getProject(BASIC_ERRORS_PROJECT_NAME);
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
Expand Down
3 changes: 2 additions & 1 deletion org.eclipse.corrosion/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.core.contenttype,
org.eclipse.ui.genericeditor;bundle-version="1.0.1",
org.eclipse.ui,
org.eclipse.lsp4e;bundle-version="0.9.0",
org.eclipse.lsp4e;bundle-version="0.17.0",
org.eclipse.tm4e.core,
org.eclipse.tm4e.ui,
org.eclipse.core.runtime;bundle-version="3.22.0",
Expand Down Expand Up @@ -51,3 +51,4 @@ Export-Package: org.eclipse.corrosion;x-friends:="org.eclipse.corrosion.tests",
org.eclipse.corrosion.snippet;x-friends:="org.eclipse.corrosion.tests",
org.eclipse.corrosion.wizards.export;x-friends:="org.eclipse.corrosion.tests",
org.eclipse.corrosion.wizards.newproject;x-friends:="org.eclipse.corrosion.tests"
Import-Package: org.eclipse.jdt.annotation
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransfer;
import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
Expand Down Expand Up @@ -361,4 +364,8 @@ private static boolean startBundle(String bundleId) {
}
return false;
}

public static @NonNull LanguageServerDefinition languageServerDefinition() {
return LanguageServersRegistry.getInstance().getDefinition("org.eclipse.corrosion.rls"); //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class RustManager {
* Set according to rust-analyzer documentation
*/
static final File RUST_ANALYZER_DEFAULT_LOCATION = new File(System.getProperty("user.home"), //$NON-NLS-1$
".local/bin/rust-analyzer"); //$NON-NLS-1$
".cargo/bin/rust-analyzer"); //$NON-NLS-1$
public static final String RLS_VERSION_FORMAT_REGEX = "^(rls|rust-analyzer).*$"; //$NON-NLS-1$
public static final String CARGO_VERSION_FORMAT_REGEX = "^cargo .*$"; //$NON-NLS-1$
public static final String RUSTUP_VERSION_FORMAT_REGEX = "^rustup .*$"; //$NON-NLS-1$
Expand Down Expand Up @@ -146,7 +146,7 @@ protected IStatus run(IProgressMonitor monitor) {
toolchainId));
jobs.add(createRustupCommandJob(Messages.RustManager_addingRustAnalysisRustSrc,
Messages.RustManager_unableToAddComponent, "component", //$NON-NLS-1$
"add", "rust-analysis")); //$NON-NLS-1$ //$NON-NLS-2$
"add", "rust-analysis", "rust-analyzer")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

for (CommandJob commandJob : jobs) {
currentCommandJob = commandJob;
Expand Down Expand Up @@ -177,8 +177,7 @@ private static void sendDidChangeConfigurationsMessage(Map<String, String> updat
params.setSettings(updatedSettings);
LSPDocumentInfo info = infoFromOpenEditors();
if (info != null) {
info.getInitializedLanguageClient()
.thenAccept(languageServer -> languageServer.getWorkspaceService().didChangeConfiguration(params));
info.getLanguageServerWrapper().sendNotification(languageServer -> languageServer.getWorkspaceService().didChangeConfiguration(params));
}
}

Expand Down Expand Up @@ -327,6 +326,7 @@ public static CompletableFuture<File> downloadAndInstallRustAnalyzer(DoubleConsu

// Use retrieve to initiate file transfer
File archiveFile = new File(RUST_ANALYZER_DEFAULT_LOCATION.getParentFile(), filename);
CorrosionPlugin.getDefault().getLog().log(Status.info("Downloading to " + archiveFile)); //$NON-NLS-1$
try {
CompletableFuture<File> res = new CompletableFuture<>();
IFileID id = FileIDFactory.getDefault().createFileID(retrieve.getRetrieveNamespace(), URI.create(url));
Expand Down Expand Up @@ -371,6 +371,7 @@ public static void decompressGzip(File input, File output) throws IOException {
try (FileOutputStream out = new FileOutputStream(output)) {
in.transferTo(out);
output.setExecutable(true);
CorrosionPlugin.getDefault().getLog().info("UnGZipped to " + output); //$NON-NLS-1$
input.delete();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public IStatus run(IProgressMonitor monitor) {
params.setContext(new ReferenceContext(true));
params.setTextDocument(new TextDocumentIdentifier(info.getFileUri().toString()));
params.setPosition(position);
info.getInitializedLanguageClient()
.thenCompose(languageServer -> ((RLSServerInterface) languageServer).implementations(params))
info.getLanguageServerWrapper()
.execute(languageServer -> ((RLSServerInterface) languageServer).implementations(params))
.thenAccept(locs -> {
// Loop for each LSP Location and convert it to Match search.
for (Location loc : locs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.corrosion.test.actions;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand All @@ -29,6 +30,7 @@
import org.eclipse.jface.action.Action;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.eclipse.lsp4e.LanguageServerPlugin;
import org.eclipse.lsp4e.LanguageServerWrapper;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.Position;
Expand All @@ -38,7 +40,6 @@
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.WorkspaceSymbolParams;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.unittest.model.ITestCaseElement;
Expand Down Expand Up @@ -69,13 +70,17 @@ public void run() {
if (project == null) {
return;
}
List<LanguageServer> languageServers = LanguageServiceAccessor.getLanguageServers(project,
capabilities -> Boolean.TRUE.equals(capabilities.getWorkspaceSymbolProvider().get()));
if (languageServers != null && languageServers.isEmpty()) {
LanguageServerWrapper languageServer = null;
try {
languageServer = LanguageServiceAccessor.getLSWrapper(project, CorrosionPlugin.languageServerDefinition());
} catch (IOException ex) {
CorrosionPlugin.logError(ex);
}
if (languageServer == null) {
return;
}
SymbolKind kind = fTestElement instanceof ITestCaseElement ? SymbolKind.Function : SymbolKind.Module;
List<SymbolInformation> result = getQualifiedSymbols(languageServers, fTestElement.getTestName(), kind);
List<SymbolInformation> result = getQualifiedSymbols(languageServer, fTestElement.getTestName(), kind);
if (result == null || result.isEmpty()) {
return;
}
Expand Down Expand Up @@ -108,7 +113,7 @@ private static IProject getProject(ITestElement element) {
return null;
}

private static List<SymbolInformation> getQualifiedSymbols(List<LanguageServer> languageServers, String path,
private static List<SymbolInformation> getQualifiedSymbols(LanguageServerWrapper languageServer, String path,
SymbolKind kind) {
List<SymbolInformation> result = new ArrayList<>();

Expand All @@ -123,7 +128,7 @@ private static List<SymbolInformation> getQualifiedSymbols(List<LanguageServer>
String parent = i > 0 ? pathArray[i - 1] : null;
SymbolKind expectedKind = i < pathArray.length - 1 ? SymbolKind.Module : kind;

List<SymbolInformation> symbols = getSymbols(languageServers, name, parent, expectedKind);
List<SymbolInformation> symbols = getSymbols(languageServer, name, parent, expectedKind);
List<SymbolInformation> currents;
if (parents != null) {
List<SymbolInformation> matches = new ArrayList<>();
Expand All @@ -150,30 +155,27 @@ private static List<SymbolInformation> getQualifiedSymbols(List<LanguageServer>
return parents;
}

private static List<SymbolInformation> getSymbols(List<LanguageServer> languageServers, String name, String parent,
private static List<SymbolInformation> getSymbols(LanguageServerWrapper languageServer, final String name, String parent,
SymbolKind kind) {
List<SymbolInformation> result = new ArrayList<>();

for (LanguageServer server : languageServers) {
WorkspaceSymbolParams params = new WorkspaceSymbolParams(name);
CompletableFuture<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> symbols = server
.getWorkspaceService().symbol(params);

try {
List<?> items = (List<?>) symbols.get(10, TimeUnit.SECONDS).get();
if (items != null) {
for (Object item : items) {
SymbolInformation match = getMatchingItem(item, name, parent, kind);
if (match != null) {
result.add(match);
}
WorkspaceSymbolParams params = new WorkspaceSymbolParams(name);
CompletableFuture<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> symbols = languageServer.execute(ls -> ls.getWorkspaceService().symbol(params));

try {
List<?> items = (List<?>) symbols.get(10, TimeUnit.SECONDS).get();
if (items != null) {
for (Object item : items) {
SymbolInformation match = getMatchingItem(item, name, parent, kind);
if (match != null) {
result.add(match);
}
}
} catch (ExecutionException | TimeoutException e) {
LanguageServerPlugin.logError(e);
} catch (InterruptedException e) {
LanguageServerPlugin.logError(e);
}
} catch (ExecutionException | TimeoutException e) {
LanguageServerPlugin.logError(e);
} catch (InterruptedException e) {
LanguageServerPlugin.logError(e);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion repository/corrosion.product
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ United States, other countries, or both.
</plugins>

<features>
<feature id="org.eclipse.epp.package.common.feature" version="4.28.0.qualifier"/>
<feature id="org.eclipse.epp.package.common.feature"/>
<feature id="org.eclipse.platform"/>
<feature id="org.eclipse.epp.mpc" installMode="root"/>
<feature id="org.eclipse.justj.openjdk.hotspot.jre.full" installMode="root"/>
Expand Down
Loading