Removed comments from resolving expressions

This commit is contained in:
bigguy345 committed 2026-03-07 13:54:13 +02:00
1 parent 19c1458b1d
commit ec885d5ddb
1 file changed
+23 -2
@@ -4898,8 +4898,9 @@ public class ScriptDocument {
*/
public TypeInfo resolveExpressionType(String expr, int position) {
expr = expr.trim();
if (expr.isEmpty()) {
expr = stripLineComments(expr);
if (expr.isEmpty())
return null;
}
@@ -5336,6 +5337,26 @@ public class ScriptDocument {
}
}
/**
*
*/
private String stripLineComments(String expr) {
if (!expr.contains("//"))
return expr;
String[] lines = expr.split("\n", -1);
StringBuilder result = new StringBuilder();
for (String line : lines) {
int ci = line.indexOf("//");
String part = (ci >= 0 ? line.substring(0, ci) : line).trim();
if (!part.isEmpty()) {
if (result.length() > 0) result.append(' ');
result.append(part);
}
}
return result.toString().trim();
}
/**
* Extract the element type from an array type, using multiple fallback strategies.
*