mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 00:50:51 +00:00
AS1/2/3 - highlight variables and errors on panel next to vertical scrollbar
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- AS1/2/3 - highlight variable definition and all its instances on cursor place
|
- AS1/2/3 - highlight variable definition and all its instances on cursor place
|
||||||
(also in edit mode)
|
(also in edit mode)
|
||||||
- AS1/2/3 - underline errors in the code (also in edit mode)
|
- AS1/2/3 - underline errors in the code (also in edit mode)
|
||||||
- AS1/2/3 - highlight variables and errors on scrollbar
|
- AS1/2/3 - highlight variables and errors on panel next to vertical scrollbar
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- AS1/2 - Single DoAction tag inside frame is now displayed directly as frame node
|
- AS1/2 - Single DoAction tag inside frame is now displayed directly as frame node
|
||||||
|
|||||||
Binary file not shown.
@@ -45,7 +45,7 @@ public abstract class ParseException extends Exception {
|
|||||||
* @param line Line number where the exception occurred
|
* @param line Line number where the exception occurred
|
||||||
*/
|
*/
|
||||||
public ParseException(String text, long line) {
|
public ParseException(String text, long line) {
|
||||||
super("ParseException:" + text + " on line " + line);
|
super(text + " on line " + line);
|
||||||
this.line = line;
|
this.line = line;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.position = -1;
|
this.position = -1;
|
||||||
@@ -58,7 +58,7 @@ public abstract class ParseException extends Exception {
|
|||||||
* @param line Line number where the exception occurred
|
* @param line Line number where the exception occurred
|
||||||
*/
|
*/
|
||||||
public ParseException(String text, long line, long position) {
|
public ParseException(String text, long line, long position) {
|
||||||
super("ParseException:" + text + " on line " + line);
|
super(text + " on line " + line);
|
||||||
this.line = line;
|
this.line = line;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
|||||||
+72
-46
@@ -212,7 +212,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
s = lex();
|
s = lex();
|
||||||
} else {
|
} else {
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.MULTIPLY);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.MULTIPLY)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
String propName = s.value.toString(); //Can be *
|
String propName = s.value.toString(); //Can be *
|
||||||
int propPosition = s.position;
|
int propPosition = s.position;
|
||||||
s = lex();
|
s = lex();
|
||||||
@@ -246,38 +248,38 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
|
|
||||||
private boolean name(List<SimpleParseException> errors, TypeItem thisType, Reference<Boolean> needsActivation, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<VariableOrScope> variables, List<DottedChain> importedClasses, ABC abc) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException {
|
private boolean name(List<SimpleParseException> errors, TypeItem thisType, Reference<Boolean> needsActivation, List<NamespaceItem> openedNamespaces, HashMap<String, Integer> registerVars, boolean inFunction, boolean inMethod, List<VariableOrScope> variables, List<DottedChain> importedClasses, ABC abc) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException {
|
||||||
ParsedSymbol s = lex();
|
ParsedSymbol s = lex();
|
||||||
DottedChain name = new DottedChain(new String[]{}, new String[]{""});
|
|
||||||
boolean attribute = false;
|
String lastName = "";
|
||||||
String name2 = "";
|
|
||||||
if (s.type == SymbolType.ATTRIBUTE) {
|
if (s.type == SymbolType.ATTRIBUTE) {
|
||||||
attribute = true;
|
lastName = s.value.toString();
|
||||||
s = lex();
|
s = lex();
|
||||||
}
|
}
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP)) {
|
||||||
name2 += s.value.toString();
|
return true;
|
||||||
|
}
|
||||||
|
lastName += s.value.toString();
|
||||||
int identPos = s.position;
|
int identPos = s.position;
|
||||||
s = lex();
|
s = lex();
|
||||||
boolean attrBracket = false;
|
boolean attrBracket = false;
|
||||||
String nsSuffix = "";
|
|
||||||
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
||||||
s = lex();
|
s = lex();
|
||||||
nsSuffix = "#" + s.value;
|
lastName += "#" + s.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = name.add(attribute, name2, nsSuffix);
|
String fullName = lastName;
|
||||||
|
|
||||||
while (s.isType(SymbolType.DOT)) {
|
while (s.isType(SymbolType.DOT)) {
|
||||||
variables.add(new Variable(false, name.toPrintableString(true), identPos));
|
variables.add(new Variable(false, fullName, identPos));
|
||||||
s = lex();
|
s = lex();
|
||||||
name2 = "";
|
lastName = "";
|
||||||
attribute = false;
|
|
||||||
if (s.type == SymbolType.ATTRIBUTE) {
|
if (s.type == SymbolType.ATTRIBUTE) {
|
||||||
attribute = true;
|
lastName += s.value.toString();
|
||||||
s = lex();
|
s = lex();
|
||||||
if (s.type == SymbolType.MULTIPLY) {
|
if (s.type == SymbolType.MULTIPLY) {
|
||||||
name2 += s.value.toString();
|
lastName += s.value.toString();
|
||||||
identPos = s.position;
|
identPos = s.position;
|
||||||
} else if (s.group == SymbolGroup.IDENTIFIER) {
|
} else if (s.group == SymbolGroup.IDENTIFIER) {
|
||||||
name2 += s.value.toString();
|
lastName += s.value.toString();
|
||||||
identPos = s.position;
|
identPos = s.position;
|
||||||
} else {
|
} else {
|
||||||
if (s.type != SymbolType.BRACKET_OPEN) {
|
if (s.type != SymbolType.BRACKET_OPEN) {
|
||||||
@@ -287,39 +289,34 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.NAMESPACE, SymbolType.MULTIPLY);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.NAMESPACE, SymbolType.MULTIPLY)) {
|
||||||
name2 += s.value.toString();
|
return true;
|
||||||
|
}
|
||||||
|
lastName = s.value.toString();
|
||||||
identPos = s.position;
|
identPos = s.position;
|
||||||
}
|
}
|
||||||
s = lex();
|
s = lex();
|
||||||
nsSuffix = "";
|
|
||||||
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
||||||
nsSuffix = "#" + s.value;
|
lastName += "#" + s.value;
|
||||||
s = lex();
|
s = lex();
|
||||||
}
|
}
|
||||||
name = name.add(attribute, name2, nsSuffix);
|
fullName += "." + lastName;
|
||||||
}
|
}
|
||||||
if (s.type == SymbolType.NAMESPACE_OP) {
|
if (s.type == SymbolType.NAMESPACE_OP) {
|
||||||
String nsname = name.getLast();
|
|
||||||
boolean nsAtribute = name.isLastAttribute();
|
|
||||||
s = lex();
|
s = lex();
|
||||||
if (s.group == SymbolGroup.IDENTIFIER) {
|
if (s.group == SymbolGroup.IDENTIFIER) {
|
||||||
String nsprop = s.value.toString();
|
String nsprop = s.value.toString();
|
||||||
variables.add(new Variable(false, (nsAtribute ? "@" : "") + nsname + "::" + nsprop, s.position));
|
variables.add(new Variable(false, lastName + "::" + nsprop, s.position));
|
||||||
} else if (s.type == SymbolType.BRACKET_OPEN) {
|
} else if (s.type == SymbolType.BRACKET_OPEN) {
|
||||||
expression(errors, thisType, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false, abc);
|
expression(errors, thisType, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false, abc);
|
||||||
expectedType(errors, SymbolType.BRACKET_CLOSE);
|
expectedType(errors, SymbolType.BRACKET_CLOSE);
|
||||||
}
|
}
|
||||||
name = name.getWithoutLast();
|
|
||||||
s = lex();
|
s = lex();
|
||||||
} else {
|
} else {
|
||||||
variables.add(new Variable(false, name.toPrintableString(true), identPos));
|
variables.add(new Variable(false, fullName, identPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ret = false;
|
boolean ret = true;
|
||||||
if (!name.isEmpty()) {
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
if (s.type == SymbolType.BRACKET_OPEN) {
|
if (s.type == SymbolType.BRACKET_OPEN) {
|
||||||
lexer.pushback(s);
|
lexer.pushback(s);
|
||||||
if (attrBracket) {
|
if (attrBracket) {
|
||||||
@@ -333,7 +330,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expected(List<SimpleParseException> errors, ParsedSymbol symb, int line, Object... expected) throws IOException, AVM2ParseException, SimpleParseException {
|
private boolean expected(List<SimpleParseException> errors, ParsedSymbol symb, int line, Object... expected) throws IOException, AVM2ParseException, SimpleParseException {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Object t : expected) {
|
for (Object t : expected) {
|
||||||
if (symb.type == t) {
|
if (symb.type == t) {
|
||||||
@@ -355,6 +352,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
}
|
}
|
||||||
errors.add(new SimpleParseException("" + expStr + " expected but " + symb.type + " found", line, symb.position));
|
errors.add(new SimpleParseException("" + expStr + " expected but " + symb.type + " found", line, symb.position));
|
||||||
}
|
}
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParsedSymbol expectedType(List<SimpleParseException> errors, Object... type) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException {
|
private ParsedSymbol expectedType(List<SimpleParseException> errors, Object... type) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException {
|
||||||
@@ -383,7 +381,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
}
|
}
|
||||||
expression(errors, thisType, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false, abc);
|
expression(errors, thisType, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false, abc);
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE);
|
if (!expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +408,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
hasRest = true;
|
hasRest = true;
|
||||||
s = lex();
|
s = lex();
|
||||||
}
|
}
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
paramNames.add(s.value.toString());
|
paramNames.add(s.value.toString());
|
||||||
paramPositions.add(s.position);
|
paramPositions.add(s.position);
|
||||||
@@ -513,7 +515,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void classTraits(List<SimpleParseException> errors, boolean outsidePackage, Reference<Boolean> cinitNeedsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, String classNameStr, boolean isInterface, Reference<Boolean> iinitNeedsActivation, ABC abc, List<VariableOrScope> classVariables) throws AVM2ParseException, SimpleParseException, IOException, CompilationException, InterruptedException {
|
private void classTraits(List<SimpleParseException> errors, boolean outsidePackage, Reference<Boolean> cinitNeedsActivation, List<DottedChain> importedClasses, List<NamespaceItem> openedNamespaces, DottedChain pkg, String classNameStr, boolean isInterface, Reference<Boolean> iinitNeedsActivation, ABC abc, List<VariableOrScope> classVariables) throws AVM2ParseException, SimpleParseException, IOException, CompilationException, InterruptedException {
|
||||||
|
|
||||||
Stack<Loop> cinitLoops = new Stack<>();
|
Stack<Loop> cinitLoops = new Stack<>();
|
||||||
Map<Loop, String> cinitLoopLabels = new HashMap<>();
|
Map<Loop, String> cinitLoopLabels = new HashMap<>();
|
||||||
@@ -626,6 +628,8 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
s = lex();
|
s = lex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String prefix = isStatic ? pkg.addWithSuffix(classNameStr).toPrintableString(true) + "." : "this.";
|
||||||
|
|
||||||
switch (s.type) {
|
switch (s.type) {
|
||||||
case FUNCTION:
|
case FUNCTION:
|
||||||
s = lex();
|
s = lex();
|
||||||
@@ -636,8 +640,10 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
isSetter = true;
|
isSetter = true;
|
||||||
s = lex();
|
s = lex();
|
||||||
}
|
}
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.PARENT_OPEN);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.PARENT_OPEN)) {
|
||||||
String fname = null;
|
break;
|
||||||
|
}
|
||||||
|
String fname;
|
||||||
int fnamePos = s.position;
|
int fnamePos = s.position;
|
||||||
|
|
||||||
//fix for methods with name "get" or "set" - they are not getters/setters!
|
//fix for methods with name "get" or "set" - they are not getters/setters!
|
||||||
@@ -651,10 +657,12 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
//isSetter = false;
|
//isSetter = false;
|
||||||
} else {
|
} else {
|
||||||
errors.add(new SimpleParseException("Missing method name", lexer.yyline(), s.position));
|
errors.add(new SimpleParseException("Missing method name", lexer.yyline(), s.position));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fname = s.value.toString();
|
fname = s.value.toString();
|
||||||
}
|
}
|
||||||
|
classVariables.add(new Variable(true, prefix + fname, fnamePos));
|
||||||
if (fname.equals(classNameStr)) { //constructor
|
if (fname.equals(classNameStr)) { //constructor
|
||||||
if (isStatic) {
|
if (isStatic) {
|
||||||
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), s.position));
|
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), s.position));
|
||||||
@@ -709,9 +717,13 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
errors.add(new SimpleParseException("Interface cannot have namespace fields", lexer.yyline(), s.position));
|
errors.add(new SimpleParseException("Interface cannot have namespace fields", lexer.yyline(), s.position));
|
||||||
}
|
}
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
String nname = s.value.toString();
|
String nname = s.value.toString();
|
||||||
int npos = s.position;
|
int npos = s.position;
|
||||||
|
|
||||||
|
classVariables.add(new Variable(true, prefix + nname, npos));
|
||||||
s = lex();
|
s = lex();
|
||||||
|
|
||||||
if (s.type == SymbolType.ASSIGN) {
|
if (s.type == SymbolType.ASSIGN) {
|
||||||
@@ -739,8 +751,10 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
classVariables.add(new Variable(true, s.value.toString(), s.position));
|
break;
|
||||||
|
}
|
||||||
|
classVariables.add(new Variable(true, prefix + s.value.toString(), s.position));
|
||||||
s = lex();
|
s = lex();
|
||||||
|
|
||||||
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
if (s.type == SymbolType.NAMESPACESUFFIX) {
|
||||||
@@ -909,8 +923,12 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
String subNameStr;
|
String subNameStr;
|
||||||
|
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
subNameStr = s.value.toString();
|
subNameStr = s.value.toString();
|
||||||
|
int subNamePos = s.position;
|
||||||
|
sinitVariables.add(new Variable(true, pkgName.addWithSuffix(subNameStr).toPrintableString(true), subNamePos));
|
||||||
s = lex();
|
s = lex();
|
||||||
|
|
||||||
if (s.type == SymbolType.NOT) {
|
if (s.type == SymbolType.NOT) {
|
||||||
@@ -946,7 +964,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
Reference<Boolean> iinitNeedsActivation = new Reference<>(false);
|
Reference<Boolean> iinitNeedsActivation = new Reference<>(false);
|
||||||
List<VariableOrScope> classVariables = new ArrayList<>();
|
List<VariableOrScope> classVariables = new ArrayList<>();
|
||||||
|
|
||||||
classTraits(errors, !inPackage, cinitNeedsActivation, importedClasses, subOpenedNamespaces, subNameStr, isInterface, iinitNeedsActivation, abc, classVariables);
|
classTraits(errors, !inPackage, cinitNeedsActivation, importedClasses, subOpenedNamespaces, pkgName, subNameStr, isInterface, iinitNeedsActivation, abc, classVariables);
|
||||||
|
|
||||||
sinitVariables.add(new ClassScope(classVariables));
|
sinitVariables.add(new ClassScope(classVariables));
|
||||||
|
|
||||||
@@ -969,7 +987,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
sinitVariables.add(new Variable(true, s.value.toString(), s.position));
|
sinitVariables.add(new Variable(true, s.value.toString(), s.position));
|
||||||
s = lex();
|
s = lex();
|
||||||
if (s.type == SymbolType.COLON) {
|
if (s.type == SymbolType.COLON) {
|
||||||
@@ -993,8 +1013,11 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
errors.add(new SimpleParseException("Final flag not allowed for namespaces", lexer.yyline(), s.position));
|
errors.add(new SimpleParseException("Final flag not allowed for namespaces", lexer.yyline(), s.position));
|
||||||
}
|
}
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
sinitVariables.add(new Variable(true, s.value.toString(), s.position));
|
sinitVariables.add(new Variable(true, s.value.toString(), s.position));
|
||||||
|
|
||||||
s = lex();
|
s = lex();
|
||||||
|
|
||||||
if (s.type == SymbolType.ASSIGN) {
|
if (s.type == SymbolType.ASSIGN) {
|
||||||
@@ -1205,7 +1228,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
case VAR:
|
case VAR:
|
||||||
case CONST:
|
case CONST:
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
String varIdentifier = s.value.toString();
|
String varIdentifier = s.value.toString();
|
||||||
int varPos = s.position;
|
int varPos = s.position;
|
||||||
s = lex();
|
s = lex();
|
||||||
@@ -1410,8 +1435,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
|||||||
while (s.type == SymbolType.CATCH) {
|
while (s.type == SymbolType.CATCH) {
|
||||||
expectedType(errors, SymbolType.PARENT_OPEN);
|
expectedType(errors, SymbolType.PARENT_OPEN);
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP);
|
if (!expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
String enamestr = s.value.toString();
|
String enamestr = s.value.toString();
|
||||||
int ePos = s.position;
|
int ePos = s.position;
|
||||||
expectedType(errors, SymbolType.COLON);
|
expectedType(errors, SymbolType.COLON);
|
||||||
|
|||||||
+11
-8
@@ -153,7 +153,9 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
|||||||
}
|
}
|
||||||
expression(errors, inFunction, inMethod, inTellTarget, true, variables, false, hasEval);
|
expression(errors, inFunction, inMethod, inTellTarget, true, variables, false, hasEval);
|
||||||
s = lex();
|
s = lex();
|
||||||
expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE);
|
if (!expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -181,7 +183,9 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!s.isType(SymbolType.COMMA, SymbolType.PARENT_CLOSE)) {
|
if (!s.isType(SymbolType.COMMA, SymbolType.PARENT_CLOSE)) {
|
||||||
expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE);
|
if (!expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<VariableOrScope> subvariables = new ArrayList<>();
|
List<VariableOrScope> subvariables = new ArrayList<>();
|
||||||
@@ -1619,17 +1623,16 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
|||||||
inOnHandler = true;
|
inOnHandler = true;
|
||||||
} else {
|
} else {
|
||||||
lexer.pushback(symb);
|
lexer.pushback(symb);
|
||||||
}
|
}
|
||||||
|
Reference<Boolean> hasEval = new Reference<>(false);
|
||||||
|
commands(errors, false, false, 0, false, vars, hasEval);
|
||||||
|
|
||||||
if (inOnHandler) {
|
if (inOnHandler) {
|
||||||
expectedType(errors, SymbolType.CURLY_CLOSE);
|
expectedType(errors, SymbolType.CURLY_CLOSE);
|
||||||
}
|
}
|
||||||
if (lexer.lex().type != SymbolType.EOF) {
|
if (lexer.lex().type != SymbolType.EOF) {
|
||||||
errors.add(new SimpleParseException("Parsing finished before end of the file", lexer.yyline(), lexer.yychar()));
|
errors.add(new SimpleParseException("Parsing finished before end of the file", lexer.yyline(), lexer.yychar()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference<Boolean> hasEval = new Reference<>(false);
|
|
||||||
commands(errors, false, false, 0, false, vars, hasEval);
|
|
||||||
|
|
||||||
} catch (ActionParseException ex) {
|
} catch (ActionParseException ex) {
|
||||||
errors.add(new SimpleParseException(ex.getMessage(), ex.line, ex.position));
|
errors.add(new SimpleParseException(ex.getMessage(), ex.line, ex.position));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 JPEXS
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.jpexs.decompiler.flash.gui.editor;
|
||||||
|
|
||||||
|
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollBar;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.plaf.ScrollBarUI;
|
||||||
|
import javax.swing.text.BadLocationException;
|
||||||
|
import javax.swing.text.Highlighter;
|
||||||
|
import jsyntaxpane.actions.ActionUtils;
|
||||||
|
import jsyntaxpane.components.Markers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author JPEXS
|
||||||
|
*/
|
||||||
|
public class HighlightsPanel extends JPanel {
|
||||||
|
|
||||||
|
private final LineMarkedEditorPane editorPane;
|
||||||
|
private Cursor HAND_CURSOR = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
|
||||||
|
private Cursor DEFAULT_CURSOR = Cursor.getDefaultCursor();
|
||||||
|
private Map<Integer, String> errors = new LinkedHashMap<>();
|
||||||
|
private int scrollBarButtonSize = 0;
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
|
||||||
|
public HighlightsPanel(LineMarkedEditorPane editorPane) {
|
||||||
|
this.editorPane = editorPane;
|
||||||
|
|
||||||
|
scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, editorPane);
|
||||||
|
|
||||||
|
JScrollBar bar = new JScrollBar(JScrollBar.VERTICAL, 0, 1, 0, 100);
|
||||||
|
scrollBarButtonSize = bar.getPreferredSize().width;
|
||||||
|
setPreferredSize(new Dimension(16, Integer.MAX_VALUE));
|
||||||
|
addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if (!SwingUtilities.isLeftMouseButton(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int totalLineCount = ActionUtils.getLineCount(editorPane);
|
||||||
|
Rectangle r = getScrollbarTrackRect();
|
||||||
|
int line = (e.getY() - r.y) * totalLineCount / r.height;
|
||||||
|
int linesCountPer1Px = totalLineCount / r.height;
|
||||||
|
if (!scrollPane.getVerticalScrollBar().isVisible()) {
|
||||||
|
linesCountPer1Px = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Highlighter.Highlight highlight : editorPane.getHighlighter().getHighlights()) {
|
||||||
|
Highlighter.HighlightPainter painter = highlight.getPainter();
|
||||||
|
if (painter instanceof Markers.SimpleMarker) {
|
||||||
|
try {
|
||||||
|
int lineNum = ActionUtils.getLineNumber(editorPane, highlight.getStartOffset());
|
||||||
|
if (lineNum >= line - linesCountPer1Px && lineNum <= line + linesCountPer1Px) {
|
||||||
|
editorPane.setCaretPosition(highlight.getStartOffset());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (BadLocationException ex) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addMouseMotionListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
int totalLineCount = ActionUtils.getLineCount(editorPane);
|
||||||
|
Rectangle r = getScrollbarTrackRect();
|
||||||
|
int line = (e.getY() - r.y) * totalLineCount / r.height;
|
||||||
|
|
||||||
|
int linesCountPer1Px = totalLineCount / r.height;
|
||||||
|
if (!scrollPane.getVerticalScrollBar().isVisible()) {
|
||||||
|
linesCountPer1Px = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lineStart = line * r.height / totalLineCount;
|
||||||
|
int lineEnd = (line + 1) * r.height / totalLineCount;
|
||||||
|
if (e.getY() - r.y < lineStart - 1 || e.getY() - r.y > lineStart + 2) {
|
||||||
|
if (getCursor() != DEFAULT_CURSOR) {
|
||||||
|
setCursor(DEFAULT_CURSOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
setToolTipText(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentLine = editorPane.getLine();
|
||||||
|
|
||||||
|
for (Highlighter.Highlight highlight : editorPane.getHighlighter().getHighlights()) {
|
||||||
|
Highlighter.HighlightPainter painter = highlight.getPainter();
|
||||||
|
if (painter instanceof Markers.SimpleMarker) {
|
||||||
|
try {
|
||||||
|
int lineNum = ActionUtils.getLineNumber(editorPane, highlight.getStartOffset());
|
||||||
|
if (lineNum >= line - linesCountPer1Px && lineNum <= line + linesCountPer1Px) {
|
||||||
|
if (line != currentLine) {
|
||||||
|
if (getCursor() != HAND_CURSOR) {
|
||||||
|
setCursor(HAND_CURSOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errors.containsKey(highlight.getStartOffset())) {
|
||||||
|
setToolTipText(AppStrings.translate("highlighter.error").replace("%error%", errors.get(highlight.getStartOffset())));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (line != currentLine && painter instanceof OccurencesMarker) {
|
||||||
|
setToolTipText(AppStrings.translate("highlighter.occurences"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line == currentLine) {
|
||||||
|
setToolTipText(AppStrings.translate("highlighter.currentLine"));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (BadLocationException ex) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getCursor() != DEFAULT_CURSOR) {
|
||||||
|
setCursor(DEFAULT_CURSOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
setToolTipText(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrors(Map<Integer, String> errors) {
|
||||||
|
this.errors = errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Rectangle getScrollbarTrackRect() {
|
||||||
|
return new Rectangle(0, scrollBarButtonSize, 16, getHeight() + - 2 * scrollBarButtonSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
Rectangle r = getScrollbarTrackRect();
|
||||||
|
|
||||||
|
int totalLineCount = ActionUtils.getLineCount(editorPane);
|
||||||
|
int h = 3;
|
||||||
|
Highlighter.Highlight[] highlights = editorPane.getHighlighter().getHighlights();
|
||||||
|
Set<Integer> ignoredLines = new HashSet<>();
|
||||||
|
int currentLine = editorPane.getLine();
|
||||||
|
|
||||||
|
for (Highlighter.Highlight highlight : highlights) {
|
||||||
|
Highlighter.HighlightPainter painter = highlight.getPainter();
|
||||||
|
if (painter instanceof Markers.SimpleMarker) {
|
||||||
|
Markers.SimpleMarker simpleMarker = (Markers.SimpleMarker) painter;
|
||||||
|
g.setColor(simpleMarker.getColor());
|
||||||
|
|
||||||
|
try {
|
||||||
|
int line = ActionUtils.getLineNumber(editorPane, highlight.getStartOffset());
|
||||||
|
|
||||||
|
//prefer error lines
|
||||||
|
if (painter instanceof WavyUnderLinePainter) {
|
||||||
|
ignoredLines.add(line);
|
||||||
|
} else if (ignoredLines.contains(line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float ratio = (float) line / totalLineCount;
|
||||||
|
int y = r.y + (int) (ratio * r.height);
|
||||||
|
g.fillRect(0, y, getWidth(), h);
|
||||||
|
} catch (BadLocationException ex) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLine >= 0) {
|
||||||
|
float ratio = (float) currentLine / totalLineCount;
|
||||||
|
int y = r.y + (int) (ratio * r.height) + 1;
|
||||||
|
g.setColor(Color.gray);
|
||||||
|
g.fillRect(0, y, getWidth(), 1);
|
||||||
|
g.fillOval(16 / 2 - 2, y - 1, 3, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 JPEXS
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.jpexs.decompiler.flash.gui.editor;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import jsyntaxpane.components.Markers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author JPEXS
|
||||||
|
*/
|
||||||
|
public class OccurencesMarker extends Markers.SimpleMarker {
|
||||||
|
|
||||||
|
public OccurencesMarker(Color color) {
|
||||||
|
super(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2025 JPEXS
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.jpexs.decompiler.flash.gui.editor;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLayer;
|
|
||||||
import javax.swing.JScrollBar;
|
|
||||||
import javax.swing.plaf.LayerUI;
|
|
||||||
import javax.swing.plaf.ScrollBarUI;
|
|
||||||
import jsyntaxpane.actions.ActionUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author JPEXS
|
|
||||||
*/
|
|
||||||
public class ScrollbarOverlay extends LayerUI<JScrollBar> {
|
|
||||||
|
|
||||||
private final LineMarkedEditorPane editorPane;
|
|
||||||
private final Map<Integer, Color> markedLines = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
public ScrollbarOverlay(LineMarkedEditorPane editorPane) {
|
|
||||||
this.editorPane = editorPane;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeMarkers(Color color) {
|
|
||||||
Set<Integer> lines = new HashSet<>(markedLines.keySet());
|
|
||||||
for (int key : lines) {
|
|
||||||
if (markedLines.get(key).equals(color)) {
|
|
||||||
markedLines.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearMarkers() {
|
|
||||||
markedLines.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMarker(int line, Color color) {
|
|
||||||
markedLines.put(line, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMarkedLines(Map<Integer, Color> markedLines) {
|
|
||||||
this.markedLines.clear();
|
|
||||||
this.markedLines.putAll(markedLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paint(Graphics g, JComponent c) {
|
|
||||||
super.paint(g, c);
|
|
||||||
JScrollBar bar = (JScrollBar) ((JLayer<?>) c).getView();
|
|
||||||
ScrollBarUI ui = bar.getUI();
|
|
||||||
Rectangle r;
|
|
||||||
if (ui instanceof TrackRectSubstanceScrollbarUI) {
|
|
||||||
r = ((TrackRectSubstanceScrollbarUI) ui).getTrackBounds();
|
|
||||||
} else {
|
|
||||||
r = new Rectangle(0, 16, 16, bar.getHeight() - 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
int totalLineCount = ActionUtils.getLineCount(editorPane);
|
|
||||||
for (Map.Entry<Integer, Color> entry : markedLines.entrySet()) {
|
|
||||||
g.setColor(entry.getValue());
|
|
||||||
|
|
||||||
float ratio = (float) entry.getKey() / totalLineCount;
|
|
||||||
int y = r.y + (int) (ratio * r.height);
|
|
||||||
g.drawLine(0, y, bar.getWidth(), y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -75,7 +75,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
private static final Color SCROLLBAR_ERROR_COLOR = new Color(0xff0000);
|
private static final Color SCROLLBAR_ERROR_COLOR = new Color(0xff0000);
|
||||||
private JEditorPane pane;
|
private JEditorPane pane;
|
||||||
private final Set<TokenType> tokenTypes = new HashSet<>();
|
private final Set<TokenType> tokenTypes = new HashSet<>();
|
||||||
private Markers.SimpleMarker marker;
|
private OccurencesMarker marker;
|
||||||
private Markers.SimpleMarker errorMarker;
|
private Markers.SimpleMarker errorMarker;
|
||||||
private Status status;
|
private Status status;
|
||||||
private Map<Integer, String> errors = new LinkedHashMap<>();
|
private Map<Integer, String> errors = new LinkedHashMap<>();
|
||||||
@@ -87,9 +87,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
|
|
||||||
private MouseMotionAdapter mouseMotionAdapter;
|
private MouseMotionAdapter mouseMotionAdapter;
|
||||||
|
|
||||||
private JLayer<JScrollBar> layer;
|
private HighlightsPanel highlightsPanel;
|
||||||
|
|
||||||
private ScrollbarOverlay scrollbarOverlay;
|
|
||||||
|
|
||||||
private ScrollPaneUI originalScrollPaneUI;
|
private ScrollPaneUI originalScrollPaneUI;
|
||||||
|
|
||||||
@@ -120,7 +118,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
if (token != null && tokenTypes.contains(token.type)) {
|
if (token != null && tokenTypes.contains(token.type)) {
|
||||||
addMarkers(token);
|
addMarkers(token);
|
||||||
}
|
}
|
||||||
layer.repaint();
|
highlightsPanel.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,12 +127,10 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
*/
|
*/
|
||||||
public void removeMarkers() {
|
public void removeMarkers() {
|
||||||
Markers.removeMarkers(pane, marker);
|
Markers.removeMarkers(pane, marker);
|
||||||
scrollbarOverlay.removeMarkers(SCROLLBAR_VARIABLE_COLOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeErrorMarkers() {
|
public void removeErrorMarkers() {
|
||||||
Markers.removeMarkers(pane, errorMarker);
|
Markers.removeMarkers(pane, errorMarker);
|
||||||
scrollbarOverlay.removeMarkers(SCROLLBAR_ERROR_COLOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Token getIdentifierTokenAt(SyntaxDocument sDoc, int pos) {
|
private Token getIdentifierTokenAt(SyntaxDocument sDoc, int pos) {
|
||||||
@@ -188,6 +184,8 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addErrorMarkers() {
|
void addErrorMarkers() {
|
||||||
|
highlightsPanel.setErrors(errors);
|
||||||
|
|
||||||
SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
|
SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
|
||||||
if (doc == null) {
|
if (doc == null) {
|
||||||
return;
|
return;
|
||||||
@@ -197,10 +195,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
Token token = getNearestTokenAt(doc, position);
|
Token token = getNearestTokenAt(doc, position);
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
Markers.markToken(pane, token, errorMarker);
|
Markers.markToken(pane, token, errorMarker);
|
||||||
markPositionOnScrollbar(position, SCROLLBAR_ERROR_COLOR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer.repaint();
|
highlightsPanel.repaint();
|
||||||
doc.readUnlock();
|
doc.readUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,12 +217,10 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
if (definitionToken != null) {
|
if (definitionToken != null) {
|
||||||
if (definitionPosToReferences.containsKey(definitionPos)) {
|
if (definitionPosToReferences.containsKey(definitionPos)) {
|
||||||
Markers.markToken(pane, definitionToken, marker);
|
Markers.markToken(pane, definitionToken, marker);
|
||||||
markPositionOnScrollbar(definitionToken.start, SCROLLBAR_VARIABLE_COLOR);
|
|
||||||
for (int i : definitionPosToReferences.get(definitionPos)) {
|
for (int i : definitionPosToReferences.get(definitionPos)) {
|
||||||
Token referenceToken = getIdentifierTokenAt(sDoc, i);
|
Token referenceToken = getIdentifierTokenAt(sDoc, i);
|
||||||
if (referenceToken != null) {
|
if (referenceToken != null) {
|
||||||
Markers.markToken(pane, referenceToken, marker);
|
Markers.markToken(pane, referenceToken, marker);
|
||||||
markPositionOnScrollbar(referenceToken.start, SCROLLBAR_VARIABLE_COLOR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,19 +228,11 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
sDoc.readUnlock();
|
sDoc.readUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markPositionOnScrollbar(int position, Color color) {
|
|
||||||
try {
|
|
||||||
scrollbarOverlay.addMarker(ActionUtils.getLineNumber(pane, position), color);
|
|
||||||
} catch (BadLocationException ex) {
|
|
||||||
//ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void config(Configuration config) {
|
public void config(Configuration config) {
|
||||||
Color markerColor = config.getColor(PROPERTY_COLOR, DEFAULT_COLOR);
|
Color markerColor = config.getColor(PROPERTY_COLOR, DEFAULT_COLOR);
|
||||||
Color errorColor = config.getColor(PROPERTY_ERRORCOLOR, DEFAULT_ERRORCOLOR);
|
Color errorColor = config.getColor(PROPERTY_ERRORCOLOR, DEFAULT_ERRORCOLOR);
|
||||||
this.marker = new Markers.SimpleMarker(markerColor);
|
this.marker = new OccurencesMarker(markerColor);
|
||||||
this.errorMarker = new WavyUnderLinePainter(errorColor); //Markers.SimpleMarker(errorColor);
|
this.errorMarker = new WavyUnderLinePainter(errorColor); //Markers.SimpleMarker(errorColor);
|
||||||
String types = config.getString(
|
String types = config.getString(
|
||||||
PROPERTY_TOKENTYPES, DEFAULT_TOKENTYPES);
|
PROPERTY_TOKENTYPES, DEFAULT_TOKENTYPES);
|
||||||
@@ -290,13 +277,10 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
verticalScrollBar.setUI(new TrackRectSubstanceScrollbarUI(verticalScrollBar));
|
verticalScrollBar.setUI(new TrackRectSubstanceScrollbarUI(verticalScrollBar));
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollbarOverlay = new ScrollbarOverlay((LineMarkedEditorPane) pane);
|
highlightsPanel = new HighlightsPanel((LineMarkedEditorPane) pane);
|
||||||
|
//scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
layer = new JLayer<>(verticalScrollBar, scrollbarOverlay);
|
|
||||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
|
||||||
|
|
||||||
JPanel panel = (JPanel) SwingUtilities.getAncestorOfClass(JPanel.class, scrollPane);
|
JPanel panel = (JPanel) SwingUtilities.getAncestorOfClass(JPanel.class, scrollPane);
|
||||||
panel.add(layer, BorderLayout.EAST);
|
panel.add(highlightsPanel, BorderLayout.EAST);
|
||||||
|
|
||||||
documentUpdated();
|
documentUpdated();
|
||||||
markTokenAt(editor.getCaretPosition());
|
markTokenAt(editor.getCaretPosition());
|
||||||
@@ -335,8 +319,8 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
}
|
}
|
||||||
JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, editor);
|
JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, editor);
|
||||||
JPanel panel = (JPanel) SwingUtilities.getAncestorOfClass(JPanel.class, scrollPane);
|
JPanel panel = (JPanel) SwingUtilities.getAncestorOfClass(JPanel.class, scrollPane);
|
||||||
panel.remove(layer);
|
panel.remove(highlightsPanel);
|
||||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
//scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||||
panel.revalidate();
|
panel.revalidate();
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
scrollPane.setUI(originalScrollPaneUI);
|
scrollPane.setUI(originalScrollPaneUI);
|
||||||
@@ -362,7 +346,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
private void documentUpdated() {
|
private void documentUpdated() {
|
||||||
errors.clear();
|
errors.clear();
|
||||||
removeErrorMarkers();
|
removeErrorMarkers();
|
||||||
layer.repaint();
|
highlightsPanel.repaint();
|
||||||
try {
|
try {
|
||||||
SyntaxDocument sDoc = (SyntaxDocument) pane.getDocument();
|
SyntaxDocument sDoc = (SyntaxDocument) pane.getDocument();
|
||||||
|
|
||||||
@@ -392,8 +376,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
|||||||
} catch (SimpleParseException ex) {
|
} catch (SimpleParseException ex) {
|
||||||
definitionPosToReferences.clear();
|
definitionPosToReferences.clear();
|
||||||
referenceToDefinition.clear();
|
referenceToDefinition.clear();
|
||||||
errors.put((int) ex.position, ex.getMessage());
|
errors.put((int) ex.position, ex.getMessage());
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
Timer tim = errorsTimer;
|
Timer tim = errorsTimer;
|
||||||
if (tim != null) {
|
if (tim != null) {
|
||||||
|
|||||||
@@ -1057,4 +1057,8 @@ work.debugging.start = Starting Flash content debugger
|
|||||||
|
|
||||||
menu.file.view.alwaysOnTop = Always on top
|
menu.file.view.alwaysOnTop = Always on top
|
||||||
|
|
||||||
contextmenu.showDetail = Show detail
|
contextmenu.showDetail = Show detail
|
||||||
|
|
||||||
|
highlighter.occurences = Mark occurences
|
||||||
|
highlighter.currentLine = Current line
|
||||||
|
highlighter.error = Error: %error%
|
||||||
Reference in New Issue
Block a user