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

Merge flow_model into master #43594

Merged
merged 66 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d611ec2
Load central package from pre generated JSON
KavinduZoysa Jul 24, 2024
3d2704e
Export ballerina packages in module info
mindula Aug 24, 2024
6ec0c00
Merge pull request #43320 from mindula/export_package_service
nipunayf Aug 24, 2024
92b09f6
Merge pull request #43166 from KavinduZoysa/load-ls-pkg-refactor
nipunayf Aug 26, 2024
1e44a68
Merge branch 'master' of https://github.com/ballerina-platform/baller…
KavinduZoysa Sep 3, 2024
475d1e3
Merge pull request #43354 from KavinduZoysa/update-flow-model
KavinduZoysa Sep 3, 2024
ec6b230
Initial working commit for CommentNode
KavinduZoysa Sep 8, 2024
e161ddb
Add simplified changes for comment node
KavinduZoysa Sep 10, 2024
4df0e3a
Clean the code
KavinduZoysa Sep 10, 2024
410ecfa
Change NodeList type
KavinduZoysa Sep 10, 2024
81860e0
Add more tests
KavinduZoysa Sep 11, 2024
55b5a67
Merge pull request #43376 from KavinduZoysa/comment-as-a-node
KavinduZoysa Sep 11, 2024
6117ddd
Add configurable and automations to the components
nipunayf Oct 9, 2024
a5c703d
Merge pull request #43476 from nipunayf/improve-components-api
hasithaa Oct 9, 2024
87b0fa3
Generate Type model for referenced type symbol
KavinduZoysa Oct 16, 2024
3765a01
LS apis to get diagnostics and main function args
LakshanWeerasinghe Oct 16, 2024
0956ccd
Support passing main function args for fast run
LakshanWeerasinghe Oct 16, 2024
19f3c2b
Add capablity classes to new ls apis
LakshanWeerasinghe Oct 16, 2024
1cb0ec9
Merge pull request #43491 from KavinduZoysa/add-type-def
KavinduZoysa Oct 16, 2024
54d6301
Add tests for diagnostics ls extension ep
LakshanWeerasinghe Oct 18, 2024
108135f
Add tests for mainFuncParams ls extension ep
LakshanWeerasinghe Oct 18, 2024
04a1bea
Support mainFuncParams api for rest params
LakshanWeerasinghe Oct 18, 2024
42769af
Add tests
LakshanWeerasinghe Oct 18, 2024
f9eec79
Address review suggestions
LakshanWeerasinghe Oct 18, 2024
858b038
Merge pull request #43494 from LakshanWeerasinghe/run-main-with-param…
LakshanWeerasinghe Oct 20, 2024
1b269a9
Change the resource function signature
KavinduZoysa Oct 21, 2024
5d9f755
Merge pull request #43499 from KavinduZoysa/resource-signature
KavinduZoysa Oct 21, 2024
a316a14
Add new trigger service with inbuilt triggers
TharmiganK Oct 23, 2024
07a4f68
Add tests
TharmiganK Oct 23, 2024
293df8e
Add more inbuilt triggers
TharmiganK Oct 24, 2024
36c1ee9
Merge pull request #43519 from ballerina-platform/new-triggers
LakshanWeerasinghe Oct 24, 2024
641fc1f
Fix filter and limit functionalities
TharmiganK Oct 25, 2024
1121d55
Add test cases
TharmiganK Oct 25, 2024
62c40bd
Merge remote-tracking branch 'origin/flow_model' into new-triggers
TharmiganK Oct 25, 2024
f43f835
Update descriptions
TharmiganK Oct 25, 2024
066b91a
Ignore properties read failure
TharmiganK Oct 25, 2024
8263716
Add remote functions to components
nipunayf Oct 28, 2024
37612b9
Merge pull request #43529 from nipunayf/add-remote-functions
KavinduZoysa Oct 28, 2024
46cb697
Merge pull request #43522 from ballerina-platform/new-triggers
TharmiganK Oct 29, 2024
4c9afee
Add search by name support in the new trigger service
TharmiganK Oct 29, 2024
9c33079
Add test
TharmiganK Oct 29, 2024
5b1904c
Fix incorrect name fields
TharmiganK Nov 1, 2024
413e1ba
Merge pull request #43530 from ballerina-platform/new-triggers
TharmiganK Nov 4, 2024
70af8c8
Add resource calls to visible endpoints
LakshanWeerasinghe Nov 4, 2024
5c65767
Merge pull request #43547 from LakshanWeerasinghe/resource-path-visib…
hasithaa Nov 4, 2024
408cccc
Add generate variable name method
nipunayf Nov 6, 2024
46e0c91
Merge pull request #43553 from nipunayf/add-default-name-gen
LakshanWeerasinghe Nov 6, 2024
2674619
Update new trigger service to return only the stable triggers
TharmiganK Nov 7, 2024
f425228
Update trigger models to support listener creation
TharmiganK Nov 7, 2024
3a895c2
Add new stable triggers
TharmiganK Nov 7, 2024
6ae7552
Fix test cases
TharmiganK Nov 7, 2024
e56e60b
Merge pull request #43556 from ballerina-platform/new-triggers
hasithaa Nov 7, 2024
1336528
Merge branch 'master' into flow_model-update
dulajdilshan Nov 18, 2024
4ea3365
Fix tests
dulajdilshan Nov 18, 2024
183c845
Merge branch 'master' into flow_model-update
dulajdilshan Nov 18, 2024
2bd7df0
Fix tests conflicts
dulajdilshan Nov 18, 2024
71200f7
Merge pull request #43598 from dulajdilshan/flow_model-update
KavinduZoysa Nov 18, 2024
57fd2cf
Fix spotbugs warnings and errors
dulajdilshan Nov 19, 2024
fe8bc64
Merge pull request #43605 from dulajdilshan/flow_model-update
KavinduZoysa Nov 19, 2024
914203e
Update component tests
dulajdilshan Nov 20, 2024
a7a800e
Fix project-component API responses
dulajdilshan Nov 20, 2024
2482235
Merge branch 'master' into flow_model-update
dulajdilshan Nov 20, 2024
12fa790
Merge pull request #43625 from dulajdilshan/flow_model-update
dulajdilshan Nov 20, 2024
ee48629
Fix language server checkstyle error
dulajdilshan Nov 21, 2024
12e9abf
Fix language server tests
dulajdilshan Nov 21, 2024
4cb88f2
Merge pull request #43627 from dulajdilshan/flow_model-update
HindujaB Nov 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4881,7 +4881,7 @@ private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvoka
List<BResourcePathSegmentSymbol> pathSegmentSymbols = new ArrayList<>(resourcePathCount);
BResourcePathSegmentSymbol parentResource = null;
for (BLangResourcePathSegment pathSegment : pathSegments) {
Name resourcePathSymbolName = Names.fromString(pathSegment.name.value);
Name resourcePathSymbolName = Names.fromString(pathSegment.name.originalValue);
BType resourcePathSegmentType = pathSegment.typeNode == null ?
symTable.noType : symResolver.resolveTypeNode(pathSegment.typeNode, env);
pathSegment.setBType(resourcePathSegmentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public NodeList<StatementNode> statements() {
return new NodeList<>(childInBucket(1));
}

public NodeAndCommentList<Node> statementsWithComments() {
return new NodeAndCommentList<>(childInBucket(1), childInBucket(2));
}

public Token closeBraceToken() {
return childInBucket(2);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://wso2.com)
*
* Licensed 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.compiler.syntax.tree;

import io.ballerina.compiler.internal.parser.tree.STNode;

import java.util.List;

/**
* Represents a comment. This is not a part of the Ballerina syntax tree.
*
* @since 2201.10.0
*/
public class CommentNode extends NonTerminalNode {
private Node commentAttachedNode;
private Minutiae lastMinutiae;
private List<String> commentLines;

public CommentNode(STNode commentAttachedSTNode, int position, NonTerminalNode commentAttachedNode) {
super(commentAttachedSTNode, position, commentAttachedNode);
}

public Node getCommentAttachedNode() {
return this.commentAttachedNode;
}

public void setCommentAttachedNode(Node commentAttachedNode) {
this.commentAttachedNode = commentAttachedNode;
}

public Minutiae getLastMinutiae() {
return this.lastMinutiae;
}

public void setLastMinutiae(Minutiae lastMinutiae) {
this.lastMinutiae = lastMinutiae;
}

public List<String> getCommentLines() {
return this.commentLines;
}

public void setCommentLines(List<String> commentLines) {
this.commentLines = commentLines;
}

@Override
protected String[] childNames() {
return new String[0];
}

@Override
public void accept(NodeVisitor visitor) {
visitor.visit(this);
}

@Override
public <T> T apply(NodeTransformer<T> visitor) {
return visitor.transform(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public NodeList<StatementNode> statements() {
return new NodeList<>(childInBucket(2));
}

public NodeAndCommentList<Node> statementsWithComments() {
return new NodeAndCommentList<>(childInBucket(2), childInBucket(3));
}

public Token closeBraceToken() {
return childInBucket(3);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://wso2.com)
*
* Licensed 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.compiler.syntax.tree;

import io.ballerina.compiler.internal.parser.tree.STNode;
import io.ballerina.compiler.internal.parser.tree.STNodeList;
import io.ballerina.compiler.internal.syntax.NodeListUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import static io.ballerina.compiler.internal.syntax.NodeListUtils.rangeCheck;
import static io.ballerina.compiler.internal.syntax.NodeListUtils.rangeCheckForAdd;

/**
* Represent both nodes and attached comments to each node.
*
* @param <T> The type of Node
*/
public class NodeAndCommentList<T extends Node> implements Iterable<T> {
protected final STNodeList internalListNode;
protected final NonTerminalNode nonTerminalNode;
protected final int size;
protected final Node[] nodes;

NodeAndCommentList(NonTerminalNode nonTerminalNode, Token semicolon) {
this(nonTerminalNode, semicolon, nonTerminalNode.bucketCount() * 2 + 1);
}

protected NodeAndCommentList(NonTerminalNode nonTerminalNode, Token semicolon, int size) {
if (!NodeListUtils.isSTNodeList(nonTerminalNode.internalNode())) {
throw new IllegalArgumentException("An STNodeList instance is expected");
}

this.internalListNode = (STNodeList) nonTerminalNode.internalNode();
this.nonTerminalNode = nonTerminalNode;
this.nodes = new Node[size];
int nodeIndex = 0;
for (int i = 0; i < nonTerminalNode.bucketCount(); i++) {
Node node = nonTerminalNode.childInBucket(i);
CommentNode commentNode = getCommentNode(node);
if (commentNode != null) {
this.nodes[nodeIndex++] = commentNode;
}
this.nodes[nodeIndex++] = node;
}

CommentNode commentNodeBeforeEnd = getCommentNode(semicolon);
if (commentNodeBeforeEnd != null) {
this.nodes[nodeIndex++] = commentNodeBeforeEnd;
}
this.size = nodeIndex;
}

private CommentNode getCommentNode(Node node) {
List<String> commentLines = new ArrayList<>();
Minutiae lastMinutiae = null;
for (Minutiae minutiae : node.leadingMinutiae()) {
String[] splits = minutiae.text().split("// ");
if (splits.length >= 2) {
commentLines.add(splits[1]);
lastMinutiae = minutiae;
} else if (splits.length == 1 && splits[0].contains("//")) {
commentLines.add("");
lastMinutiae = minutiae;
}
}
if (commentLines.isEmpty()) {
return null;
}
CommentNode commentNode = new CommentNode(node.internalNode(), 0, null);
commentNode.setCommentAttachedNode(node);
commentNode.setLastMinutiae(lastMinutiae);
commentNode.setCommentLines(commentLines);
return commentNode;
}

// Positional access methods

public T get(int index) {
rangeCheck(index, size);
return (T) this.nodes[index];
}

// Modification methods

public NodeAndCommentList<T> add(T node) {
Objects.requireNonNull(node, "node should not be null");
return new NodeAndCommentList<>(internalListNode.add(node.internalNode()).createUnlinkedFacade(), null);
}

public NodeAndCommentList<T> add(int index, T node) {
Objects.requireNonNull(node, "node should not be null");
rangeCheckForAdd(index, size);
return new NodeAndCommentList<>(internalListNode.add(index, node.internalNode()).createUnlinkedFacade(), null);
}

public NodeAndCommentList<T> addAll(Collection<T> c) {
if (c.isEmpty()) {
return this;
}

List<STNode> stNodesToBeAdded = c.stream()
.map(node -> Objects.requireNonNull(node, "node should not be null"))
.map(Node::internalNode)
.collect(Collectors.toList());
return new NodeAndCommentList<>(internalListNode.addAll(stNodesToBeAdded).createUnlinkedFacade(), null);
}

public NodeAndCommentList<T> set(int index, T node) {
Objects.requireNonNull(node, "node should not be null");
rangeCheck(index, size);
if (nonTerminalNode.checkForReferenceEquality(index, node)) {
return this;
}

return new NodeAndCommentList<>(internalListNode.set(index, node.internalNode()).createUnlinkedFacade(), null);
}

public NodeAndCommentList<T> remove(int index) {
rangeCheck(index, size);
return new NodeAndCommentList<>(internalListNode.remove(index).createUnlinkedFacade(), null);
}

public NodeAndCommentList<T> remove(T node) {
Objects.requireNonNull(node, "node should not be null");
for (int bucket = 0; bucket < nonTerminalNode.bucketCount(); bucket++) {
if (nonTerminalNode.checkForReferenceEquality(bucket, node)) {
return remove(bucket);
}
}
return this;
}

@SuppressWarnings("SuspiciousMethodCalls")
public NodeAndCommentList<T> removeAll(Collection<T> c) {
if (c.isEmpty()) {
return this;
}
c.forEach(node -> Objects.requireNonNull(node, "node should not be null"));

List<STNode> toBeDeletedList = new ArrayList<>();
for (int bucket = 0; bucket < nonTerminalNode.bucketCount(); bucket++) {
Node childNode = nonTerminalNode.childBuckets[bucket];
if (c.contains(childNode)) {
toBeDeletedList.add(childNode.internalNode());
}
}

return new NodeAndCommentList<>(internalListNode.removeAll(toBeDeletedList).createUnlinkedFacade(), null);
}

//query methods

public int size() {
return this.size;
}

public boolean isEmpty() {
return this.size == 0;
}

@Override
public Iterator<T> iterator() {
return new NodeAndCommentListIterator();
}

public Stream<T> stream() {
return StreamSupport.stream(spliterator(), false);
}

NonTerminalNode underlyingListNode() {
return this.nonTerminalNode;
}

/**
* An iterator for this list of nodes.
*
* @since 2201.10.0
*/
protected class NodeAndCommentListIterator implements Iterator<T> {
private int currentIndex = 0;

@Override
public boolean hasNext() {
return this.currentIndex < size;
}

@Override
public T next() {
return get(currentIndex++);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,10 @@ public T transform(ReceiveFieldNode receiveFieldNode) {
return transformSyntaxNode(receiveFieldNode);
}

public T transform(CommentNode commentNode) {
return transformSyntaxNode(commentNode);
}

// Tokens

public T transform(Token token) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,9 @@ public void visit(MemberTypeDescriptorNode memberTypeDescriptorNode) {
public void visit(ReceiveFieldNode receiveFieldNode) {
visitSyntaxNode(receiveFieldNode);
}
public void visit(CommentNode commentNode) {
visitSyntaxNode(commentNode);
}

// Tokens

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.ballerina.compiler.internal.parser.tree.STNodeList;
import io.ballerina.compiler.internal.parser.tree.STToken;
import io.ballerina.compiler.internal.syntax.SyntaxUtils;
import io.ballerina.compiler.syntax.tree.CommentNode;
import io.ballerina.compiler.syntax.tree.Node;
import io.ballerina.compiler.syntax.tree.SyntaxKind;
import io.ballerina.compiler.syntax.tree.SyntaxTree;
Expand All @@ -46,6 +47,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;

import static io.ballerina.compiler.internal.syntax.SyntaxUtils.isSTNodePresent;
import static io.ballerinalang.compiler.parser.test.ParserTestConstants.CHILDREN_FIELD;
Expand Down Expand Up @@ -987,4 +989,14 @@ private static SyntaxKind getDocumentationKind(String kind) {
default -> throw new UnsupportedOperationException("cannot find syntax kind: " + kind);
};
}

public static void assertCommentNode(Node node, List<String> comments) {
Assert.assertTrue(node instanceof CommentNode);
CommentNode commentNode = (CommentNode) node;
List<String> commentLines = commentNode.getCommentLines();
Assert.assertEquals(commentLines.size(), comments.size());
for (int i = 0; i < comments.size(); i++) {
Assert.assertEquals(commentLines.get(i), comments.get(i));
}
}
}
Loading
Loading