Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #332 from aashikam/deprecate
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam authored Mar 20, 2023
2 parents ccb8c69 + 9c64537 commit 78d7863
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "stan"
version = "2.6.0"
version = "2.6.1"
authors = ["Ballerina"]
keywords = ["service", "client", "messaging", "network", "streaming"]
repository = "https://github.com/ballerina-platform/module-ballerinax-stan"
Expand All @@ -21,8 +21,8 @@ path = "./lib/protobuf-java-3.20.3.jar"
[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "stan-native"
version = "2.6.0"
path = "../native/build/libs/stan-native-2.6.0.jar"
version = "2.6.1"
path = "../native/build/libs/stan-native-2.6.1-SNAPSHOT.jar"

[build-options]
observabilityIncluded=true
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "stan-compiler-plugin"
class = "io.ballerina.stdlib.stan.plugin.StanCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/stan-compiler-plugin-2.6.0.jar"
path = "../compiler-plugin/build/libs/stan-compiler-plugin-2.6.1-SNAPSHOT.jar"
4 changes: 2 additions & 2 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.0.6"
version = "1.0.7"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down Expand Up @@ -137,7 +137,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "stan"
version = "2.6.0"
version = "2.6.1"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ This file contains all the notable changes done to the Ballerina STAN package th

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- [Add deprecation warning to compiler plugin.](https://github.com/ballerina-platform/ballerina-standard-library/issues/4227)

## [2.5.0] - 2022-11-29

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ public void testValidService7() {
Assert.assertEquals(diagnosticResult.errors().size(), 0);
}

public void testDeprecationNotice() {
Package currentPackage = loadPackage("deprecation_notice");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
Assert.assertEquals(diagnosticResult.warnings().size(), 1);
Diagnostic diagnostic = (Diagnostic) diagnosticResult.warnings().toArray()[0];
assertDiagnostic(diagnostic, CompilationErrors.DEPRECATION_WARNING);
}

@Test
public void testInvalidService1() {
Package currentPackage = loadPackage("invalid_service_1");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
org = "stan_test"
name = "deprecation_notice"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerinax/stan;

public function main() returns error? {
stan:Client stanClient = check new(stan:DEFAULT_URL);
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ enum CompilationErrors {
INVALID_ANNOTATION("Invalid service config annotation. Only @nats:ServiceConfig{} is allowed.",
"STAN_116"),
INVALID_SERVICE_ATTACH_POINT("Invalid service attach point. Only string literals are allowed.",
"STAN_117");
"STAN_117"),
DEPRECATION_WARNING("The ballerinax/stan module is being deprecated. NATS enabled applications requiring " +
"persistence should use the JetStreamClient provided by ballerinax/nats module.", "STAN_118");

private final String error;
private final String errorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class StanCodeAnalyzer extends CodeAnalyzer {
@Override
public void init(CodeAnalysisContext codeAnalysisContext) {
codeAnalysisContext.addSyntaxNodeAnalysisTask(new StanImportAnalysisTask(), SyntaxKind.IMPORT_DECLARATION);
codeAnalysisContext.addSyntaxNodeAnalysisTask(new StanServiceAnalysisTask(), SyntaxKind.SERVICE_DECLARATION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.ballerina.stdlib.stan.plugin;

import io.ballerina.compiler.syntax.tree.ImportDeclarationNode;
import io.ballerina.projects.plugins.AnalysisTask;
import io.ballerina.projects.plugins.SyntaxNodeAnalysisContext;
import io.ballerina.tools.diagnostics.DiagnosticSeverity;

/**
* STAN import declaration analysis task.
*/
public class StanImportAnalysisTask implements AnalysisTask<SyntaxNodeAnalysisContext> {
@Override
public void perform(SyntaxNodeAnalysisContext context) {
ImportDeclarationNode importNode = (ImportDeclarationNode) context.node();
if (importNode.orgName().isPresent() &&
importNode.orgName().get().orgName().toString().equals(PluginConstants.PACKAGE_ORG) &&
importNode.moduleName().get(0).toString().equals(PluginConstants.PACKAGE_PREFIX)) {
context.reportDiagnostic(PluginUtils.getDiagnostic(
PluginConstants.CompilationErrors.DEPRECATION_WARNING,
DiagnosticSeverity.WARNING, importNode.location()));
}
}
}

0 comments on commit 78d7863

Please sign in to comment.