AS1/2: Variable hilighter - hilight variables with no definition, catch variable

This commit is contained in:
Jindra Petřík
2025-05-27 20:48:34 +02:00
parent 9ee3992336
commit 8bb357d3b0
7 changed files with 413 additions and 261 deletions

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.parser.script.variables;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public class CatchScope implements Scope {
private final List<VariableOrScope> privateItems;
private final List<VariableOrScope> sharedItems;
public CatchScope(Variable catchVariable, List<VariableOrScope> catchBody) {
this.privateItems = new ArrayList<>();
this.privateItems.add(catchVariable);
this.sharedItems = catchBody;
}
@Override
public List<VariableOrScope> getSharedItems() {
return sharedItems;
}
@Override
public List<VariableOrScope> getPrivateItems() {
return privateItems;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.parser.script.variables;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public class FunctionScope implements Scope {
private final List<VariableOrScope> privateItems;
public FunctionScope(List<VariableOrScope> functionBody) {
this.privateItems = functionBody;
}
@Override
public List<VariableOrScope> getSharedItems() {
return new ArrayList<>();
}
@Override
public List<VariableOrScope> getPrivateItems() {
return privateItems;
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.parser.script.variables;
import java.util.List;
/**
*
* @author JPEXS
*/
public interface Scope extends VariableOrScope {
public List<VariableOrScope> getSharedItems();
public List<VariableOrScope> getPrivateItems();
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.parser.script.variables;
/**
*
* @author JPEXS
*/
public class Variable implements VariableOrScope {
public boolean definition;
public String name;
public int position;
public Variable(boolean definition, String name, int position) {
this.definition = definition;
this.name = name;
this.position = position;
}
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.parser.script.variables;
/**
*
* @author JPEXS
*/
public interface VariableOrScope {
}