From 0aadf53cb7116745f79a5ad8187b8be759fd213d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 16 Jun 2013 20:19:25 +0200 Subject: [PATCH] Issue #128 improved imports --- .../flash/abc/types/traits/TraitClass.java | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index e92a7ddaf..05e96399e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -77,6 +77,13 @@ public class TraitClass extends Trait implements TraitWithSlot { name = "*"; } String newimport = ns.getName(abc.constants); + System.out.println(newimport + ":" + name + ":" + ns.getKindStr()); + if ((ns.kind != Namespace.KIND_PACKAGE) + && (ns.kind != Namespace.KIND_NAMESPACE) + && (ns.kind != Namespace.KIND_STATIC_PROTECTED)) { + return false; + } + System.out.println(newimport); /*if (ns.kind == Namespace.KIND_NAMESPACE)*/ { String oldimport = newimport; newimport = null; @@ -90,7 +97,18 @@ public class TraitClass extends Trait implements TraitWithSlot { break; } } + if (newimport == null) { + newimport = oldimport; + newimport += "." + name; + } + if (newimport.equals("")) { + newimport = null; + } if (newimport != null) { + /* if(ns.kind==Namespace.KIND_PACKAGE){ + newimport+=".*"; + }*/ + if (!imports.contains(newimport)) { if (newimport.contains(":")) { return true; @@ -103,11 +121,15 @@ public class TraitClass extends Trait implements TraitWithSlot { if (usname.contains(".")) { usname = usname.substring(usname.lastIndexOf(".") + 1); } - if (!pkg.equals(ignorePackage)) { - imports.add(newimport); + if (ns.kind == Namespace.KIND_PACKAGE) { + if (!pkg.equals(ignorePackage)) { + imports.add(newimport); + } } - if (!uses.contains(usname)) { - uses.add(usname); + if (ns.kind == Namespace.KIND_NAMESPACE) { + if (!uses.contains(usname)) { + uses.add(usname); + } } } return true; @@ -166,6 +188,10 @@ public class TraitClass extends Trait implements TraitWithSlot { if (nss != null) { if (nss.namespaces.length == 1) { parseUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name); + } else { + for (int n : nss.namespaces) { + parseUsagesFromNS(abcTags, abc, imports, uses, n, ignorePackage, ""); + } } } } @@ -379,6 +405,19 @@ public class TraitClass extends Trait implements TraitWithSlot { } imports = imports2;*/ + for(int i=0;i