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

Revert Xtext upgrade #946

Merged
merged 1 commit into from
Mar 5, 2025
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
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

"packageRules": [
{
"description": "Group all Eclipse related dependencies (including Xtext). These dependencies often introduce breaking changes in minor version upgrades.",
"description": "Group all Eclipse related dependencies (including Xtext). Because these dependencies often introduce breaking changes in minor version upgrades, we always require an explicit approval in the dependency dashboard before creating a PR.",
"matchPackagePatterns": ["^org\\.eclipse\\."],
"groupName": "eclipse dependencies",
"groupSlug": "eclipse-dependencies"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/license-scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ env:
ALLOW_LICENSES: "
licenses/license/name!='Apache License, Version 2.0' and
not(contains(licenses/license/url, '://www.apache.org/licenses/LICENSE-2.0.txt')) and
not(contains(licenses/license/url, '://opensource.org/licenses/Apache-2.0')) and

licenses/license/name!='BSD License' and
not(contains(licenses/license/url, 'antlr.org/license.html')) and
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ To build the project, run `mvn clean install`.

### 2. Setting things up in Eclipse
#### Install Eclipse IDE for Java and DSL Developers
Install version `2025-06` of the "Eclipse IDE for Java and DSL Developers" using the [Eclipse Installer](https://www.eclipse.org/downloads/packages/installer). You might have to enable "Advanced Mode" in the settings of the Eclipse Installer to install a specific version.
Install version `2022-06` of the "Eclipse IDE for Java and DSL Developers" using the [Eclipse Installer](https://www.eclipse.org/downloads/packages/installer). Make sure to install version `2022-06`! Later versions dropped support for Java 8 Xtend files, which we need. You might have to enable "Advanced Mode" in the settings of the Eclipse Installer to install a specific version.

#### Configure Eclipse with the right version of Java
Xtend files cannot be build with any Java version later than 21. In Eclipse, go to Settings... > Java > Installed JREs and make sure the checked JRE points to a Java version of 21.
Xtend files cannot be build with any Java version later than 17. In Eclipse, go to Settings... > Java > Installed JREs and make sure the checked JRE points to a Java version of 17.

#### Install the Checkstyle plugin
We use [Checkstyle](https://checkstyle.sourceforge.io/) for enforcing good coding practices. The Eclipse plugin for Checkstyle can be found here: [https://checkstyle.org/eclipse-cs/#!/](https://checkstyle.org/eclipse-cs/#!/).
Expand Down
6 changes: 2 additions & 4 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
<property name="localeCountry" value="UK"/>
<property name="localeLanguage" value="en"/>
<module name="TreeWalker">
<!-- Forbid using Google Inject and the deprecated javax Inject in favour of jakarta Inject. -->
<!-- Forbid using Google Inject in favor of javax Inject. -->
<module name="IllegalImport">
<property name="illegalClasses"
value="com.google.inject.Inject, com.google.inject.name.Named, com.google.inject.Provider, com.google.inject.Singleton" />
<property name="illegalPkgs"
value="javax.inject" />
value="com.google.inject.Inject, com.google.inject.name.Named, com.google.inject.Provider" />
</module>
</module>
<module name="BeforeExecutionExclusionFileFilter">
Expand Down
15 changes: 4 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
<stagingTimeoutInMinutes>10</stagingTimeoutInMinutes>

<!-- Dependency management -->
<xtext.version>2.38.0</xtext.version>
<xtext.version>2.27.0</xtext.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<commons-text.version>1.12.0</commons-text.version>
<snakeyaml.version>2.2</snakeyaml.version>
<org.eclipse.emf.ecore.xcore.lib.version>1.7.0</org.eclipse.emf.ecore.xcore.lib.version>
<org.eclipse.emf.ecore.xcore.lib.version>1.6.0</org.eclipse.emf.ecore.xcore.lib.version>
<maven-plugin-api.version>3.9.8</maven-plugin-api.version>
<maven-core.version>3.9.8</maven-core.version>
<maven-plugin-annotations.version>3.13.1</maven-plugin-annotations.version>
Expand All @@ -116,7 +116,7 @@
<mockito-core.version>5.12.0</mockito-core.version>

<!-- Plugin and plugin dependency management -->
<org.eclipse.emf.ecore.xcore.version>1.32.0</org.eclipse.emf.ecore.xcore.version>
<org.eclipse.emf.ecore.xcore.version>1.23.0</org.eclipse.emf.ecore.xcore.version>
<maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
<exec-maven-plugin.version>3.3.0</exec-maven-plugin.version>
Expand Down Expand Up @@ -180,13 +180,6 @@
</dependency>

<!-- Runtime dependencies -->
<!-- The following dependency can be removed in a next major version
once this issue has been addressed: https://github.com/finos/rune-dsl/issues/938 -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>xtext-dev-bom</artifactId>
Expand Down Expand Up @@ -227,7 +220,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.xtext</groupId>
<artifactId>org.eclipse.xtext.xtext.generator</artifactId>
<artifactId>org.eclipse.xtext.generator</artifactId>
<version>${xtext.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.regnosys.rosetta.ide.contentassist;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.RuleCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Collection;
import java.util.Collections;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.Token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Arrays;
import java.util.concurrent.ExecutorService;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
import javax.inject.Inject;
import javax.inject.Provider;

import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.CompletionList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.Collection;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.antlr.runtime.TokenSource;
import org.eclipse.xtext.AbstractElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.ArrayList;
import java.util.List;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
import javax.inject.Inject;
import javax.inject.Provider;

import org.eclipse.lsp4j.FormattingOptions;
import org.eclipse.lsp4j.TextEdit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import java.util.stream.Collectors;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.lsp4j.Hover;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.util.CancelIndicator;

import jakarta.inject.Inject;
import javax.inject.Inject;
import java.util.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.regnosys.rosetta.ide.inlayhints;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.lsp4j.InlayHint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.common.util.EList;
import org.eclipse.lsp4j.CodeAction;
Expand All @@ -18,8 +18,6 @@
import com.regnosys.rosetta.utils.ImportManagementService;

public class RosettaCodeActionProvider extends AbstractCodeActionProvider {
private static final String SORT_IMPORTS_LABEL = "Sort imports";

@Inject
private ImportManagementService importManagementService;
@Inject
Expand All @@ -32,14 +30,14 @@ public List<CodeAction> getCodeActions(Options options) {
// Handle Sorting CodeAction
RosettaModel model = (RosettaModel) options.getResource().getContents().get(0);
if (!importManagementService.isSorted(model.getImports())) {
result.add(codeActionUtils.createUnresolvedCodeAction(SORT_IMPORTS_LABEL, options.getCodeActionParams(),
result.add(codeActionUtils.createUnresolvedCodeAction("Sort imports", options.getCodeActionParams(),
CodeActionKind.SourceOrganizeImports));
}

return result;
}

@CodeActionResolution(SORT_IMPORTS_LABEL)
@CodeActionResolution("Sort imports")
public List<TextEdit> sortImports(RosettaModel model) {
EList<Import> imports = model.getImports();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;
import java.util.stream.Collectors;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeActionKind;
Expand All @@ -30,7 +30,6 @@
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.eclipse.xtext.ide.editor.quickfix.DiagnosticResolution;
import org.eclipse.xtext.ide.editor.quickfix.IQuickFixProvider;
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
import org.eclipse.xtext.ide.server.codeActions.ICodeActionService2;

import com.regnosys.rosetta.ide.util.CodeActionUtils;
Expand All @@ -48,16 +47,7 @@ public class RosettaCodeActionService implements ICodeActionService2 {
public List<Either<Command, CodeAction>> getCodeActions(Options options) {
List<Either<Command, CodeAction>> result = new ArrayList<>();

// By default, Xtext only reads the resource if there is a diagnostic relevant for the quick fix provider.
// However, we always require the resource, since we always check contents to, e.g., check whether the imports are sorted or not.
options.getLanguageServerAccess()
.doSyncRead(options.getURI(), (ILanguageServerAccess.Context context) -> {
options.setDocument(context.getDocument());
options.setResource(context.getResource());
return null;
});

// Handle code actions
//Handle Code Actions
List<Either<Command, CodeAction>> codeActions = codeActionProvider.getCodeActions(options).stream()
.map(action -> Either.<Command, CodeAction>forRight(action))
.collect(Collectors.toList());
Expand All @@ -68,7 +58,6 @@ public List<Either<Command, CodeAction>> getCodeActions(Options options) {
|| options.getCodeActionParams().getContext().getOnly().contains(CodeActionKind.QuickFix);

if (handleQuickfixes) {
// Handle quick fixes
List<Diagnostic> diagnostics = options.getCodeActionParams().getContext().getDiagnostics();

for (Diagnostic diagnostic : diagnostics) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.util.List;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.lsp4j.Diagnostic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;
import java.util.stream.Collectors;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeActionKind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.stream.Collectors;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.regnosys.rosetta.ide.semantictokens;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.emf.common.util.URI;
import org.eclipse.lsp4j.CodeAction;
Expand Down Expand Up @@ -62,7 +62,7 @@
* TODO: contribute to Xtext.
*
*/
public class RosettaLanguageServerImpl extends LanguageServerImpl implements RosettaLanguageServer{
public class RosettaLanguageServerImpl extends LanguageServerImpl implements RosettaLanguageServer{
@Inject FormattingOptionsAdaptor formattingOptionsAdapter;
@Inject CodeActionUtils codeActionUtils;

Expand Down Expand Up @@ -156,25 +156,16 @@ protected URI uninstallInlayHintURI(InlayHint inlayHint) {

/*** SEMANTIC TOKENS ***/
public List<SemanticToken> semanticTokens(SemanticTokensParams params, CancelIndicator cancelIndicator) {
URI uri = getURI(params.getTextDocument());
return getWorkspaceManager().doRead(uri, (document, resource) -> {
URI uri = this.getURI(params.getTextDocument());
return this.getWorkspaceManager().doRead(uri, (document, resource) -> {
ISemanticTokensService service = getService(uri, ISemanticTokensService.class);
return service.computeSemanticTokens(document, resource, params, cancelIndicator);
});
}

/**
* LSP method: textDocument/semanticTokens/full
*/
@Override
public CompletableFuture<SemanticTokens> semanticTokensFull(SemanticTokensParams params) {
return getRequestManager().runRead((cancelIndicator) -> semanticTokensFull(params, cancelIndicator));
}

@Override
protected SemanticTokens semanticTokensFull(SemanticTokensParams params, CancelIndicator cancelIndicator) {
URI uri = getURI(params.getTextDocument());
return getWorkspaceManager().doRead(uri, (document, resource) -> {
URI uri = this.getURI(params.getTextDocument());
return this.getWorkspaceManager().doRead(uri, (document, resource) -> {
ISemanticTokensService service = getService(uri, ISemanticTokensService.class);
List<SemanticToken> tokens = service.computeSemanticTokens(document, resource, params, cancelIndicator);
SemanticTokens result = service.toSemanticTokensResponse(tokens);
Expand All @@ -183,30 +174,38 @@ protected SemanticTokens semanticTokensFull(SemanticTokensParams params, CancelI
}

/**
* LSP method: textDocument/semanticTokens/full/delta
* LSP method: textDocument/semanticTokens/full
*/
@Override
public CompletableFuture<Either<SemanticTokens, SemanticTokensDelta>> semanticTokensFullDelta(SemanticTokensDeltaParams params) {
throw new UnsupportedOperationException();
public CompletableFuture<SemanticTokens> semanticTokensFull(SemanticTokensParams params) {
return this.getRequestManager().runRead((cancelIndicator) -> this.semanticTokensFull(params, cancelIndicator));
}

/**
* LSP method: textDocument/semanticTokens/range
* LSP method: textDocument/semanticTokens/full/delta
*/
@Override
public CompletableFuture<SemanticTokens> semanticTokensRange(SemanticTokensRangeParams params) {
return this.getRequestManager().runRead((cancelIndicator) -> this.semanticTokensRange(params, cancelIndicator));
public CompletableFuture<Either<SemanticTokens, SemanticTokensDelta>> semanticTokensFullDelta(SemanticTokensDeltaParams params) {
throw new UnsupportedOperationException();
}

protected SemanticTokens semanticTokensRange(SemanticTokensRangeParams params, CancelIndicator cancelIndicator) {
URI uri = getURI(params.getTextDocument());
return getWorkspaceManager().doRead(uri, (document, resource) -> {
URI uri = this.getURI(params.getTextDocument());
return this.getWorkspaceManager().doRead(uri, (document, resource) -> {
ISemanticTokensService service = getService(uri, ISemanticTokensService.class);
List<SemanticToken> tokens = service.computeSemanticTokensInRange(document, resource, params, cancelIndicator);
SemanticTokens result = service.toSemanticTokensResponse(tokens);
return result;
});
}

/**
* LSP method: textDocument/semanticTokens/range
*/
@Override
public CompletableFuture<SemanticTokens> semanticTokensRange(SemanticTokensRangeParams params) {
return this.getRequestManager().runRead((cancelIndicator) -> this.semanticTokensRange(params, cancelIndicator));
}

@Override
public CompletableFuture<FormattingOptions> getDefaultFormattingOptions() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.regnosys.rosetta.ide.server;

import jakarta.inject.Inject;
import javax.inject.Inject;

import org.eclipse.xtext.ide.server.ILanguageServerShutdownAndExitHandler;
import org.eclipse.xtext.ide.server.concurrent.RequestManager;
Expand Down
Loading
Loading