Skip to content

Commit

Permalink
Merge branch 'master' into nullable-annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow-Devil authored Dec 7, 2024
2 parents bfd9500 + 28e7cd7 commit 9bfe92f
Show file tree
Hide file tree
Showing 14 changed files with 250 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ private LambdaDetails populateAsyncLambdaDetails(BIRTerminator.AsyncCall asyncIn
lambdaDetails.lhsType = asyncIns.lhsOp != null ? asyncIns.lhsOp.variableDcl.type : null;
lambdaDetails.packageID = asyncIns.calleePkg;
lambdaDetails.funcName = asyncIns.name.getValue();
lambdaDetails.encodedFuncName = Utils.encodeFunctionIdentifier(lambdaDetails.funcName);
if (!asyncIns.isVirtual) {
populateLambdaFunctionDetails(lambdaDetails);
}
Expand Down
3 changes: 3 additions & 0 deletions distribution/zip/jballerina-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ dependencies {
dist libs.ow2.asm.util
dist libs.jackson.datatype.jsr310

// Following dependencies are required for lang-server
dist libs.sqlite.jdbc;

// Following dependencies are required for transactions
dist libs.atomikos.transactions.jta
dist libs.atomikos.transactions.api
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ slf4jJdk14Version="2.0.7"
slf4jSimpleVersion="2.0.7"
snakeyamlVersion="2.0"
sonarqubeGradlePluginVersion="4.0.0.2929"
sqliteJdbcVersion="3.47.0.0"
squareupOkioVersion="3.4.0"
swaggerModelsVersion="2.2.22"
swaggerParserV2Version="2.1.22"
Expand Down Expand Up @@ -241,6 +242,7 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4jApiVersion"}
slf4j-jdk14 = { module = "org.slf4j:slf4j-jdk14", version.ref = "slf4jJdk14Version"}
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4jSimpleVersion"}
snakeyaml = { module = "org.yaml:snakeyaml", version.ref = "snakeyamlVersion"}
sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqliteJdbcVersion"}
squareup-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpVersion"}
squareup-mock-webserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttpVersion"}
squareup-okio = { module = "com.squareup.okio:okio", version.ref = "squareupOkioVersion"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
</And>
<And>
<Bug pattern="DE_MIGHT_IGNORE"/>
<Method name="terminateDebugServer"/>
<Method name="terminateDebuggee"/>
</And>
<And>
<Bug pattern="BC_UNCONFIRMED_CAST"/>
<Or>
<Method name="attach"/>
<Method name="launch"/>
<Method name="launchDebuggeeProgram"/>
</Or>
</And>
</Or>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ void activateDynamicBreakPoints(int threadId, DynamicBreakpointMode mode, boolea
*/
private boolean isWithinSameSource(Location currentLocation, Location prevLocation) {
try {
return Objects.equals(currentLocation.sourcePath(), prevLocation.sourcePath());
return Objects.equals(currentLocation.sourcePath(), prevLocation.sourcePath())
&& Objects.equals(currentLocation.method().name(), prevLocation.method().name());
} catch (AbsentInformationException e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class DebugExecutionManager {
private static final String SOCKET_CONNECTOR_NAME = "com.sun.jdi.SocketAttach";
private static final String CONNECTOR_ARGS_HOST = "hostname";
private static final String CONNECTOR_ARGS_PORT = "port";
private static final String VALUE_UNKNOWN = "unknown";
private static final Logger LOGGER = LoggerFactory.getLogger(DebugExecutionManager.class);

DebugExecutionManager(JBallerinaDebugServer server) {
Expand All @@ -61,6 +62,12 @@ public Optional<Integer> getPort() {
return Optional.ofNullable(port);
}

public String getRemoteVMAddress() {
String host = getHost().orElse(VALUE_UNKNOWN);
String port = getPort().map(String::valueOf).orElse(VALUE_UNKNOWN);
return String.format("%s:%s", host, port);
}

/**
* Attaches to an existing JVM using an SocketAttachingConnector and returns the attached VM instance.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class DebugOutputLogger {

public DebugOutputLogger(IDebugProtocolClient client) {
this.client = client;
this.isCompilationDone = false;
}

/**
Expand Down Expand Up @@ -129,4 +130,8 @@ private static boolean isInternalLog(String output) {
|| output.startsWith("JAVACMD")
|| output.startsWith("Stream closed");
}

public void reset() {
isCompilationDone = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,24 @@ public DebugProjectCache() {
public Project getProject(Path filePath) {
Map.Entry<ProjectKind, Path> projectKindAndRoot = computeProjectKindAndRoot(filePath);
Path projectRoot = projectKindAndRoot.getValue();
if (!loadedProjects.containsKey(projectRoot)) {
addProject(loadProject(filePath.toAbsolutePath().toString()));
}
return loadedProjects.get(projectRoot);

return loadedProjects.computeIfAbsent(projectRoot, key -> loadProject(projectKindAndRoot));
}

/**
* Adds the given project instance into the cache.
*
* @param project project instance.
* Clears the project cache.
*/
public void addProject(Project project) {
Path projectSourceRoot = project.sourceRoot().toAbsolutePath();
loadedProjects.put(projectSourceRoot, project);
public void clear() {
loadedProjects.clear();
}

/**
* Loads the target ballerina source project instance using the Project API, from the file path of the open/active
* editor instance in the client(plugin) side.
*
* @param filePath file path of the open/active editor instance in the plugin side.
*/
private static Project loadProject(String filePath) {
Map.Entry<ProjectKind, Path> projectKindAndProjectRootPair = computeProjectKindAndRoot(Path.of(filePath));
ProjectKind projectKind = projectKindAndProjectRootPair.getKey();
Path projectRoot = projectKindAndProjectRootPair.getValue();
private static Project loadProject(Map.Entry<ProjectKind, Path> projectKindAndRoot) {
ProjectKind projectKind = projectKindAndRoot.getKey();
Path projectRoot = projectKindAndRoot.getValue();
BuildOptions options = BuildOptions.builder().setOffline(true).build();
if (projectKind == ProjectKind.BUILD_PROJECT) {
return BuildProject.load(projectRoot, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,12 @@ public Project getSourceProject() {
public void setSourceProject(Project sourceProject) {
this.sourceProject = sourceProject;
this.setSourceProjectRoot(sourceProject.sourceRoot().toAbsolutePath().toString());
updateProjectCache(sourceProject);
}

public DebugProjectCache getProjectCache() {
return projectCache;
}

public void updateProjectCache(Project project) {
this.projectCache.addProject(project);
}

public String getSourceProjectRoot() {
return sourceProjectRoot;
}
Expand All @@ -171,6 +166,19 @@ public boolean getSupportsRunInTerminalRequest() {
return supportsRunInTerminalRequest;
}

public void reset() {
this.projectCache.clear();
this.debugMode = null;
this.debuggeeVM = null;
this.prevLocation = null;
this.sourceProject = null;
this.launchedProcess = null;
this.sourceProjectRoot = null;
this.terminateRequestReceived = false;
this.supportsRunInTerminalRequest = false;
this.prevInstruction = DebugInstruction.CONTINUE;
}

/**
* Currently supported debug configuration modes.
*/
Expand Down
Loading

0 comments on commit 9bfe92f

Please sign in to comment.