-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57e8fc0
commit bc631dc
Showing
154 changed files
with
6,758 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_1/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "http_test" | ||
name = "codeaction_sample_1" | ||
version = "0.1.0" |
28 changes: 28 additions & 0 deletions
28
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_1/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. 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 ballerina/http; | ||
|
||
service / on new http:Listener(9999) { | ||
|
||
resource function get . (@http:Header json length) { | ||
|
||
} | ||
|
||
resource function get path1(http:Caller caller) returns string { | ||
return ""; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_2/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "http_test" | ||
name = "codeaction_sample_2" | ||
version = "0.1.0" |
35 changes: 35 additions & 0 deletions
35
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_2/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. 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 ballerina/http; | ||
|
||
service /greeting on new http:Listener(0) { | ||
resource function get hi() returns string { | ||
return "hi"; | ||
} | ||
|
||
resource function post hi(@http:Payload string payload) returns string { | ||
return "hi"; | ||
} | ||
|
||
resource function post hello() returns string { | ||
return "hello"; | ||
} | ||
|
||
resource function post hey(@http:Header string header) returns string { | ||
return "hey"; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_3/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "http_test" | ||
name = "codeaction_sample_3" | ||
version = "0.1.0" |
42 changes: 42 additions & 0 deletions
42
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_3/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. 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. | ||
|
||
// This is added to test some auto generated code segments. | ||
// Please ignore the indentation. | ||
|
||
import ballerina/http; | ||
|
||
service class RequestInterceptor { | ||
*http:RequestInterceptor; | ||
} | ||
|
||
service class RequestErrorInterceptor { | ||
*http:RequestErrorInterceptor; | ||
} | ||
|
||
service class ResponseInterceptor { | ||
*http:ResponseInterceptor; | ||
} | ||
|
||
service class ResponseErrorInterceptor { | ||
*http:ResponseErrorInterceptor; | ||
} | ||
|
||
service /greeting on new http:Listener(9090) { | ||
resource function get hi() returns string { | ||
return "hi"; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_4/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "http_test" | ||
name = "codeaction_sample_4" | ||
version = "0.1.0" |
186 changes: 186 additions & 0 deletions
186
compiler-plugin-tests/bin/test/ballerina_sources/sample_codeaction_package_4/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org). | ||
// | ||
// 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. | ||
|
||
// This is added to test some auto generated code segments. | ||
// Please ignore the indentation. | ||
|
||
import ballerina/http; | ||
|
||
import ballerina/http; | ||
import ballerina/log; | ||
|
||
# The service type that handles the social media API | ||
@http:ServiceConfig { | ||
mediaTypeSubtypePrefix: "vnd.socialMedia", | ||
basePath: "/socialMedia" | ||
} | ||
public type Service service object { | ||
*http:ServiceContract; | ||
*http:InterceptableService; | ||
|
||
public function createInterceptors() returns ErrorInterceptor; | ||
|
||
# Get all users | ||
# | ||
# + return - List of users(`User[]`) or an error | ||
@http:ResourceConfig { | ||
name: "users" | ||
} | ||
resource function get users() returns @http:Cache {maxAge: 10} User[]|error; | ||
|
||
# Get a user by ID | ||
# | ||
# + id - User ID | ||
# + return - `User` or NotFound response(`UserNotFound`) when the user is not found or an error | ||
@http:ResourceConfig { | ||
name: "user", | ||
linkedTo: [ | ||
{name: "user", method: http:DELETE, relation: "delete-user"}, | ||
{name: "posts", method: http:POST, relation: "create-posts"}, | ||
{name: "posts", method: http:GET, relation: "get-posts"} | ||
] | ||
} | ||
resource function get users/[int id]() returns User|UserNotFound|error; | ||
|
||
# Create a new user | ||
# | ||
# + newUser - New user details(`NewUser`) as payload | ||
# + return - Created(`http:Created`) response or an error | ||
@http:ResourceConfig { | ||
name: "users", | ||
linkedTo: [ | ||
{name: "user", method: http:GET, relation: "get-user"}, | ||
{name: "user", method: http:DELETE, relation: "delete-user"}, | ||
{name: "posts", method: http:POST, relation: "create-posts"}, | ||
{name: "posts", method: http:GET, relation: "get-posts"} | ||
], | ||
consumes: ["application/vnd.socialMedia+json"] | ||
} | ||
resource function post users(NewUser newUser) returns http:Created|error; | ||
|
||
# Delete a user by ID | ||
# | ||
# + id - User ID | ||
# + return - NoContent response(`http:NoContent`) or an error | ||
@http:ResourceConfig { | ||
name: "user" | ||
} | ||
resource function delete users/[int id]() returns http:NoContent|error; | ||
|
||
# Get all posts of a user | ||
# | ||
# + id - User ID | ||
# + return - List of posts with metadata(`PostWithMeta[]`) or NotFound response(`UserNotFound`) when the user is not found or an error | ||
@http:ResourceConfig { | ||
name: "posts" | ||
} | ||
resource function get users/[int id]/posts() returns @http:Cache {maxAge: 25} PostWithMeta[]|UserNotFound|error; | ||
|
||
# Create a new post for a user | ||
# | ||
# + id - User ID | ||
# + newPost - New post details(`NewPost`) as payload | ||
# + return - Created(`http:Created`) response or an error | ||
@http:ResourceConfig { | ||
name: "posts", | ||
linkedTo: [ | ||
{name: "posts", method: http:POST, relation: "create-posts"} | ||
], | ||
consumes: ["application/vnd.socialMedia+json"] | ||
} | ||
resource function post users/[int id]/posts(@http:Payload NewPost newPost) returns http:Created|UserNotFound|PostForbidden|error; | ||
}; | ||
|
||
public isolated service class ErrorInterceptor { | ||
*http:ResponseErrorInterceptor; | ||
|
||
isolated remote function interceptResponseError(error err, http:Response res, http:RequestContext ctx) returns DefaultResponse { | ||
log:printError("error occurred", err); | ||
return { | ||
body: err.message(), | ||
status: new (res.statusCode) | ||
}; | ||
} | ||
} | ||
|
||
# Represents a user in the system | ||
# | ||
# + id - user ID | ||
# + name - user name | ||
# + email - user email | ||
public type User record { | ||
int id; | ||
string name; | ||
string email; | ||
}; | ||
|
||
# Represents a new user | ||
# | ||
# + name - user name | ||
# + email - user email | ||
public type NewUser record { | ||
string name; | ||
string email; | ||
}; | ||
|
||
# Represents a user not found error | ||
# | ||
# + body - error message | ||
public type UserNotFound record {| | ||
*http:NotFound; | ||
ErrorMessage body; | ||
|}; | ||
|
||
# Represents a new post | ||
# | ||
# + content - post content | ||
public type NewPost record { | ||
string content; | ||
}; | ||
|
||
# Represents a post with metadata | ||
# | ||
# + id - post ID | ||
# + content - post content | ||
# + createdAt - post creation time | ||
public type PostWithMeta record { | ||
int id; | ||
string content; | ||
string createdAt; | ||
}; | ||
|
||
# Represents a post forbidden error | ||
# | ||
# + body - error message | ||
public type PostForbidden record {| | ||
*http:Forbidden; | ||
ErrorMessage body; | ||
|}; | ||
|
||
# Represents a default response | ||
# | ||
# + body - response body | ||
public type DefaultResponse record {| | ||
*http:DefaultStatusCodeResponse; | ||
ErrorMessage body; | ||
|}; | ||
|
||
# Represents a error message | ||
public type ErrorMessage string; | ||
|
||
service Service on new http:Listener(9090) { | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
compiler-plugin-tests/bin/test/ballerina_sources/sample_completion_package_1/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
org = "http_test" | ||
name = "sample_completion_package_1" | ||
version = "0.1.0" | ||
|
Oops, something went wrong.