[] and () separated

This commit is contained in:
Jindra Petřík
2025-06-08 14:52:32 +02:00
parent f4e3d99aea
commit 079b0d0b36
2 changed files with 7 additions and 36 deletions

View File

@@ -121,7 +121,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
break;
case PARENT_OPEN:
call(errors, thisType, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, isStatic, variables, abc);
lastVarName += "()";
lastVarName += ".()";
ret = true;
break;
case DESCENDANTS:
@@ -215,7 +215,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
ret = true;
s = lex();
} else if (s.type == SymbolType.BRACKET_OPEN) {
lastVarName += "[]";
lastVarName += ".[]";
expression(errors, thisType, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, isStatic, true, variables, false, abc);
expectedType(errors, SymbolType.BRACKET_CLOSE);
ret = true;

View File

@@ -61,11 +61,7 @@ public class Variable implements VariableOrScope {
String ret = name;
if (ret.contains(".")) {
ret = ret.substring(ret.lastIndexOf(".") + 1);
}
if (ret.endsWith("()") || ret.endsWith("[]")) {
ret = ret.substring(0, ret.length() - 2);
}
}
return ret;
}
@@ -73,21 +69,10 @@ public class Variable implements VariableOrScope {
String ret = name;
if (ret.contains(".")) {
ret = ret.substring(0, ret.indexOf("."));
}
if (ret.endsWith("()") || ret.endsWith("[]")) {
ret = ret.substring(0, ret.length() - 2);
}
}
return ret;
}
public boolean firstNameIsCall() {
String ret = name;
if (ret.contains(".")) {
ret = ret.substring(0, ret.indexOf("."));
}
return ret.endsWith("()");
}
public String getParentName() {
if (name.contains(".")) {
return name.substring(0, name.lastIndexOf("."));
@@ -96,24 +81,10 @@ public class Variable implements VariableOrScope {
}
public List<String> getParts() {
List<String> ret = new ArrayList<>();
String[] dotSplit = name.split("\\.", -1);
Pattern pat = Pattern.compile("[^\\(\\)\\[\\]]+|\\(\\)|\\[\\]");
for (String s : dotSplit) {
Matcher m = pat.matcher(s);
while (m.find()) {
ret.add(m.group());
}
}
return ret;
return Arrays.asList(name.split("\\.", -1));
}
public boolean hasParent() {
return name.contains(".");
}
public static void main(String[] args) {
String v = "v.getPoint().x";
}
}
}