Skip to content

Commit

Permalink
Remove parameter annotation restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
TharmiganK committed Jul 17, 2024
1 parent e6836f6 commit 7bf5e95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void testInValidInputPayloadArgs() {
Package currentPackage = loadPackage("sample_package_4");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
Assert.assertEquals(diagnosticResult.errorCount(), 8);
Assert.assertEquals(diagnosticResult.errorCount(), 7);
assertError(diagnosticResult, 0, "invalid multiple resource parameter annotations for 'abc': expected one of " +
"the following types: 'http:Payload', 'http:CallerInfo', 'http:Header', 'http:Query'", HTTP_108);
assertError(diagnosticResult, 1, "invalid usage of payload annotation for a non entity body " +
Expand All @@ -147,13 +147,11 @@ public void testInValidInputPayloadArgs() {
"resource : 'head'. Use an accessor that supports entity body", HTTP_129);
assertError(diagnosticResult, 3, "invalid usage of payload annotation for a non entity body resource" +
" : 'options'. Use an accessor that supports entity body", HTTP_129);
assertError(diagnosticResult, 4, "invalid annotation type on param 'a': expected one of the following types: " +
"'http:Payload', 'http:CallerInfo', 'http:Header', 'http:Query'", CompilerPluginTestConstants.HTTP_104);
assertTrue(diagnosticResult, 5, "invalid payload parameter type: 'string|ballerina/http:",
assertTrue(diagnosticResult, 4, "invalid payload parameter type: 'string|ballerina/http:",
CompilerPluginTestConstants.HTTP_107);
assertTrue(diagnosticResult, 6, "invalid payload parameter type:",
assertTrue(diagnosticResult, 5, "invalid payload parameter type:",
CompilerPluginTestConstants.HTTP_107);
assertTrue(diagnosticResult, 7, "invalid payload parameter type:",
assertTrue(diagnosticResult, 6, "invalid payload parameter type:",
CompilerPluginTestConstants.HTTP_107);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private CompilerPluginTestConstants() {}

public static final String HTTP_101 = "HTTP_101";
public static final String HTTP_102 = "HTTP_102";
public static final String HTTP_104 = "HTTP_104";
public static final String HTTP_105 = "HTTP_105";
public static final String HTTP_106 = "HTTP_106";
public static final String HTTP_107 = "HTTP_107";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ public static void extractInputParamTypeAndValidate(SyntaxNodeAnalysisContext ct
continue;
}
if (!HTTP.equals(nameSymbolOptional.get())) {
reportInvalidParameterAnnotation(ctx, paramLocation, paramName);
continue;
}

Expand Down Expand Up @@ -452,7 +451,6 @@ public static void extractInputParamTypeAndValidate(SyntaxNodeAnalysisContext ct
break;
}
default:
reportInvalidParameterAnnotation(ctx, paramLocation, paramName);
break;
}
}
Expand Down Expand Up @@ -921,11 +919,6 @@ private static boolean isValidReturnTypeWithCaller(TypeSymbol returnTypeDescript
}
}

private static void reportInvalidParameterAnnotation(SyntaxNodeAnalysisContext ctx, Location location,
String paramName) {
updateDiagnostic(ctx, location, HttpDiagnosticCodes.HTTP_104, paramName);
}

private static void reportInvalidParameter(SyntaxNodeAnalysisContext ctx, Location location,
String paramName) {
updateDiagnostic(ctx, location, HttpDiagnosticCodes.HTTP_105, paramName);
Expand Down

0 comments on commit 7bf5e95

Please sign in to comment.