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
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ jobs:
- windows-latest
# https://github.com/actions/partner-runner-images
- ubuntu-24.04-arm
target-platform:
- oldest
- latest
include:
- os: ubuntu-latest
target-platform: staging
runs-on: ${{ matrix.os }}
timeout-minutes: 20

Expand Down Expand Up @@ -160,10 +166,11 @@ jobs:
~/.m2/repository/.cache/tycho
~/.m2/repository/.meta/p2-artifacts.properties
~/.m2/repository/p2
key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platforms/target-platform-latest/target-platform-latest.target') }}
key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles(format('target-platforms/{0}.target', matrix.target-platform)) }}


- name: "Build with Maven 🔨"
continue-on-error: ${{ matrix.target-platform == 'staging' }}
uses: nick-fields/retry@v4
with:
max_attempts: 3
Expand Down Expand Up @@ -195,6 +202,7 @@ jobs:
--errors \
--update-snapshots \
--batch-mode \
-Dlsp4e.targetPlatform=${{ matrix.target-platform }} \
--show-version \
-Declipse.p2.mirrors=false \
-Dsurefire.rerunFailingTestsCount=3 \
Expand All @@ -215,7 +223,7 @@ jobs:

- name: "Upload: Repository Zip"
uses: actions/upload-artifact@v7
if: runner.os == 'Linux'
if: runner.os == 'Linux' && matrix.target-platform == 'oldest'
with:
name: org.eclipse.lsp4e.repository-${{matrix.target-platform}}-${{matrix.os}}
path: repository/target/org.eclipse.lsp4e.repository-*.zip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
~/.m2/repository/.cache/tycho
~/.m2/repository/.meta/p2-artifacts.properties
~/.m2/repository/p2
key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platforms/target-platform-latest/target-platform-latest.target') }}
key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platforms/oldest.target') }}


# https://docs.github.com/en/code-security/code-scanning
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/licensecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
~/.m2/repository/.cache/tycho
~/.m2/repository/.meta/p2-artifacts.properties
~/.m2/repository/p2
key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platforms/target-platform-latest/target-platform-latest.target') }}
key: ${{ runner.os }}-${{ runner.arch }}-repo-tycho-${{ hashFiles('target-platforms/oldest.target') }}


