Skip to content

Commit

Permalink
Fix failing debugger test
Browse files Browse the repository at this point in the history
  • Loading branch information
poorna2152 committed Nov 6, 2023
1 parent 9372e89 commit 8c1e270
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import io.ballerina.compiler.syntax.tree.TreeModifier;
import io.ballerina.identifier.Utils;

import static io.ballerina.identifier.Utils.unescapeUnicodeCodepoints;

/**
* Identifier specific expression modifier implementation.
*/
Expand All @@ -39,7 +37,7 @@ public IdentifierToken transform(IdentifierToken identifier) {
identifierText = identifierText.substring(1);
}
// Processes escaped unicode codepoints.
String unescapedIdentifier = unescapeUnicodeCodepoints(identifierText);
String unescapedIdentifier = Utils.unescapeBallerina(identifierText);

// Encodes the user provided identifier in order to be aligned with JVM runtime identifiers.
NonTerminalNode parent = identifier.parent();
Expand All @@ -58,7 +56,7 @@ public static String encodeIdentifier(String identifier, IdentifierType type) {
if (identifier.startsWith(QUOTED_IDENTIFIER_PREFIX)) {
identifier = identifier.substring(1);
}
identifier = Utils.unescapeUnicodeCodepoints(identifier);
identifier = Utils.unescapeBallerina(identifier);
return type == IdentifierType.METHOD_NAME ? Utils.encodeFunctionIdentifier(identifier) :
Utils.encodeNonFunctionIdentifier(identifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public Value getChildByName(String name) throws DebugVariableException {
}

if (!namedChildVariables.containsKey(name)) {
for (Map.Entry<String, Value> childVariable : namedChildVariables.entrySet()) {
String escaped = childVariable.getKey().replaceAll("\\$0092(\\$0092)?", "$1");
if (escaped.equals(name)) {
return childVariable.getValue();
}
}
throw new DebugVariableException("No child variables found with name: '" + name + "'");
}
return namedChildVariables.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public void testInvalidImportOnMultipleFiles() {
public void testEscapedIdentifier() {
CompileResult result = BCompileUtil.compile("test-src/identifiers/identifier_with_escape_char.bal");
int index = 0;
validateError(result, index++, "redeclared symbol 'a3'", 20, 9);
validateError(result, index++, "redeclared symbol 'student-performance'", 22, 9);
validateError(result, index++, "redeclared symbol 'resource\\1path'", 24, 12);
validateError(result, index++, "redeclared symbol 'a3'", 23, 9);
validateError(result, index++, "redeclared symbol 'student-performance'", 25, 9);
validateError(result, index++, "redeclared symbol 'resource\\1path'", 27, 12);
assertEquals(result.getErrorCount(), index);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
import ballerina/io;

public function bar(string x) returns string {
return x;
}

public function foo() {
int a\3 = 0;
Expand All @@ -22,5 +25,5 @@ public function foo() {
int student\u{002D}performance = 2;
string resource\\1path = "https:\\";
string resource\u{005c}1path = "http";
io:println(resource\\1path);
_ = bar(resource\\1path);
}

0 comments on commit 8c1e270

Please sign in to comment.