-
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
005d667
commit e67eb21
Showing
20 changed files
with
1,440 additions
and
74 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
91 changes: 91 additions & 0 deletions
91
...iler-plugin/src/main/java/io/ballerina/stdlib/http/compiler/HttpResourceFunctionNode.java
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,91 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* 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.http.compiler; | ||
|
||
import io.ballerina.compiler.api.SemanticModel; | ||
import io.ballerina.compiler.api.symbols.Symbol; | ||
import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; | ||
import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; | ||
import io.ballerina.compiler.syntax.tree.IdentifierToken; | ||
import io.ballerina.compiler.syntax.tree.MetadataNode; | ||
import io.ballerina.compiler.syntax.tree.MethodDeclarationNode; | ||
import io.ballerina.compiler.syntax.tree.Node; | ||
import io.ballerina.compiler.syntax.tree.NodeList; | ||
import io.ballerina.compiler.syntax.tree.NodeVisitor; | ||
import io.ballerina.compiler.syntax.tree.SyntaxKind; | ||
import io.ballerina.tools.diagnostics.Location; | ||
|
||
import java.util.Optional; | ||
|
||
public class HttpResourceFunctionNode { | ||
|
||
Node functionNode; | ||
Optional<MetadataNode> metadata; | ||
NodeList<Node> resourcePath; | ||
FunctionSignatureNode functionSignatureNode; | ||
IdentifierToken functionName; | ||
|
||
public HttpResourceFunctionNode(FunctionDefinitionNode functionDefinitionNode) { | ||
functionNode = functionDefinitionNode; | ||
metadata = functionDefinitionNode.metadata(); | ||
resourcePath = functionDefinitionNode.relativeResourcePath(); | ||
functionSignatureNode = functionDefinitionNode.functionSignature(); | ||
functionName = functionDefinitionNode.functionName(); | ||
} | ||
|
||
public HttpResourceFunctionNode(MethodDeclarationNode methodDeclarationNode) { | ||
functionNode = methodDeclarationNode; | ||
metadata = methodDeclarationNode.metadata(); | ||
resourcePath = methodDeclarationNode.relativeResourcePath(); | ||
functionSignatureNode = methodDeclarationNode.methodSignature(); | ||
functionName = methodDeclarationNode.methodName(); | ||
} | ||
|
||
public void accept(NodeVisitor nodeVisitor) { | ||
functionNode.accept(nodeVisitor); | ||
} | ||
|
||
public Optional<MetadataNode> metadata() { | ||
return metadata; | ||
} | ||
|
||
public NodeList<Node> relativeResourcePath() { | ||
return resourcePath; | ||
} | ||
|
||
public FunctionSignatureNode functionSignature() { | ||
return functionSignatureNode; | ||
} | ||
|
||
public IdentifierToken functionName() { | ||
return functionName; | ||
} | ||
|
||
public Location location() { | ||
return functionNode.location(); | ||
} | ||
|
||
public Optional<FunctionDefinitionNode> getFunctionDefinitionNode() { | ||
return functionNode.kind().equals(SyntaxKind.FUNCTION_DEFINITION) ? | ||
Optional.of((FunctionDefinitionNode) functionNode) : Optional.empty(); | ||
} | ||
|
||
public Optional<Symbol> getSymbol(SemanticModel semanticModel) { | ||
return semanticModel.symbol(functionNode); | ||
} | ||
} |
Oops, something went wrong.