]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/Find.java
1. Fix EDKT447 Keep PPI/Protocol/GUID/PCD in find result even if they are only declar...
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / find / Find.java
index c735b5e6b4da4dc85d9039dc7e5ae7d57c885816..de67728dfc91b27ef47d87480bbd67dec266e463 100644 (file)
@@ -16,11 +16,14 @@ package org.tianocore.frameworkwizard.common.find;
 \r
 import java.util.Vector;\r
 \r
+import org.tianocore.GuidDeclarationsDocument.GuidDeclarations;\r
 import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass;\r
 import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
 import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;\r
 import org.tianocore.PcdDeclarationsDocument.PcdDeclarations.PcdEntry;\r
+import org.tianocore.PpiDeclarationsDocument.PpiDeclarations;\r
+import org.tianocore.ProtocolDeclarationsDocument.ProtocolDeclarations;\r
 import org.tianocore.frameworkwizard.common.DataType;\r
 import org.tianocore.frameworkwizard.common.GlobalData;\r
 import org.tianocore.frameworkwizard.common.Sort;\r
@@ -160,6 +163,39 @@ public class Find {
                 }\r
             }\r
         }\r
+        //\r
+        // Go through all defined ppi to find which is not added yet.\r
+        //\r
+        for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
+            PackageSurfaceArea spd = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage).getXmlSpd();\r
+            PackageIdentification packageId = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage)\r
+                                                                           .getId();\r
+            if (spd.getPpiDeclarations() != null) {\r
+                for (int indexOfPpis = 0; indexOfPpis < spd.getPpiDeclarations().getEntryList().size(); indexOfPpis++) {\r
+                    boolean isFound = false;\r
+                    PpiDeclarations.Entry e = spd.getPpiDeclarations().getEntryList().get(indexOfPpis);\r
+                    for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {\r
+                        if (e.getCName().equals(pv.getPpis(indexOfPv).getName())) {\r
+                            isFound = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                    if (!isFound) {\r
+                        String arg0 = e.getCName();\r
+                        String arg1 = "";\r
+                        String arg2 = "";\r
+                        String arg3 = "";\r
+                        Vector<String> arg4 = Tools.convertListToVector(e.getSupArchList());\r
+                        String arg5 = e.getHelpText();\r
+\r
+                        pid = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
+                        pid.setBelongModule(null);\r
+                        pid.setDeclaredBy(packageId);\r
+                        pv.addPpis(pid);\r
+                    }\r
+                }\r
+            }\r
+        }\r
         Sort.sortPpis(pv, DataType.SORT_TYPE_ASCENDING);\r
         return pv;\r
     }\r
@@ -197,7 +233,10 @@ public class Find {
             //\r
             // Get the sting "PackageName.ModuleName" \r
             //\r
-            String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
+            String tmp = "";\r
+            if (pvId.getBelongModule() != null) {\r
+                tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
+            }\r
 \r
             //\r
             // Check if the item has been added in\r
@@ -353,6 +392,39 @@ public class Find {
                 }\r
             }\r
         }\r
+        //\r
+        // Go through all defined protocols to find which is not added yet.\r
+        //\r
+        for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
+            PackageSurfaceArea spd = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage).getXmlSpd();\r
+            PackageIdentification packageId = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage)\r
+                                                                           .getId();\r
+            if (spd.getProtocolDeclarations() != null) {\r
+                for (int indexOfProtocols = 0; indexOfProtocols < spd.getProtocolDeclarations().getEntryList().size(); indexOfProtocols++) {\r
+                    boolean isFound = false;\r
+                    ProtocolDeclarations.Entry e = spd.getProtocolDeclarations().getEntryList().get(indexOfProtocols);\r
+                    for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {\r
+                        if (e.getCName().equals(pv.getProtocols(indexOfPv).getName())) {\r
+                            isFound = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                    if (!isFound) {\r
+                        String arg0 = e.getCName();\r
+                        String arg1 = "";\r
+                        String arg2 = "";\r
+                        String arg3 = "";\r
+                        Vector<String> arg4 = Tools.convertListToVector(e.getSupArchList());\r
+                        String arg5 = e.getHelpText();\r
+\r
+                        pid = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
+                        pid.setBelongModule(null);\r
+                        pid.setDeclaredBy(packageId);\r
+                        pv.addProtocols(pid);\r
+                    }\r
+                }\r
+            }\r
+        }\r
         Sort.sortProtocols(pv, DataType.SORT_TYPE_ASCENDING);\r
         return pv;\r
     }\r
