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

Remove ORACLE_901 diagnostic hint #458

Merged
merged 4 commits into from
Nov 4, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- 2201.[0-9]+.x
- update4

jobs:
ubuntu-build:
Expand Down
12 changes: 6 additions & 6 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[package]
org = "ballerinax"
name = "oracledb"
version = "1.6.0"
version = "1.7.0"
authors = ["Ballerina"]
keywords = ["database", "client", "network", "SQL", "RDBMS", "OracleDB", "Oracle"]
repository = "https://github.com/ballerina-platform/module-ballerinax-oracledb"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.3.0"
distribution = "2201.4.0"

[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "oracledb-native"
version = "1.6.0"
path = "../native/build/libs/oracledb-native-1.6.0-SNAPSHOT.jar"
version = "1.7.0"
path = "../native/build/libs/oracledb-native-1.7.0-SNAPSHOT.jar"

[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "sql-native"
version = "1.6.0"
path = "./lib/sql-native-1.6.0-20221017-111500-2844cd5.jar"
version = "1.7.0"
path = "./lib/sql-native-1.7.0-20221104-172000-addd057.jar"

[[platform.java11.dependency]]
path = "./lib/ojdbc8-12.2.0.1.jar"
Expand Down
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 = "oracledb-compiler-plugin"
class = "io.ballerina.stdlib.oracledb.compiler.OracleDBCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/oracledb-compiler-plugin-1.6.0-SNAPSHOT.jar"
path = "../compiler-plugin/build/libs/oracledb-compiler-plugin-1.7.0-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "cache"
version = "3.4.0"
version = "3.3.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "constraint"},
Expand Down Expand Up @@ -300,7 +300,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "sql"
version = "1.6.0"
version = "1.7.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -391,7 +391,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "oracledb"
version = "1.6.0"
version = "1.7.0"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
Expand Down
2 changes: 1 addition & 1 deletion build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["database", "client", "network", "SQL", "RDBMS", "OracleDB", "Oracle
repository = "https://github.com/ballerina-platform/module-ballerinax-oracledb"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.3.0"
distribution = "2201.4.0"

[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

### Changed
- [Remove SQL_901 diagnostic hint](https://github.com/ballerina-platform/ballerina-standard-library/issues/3609)

## [1.6.0]

### Changed
- [Updated API Docs](https://github.com/ballerina-platform/ballerina-standard-library/issues/3463)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_101;
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_201;
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_202;
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_901;
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_902;
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_903;
import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.SQL_101;

/**
Expand All @@ -65,34 +62,6 @@ private Package loadPackage(String path) {
return project.currentPackage();
}

@Test
public void testFunctionHints() {
Package currentPackage = loadPackage("sample1");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
long availableErrors = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR)).count();
Assert.assertEquals(availableErrors, 3);

List<Diagnostic> diagnosticHints = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.HINT))
.collect(Collectors.toList());
long availableHints = diagnosticHints.size();
Assert.assertEquals(availableHints, 3);

DiagnosticInfo hint1 = diagnosticHints.get(0).diagnosticInfo();
Assert.assertEquals(hint1.code(), ORACLEDB_901.getCode());
Assert.assertEquals(hint1.messageFormat(), ORACLEDB_901.getMessage());

DiagnosticInfo hint2 = diagnosticHints.get(1).diagnosticInfo();
Assert.assertEquals(hint2.code(), ORACLEDB_902.getCode());
Assert.assertEquals(hint2.messageFormat(), ORACLEDB_902.getMessage());

DiagnosticInfo hint3 = diagnosticHints.get(2).diagnosticInfo();
Assert.assertEquals(hint3.code(), ORACLEDB_901.getCode());
Assert.assertEquals(hint3.messageFormat(), ORACLEDB_901.getMessage());
}

@Test
public void testSQLConnectionPoolFieldsInNewExpression() {
Package currentPackage = loadPackage("sample2");
Expand Down Expand Up @@ -164,33 +133,6 @@ public void testOutParameterValidations() {

}

@Test
public void testOutParameterHint() {
Package currentPackage = loadPackage("sample5");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
List<Diagnostic> errorDiagnosticsList = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR))
.collect(Collectors.toList());
long availableErrors = errorDiagnosticsList.size();

Assert.assertEquals(availableErrors, 1);

List<Diagnostic> hintDiagnosticsList = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.HINT))
.collect(Collectors.toList());
long availableHints = hintDiagnosticsList.size();

Assert.assertEquals(availableHints, 1);

hintDiagnosticsList.forEach(diagnostic -> {
Assert.assertEquals(diagnostic.diagnosticInfo().code(), ORACLEDB_903.getCode());
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(), ORACLEDB_903.getMessage());
});

}


@Test
public void testOptionsWithVariables() {
Package currentPackage = loadPackage("sample6");
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.ballerina.stdlib.oracledb.compiler.analyzer.InitializerParamAnalyzer;
import io.ballerina.stdlib.oracledb.compiler.analyzer.MethodAnalyzer;
import io.ballerina.stdlib.oracledb.compiler.analyzer.RecordAnalyzer;
import io.ballerina.stdlib.oracledb.compiler.analyzer.RemoteMethodAnalyzer;

import java.util.List;

Expand All @@ -35,7 +34,6 @@ public class OracleDBCodeAnalyzer extends CodeAnalyzer {

@Override
public void init(CodeAnalysisContext ctx) {
ctx.addSyntaxNodeAnalysisTask(new RemoteMethodAnalyzer(), SyntaxKind.REMOTE_METHOD_CALL_ACTION);
ctx.addSyntaxNodeAnalysisTask(new InitializerParamAnalyzer(),
List.of(SyntaxKind.IMPLICIT_NEW_EXPRESSION, SyntaxKind.EXPLICIT_NEW_EXPRESSION));
ctx.addSyntaxNodeAnalysisTask(new RecordAnalyzer(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.ballerina.tools.diagnostics.DiagnosticSeverity;

import static io.ballerina.tools.diagnostics.DiagnosticSeverity.ERROR;
import static io.ballerina.tools.diagnostics.DiagnosticSeverity.HINT;

/**
* Enum class to hold OracleDB module diagnostic codes.
Expand All @@ -37,14 +36,7 @@ public enum OracleDBDiagnosticsCode {

// Out parameter return type validations diagnostics
ORACLEDB_201("ORACLEDB_201", "invalid value: expected value is either record or object", ERROR),
ORACLEDB_202("ORACLEDB_202", "invalid value: expected value is xml", ERROR),

ORACLEDB_901("ORACLEDB_901",
"parameter 'rowType' should be explicitly passed when the return data is ignored", HINT),
ORACLEDB_902("ORACLEDB_902",
"parameter 'returnType' should be explicitly passed when the return data is ignored", HINT),
ORACLEDB_903("ORACLEDB_903",
"parameter 'typeDesc' should be explicitly passed when the return data is ignored", HINT);
ORACLEDB_202("ORACLEDB_202", "invalid value: expected value is xml", ERROR);

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
import java.util.List;
import java.util.Optional;

import static io.ballerina.stdlib.oracledb.compiler.OracleDBDiagnosticsCode.ORACLEDB_903;
import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.CANNOT_INFER_TYPE_FOR_PARAM;
import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.INCOMPATIBLE_TYPE_FOR_INFERRED_TYPEDESC_VALUE;

/**
* Code Analyser for OutParameter get method type validations.
*/
Expand All @@ -51,15 +47,10 @@ public class MethodAnalyzer implements AnalysisTask<SyntaxNodeAnalysisContext> {
public void perform(SyntaxNodeAnalysisContext ctx) {
MethodCallExpressionNode node = (MethodCallExpressionNode) ctx.node();
List<Diagnostic> diagnostics = ctx.semanticModel().diagnostics();
if (!diagnostics.isEmpty()) {
diagnostics.stream()
.filter(diagnostic -> diagnostic.diagnosticInfo().severity() == DiagnosticSeverity.ERROR)
.filter(diagnostic ->
diagnostic.diagnosticInfo().code().equals(CANNOT_INFER_TYPE_FOR_PARAM.diagnosticId()) ||
diagnostic.diagnosticInfo().code().equals(
INCOMPATIBLE_TYPE_FOR_INFERRED_TYPEDESC_VALUE.diagnosticId()))
.filter(diagnostic -> diagnostic.location().lineRange().equals(node.location().lineRange()))
.forEach(diagnostic -> addHint(ctx, node));
for (Diagnostic diagnostic : diagnostics) {
if (diagnostic.diagnosticInfo().severity() == DiagnosticSeverity.ERROR) {
return;
}
}

// Get the object type to validate arguments
Expand Down Expand Up @@ -113,28 +104,4 @@ public void perform(SyntaxNodeAnalysisContext ctx) {
node.arguments().get(0).location()));
}
}

private void addHint(SyntaxNodeAnalysisContext ctx, MethodCallExpressionNode node) {
if (!(Utils.isOracleDBObject(ctx, node.expression(), Constants.OUT_PARAMETER_POSTFIX))) {
return;
}
if (isGetMethod(ctx, node)) {
return;
}
ctx.reportDiagnostic(DiagnosticFactory.createDiagnostic(
new DiagnosticInfo(ORACLEDB_903.getCode(), ORACLEDB_903.getMessage(), ORACLEDB_903.getSeverity()),
node.location()));
}

private boolean isGetMethod(SyntaxNodeAnalysisContext ctx, MethodCallExpressionNode node) {
Optional<Symbol> methodSymbol = ctx.semanticModel().symbol(node.methodName());
if (methodSymbol.isEmpty()) {
return true;
}
Optional<String> methodName = methodSymbol.get().getName();
if (methodName.isEmpty()) {
return true;
}
return !methodName.get().equals(Constants.OutParameter.METHOD_NAME);
}
}
Loading