mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-26 23:05:34 +00:00
Find declaration menuItem,
AS Highlighter - forward declarations
This commit is contained in:
@@ -515,6 +515,8 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
|
||||
Stack<Loop> cinitLoops = new Stack<>();
|
||||
Map<Loop, String> cinitLoopLabels = new HashMap<>();
|
||||
|
||||
List<VariableOrScope> traitVariables = new ArrayList<>();
|
||||
|
||||
looptraits:
|
||||
while (true) {
|
||||
@@ -660,7 +662,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
} else {
|
||||
fname = s.value.toString();
|
||||
}
|
||||
classVariables.add(new Variable(true, prefix + fname, fnamePos));
|
||||
traitVariables.add(new Variable(true, prefix + fname, fnamePos));
|
||||
if (fname.equals(classNameStr)) { //constructor
|
||||
if (isStatic) {
|
||||
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), s.position));
|
||||
@@ -721,7 +723,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
String nname = s.value.toString();
|
||||
int npos = s.position;
|
||||
|
||||
classVariables.add(new Variable(true, prefix + nname, npos));
|
||||
traitVariables.add(new Variable(true, prefix + nname, npos));
|
||||
s = lex();
|
||||
|
||||
if (s.type == SymbolType.ASSIGN) {
|
||||
@@ -752,7 +754,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||
break;
|
||||
}
|
||||
classVariables.add(new Variable(true, prefix + s.value.toString(), s.position));
|
||||
traitVariables.add(new Variable(true, prefix + s.value.toString(), s.position));
|
||||
s = lex();
|
||||
|
||||
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
||||
@@ -789,6 +791,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
classVariables.addAll(0, traitVariables);
|
||||
}
|
||||
|
||||
private void scriptTraits(
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void function(List<SimpleParseException> errors, boolean withBody, String functionName, int functionNamePosition, boolean isMethod, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
private FunctionScope function(List<SimpleParseException> errors, boolean withBody, String functionName, int functionNamePosition, boolean isMethod, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
ParsedSymbol s;
|
||||
expectedType(errors, SymbolType.PARENT_OPEN);
|
||||
s = lex();
|
||||
@@ -192,7 +192,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
Reference<Boolean> subHasEval = new Reference<>(false);
|
||||
|
||||
if (!functionName.isEmpty()) {
|
||||
variables.add(new Variable(true, functionName, functionNamePosition));
|
||||
variables.add(0, new Variable(true, functionName, functionNamePosition));
|
||||
}
|
||||
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
@@ -209,13 +209,15 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
hasEval.setVal(true);
|
||||
}
|
||||
|
||||
variables.add(new FunctionScope(subvariables));
|
||||
return new FunctionScope(subvariables);
|
||||
}
|
||||
|
||||
private boolean traits(List<SimpleParseException> errors, boolean isInterface, String className, List<VariableOrScope> variables, boolean inTellTarget, Reference<Boolean> hasEval) throws IOException, InterruptedException, SimpleParseException, ActionParseException {
|
||||
|
||||
ParsedSymbol s;
|
||||
|
||||
List<VariableOrScope> traitVariables = new ArrayList<>();
|
||||
|
||||
looptrait:
|
||||
while (true) {
|
||||
boolean isStatic = false;
|
||||
@@ -238,14 +240,14 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
|
||||
if (expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
if (!isInterface) {
|
||||
function(errors, !isInterface, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), isStatic ? -1 : s.position, true, variables, inTellTarget, hasEval);
|
||||
variables.add(function(errors, !isInterface, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), isStatic ? -1 : s.position, true, traitVariables, inTellTarget, hasEval));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VAR:
|
||||
s = lex();
|
||||
if (expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
variables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position));
|
||||
traitVariables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position));
|
||||
}
|
||||
s = lex();
|
||||
if (s.type == SymbolType.COLON) {
|
||||
@@ -266,6 +268,8 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
variables.addAll(0, traitVariables);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -799,7 +803,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
case FUNCTION:
|
||||
s = lexer.lex();
|
||||
if (expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
function(errors, true, s.value.toString(), s.position, false, variables, inTellTarget, hasEval);
|
||||
variables.add(function(errors, true, s.value.toString(), s.position, false, variables, inTellTarget, hasEval));
|
||||
}
|
||||
break;
|
||||
case VAR:
|
||||
@@ -1389,7 +1393,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
}
|
||||
function(errors, true, fname, fnamePos, false, variables, inTellTarget, hasEval);
|
||||
variables.add(function(errors, true, fname, fnamePos, false, variables, inTellTarget, hasEval));
|
||||
ret = true;
|
||||
allowMemberOrCall = true;
|
||||
break;
|
||||
|
||||
@@ -35,6 +35,9 @@ public class LexBufferer implements LexListener {
|
||||
|
||||
@Override
|
||||
public void onPushBack(ParsedSymbol s) {
|
||||
if (items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (items.get(items.size() - 1) == s) {
|
||||
items.remove(items.size() - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user