Skip to content
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4dac044
WIP: adding pom.xml validator to the extension
rodinaarssen Jul 31, 2026
8de5482
Launch REPL for open Rascal project.
toinehartman Aug 4, 2026
2d0f50d
Work around nullability analysis.
toinehartman Aug 5, 2026
2b9a392
Fix Maven resolution.
toinehartman Aug 5, 2026
8a99601
Merge branch 'feature/remove-std-scheme' into feature/add-pomxml-vali…
toinehartman Aug 6, 2026
0024640
Merge remote-tracking branch 'origin/feature/remove-std-scheme' into …
toinehartman Aug 7, 2026
3dbbc5e
WIP: Add pom analyzer in Rascal.
toinehartman Aug 24, 2026
37968f2
Improvements.
toinehartman Aug 25, 2026
a755a31
Merge remote-tracking branch 'origin/main' into feature/add-pomxml-va…
rodinaarssen Sep 4, 2026
55fca31
Merge remote-tracking branch 'refs/remotes/origin/feature/add-pomxml-…
rodinaarssen Sep 4, 2026
b3a8714
PomValidator progress
rodinaarssen Sep 10, 2026
e62939f
Added cache for pom.xml files
rodinaarssen Sep 14, 2026
b4ec870
Added missing license
rodinaarssen Sep 14, 2026
6754d06
Added keyword parameters for the versions
rodinaarssen Sep 14, 2026
39ada87
Made pom analyzer more robust
rodinaarssen Sep 14, 2026
d03ec97
Added support for exclusions
rodinaarssen Sep 14, 2026
30026f5
Wired up pom analyzer in the global analyzer
rodinaarssen Sep 14, 2026
bf82636
Added Rascal dependency check to analyzer
rodinaarssen Sep 14, 2026
bf215fd
Improved rascal-lsp dependency check
rodinaarssen Sep 14, 2026
dbb6033
Removed TS implementation of the pom.xml analyzer
rodinaarssen Sep 14, 2026
a49f1b9
Added comment
rodinaarssen Sep 14, 2026
dc4c458
Removed reference to removed file
rodinaarssen Sep 14, 2026
a61a968
Removed code action that no longer exists
rodinaarssen Sep 14, 2026
faaa5d7
Merge remote-tracking branch 'origin/main' into feature/add-pomxml-va…
rodinaarssen Sep 15, 2026
2c651a8
Newline detection is now robust against single-line pom.xml files
rodinaarssen Sep 15, 2026
386eaf9
Added Java functions to obtain Maven dependencies
rodinaarssen Sep 15, 2026
25250ed
Rewrote addDependency TextEdit generation to work on plain nodes
rodinaarssen Sep 15, 2026
65793a5
Cleanup of PomAnalyzer.rsc
rodinaarssen Sep 15, 2026
8c82320
Analyzer now uses proper PomAnalyzer functions
rodinaarssen Sep 15, 2026
65e98dd
Merge branch 'main' into feature/add-pomxml-validator
rodinaarssen Sep 15, 2026
4ef3048
Using SpecificationVersion first to find the active rascal-lsp version
rodinaarssen Sep 15, 2026
9415c2d
Added Rascal commands in favor of plain text edits
rodinaarssen Sep 15, 2026
7b7ba65
Removed pom.xml check for a Rascal dependency; this is moved to Rascal
rodinaarssen Sep 15, 2026
4848d6f
Added custom code action provider for xml files to be able to provide…
rodinaarssen Sep 21, 2026
f7fd701
Made Rascal version check robust against running from a target folder
rodinaarssen Sep 21, 2026
4285706
Always read full pom.xml files
rodinaarssen Sep 21, 2026
f19683d
Correctly added argument to command
rodinaarssen Sep 21, 2026
c62b360
RascalTextDocumentService also handles xml files now
rodinaarssen Sep 21, 2026
73ad8d5
Fixed typo
rodinaarssen Sep 21, 2026
01aafa0
Extracted code action conversion function
rodinaarssen Sep 21, 2026
1d4f791
Prevent RascalTextDocumentService from trying to parse pom.xml files …
rodinaarssen Sep 21, 2026
d5701cb
Fixed ShellEvaluatorFactory call after a formal argument got removed …
rodinaarssen Sep 21, 2026
9a72d44
Fixed off-by-one error and added an overload for inferNewline in the …
rodinaarssen Sep 22, 2026
bc37a5b
Added tests for the pom.xml analyzer
rodinaarssen Sep 22, 2026
44ca5de
Slightly simplified inferIndentation
rodinaarssen Sep 22, 2026
e933c47
Removed unused code
rodinaarssen Sep 22, 2026
75f44a8
Unexported a variable
rodinaarssen Sep 22, 2026
5fc6530
Only provide code actions for pom.xml files instead of for all xml files
rodinaarssen Sep 22, 2026
b5c0cba
Using latest RC of Rascal
rodinaarssen Sep 22, 2026
6e2ec42
Removed unused imports
rodinaarssen Sep 22, 2026
f8ad534
Fixed CF error
rodinaarssen Sep 22, 2026
71c59be
Incorporated feedback by @DavyLandman
rodinaarssen Sep 22, 2026
b549a59
Moved code action provider for pom.xml files to a discrete class
rodinaarssen Sep 22, 2026
828b681
Got rid of fixed back-up versions for rascal and rascal-lsp in the code
rodinaarssen Sep 22, 2026
6dcdf51
Unused import removed
rodinaarssen Sep 22, 2026
0dac9f0
Changed log level
rodinaarssen Sep 22, 2026
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
Expand Up @@ -279,7 +279,7 @@ public void initialized() {

@Override
public Collection<String> extensions() {
return Set.of("rsc");
return Set.of("rsc", "xml");
}

// LSP interface methods
Expand Down Expand Up @@ -657,6 +657,10 @@ public CompletableFuture<List<Either<Command, CodeAction>>> codeAction(CodeActio
CompletableFuture<Stream<IValue>> quickfixes
= CodeActions.extractActionsFromDiagnostics(params, availableRascalServices()::parseCodeActions, exec);

if (params.getTextDocument().getUri().endsWith("pom.xml")) {
return CodeActions.convertCodeActions(this, "", BaseWorkspaceService.RASCAL_LANGUAGE, quickfixes);
}

// here we dynamically ask the contributions for more actions,
// based on the cursor position in the file and the current parse tree
CompletableFuture<Stream<IValue>> codeActions = recoverExceptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ public static CompletableFuture<Stream<IValue>> extractActionsFromDiagnostics(Co

/* merges two streams of CodeAction terms and then converts them to LSP objects */
public static CompletableFuture<List<Either<Command, CodeAction>>> mergeAndConvertCodeActions(IBaseTextDocumentService doc, String dedicatedLanguageName, String languageName, CompletableFuture<Stream<IValue>> quickfixes, CompletableFuture<Stream<IValue>> codeActions) {
return codeActions.thenCombine(quickfixes, (actions, quicks) ->
Stream.concat(quicks, actions)
.map(IConstructor.class::cast)
.map(cons -> constructorToCodeAction(doc, dedicatedLanguageName, languageName, cons))
.map(Either::<Command,CodeAction>forRight)
.collect(Collectors.toList())
);
return convertCodeActions(doc, dedicatedLanguageName, languageName, codeActions.thenCombine(quickfixes, (actions, quicks) -> Stream.concat(quicks, actions)));
}

public static CompletableFuture<List<Either<Command, CodeAction>>> convertCodeActions(IBaseTextDocumentService doc, String dedicatedLanguageName, String languageName, CompletableFuture<Stream<IValue>> items) {
return items.thenApply(is -> is
.map(IConstructor.class::cast)
.map(cons -> constructorToCodeAction(doc, dedicatedLanguageName, languageName, cons))
.map(Either::<Command,CodeAction>forRight)
.collect(Collectors.toList()))
;
}

private static CodeAction constructorToCodeAction(IBaseTextDocumentService doc, String dedicatedLanguageName, String languageName, IConstructor codeAction) {
Expand Down Expand Up @@ -131,7 +134,7 @@ private static CodeAction constructorToCodeAction(IBaseTextDocumentService doc,

/**
* Translates `refactor(inline())` to `"refactor.inline"` and `empty()` to `""`, etc.
* `kind == null` signals absence of the optional parameter. This is factorede into
* `kind == null` signals absence of the optional parameter. This is factored into
* this private function because otherwise every call has to check it.
*/
private static String constructorToCodeActionKind(@Nullable IConstructor kind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@
String jobName = "Loading " + label;
try {
services.jobStart(jobName, imports.length);
var eval = ShellEvaluatorFactory.getDefaultEvaluatorForPathConfig(

Check failure on line 386 in rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

View workflow job for this annotation

GitHub Actions / normal-tests

no suitable method found for getDefaultEvaluatorForPathConfig(org.rascalmpl.library.util.PathConfig,java.io.Reader,java.io.PrintWriter,java.io.PrintWriter,org.rascalmpl.ideservices.IDEServices)

Check failure on line 386 in rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

View workflow job for this annotation

GitHub Actions / normal-tests

no suitable method found for getDefaultEvaluatorForPathConfig(org.rascalmpl.library.util.PathConfig,java.io.Reader,java.io.PrintWriter,java.io.PrintWriter,org.rascalmpl.ideservices.IDEServices)

Check failure on line 386 in rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

View workflow job for this annotation

GitHub Actions / ui-test (macos-latest)

no suitable method found for getDefaultEvaluatorForPathConfig(org.rascalmpl.library.util.PathConfig,java.io.Reader,java.io.PrintWriter,java.io.PrintWriter,org.rascalmpl.ideservices.IDEServices)

Check failure on line 386 in rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

View workflow job for this annotation

GitHub Actions / ui-test (macos-latest)

no suitable method found for getDefaultEvaluatorForPathConfig(org.rascalmpl.library.util.PathConfig,java.io.Reader,java.io.PrintWriter,java.io.PrintWriter,org.rascalmpl.ideservices.IDEServices)

Check failure on line 386 in rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

View workflow job for this annotation

GitHub Actions / ui-test (ubicloud-standard-4)

no suitable method found for getDefaultEvaluatorForPathConfig(org.rascalmpl.library.util.PathConfig,java.io.Reader,java.io.PrintWriter,java.io.PrintWriter,org.rascalmpl.ideservices.IDEServices)

Check failure on line 386 in rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

View workflow job for this annotation

GitHub Actions / ui-test (ubicloud-standard-4)

no suitable method found for getDefaultEvaluatorForPathConfig(org.rascalmpl.library.util.PathConfig,java.io.Reader,java.io.PrintWriter,java.io.PrintWriter,org.rascalmpl.ideservices.IDEServices)
pcfg.getProjectRoot(),
pcfg,
Reader.nullReader(),
logWriter(customLog, Level.INFO),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.rascalmpl.vscode.lsp.xml;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Properties;

import org.rascalmpl.util.maven.Artifact;
import org.rascalmpl.util.maven.MavenParser;
import org.rascalmpl.util.maven.ModelResolutionError;
import org.rascalmpl.util.maven.Scope;

import io.usethesource.vallang.IBool;
import io.usethesource.vallang.ISourceLocation;
import io.usethesource.vallang.IString;
import io.usethesource.vallang.IValueFactory;

public class PomAnalyzer {
private IValueFactory vf;

public PomAnalyzer(IValueFactory vf) {
this.vf = vf;
}

IBool hasDependency(ISourceLocation pomLoc, String groupId, String artifactId) {
try {
var mavenParser = new MavenParser(Path.of(pomLoc.getURI()));
var rootProject = mavenParser.parseProject();
var resolvedDependencies = rootProject.resolveDependencies(Scope.COMPILE, mavenParser);
return vf.bool(resolvedDependencies.stream()
.map(Artifact::getCoordinate)
.filter(a -> a.getGroupId().equals(groupId) && a.getArtifactId().equals(artifactId))
.findAny()
.isPresent());
Comment thread
rodinaarssen marked this conversation as resolved.
Outdated
} catch (ModelResolutionError e) {
return vf.bool(false);
}
}

public IBool hasRascalDependency(ISourceLocation pomLoc) {
return hasDependency(pomLoc, "org.rascalmpl", "rascal");
}

public IBool hasRascalLspDependency(ISourceLocation pomLoc) {
return hasDependency(pomLoc, "org.rascalmpl", "rascal-lsp");
}

public IString getCurrentRascalLspVersion() {
var specificationVersion = PomAnalyzer.class.getPackage().getSpecificationVersion();
if (specificationVersion != null) {
return vf.string(specificationVersion);
}

try (InputStream prop = PomAnalyzer.class.getClassLoader().getResourceAsStream("project.properties")) {
if (prop != null) {
Properties properties = new Properties();
properties.load(prop);
var version = properties.getProperty("rascal.lsp.version");
if (version != null) {
return vf.string(version);
}
}
} catch (IOException e) {
// Fall through
}

var fallbackVersion = "2.22.5";
return vf.string(fallbackVersion);
Comment thread
rodinaarssen marked this conversation as resolved.
Outdated
}
}
12 changes: 12 additions & 0 deletions rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/Actions.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import util::Reflective;
import util::IDEServices;
import List;
import IO;
import lang::xml::PomAnalyzer;

@synopsis{Here we list Rascal-specific code commands}
@description{
Expand All @@ -48,6 +49,8 @@ data Command
= visualImportGraphCommand(PathConfig pcfg)
| sortImportsAndExtends(Header h)
| upgradeAnnotations(PathConfig pcfg)
| addRascalDependencyToPom(loc pomLoc)
| addRascalLspDependencyToPom(loc pomLoc)
;


Expand Down Expand Up @@ -165,3 +168,12 @@ value evaluateRascalCommand(upgradeAnnotations(PathConfig pcfg)) {
return ("result":true);
}

value evaluateRascalCommand(addRascalDependencyToPom(loc pomLoc)) {
applyDocumentsEdits([changed(pomLoc, [addRascalDependency(pomLoc)])]);
return ("result": true);
}

value evaluateRascalCommand(addRascalLspDependencyToPom(loc pomLoc)) {
applyDocumentsEdits([changed(pomLoc, [addRascalLspDependency(pomLoc)])]);
return ("result": true);
}
16 changes: 15 additions & 1 deletion rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/Analyzer.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ import IO;
import String;
import ParseTree;
import util::IDEServices;
import util::Maybe;
import util::PathConfig;
import lang::rascal::\syntax::Rascal;
import lang::rascal::lsp::Actions;
import lang::xml::PomAnalyzer;


@synopsis{A fast analyzer, is run on most parse trees, so it should be fast}
list[Message] analyze(start[Module] tree, PathConfig(loc file) getPathConfig) {
result = [];
pcfg = getPathConfig(tree.src.top);
Comment thread
rodinaarssen marked this conversation as resolved.
Outdated

annotationAlreadyReported = false;
void reportAnnotationDeprecation(Tree t) {
Expand All @@ -48,7 +51,7 @@ list[Message] analyze(start[Module] tree, PathConfig(loc file) getPathConfig) {
"Annotations are no longer supported and will soon be removed, please use our build-in Quick Fix to refactor all of them into keyword parameters",
t.src, fixes=[
action(
command=upgradeAnnotations(getPathConfig(t.src.top)),
command=upgradeAnnotations(pcfg),
title="Upgrade all annotations to keyword fields in this project (annotation syntax is no longer supported)."
)
]
Expand All @@ -66,6 +69,16 @@ list[Message] analyze(start[Module] tree, PathConfig(loc file) getPathConfig) {
result += error("`<s>://` scheme is not supported anymore. In most cases it can be replaced by <illegalSchemeSuggestions[s]>", l.src);
}

case i:(Import)`import util::LanguageServer;`: {
pomLoc = pcfg.projectRoot + "pom.xml";
if (!hasRascalLspDependency(pomLoc)) {
result += warning(
"Importing `util::LanguageServer` requires a dependency on `rascal-lsp`",
i.src, fixes=[action(title="Add rascal-lsp dependency to pom.xml", command=addRascalLspDependencyToPom(pomLoc))]
);
}
}

// annotation cases
case t:(Declaration) `<Tags _> <Visibility _> anno <Type _> <Type _> @ <Name _>;`: reportAnnotationDeprecation(t);
case t:(Expression)`<Expression _>[@ <Name _> = <Expression _>]`: reportAnnotationDeprecation(t);
Expand All @@ -76,6 +89,7 @@ list[Message] analyze(start[Module] tree, PathConfig(loc file) getPathConfig) {
case t:(Expression) `delAnnotation(<Expression _>, <Expression _>)`: reportAnnotationDeprecation(t);
case t:(Catch) `catch NoSuchAnnotation(<Pattern _>) : <Statement _>`: reportAnnotationDeprecation(t);
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
@license{
Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
module lang::rascal::tests::pom::PomAnalyzerTests

import IO;
import String;
import analysis::diff::edits::TextEdits;
import lang::xml::PomAnalyzer;

public str pomWithRascal = "\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>
'\<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
'xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\>
' \<modelVersion\>4.0.0\</modelVersion\>
'
' \<groupId\>org.rascalmpl\</groupId\>
' \<artifactId\>test-lib\</artifactId\>
' \<version\>0.1.0-SNAPSHOT\</version\>
'
' \<dependencies\>
' \<dependency\>
' \<groupId\>org.rascalmpl\</groupId\>
' \<artifactId\>rascal\</artifactId\>
' \<version\>0.43.0-RC14\</version\>
' \</dependency\>
' \</dependencies\>
'\</project\>";

public str pomWithoutDependencies = "\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>
'\<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
'xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\>
' \<modelVersion\>4.0.0\</modelVersion\>
'
' \<groupId\>org.rascalmpl\</groupId\>
' \<artifactId\>test-lib\</artifactId\>
' \<version\>0.1.0-SNAPSHOT\</version\>
'
'\</project\>";

public str pomWithEmptyDependenciesBlock = "\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>
'\<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
'xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\>
' \<modelVersion\>4.0.0\</modelVersion\>
'
' \<groupId\>org.rascalmpl\</groupId\>
' \<artifactId\>test-lib\</artifactId\>
' \<version\>0.1.0-SNAPSHOT\</version\>
'
' \<dependencies\>
' \</dependencies\>
'\</project\>";

public str pomWithNonEmptyDependenciesBlock = "\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>
'\<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
'xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"\>
' \<modelVersion\>4.0.0\</modelVersion\>
'
' \<groupId\>org.rascalmpl\</groupId\>
' \<artifactId\>test-lib\</artifactId\>
' \<version\>0.1.0-SNAPSHOT\</version\>
'
' \<dependencies\>
' \<dependency\>
' \<groupId\>org.rascalmpl\<groupId\>
' \<artifactId\>vallang\</artifactId\>
' \<version\>0.15.1\</version\>
' \</dependency\>
' \</dependencies\>
'\</project\>";

// `Path.of` does not like `memory` or plain `tmp` locations
public loc pomLoc = resolveLocation(|tmp:///rascal-pomxml-test/pom.xml|);

test bool testPomWithRascal() {
writeFile(pomLoc, pomWithRascal);
return hasRascalDependency(pomLoc);
}

test bool testPomWithoutDependencies() {
writeFile(pomLoc, pomWithoutDependencies);
if (hasRascalDependency(pomLoc)) {
return false;
}
edit = addRascalDependency(pomLoc);
newline = inferNewline(pomLoc);
expectedLoc = pomLoc(381 + 7 * size(newline),0,<8,35>,<8,35>);
return replace(expectedLoc, / <newline><newline> \<dependencies\><newline> \<dependency\><newline> \<groupId\>org.rascalmpl\<\/groupId\><newline> \<artifactId\>rascal\<\/artifactId\><newline> \<version\>[^\<]*\<\/version\><newline> \<\/dependency\><newline> \<\/dependencies\>/) := edit;
}

test bool testPomWithEmptyDependenciesBlock() {
writeFile(pomLoc, pomWithEmptyDependenciesBlock);
if (hasRascalDependency(pomLoc)) {
return false;
}
edit = addRascalDependency(pomLoc);
newline = inferNewline(pomLoc);
expectedLoc = pomLoc(383 + 9 * size(newline),31 + size(newline),<10,2>,<11,17>);
return replace(expectedLoc, /\<dependencies\><newline> \<dependency\><newline> \<groupId\>org.rascalmpl\<\/groupId\><newline> \<artifactId\>rascal\<\/artifactId\><newline> \<version\>[^\<]*\<\/version\><newline> \<\/dependency\><newline> \<\/dependencies\>/) := edit;
}

test bool testPomWithNonEmptyDependenciesBlock() {
writeFile(pomLoc, pomWithNonEmptyDependenciesBlock);
if (hasRascalDependency(pomLoc)) {
return false;
}
edit = addRascalDependency(pomLoc);
newline = inferNewline(pomLoc);
expectedLoc = pomLoc(397 + 10 * size(newline),0,<11,0>,<11,0>);
return replace(expectedLoc, / \<dependency\><newline> \<groupId\>org.rascalmpl\<\/groupId\><newline> \<artifactId\>rascal\<\/artifactId\><newline> \<version\>[^\<]*\<\/version\><newline> \<\/dependency\><newline>/) := edit;
}

test bool testAddRascalLspDependency() {
writeFile(pomLoc, pomWithNonEmptyDependenciesBlock);
if (hasRascalLspDependency(pomLoc)) {
return false;
}
edit = addRascalLspDependency(pomLoc);
newline = inferNewline(pomLoc);
expectedLoc = pomLoc(397 + 10 * size(newline),0,<11,0>,<11,0>);
return replace(expectedLoc, / \<dependency\><newline> \<groupId\>org.rascalmpl\<\/groupId\><newline> \<artifactId\>rascal-lsp\<\/artifactId\><newline> \<version\>[^\<]*\<\/version\><newline> \<\/dependency\><newline>/) := edit;
}

Loading
Loading