- name: Dash License check # see https://github.com/eclipse/dash-licenses
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Latest snapshot builds, for testing, can usually be found at `https://download.e
1. _File > Open Projects from Filesystem..._ , select the path to the LSP4E Git repo and the relevant children projects you want to import
1. Depending on the task you're planning to work on, multiple workflows are available to configure the [target-platform](https://help.eclipse.org/latest/topic/org.eclipse.pde.doc.user/concepts/target.htm?cp=4_1_5)
* In many cases, this simplest workflow will be sufficient: Install latest LSP4E snapshot in your target-platform (can be your current IDE), or
* If you don't want to mix versions of LSP4E, open [target-platforms/target-platform-latest/target-platform-latest.target](target-platforms/target-platform-latest/target-platform-latest.target) from within Eclipse and click **Set as Active Target-Platform** in the top right corner.
* If you don't want to mix versions of LSP4E, open [target-platforms/latest.target](target-platforms/latest.target) from within Eclipse and click **Set as Active Target-Platform** in the top right corner.
1. Open the project modules you want to work on (right-click > Open project) and their dependencies
1. Happy coding! 🤗

Expand Down
6 changes: 3 additions & 3 deletions org.eclipse.lsp4e.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests for language server bundle (Incubation)
Bundle-SymbolicName: org.eclipse.lsp4e.test;singleton:=true
Bundle-Version: 0.16.9.qualifier
Bundle-Version: 0.16.10.qualifier
Fragment-Host: org.eclipse.lsp4e
Bundle-Vendor: Eclipse LSP4E
Bundle-RequiredExecutionEnvironment: JavaSE-21
Expand Down Expand Up @@ -30,8 +30,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.e4.ui.workbench,
org.eclipse.tm4e.ui,
org.eclipse.core.filesystem,
junit-jupiter-api;bundle-version="[6.0.1,7.0.0)",
junit-jupiter-params;bundle-version="[6.0.1,7.0.0)",
junit-jupiter-api;bundle-version="[5.12.2,6.0.0)",
junit-jupiter-params;bundle-version="[5.12.2,6.0.0)",
org.hamcrest,
org.opentest4j
Automatic-Module-Name: org.eclipse.lsp4e.test
7 changes: 5 additions & 2 deletions org.eclipse.lsp4e.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>org.eclipse.lsp4e.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>0.16.9-SNAPSHOT</version>
<version>0.16.10-SNAPSHOT</version>

<properties>
<os-jvm-flags /> <!-- for the default case -->
Expand Down Expand Up @@ -38,12 +38,15 @@
<version>${tycho-version}</version>
<!-- https://tycho.eclipseprojects.io/doc/latest/tycho-surefire-plugin/test-mojo.html -->
<configuration>
<systemProperties>
<!-- Set a system property, so we can disable some JUnit tests based on the current target platform -->
<lsp4e.targetPlatform>${lsp4e.targetPlatform}</lsp4e.targetPlatform>
</systemProperties>
<trimStackTrace>false</trimStackTrace>
<useUIHarness>true</useUIHarness>
<useUIThread>true</useUIThread>
<forkedProcessTimeoutInSeconds>1200</forkedProcessTimeoutInSeconds>
<argLine>-Dfile.encoding=${project.build.sourceEncoding} -Xms1g -Xmx1g -Djava.util.logging.config.file=${project.basedir}/src/jul.properties ${ui.test.vmargs} ${os-jvm-flags}</argLine>
<providerHint>junit6</providerHint>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,9 @@ public void testCodeActionLiteralWorkspaceEdit() throws CoreException {
@Test
public void testNoCodeActionOnReadOnlySource() throws CoreException {
IFile f = TestUtils.createUniqueTestFile(project, "error");
f.setResourceAttributes(new ResourceAttributes() {
@Override
public boolean isReadOnly() {
return true;
}
});
ResourceAttributes attrs = f.getResourceAttributes();
attrs.setReadOnly(true);
f.setResourceAttributes(attrs);

final var tEdit = new TextEdit(new Range(new Position(0, 0), new Position(0, 5)), "fixed");
final var wEdit = new WorkspaceEdit(Collections.singletonMap(f.getLocationURI().toString(), List.of(tEdit)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;

public class DocumentLinkReconcilingTest extends AbstractTestWithProject {

Expand Down Expand Up @@ -188,6 +189,9 @@ public void testMidLineClippedDocumentLinkReconciling() throws Exception {
}

@Test
@DisabledIfSystemProperty(named = "lsp4e.targetPlatform", matches = "oldest", disabledReason = """
Fails on oldest target platform.
Note: this will only work when called from Maven or when setting the propery explicitly.""")
public void testClippedDocumentLinkReconciling() throws Exception {
MockLanguageServer.INSTANCE.setDocumentLinks(CONTENT_LINKS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourceAttributes;
import org.eclipse.core.runtime.CoreException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -53,6 +54,17 @@ private static void deleteProjectWithRetries(IProject project, int maxAttempts,
if (!project.exists()) {
break;
}
project.open(null);
project.accept(r -> {
ResourceAttributes attrs = r.getResourceAttributes();
// At least one test creates a read-only resource.
// This leads to errors when trying to delete the project, so we make all files writable again.
if (attrs != null && attrs.isReadOnly()) {
attrs.setReadOnly(false);
r.setResourceAttributes(attrs);
}
return true;
});
project.close(null);
project.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, null);
break;
Expand Down
82 changes: 28 additions & 54 deletions org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/CNFOutlinePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.eclipse.lsp4e.internal.NullSafetyHelper.castNullable;
import static org.eclipse.lsp4e.internal.NullSafetyHelper.lateNonNull;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

import org.eclipse.core.runtime.Adapters;
Expand Down Expand Up @@ -54,7 +55,6 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.CommonViewerComparator;
import org.eclipse.ui.navigator.CommonViewerSorter;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
Expand All @@ -77,8 +77,8 @@

private final LanguageServerWrapper wrapper;

@Nullable
private static Boolean canUseCommonViewerComparator;
private static @Nullable Class<?> comparatorClass = null;
private static boolean checkedForComparatorClass = false;

public CNFOutlinePage(LanguageServerWrapper wrapper, @Nullable ITextEditor textEditor) {
preferences = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
Expand All @@ -95,7 +95,7 @@
if (document != null) {
outlineViewer.setInput(new OutlineViewerInput(document, wrapper, textEditor));
}
outlineViewer.setComparator(createComparator());
configureSorterOrComparator(outlineViewer);
outlineViewer.getLabelProvider().addListener(this);
final var textEditor = this.textEditor;
if (textEditor != null) {
Expand Down Expand Up @@ -130,60 +130,34 @@
}

/**
* Try to be compatible with older Eclipse versions (before 4.39) where
* CommonViewerComparator is not available.
*
* @return comparator for the outline
*/
private static ViewerComparator createComparator() {
if (checkIfCommonViewerComparatorAvailable()) {
return Eclipse439PlusComparator.create();
}
return EclipseBefore439Comparator.create();
}

private static boolean checkIfCommonViewerComparatorAvailable() {
if(canUseCommonViewerComparator != null) {
return canUseCommonViewerComparator.booleanValue();
}
try {
Class.forName("org.eclipse.ui.navigator.CommonViewerComparator"); //$NON-NLS-1$
canUseCommonViewerComparator = Boolean.TRUE;
return true;
} catch (ClassNotFoundException e) {
canUseCommonViewerComparator = Boolean.FALSE;
return false;
}
}

/**
* Compatible with modern Eclipse versions (4.39 and later) where
* CommonViewerComparator is available.
* <p>
* This is extracted to an extra class to avoid classloading issues on older Eclipse versions where
* the CommonViewerComparator class is not available. If we try to load a class referencing
* CommonViewerComparator on an older Eclipse version, it will result in a ClassNotFoundException.
*
* @return comparator for the outline
* Workaround for a Bug in Eclipse 4.39:
* Before 4.39, the CommonViewerSorter can be used.
* Starting with 4.39, using the CommonViewerSorter breaks sorting,
* so the newer CommonViewerComparator must be used.
* Once our oldest Target Platform contains CommonViewerComparator, we can drop this workaround.
* @param viewer The viewer to configure
*/
private static final class Eclipse439PlusComparator {
static ViewerComparator create() {
return new CommonViewerComparator();
private void configureSorterOrComparator(CommonViewer viewer) {
if (!checkedForComparatorClass) {
checkedForComparatorClass = true;
try {
comparatorClass = Class.forName("org.eclipse.ui.navigator.CommonViewerComparator"); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
// Will trigger on < 4.39.
}
}
}

/**
* Compatible with older Eclipse versions (before 4.39) where
* CommonViewerComparator is not available.
* <p>
* This is extracted to an extra class to avoid classloading issues
*
* @return comparator for the outline
*/
private static final class EclipseBefore439Comparator {
static ViewerComparator create() {
return new CommonViewerSorter();
if (comparatorClass != null) {
try {
ViewerComparator comparator = (ViewerComparator) comparatorClass.getDeclaredConstructor().newInstance();
viewer.setComparator(comparator);
return;
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
// Fall-through
}
}
viewer.setSorter(new CommonViewerSorter());

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
CommonViewer.setSorter
should be avoided because it has been deprecated.
}

/**
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<tycho.scmUrl>scm:git:https://github.com/eclipse-lsp4e/lsp4e.git</tycho.scmUrl>
<ui.test.vmargs></ui.test.vmargs>
<jgit.dirtyWorkingTree>error</jgit.dirtyWorkingTree>
<lsp4e.targetPlatform>oldest</lsp4e.targetPlatform>
</properties>

<organization>
Expand Down Expand Up @@ -75,7 +76,7 @@
<version>${tycho-version}</version>
<configuration>
<target>
<file>${maven.multiModuleProjectDirectory}/target-platforms/target-platform-latest/target-platform-latest.target</file>
<file>${maven.multiModuleProjectDirectory}/target-platforms/${lsp4e.targetPlatform}.target</file>
</target>
<environments>
<environment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.ui.tests.harness" version="0.0.0"/>
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
<repository location="https://download.eclipse.org/eclipse/updates/latest/"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.39/"/>
</location>
<location type="InstallableUnit" includeConfigurePhase="true" includeMode="planner" includeSource="true">
<repository location="https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/release/latest"/>
<repository location="https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/release/4.39.0/"/>
<unit id="org.commonmark" version="0.0.0"/>
<unit id="org.commonmark.ext-gfm-tables" version="0.0.0"/>
<unit id="com.google.guava" version="0.0.0"/>
Expand Down
42 changes: 42 additions & 0 deletions target-platforms/oldest.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="LSP4E Target-platform" sequenceNumber="1473749311">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.lsp4j" version="0.0.0"/>
<unit id="org.eclipse.lsp4j.jsonrpc" version="0.0.0"/>
<unit id="org.eclipse.lsp4j.debug" version="0.0.0"/>
<unit id="org.eclipse.lsp4j.jsonrpc.debug" version="0.0.0"/>
<unit id="com.google.gson" version="0.0.0"/>
<repository location="https://download.eclipse.org/lsp4j/updates/releases/1.0.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.ui.tests.harness" version="0.0.0"/>
<unit id="org.eclipse.sdk.ide" version="0.0.0"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.37/"/>
</location>
<location type="InstallableUnit" includeConfigurePhase="true" includeMode="planner" includeSource="true">
<repository location="https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/release/4.37.0/"/>
<unit id="org.commonmark" version="0.0.0"/>
<unit id="org.commonmark.ext-gfm-tables" version="0.0.0"/>
<unit id="com.google.guava" version="0.0.0"/>
<unit id="com.google.guava.failureaccess" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.tm4e.feature.feature.group" version="0.0.0"/>
<repository location="https://download.eclipse.org/tm4e/releases/latest/"/>
</location>
<location includeDependencyDepth="none" includeSource="false" missingManifest="error" type="Maven">
<dependencies>
<dependency>
<!-- External Eclipse null Annotations, see https://github.com/vegardit/no-npe -->
<groupId>com.vegardit.no-npe</groupId>
<artifactId>no-npe-eea-all</artifactId>
<version>1.3.9</version>
<type>jar</type>
</dependency>
</dependencies>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
</target>
Loading
Loading