Skip to content

Commit

Permalink
Merge branch 'ballerina-platform:master' into fix-xml-member-access-type
Browse files Browse the repository at this point in the history
  • Loading branch information
MaryamZi authored Oct 8, 2024
2 parents 2f37ab3 + 8197500 commit ebe9bc4
Show file tree
Hide file tree
Showing 1,110 changed files with 25,833 additions and 7,138 deletions.
12 changes: 7 additions & 5 deletions ballerina-shell/modules/shell-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* under the License.
*/

apply from: "$rootDir/gradle/javaProject.gradle"
apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle"
plugins {
id 'javaProject'
id 'ballerinaLangLibLoad'
}

description = 'Ballerina - Ballerina Shell CLI'

Expand All @@ -26,12 +28,12 @@ group = 'io.ballerina'
dependencies {
implementation project(":ballerina-shell:shell-core")
implementation project(':ballerina-parser')
implementation("org.jline:jline:${project.jlineVersion}")
implementation libs.jline
implementation project(':ballerina-lang')
implementation project(':ballerina-tools-api')

testImplementation('org.testng:testng')
implementation 'com.google.code.gson:gson:2.10.1'
testImplementation libs.testng
implementation libs.gson
}

compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -54,7 +54,7 @@ public String getDescription(String topic) throws HelpProviderException {
private static String readFileAsString(String file) throws HelpProviderException {
String content;
try {
content = Files.readString(Paths.get(file));
content = Files.readString(Path.of(file));
} catch (IOException e) {
throw new HelpProviderException("Error occurred while executing the command");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
*/
public class BbeRecord {

private String name;
private String url;
private String verifyBuild;
private String verifyOutput;
private String isLearnByExample;
private final String name;
private final String url;
private final String verifyBuild;
private final String verifyOutput;
private final String isLearnByExample;

public BbeRecord(String name, String url, String verifyBuild, String verifyOutput, String isLearnByExample) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*/
public class BbeTitle {

private String title;
private String column;
private String category;
private BbeRecord[] samples;
private final String title;
private final String column;
private final String category;
private final BbeRecord[] samples;

public BbeTitle(String title, String column, String category, BbeRecord[] samples) {
this.title = title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -88,7 +88,7 @@ public List<String> getTopicList() {
private String readFileAsString(String file) {
String content = null;
try {
content = Files.readString(Paths.get(file));
content = Files.readString(Path.of(file));
} catch (IOException e) {
addDebugDiagnostic("Error loading the file : " + e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public interface HelpProvider {
*
* @param args All the arguments given by requester.
* @param output Builder to append output.
* @throws HelpProviderException If fetching help failed.
*/
void getTopic(String[] args, StringBuilder output) throws HelpProviderException;
void getTopic(String[] args, StringBuilder output);
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void run() {
testCase.getDescription());
stdoutStream.reset();
}
} catch (IOException | InterruptedException ignored) {
} catch (IOException ignored) {
}
}

Expand All @@ -115,7 +115,7 @@ private String readResponse(BufferedReader stream) throws IOException {
/**
* Send the data given to the specific stream.
*/
private void sendRequest(PrintStream stream, String string) throws InterruptedException {
private void sendRequest(PrintStream stream, String string) {
// This is a workaround since with double `System.lineSeparator()` the tests fail on windows.
stream.append(string).append("\n\n").flush();
}
Expand Down
12 changes: 7 additions & 5 deletions ballerina-shell/modules/shell-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* under the License.
*/

apply from: "$rootDir/gradle/javaProject.gradle"
apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle"
plugins {
id 'javaProject'
id 'ballerinaLangLibLoad'
}

description = 'Ballerina - Ballerina Shell'

Expand All @@ -30,10 +32,10 @@ dependencies {
implementation project(':ballerina-tools-api')
implementation project(':ballerina-runtime')
implementation project(':identifier-util')
implementation 'com.github.spullara.mustache.java:compiler'
implementation libs.mustache.java.compiler

testImplementation('org.testng:testng')
testImplementation('com.google.code.gson:gson')
testImplementation libs.testng
testImplementation libs.gson
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashSet;
import java.util.Optional;
Expand Down Expand Up @@ -166,7 +166,7 @@ public String getBufferFileUri() throws IOException {
@Override
public void evaluateDeclarationFile(String filePath) throws BallerinaShellException {
try {
String statements = Files.readString(Paths.get(filePath), Charset.defaultCharset());
String statements = Files.readString(Path.of(filePath), Charset.defaultCharset());
Collection<Node> nodes = treeParser.parseDeclarations(statements);
Collection<Snippet> snippets = snippetFactory.createSnippets(nodes);
getValue(Optional.ofNullable(invoker.getCompilation(snippets)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,9 @@ public DualTreeParserTrial(TrialTreeParser parentParser) {
}

@Override
public Collection<Node> parse(String source) throws ParserTrialFailedException {
try {
return parseSource(source);
} catch (ParserTrialFailedException e) {
if (source.endsWith(SEMICOLON)) {
return parseSource(source.substring(0, source.length() - 1));
}
throw e;
}
public Collection<Node> parse(String source) {
return parseSource(source);
}

public abstract Collection<Node> parseSource(String source) throws ParserTrialFailedException;
public abstract Collection<Node> parseSource(String source);
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public abstract ModuleMemberDeclarationSnippet createModuleMemberDeclarationSnip
* @param node Root node to create snippet from.
* @return Snippet that contains the node.
*/
public abstract Snippet createExpressionSnippet(Node node) throws SnippetException;
public abstract Snippet createExpressionSnippet(Node node);

/**
* Snippet creation helper interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class AbstractEvaluatorTest {
*
* @param fileName File containing test cases.
*/
protected void testEvaluate(String fileName) throws BallerinaShellException {
protected void testEvaluate(String fileName) {
// Create evaluator
TestInvoker invoker = new TestInvoker();
Evaluator evaluator = new EvaluatorBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.ballerina.shell.test.evaluator;

import io.ballerina.shell.exceptions.BallerinaShellException;
import org.testng.annotations.Test;

/**
Expand All @@ -31,22 +30,22 @@ public class ActionEvaluatorTest extends AbstractEvaluatorTest {
private static final String VAR_EVALUATOR_TESTCASE = "testcases/evaluator/actions.var.json";

@Test
public void testEvaluateStart() throws BallerinaShellException {
public void testEvaluateStart() {
testEvaluate(START_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateRemote() throws BallerinaShellException {
public void testEvaluateRemote() {
testEvaluate(REMOTE_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateResource() throws BallerinaShellException {
public void testEvaluateResource() {
testEvaluate(RESOURCE_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateVar() throws BallerinaShellException {
public void testEvaluateVar() {
testEvaluate(VAR_EVALUATOR_TESTCASE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.ballerina.shell.test.evaluator;

import io.ballerina.shell.exceptions.BallerinaShellException;
import org.testng.annotations.Test;

/**
Expand All @@ -34,27 +33,27 @@ public class BasicTypeEvaluatorTest extends AbstractEvaluatorTest {
private static final String MAPS_EVALUATOR_TESTCASE = "testcases/evaluator/values.maps.json";

@Test
public void testEvaluateString() throws BallerinaShellException {
public void testEvaluateString() {
testEvaluate(STRING_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateTuples() throws BallerinaShellException {
public void testEvaluateTuples() {
testEvaluate(TUPLES_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateArrays() throws BallerinaShellException {
public void testEvaluateArrays() {
testEvaluate(ARRAYS_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateTable() throws BallerinaShellException {
public void testEvaluateTable() {
testEvaluate(TABLE_EVALUATOR_TESTCASE);
}

@Test
public void testEvaluateMaps() throws BallerinaShellException {
public void testEvaluateMaps() {
testEvaluate(MAPS_EVALUATOR_TESTCASE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.ballerina.shell.test.evaluator;

import io.ballerina.shell.exceptions.BallerinaShellException;
import org.testng.annotations.Test;

/**
Expand All @@ -38,48 +37,48 @@ public class BasicsEvaluatorTest extends AbstractEvaluatorTest {
private static final String BASICS_ERRORS_TESTCASE = "testcases/evaluator/basics.errors.json";

@Test
public void testBasicsModules() throws BallerinaShellException {
public void testBasicsModules() {
// TODO: Improve after custom classpath support
testEvaluate(BASICS_MODULES_TESTCASE);
}

@Test
public void testBasicsVariables() throws BallerinaShellException {
public void testBasicsVariables() {
testEvaluate(BASICS_VARIABLES_TESTCASE);
}

@Test
public void testEvaluateBasicsVar() throws BallerinaShellException {
public void testEvaluateBasicsVar() {
testEvaluate(BASICS_VAR_TESTCASE);
}

@Test
public void testEvaluateBasicsFunctions() throws BallerinaShellException {
public void testEvaluateBasicsFunctions() {
testEvaluate(BASICS_FUNCTIONS_TESTCASE);
}

@Test
public void testEvaluateBasicsReqParams() throws BallerinaShellException {
public void testEvaluateBasicsReqParams() {
testEvaluate(BASICS_REQ_PARAMS_TESTCASE);
}

@Test
public void testEvaluateBasicsDefParams() throws BallerinaShellException {
public void testEvaluateBasicsDefParams() {
testEvaluate(BASICS_DEF_PARAMS_TESTCASE);
}

@Test
public void testEvaluateBasicsRestParams() throws BallerinaShellException {
public void testEvaluateBasicsRestParams() {
testEvaluate(BASICS_REST_PARAMS_TESTCASE);
}

@Test
public void testEvaluateBasicsQuoted() throws BallerinaShellException {
public void testEvaluateBasicsQuoted() {
testEvaluate(BASICS_QUOTED_TESTCASE);
}

@Test
public void testEvaluateBasicsErrors() throws BallerinaShellException {
public void testEvaluateBasicsErrors() {
testEvaluate(BASICS_ERRORS_TESTCASE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.ballerina.shell.test.evaluator;

import io.ballerina.shell.exceptions.BallerinaShellException;
import org.testng.annotations.Test;

/**
Expand All @@ -30,7 +29,7 @@ public class BehaviorTypeEvaluatorTest extends AbstractEvaluatorTest {
private static final String STREAM_EVALUATOR_TESTCASE = "testcases/evaluator/streams.streams.json";

@Test
public void testEvaluateSteams() throws BallerinaShellException {
public void testEvaluateSteams() {
testEvaluate(STREAM_EVALUATOR_TESTCASE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.ballerina.shell.test.evaluator;

import io.ballerina.shell.exceptions.BallerinaShellException;
import org.testng.annotations.Test;

/**
Expand All @@ -31,7 +30,7 @@ public class ConcurrencyEvaluatorTest extends AbstractEvaluatorTest {
private static final String LOCK_EVALUATOR_TESTCASE = "testcases/evaluator/concurrency.lock.json";

@Test
public void testEvaluateLock() throws BallerinaShellException {
public void testEvaluateLock() {
testEvaluate(LOCK_EVALUATOR_TESTCASE);
}
}
Loading

0 comments on commit ebe9bc4

Please sign in to comment.