Skip to content

Commit

Permalink
Merge pull request #43149 from LakshanWeerasinghe/fix-#42985
Browse files Browse the repository at this point in the history
Support navigation/references for init functions
  • Loading branch information
LakshanWeerasinghe authored Jul 25, 2024
2 parents de5060e + 1dd1eb9 commit d7e4f3e
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ public void visit(BLangInvocation invocationExpr) {
@Override
public void visit(BLangTypeInit typeInit) {
find(typeInit.userDefinedType);
find(typeInit.argsExpr);
find(typeInit.initInvocation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected Object[][] testDataProvider() {
// being set to lang.annotations.
{"ref_package_alias_config1.json"},
{"ref_retry_spec_config1.json"},
{"init_function_references.json"},
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"source": {
"file": "projectls/class_def.bal"
},
"position": {
"line": 4,
"character": 16
},
"result": [
{
"uri": "projectls/class_def.bal",
"range": {
"start": {
"line": 10,
"character": 16
},
"end": {
"line": 10,
"character": 19
}
}
},
{
"uri": "projectls/union_types.bal",
"range": {
"start": {
"line": 6,
"character": 16
},
"end": {
"line": 6,
"character": 19
}
}
},
{
"uri": "projectls/class_def.bal",
"range": {
"start": {
"line": 4,
"character": 13
},
"end": {
"line": 4,
"character": 17
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class User {
private string uuid;
private string name;

function init(string uuid, string name) {
this.uuid = uuid;
this.name = name;
}
}

final User u1 = new User("123", "Alice");
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ import projectls.lsmod2;


public type RecUnion lsmod1:Mod1Rec|lsmod2:Mod2Rec;

final User u2 = new User("123", "Bob");
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.ballerina.tools.text.LinePosition;
import io.ballerina.tools.text.LineRange;
import org.ballerinalang.test.BCompileUtil;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -143,4 +144,9 @@ protected static void assertLocations(List<Location> locations, List<Location> e
assertTrue(lineRanges.contains(expLocation.lineRange()));
}
}

@AfterClass
public void tearDown() {
model = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package io.ballerina.semantic.api.test.allreferences;

import org.testng.annotations.AfterClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -54,7 +55,8 @@ public Object[][] getLookupPositions() {
List.of(location(24, 13, 20))
},
{30, 13, location(30, 13, 17),
List.of(location(30, 13, 17))
List.of(location(30, 13, 17),
location(52, 17, 20))
},
{34, 13, location(34, 13, 20),
List.of(location(34, 13, 20),
Expand All @@ -79,4 +81,9 @@ public Object[][] getLookupPositions() {
public String getTestSourcePath() {
return "test-src/find-all-ref/find_refs_in_class_object.bal";
}

@AfterClass
public void tearDown() {
super.tearDown();
}
}

0 comments on commit d7e4f3e

Please sign in to comment.