@@ -390,7 +462,10 @@ public class Find {
             //\r
             // Get the sting "PackageName.ModuleName" \r
             //\r
-            String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
+            String tmp = "";\r
+            if (pvId.getBelongModule() != null) {\r
+                tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
+            }\r
 \r
             //\r
             // Check if the item has been added in\r
@@ -500,6 +575,38 @@ public class Find {
                 }\r
             }\r
         }\r
+        //\r
+        // Go through all defined guids to find which is not added yet.\r
+        //\r
+        for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
+            PackageSurfaceArea spd = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage).getXmlSpd();\r
+            PackageIdentification packageId = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage)\r
+                                                                           .getId();\r
+            if (spd.getGuidDeclarations() != null) {\r
+                for (int indexOfGuids = 0; indexOfGuids < spd.getGuidDeclarations().getEntryList().size(); indexOfGuids++) {\r
+                    boolean isFound = false;\r
+                    GuidDeclarations.Entry e = spd.getGuidDeclarations().getEntryList().get(indexOfGuids);\r
+                    for (int indexOfGv = 0; indexOfGv < gv.size(); indexOfGv++) {\r
+                        if (e.getCName().equals(gv.getGuids(indexOfGv).getName())) {\r
+                            isFound = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                    if (!isFound) {\r
+                        String arg0 = e.getCName();\r
+                        String arg1 = "";\r
+                        String arg2 = "";\r
+                        Vector<String> arg3 = Tools.convertListToVector(e.getSupArchList());\r
+                        String arg4 = e.getHelpText();\r
+\r
+                        gid = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);\r
+                        gid.setBelongModule(null);\r
+                        gid.setDeclaredBy(packageId);\r
+                        gv.addGuids(gid);\r
+                    }\r
+                }\r
+            }\r
+        }\r
         Sort.sortGuids(gv, DataType.SORT_TYPE_ASCENDING);\r
         return gv;\r
     }\r
@@ -537,7 +644,10 @@ public class Find {
             //\r
             // Get the sting "PackageName.ModuleName" \r
             //\r
-            String tmp = gvId.getBelongModule().getPackageId().getName() + SEPERATOR + gvId.getBelongModule().getName();\r
+            String tmp = "";\r
+            if (gvId.getBelongModule() != null) {\r
+                tmp = gvId.getBelongModule().getPackageId().getName() + SEPERATOR + gvId.getBelongModule().getName();\r
+            }\r
 \r
             //\r
             // Check if the item has been added in\r
@@ -656,32 +766,51 @@ public class Find {
                 }\r
             }\r
         }\r
+        //\r
+        // Go through all defined pcds to find which is not added yet.\r
+        //\r
+        for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
+            PackageSurfaceArea spd = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage).getXmlSpd();\r
+            PackageIdentification packageId = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage)\r
+                                                                           .getId();\r
+            if (spd.getPcdDeclarations() != null) {\r
+                for (int indexOfPcds = 0; indexOfPcds < spd.getPcdDeclarations().getPcdEntryList().size(); indexOfPcds++) {\r
+                    boolean isFound = false;\r
+                    PcdEntry e = spd.getPcdDeclarations().getPcdEntryList().get(indexOfPcds);\r
+                    for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {\r
+                        if (e.getCName().equals(pv.getPcdCoded(indexOfPv).getName())) {\r
+                            isFound = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                    if (!isFound) {\r
+                        pid = new PcdCodedIdentification("", "", "", null, "", "", null, null);\r
+                        pid.setName(e.getCName());\r
+                        pid.setTokenSpaceGuidCName(e.getTokenSpaceGuidCName());\r
+                        pid.setToken(e.getToken().toString());\r
+                        pid.setDatumType(e.getDatumType().toString());\r
+                        pid.setValue(e.getDefaultValue());\r
+                        pid.setUsage(Tools.convertListToString(e.getValidUsage()));\r
+                        pid.setHelp(e.getHelpText());\r
+                        pid.setDeclaredBy(packageId);\r
+\r
+                        pid.setBelongModule(null);\r
+                        pv.addPcdCoded(pid);\r
+                    }\r
+                }\r
+            }\r
+        }\r
         Sort.sortPcdCodeds(pv, DataType.SORT_TYPE_ASCENDING);\r
         return pv;\r
     }\r
 \r
     /**\r
-     Re-org all guid entries for find table\r
      \r
+     @param pv\r
      @return\r
      \r
      **/\r
