AS3: Better imports, uses

Formatting code
This commit is contained in:
Jindra Petk
2013-01-01 14:03:50 +01:00
parent e018eb96a3
commit 4fd93d3e57
24 changed files with 166 additions and 87 deletions

View File

@@ -149,7 +149,7 @@ public class Main {
if (actionMainFrame != null) {
actionMainFrame.setStatus(name);
}
if(loadingDialog!=null){
if (loadingDialog != null) {
loadingDialog.setDetail(name);
}
if (Main.isCommandLineMode()) {
@@ -165,7 +165,7 @@ public class Main {
if (actionMainFrame != null) {
actionMainFrame.setStatus("");
}
if(loadingDialog!=null){
if (loadingDialog != null) {
loadingDialog.setDetail("");
}
}

View File

@@ -305,12 +305,11 @@ public class SWF {
}
}
for (int i = 0; i < abcTags.size(); i++) {
DoABCTag t=abcTags.get(i);
DoABCTag t = abcTags.get(i);
t.abc.addEventListener(evl);
t.abc.export(outdir, isPcode, abcTags,"tag "+(i+1)+"/"+abcTags.size()+" ");
t.abc.export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " ");
}
for (DoABCTag t : abcTags) {
}
if (!asV3Found) {

View File

@@ -529,7 +529,7 @@ public class ABC {
}
String cnt = "";
if (script_info.length > 1) {
cnt = "script " + (i + 1) + "/" + script_info.length+" ";
cnt = "script " + (i + 1) + "/" + script_info.length + " ";
}
String exStr = "Exporting " + abcStr + cnt + path + " ...";
informListeners("export", exStr);

View File

@@ -955,8 +955,7 @@ public class AVM2Code {
output.remove(i);
i--;
}
}else
if (output.get(i) instanceof WithTreeItem) {
} else if (output.get(i) instanceof WithTreeItem) {
clearTemporaryRegisters(((WithTreeItem) output.get(i)).items);
}
}

View File

@@ -55,21 +55,21 @@ public class ConstructIns extends InstructionDefinition {
//push new instance
}
private boolean walkXML(TreeItem item,List<TreeItem> list){
boolean ret=true;
if(item instanceof StringTreeItem){
private boolean walkXML(TreeItem item, List<TreeItem> list) {
boolean ret = true;
if (item instanceof StringTreeItem) {
list.add(item);
}else if(item instanceof AddTreeItem){
ret=ret && walkXML(((AddTreeItem)item).leftSide,list);
ret=ret && walkXML(((AddTreeItem)item).rightSide,list);
}else if(item instanceof EscapeXElemTreeItem){
} else if (item instanceof AddTreeItem) {
ret = ret && walkXML(((AddTreeItem) item).leftSide, list);
ret = ret && walkXML(((AddTreeItem) item).rightSide, list);
} else if (item instanceof EscapeXElemTreeItem) {
list.add(item);
}else{
} else {
return false;
}
return ret;
return ret;
}
@Override
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
int argCount = ins.operands[0];
@@ -86,7 +86,7 @@ public class ConstructIns extends InstructionDefinition {
if (args.size() == 1) {
TreeItem arg = args.get(0);
List<TreeItem> xmlLines = new ArrayList<TreeItem>();
if (walkXML(arg,xmlLines)) {
if (walkXML(arg, xmlLines)) {
stack.push(new XMLTreeItem(ins, xmlLines));
return;
}

View File

@@ -58,7 +58,7 @@ public class CallSuperVoidIns extends InstructionDefinition {
int argCount = ins.operands[1];
List<TreeItem> args = new ArrayList<TreeItem>();
for (int a = 0; a < argCount; a++) {
args.add(0,(TreeItem) stack.pop());
args.add(0, (TreeItem) stack.pop());
}
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
TreeItem receiver = (TreeItem) stack.pop();

View File

@@ -17,7 +17,6 @@
package com.jpexs.asdec.abc.avm2.instructions.stack;
import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.avm2.AVM2Code;
import com.jpexs.asdec.abc.avm2.ConstantPool;
import com.jpexs.asdec.abc.avm2.LocalDataArea;
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
@@ -46,8 +45,8 @@ public class PopScopeIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
TreeItem scope = (TreeItem) scopeStack.pop();
if(scope instanceof WithObjectTreeItem){
scope = ((WithObjectTreeItem)scope).scope;
if (scope instanceof WithObjectTreeItem) {
scope = ((WithObjectTreeItem) scope).scope;
}
for (int i = output.size() - 1; i >= 0; i--) {
if (output.get(i) instanceof WithTreeItem) {
@@ -60,7 +59,7 @@ public class PopScopeIns extends InstructionDefinition {
}
while (output.size() > i + 1) {
output.remove(i + 1);
}
}
/*int count=output.size()-1-(i+1);
for(int c=0;c<count;c++){
output.remove(i+1);

View File

@@ -38,7 +38,7 @@ public class PushWithIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, MethodBody body, ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
TreeItem w = (TreeItem) stack.pop();
WithObjectTreeItem wot = new WithObjectTreeItem(ins,w);
WithObjectTreeItem wot = new WithObjectTreeItem(ins, w);
scopeStack.push(wot);
output.add(new WithTreeItem(ins, w));
}

View File

@@ -41,8 +41,8 @@ public class CheckFilterIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
TreeItem obj=stack.pop();
stack.push(new FilteredCheckTreeItem(ins, obj));
TreeItem obj = stack.pop();
stack.push(new FilteredCheckTreeItem(ins, obj));
}
@Override

View File

@@ -23,7 +23,6 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.asdec.abc.avm2.treemodel.EscapeXElemTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.UnparsedTreeItem;
import com.jpexs.asdec.abc.types.MethodInfo;
import java.util.HashMap;
import java.util.List;

View File

@@ -28,15 +28,14 @@ import java.util.List;
public class FilteredCheckTreeItem extends TreeItem {
TreeItem object;
public FilteredCheckTreeItem(AVM2Instruction instruction,TreeItem object) {
public FilteredCheckTreeItem(AVM2Instruction instruction, TreeItem object) {
super(instruction, NOPRECEDENCE);
this.object=object;
this.object = object;
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(constants, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -69,7 +69,7 @@ public class FullMultinameTreeItem extends TreeItem {
cns = ns.getName(constants);
}
}
return cname.equals("XML")&&cns.equals("");
return cname.equals("XML") && cns.equals("");
}
@Override

View File

@@ -38,7 +38,7 @@ public class LocalRegTreeItem extends TreeItem {
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if(computedValue instanceof FilterTreeItem){
if (computedValue instanceof FilterTreeItem) {
return computedValue.toString(constants, localRegNames, fullyQualifiedNames);
}
return hilight(localRegName(localRegNames, regIndex));

View File

@@ -24,7 +24,7 @@ import java.util.List;
public class WithObjectTreeItem extends TreeItem {
public TreeItem scope;
public WithObjectTreeItem(AVM2Instruction instruction, TreeItem scope) {
super(instruction, PRECEDENCE_PRIMARY);
this.scope = scope;

View File

@@ -39,6 +39,6 @@ public class FilterTreeItem extends TreeItem {
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return collection.toString(constants, localRegNames, fullyQualifiedNames)+hilight(".(") + expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")");
return collection.toString(constants, localRegNames, fullyQualifiedNames) + hilight(".(") + expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")");
}
}

View File

@@ -81,8 +81,8 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
break;
}
}
Main.abcMainFrame.navigator.setClassIndex(classIndex);
Main.abcMainFrame.navigator.setABC(abcList, scriptLeaf.abc);
Main.abcMainFrame.navigator.setClassIndex(classIndex);
Main.abcMainFrame.setAbc(scriptLeaf.abc);
Main.abcMainFrame.decompiledTextArea.setScript(scriptLeaf.abc.script_info[scriptLeaf.scriptIndex], scriptLeaf.abc, abcList);
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText("");

View File

@@ -83,7 +83,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
getCaret().setVisible(true);
int pos = getCaretPosition();
classIndex = -1;
for (Highlighting cm : classHighlights) {
if ((pos >= cm.startPos) && (pos < cm.startPos + cm.len)) {
classIndex = (int) cm.offset;

View File

@@ -17,7 +17,6 @@
package com.jpexs.asdec.abc.gui;
import com.jpexs.asdec.Configuration;
import com.jpexs.asdec.EventListener;
import com.jpexs.asdec.Main;
import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.gui.tablemodels.*;
@@ -30,7 +29,6 @@ import java.awt.Dimension;
import java.awt.event.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -62,7 +60,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
public JLabel asmLabel = new JLabel("P-code source (editable)");
public JLabel decLabel = new JLabel("ActionScript source");
public DetailPanel detailPanel;
public void setStatus(String s) {
if (s.equals("")) {
loadingPanel.setVisible(false);
@@ -339,7 +337,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
setJMenuBar(menuBar);
JPanel panConstants = new JPanel();
panConstants.setLayout(new BorderLayout());
constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"});
@@ -373,7 +371,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
tabbedPane.addTab("Constants", panConstants);
View.centerScreen(this);
Main.stopWork();
}
public void actionPerformed(ActionEvent e) {

View File

@@ -41,7 +41,7 @@ public class ScriptInfo {
for (Trait t : traits.traits) {
Multiname name = t.getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE)||(ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
return ns.getName(abc.constants) + "." + name.getName(abc.constants, new ArrayList<String>());
}
}

View File

@@ -50,7 +50,8 @@ public abstract class Trait {
Multiname m = getName(abc);
if (m != null) {
String nsname = "";
if (abc.constants.constant_namespace[m.namespace_index].kind == Namespace.KIND_NAMESPACE) {
//if (abc.constants.constant_namespace[m.namespace_index].kind == Namespace.KIND_NAMESPACE) {
{
for (DoABCTag abcTag : abcTags) {
nsname = abcTag.abc.nsValueToName(abc.constants.constant_namespace[m.namespace_index].getName(abc.constants));
if (nsname.equals("-")) {
@@ -121,7 +122,7 @@ public abstract class Trait {
protected String makePackageFromIndex(ABC abc, int name_index, String value) {
Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants);
if (ns.kind == Namespace.KIND_PACKAGE) {
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants);
return "package " + nsname + "\r\n{\r\n" + value + "\r\n}";
}

View File

@@ -20,6 +20,10 @@ import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.avm2.AVM2Code;
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.asdec.abc.avm2.instructions.construction.NewFunctionIns;
import com.jpexs.asdec.abc.avm2.instructions.other.FindPropertyIns;
import com.jpexs.asdec.abc.avm2.instructions.other.FindPropertyStrictIns;
import com.jpexs.asdec.abc.avm2.instructions.other.GetLexIns;
import com.jpexs.asdec.abc.avm2.instructions.types.CoerceIns;
import com.jpexs.asdec.abc.avm2.treemodel.InitPropertyTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.SetPropertyTreeItem;
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
@@ -43,25 +47,35 @@ public class TraitClass extends Trait {
public int slot_id;
public int class_info;
private static final String[] builtInClasses = {"ArgumentError", "arguments", "Array", "Boolean", "Class", "Date", "DefinitionError", "Error", "EvalError", "Function", "int", "JSON", "Math", "Namespace", "Number", "Object", "QName", "RangeError", "ReferenceError", "RegExp", "SecurityError", "String", "SyntaxError", "TypeError", "uint", "URIError", "VerifyError", "XML", "XMLList"};
private static boolean isBuiltInClass(String name) {
for (String g : builtInClasses) {
if (g.equals(name)) {
return true;
}
}
return false;
}
@Override
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return "Class " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata);
}
private void parseImportsUsagesFromNS(List<DoABCTag> abcTags, ABC abc, List imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
private boolean parseUsagesFromNS(List<DoABCTag> abcTags, ABC abc, List imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
Namespace ns = abc.constants.constant_namespace[namespace_index];
if (name.equals("")) {
name = "*";
}
String newimport = ns.getName(abc.constants);
if (ns.kind == Namespace.KIND_NAMESPACE) {
/*if (ns.kind == Namespace.KIND_NAMESPACE)*/ {
String oldimport = newimport;
newimport = null;
for (DoABCTag abcTag : abcTags) {
String newname = abcTag.abc.nsValueToName(oldimport);
if (newname.equals("-")) {
return;
return true;
}
if (!newname.equals("")) {
newimport = newname;
@@ -71,7 +85,7 @@ public class TraitClass extends Trait {
if (newimport != null) {
if (!imports.contains(newimport)) {
if (newimport.contains(":")) {
return;
return true;
}
String pkg = "";
if (newimport.contains(".")) {
@@ -88,9 +102,21 @@ public class TraitClass extends Trait {
uses.add(usname);
}
}
return true;
}
}
return false;
}
private void parseImportsUsagesFromNS(List<DoABCTag> abcTags, ABC abc, List imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
Namespace ns = abc.constants.constant_namespace[namespace_index];
if (name.equals("")) {
name = "*";
}
String newimport = ns.getName(abc.constants);
if (parseUsagesFromNS(abcTags, abc, imports, uses, namespace_index, ignorePackage, name)) {
return;
} else if (ns.kind != Namespace.KIND_PACKAGE) {
} else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) {
return;
}
if (newimport.equals("-")) {
@@ -110,6 +136,33 @@ public class TraitClass extends Trait {
//}
}
private void parseUsagesFromMultiname(List<DoABCTag> abcTags, ABC abc, List<String> imports, List<String> uses, Multiname m, String ignorePackage, List<String> fullyQualifiedNames) {
if (m != null) {
if (m.kind == Multiname.TYPENAME) {
if (m.qname_index != 0) {
parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m.qname_index], ignorePackage, fullyQualifiedNames);
}
for (Integer i : m.params) {
if (i != 0) {
parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], ignorePackage, fullyQualifiedNames);
}
}
return;
}
Namespace ns = m.getNamespace(abc.constants);
String name = m.getName(abc.constants, fullyQualifiedNames);
NamespaceSet nss = m.getNamespaceSet(abc.constants);
if (ns != null) {
parseUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name);
}
if (nss != null) {
if (nss.namespaces.length == 1) {
parseUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name);
}
}
}
}
private void parseImportsUsagesFromMultiname(List<DoABCTag> abcTags, ABC abc, List<String> imports, List<String> uses, Multiname m, String ignorePackage, List<String> fullyQualifiedNames) {
if (m != null) {
if (m.kind == Multiname.TYPENAME) {
@@ -130,8 +183,8 @@ public class TraitClass extends Trait {
parseImportsUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name);
}
if (nss != null) {
for (int ni : nss.namespaces) {
parseImportsUsagesFromNS(abcTags, abc, imports, uses, ni, ignorePackage, name);
if (nss.namespaces.length == 1) {
parseImportsUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name);
}
}
}
@@ -148,6 +201,7 @@ public class TraitClass extends Trait {
}
MethodBody body = abc.findBody(method_index);
if (body != null) {
parseImportsUsagesFromTraits(abcTags, abc, body.traits, imports, uses, ignorePackage, fullyQualifiedNames);
for (ABCException ex : body.exceptions) {
parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ex.type_index], ignorePackage, fullyQualifiedNames);
}
@@ -155,16 +209,33 @@ public class TraitClass extends Trait {
if (ins.definition instanceof NewFunctionIns) {
parseImportsUsagesFromMethodInfo(abcTags, abc, ins.operands[0], imports, uses, ignorePackage, fullyQualifiedNames);
}
for (int k = 0; k < ins.definition.operands.length; k++) {
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
int multinameIndex = ins.operands[k];
parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[multinameIndex], ignorePackage, fullyQualifiedNames);
if ((ins.definition instanceof FindPropertyStrictIns)
|| (ins.definition instanceof FindPropertyIns)
|| (ins.definition instanceof GetLexIns)
|| (ins.definition instanceof CoerceIns)) {
int m = ins.operands[0];
if (m != 0) {
parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m], ignorePackage, fullyQualifiedNames);
}
} else {
for (int k = 0; k < ins.definition.operands.length; k++) {
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
int multinameIndex = ins.operands[k];
parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[multinameIndex], ignorePackage, fullyQualifiedNames);
}
}
}
}
}
}
private void parseImportsUsagesFromTraits(List<DoABCTag> abcTags, ABC abc, Traits ts, List<String> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames) {
for (Trait t : ts.traits) {
parseImportsUsagesFromTrait(abcTags, abc, t, imports, uses, ignorePackage, fullyQualifiedNames);
}
}
private void parseImportsUsagesFromTrait(List<DoABCTag> abcTags, ABC abc, Trait t, List<String> imports, List<String> uses, String ignorePackage, List<String> fullyQualifiedNames) {
if (t instanceof TraitMethodGetterSetter) {
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
@@ -197,17 +268,14 @@ public class TraitClass extends Trait {
}
//static
for (Trait t : abc.class_info[class_info].static_traits.traits) {
parseImportsUsagesFromTrait(abcTags, abc, t, imports, uses, packageName, fullyQualifiedNames);
}
parseImportsUsagesFromTraits(abcTags, abc, abc.class_info[class_info].static_traits, imports, uses, packageName, fullyQualifiedNames);
//static initializer
parseImportsUsagesFromMethodInfo(abcTags, abc, abc.class_info[class_info].cinit_index, imports, uses, packageName, fullyQualifiedNames);
//instance
for (Trait t : abc.instance_info[class_info].instance_traits.traits) {
parseImportsUsagesFromTrait(abcTags, abc, t, imports, uses, packageName, fullyQualifiedNames);
}
parseImportsUsagesFromTraits(abcTags, abc, abc.instance_info[class_info].instance_traits, imports, uses, packageName, fullyQualifiedNames);
//instance initializer
parseImportsUsagesFromMethodInfo(abcTags, abc, abc.instance_info[class_info].iinit_index, imports, uses, packageName, fullyQualifiedNames);
@@ -248,20 +316,6 @@ public class TraitClass extends Trait {
List<String> importnames = new ArrayList<String>();
importnames.addAll(namesInThisPackage);
/*for (String path : imports) {
String name = path;
String pkg = "";
if (name.contains(".")) {
pkg = name.substring(0, name.lastIndexOf("."));
name = name.substring(name.lastIndexOf(".") + 1);
}
if (importnames.contains(name)) {
fullyQualifiedNames.add(name);
} else {
importnames.add(name);
}
}*/
List<String> imports2 = new ArrayList<String>();
for (String path : imports) {
String name = path;
String pkg = "";
@@ -269,12 +323,26 @@ public class TraitClass extends Trait {
pkg = name.substring(0, name.lastIndexOf("."));
name = name.substring(name.lastIndexOf(".") + 1);
}
if ((!packageName.equals(pkg)) && (!fullyQualifiedNames.contains(name))) {
imports2.add(path);
if (importnames.contains(name) || ((!pkg.equals("")) && isBuiltInClass(name))) {
fullyQualifiedNames.add(name);
} else {
importnames.add(name);
}
}
imports = imports2;
/*List<String> imports2 = new ArrayList<String>();
for (String path : imports) {
String name = path;
String pkg = "";
if (name.contains(".")) {
pkg = name.substring(0, name.lastIndexOf("."));
name = name.substring(name.lastIndexOf(".") + 1);
}
if ((!packageName.equals(pkg)) && (!fullyQualifiedNames.contains(name))) {
imports2.add(path);
}
}
imports = imports2;*/
for (String imp : imports) {
if (!imp.startsWith(".")) {

View File

@@ -19,6 +19,8 @@ package com.jpexs.asdec.abc.types.traits;
import com.jpexs.asdec.abc.ABC;
import com.jpexs.asdec.abc.avm2.ConstantPool;
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
import com.jpexs.asdec.abc.types.Multiname;
import com.jpexs.asdec.abc.types.Namespace;
import com.jpexs.asdec.abc.types.ValueKind;
import com.jpexs.asdec.helpers.Helper;
import com.jpexs.asdec.helpers.Highlighting;
@@ -93,6 +95,21 @@ public class TraitSlotConst extends Trait {
if (modifier.equals(" ")) {
modifier = "";
}
Multiname n = getName(abc);
boolean showModifier = true;
if ((classIndex == -1) && (n != null)) {
Namespace ns = n.getNamespace(abc.constants);
if (ns == null) {
showModifier = false;
} else {
if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) {
showModifier = false;
}
}
}
if (!showModifier) {
modifier = "";
}
return ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + getNameValueStr(abc, fullyQualifiedNames);
}

View File

@@ -68,7 +68,7 @@ public class Traits {
}
}
if (traits[t] instanceof TraitClass) {
plus = Highlighting.hilighClass(plus, ((TraitClass)traits[t]).class_info);
plus = Highlighting.hilighClass(plus, ((TraitClass) traits[t]).class_info);
} else {
plus = Highlighting.hilighTrait(plus, h);
}

View File

@@ -24,7 +24,6 @@ import java.awt.event.WindowEvent;
import java.awt.image.ImageObserver;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
/**
@@ -36,11 +35,12 @@ public class LoadingDialog extends JFrame implements ImageObserver {
private JLabel loadingLabel = new JLabel("");
private LoadingPanel loadingPanel;
String load="Loading, please wait...";
public void setDetail(String d){
loadingLabel.setText("<html><center>"+load+"<br>"+d+"</center></html>");
String load = "Loading, please wait...";
public void setDetail(String d) {
loadingLabel.setText("<html><center>" + load + "<br>" + d + "</center></html>");
}
/**
* Constructor
*/