mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 17:47:32 +00:00
Removed comments from resolving expressions
This commit is contained in:
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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user