-/**\r
-\r
- @return\r
-\r
-**/\r
-/**\r
-\r
- @return\r
-\r
-**/\r
-/**\r
-\r
- @return\r
-\r
-**/\r
-public static Vector<PcdFindResultId> getAllPcdCodedForFind(PcdCodedVector pv) {\r
+    public static Vector<PcdFindResultId> getAllPcdCodedForFind(PcdCodedVector pv) {\r
         Vector<PcdFindResultId> pcd = new Vector<PcdFindResultId>();\r
         boolean isAdded = false;\r
         boolean isProduced = false;\r
@@ -734,13 +863,14 @@ public static Vector<PcdFindResultId> getAllPcdCodedForFind(PcdCodedVector pv) {
                 pcdId.setDatumType(pvId.getDatumType());\r
                 pcdId.setValue(pvId.getValue());\r
                 pcdId.setUsage(pvId.getUsage());\r
-                \r
+\r
                 pcd.addElement(pcdId);\r
             }\r
         }\r
 \r
         return pcd;\r
     }\r
+\r
     /**\r
      Get all library class entries from workspace\r
      \r
@@ -821,6 +951,38 @@ public static Vector<PcdFindResultId> getAllPcdCodedForFind(PcdCodedVector pv) {
                 }\r
             }\r
         }\r
+        //\r
+        // Go through all defined pcds to find which is not added yet.\r
+        //\r
+        for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
+            PackageSurfaceArea spd = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage).getXmlSpd();\r
+            PackageIdentification packageId = GlobalData.openingPackageList.getOpeningPackageByIndex(indexOfPackage)\r
+                                                                           .getId();\r
+            if (spd.getLibraryClassDeclarations() != null) {\r
+                for (int indexOfLibraryClass = 0; indexOfLibraryClass < spd.getLibraryClassDeclarations()\r
+                                                                           .getLibraryClassList().size(); indexOfLibraryClass++) {\r
+                    boolean isFound = false;\r
+                    LibraryClass lc = spd.getLibraryClassDeclarations().getLibraryClassList().get(indexOfLibraryClass);\r
+                    for (int indexOfLcv = 0; indexOfLcv < lcv.size(); indexOfLcv++) {\r
+                        if (lc.getName().equals(lcv.getLibraryClass(indexOfLcv).getLibraryClassName())) {\r
+                            isFound = true;\r
+                            break;\r
+                        }\r
+                    }\r
+                    if (!isFound) {\r
+                        lcid = new LibraryClassIdentification("", null, "", "", null, "", null, "");\r
+                        lcid.setLibraryClassName(lc.getName());\r
+                        lcid.setSupArchList(Tools.convertListToVector(lc.getSupArchList()));\r
+                        lcid.setSupModuleList(Tools.convertListToVector(lc.getSupModuleList()));\r
+                        lcid.setHelp(lc.getHelpText());\r
+                        lcid.setDeclaredBy(packageId);\r
+\r
+                        lcid.setBelongModule(null);\r
+                        lcv.addLibraryClass(lcid);\r
+                    }\r
+                }\r
+            }\r
+        }\r
         Sort.sortLibraryClass(lcv, DataType.SORT_TYPE_ASCENDING);\r
         return lcv;\r
     }\r