Ghidra is a software reverse engineering (SRE) framework
Help build fix
dragonmacher89f9e6f8d59a
diff --git a/Ghidra/Framework/Help/src/main/java/help/PathKey.java b/Ghidra/Framework/Help/src/main/java/help/PathKey.javanew file mode 100644index 0000000000..0896a22b8c--- /dev/null+++ b/Ghidra/Framework/Help/src/main/java/help/PathKey.java@@ -0,0 +1,65 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package help;++import java.nio.file.Path;+import java.util.Objects;+++/** A class that wraps a Path and allows map lookup for paths from different file systems */+public class PathKey {+ private String path;++ public PathKey(Path p) {+ if (p == null) {+ Objects.requireNonNull(p, "Path cannot be null");+ }+ this.path = p.toString().replace('\\', '/');+ }++ public PathKey(String path) {+ Objects.requireNonNull(path, "Path cannot be null");;+ this.path = path.replace('\\', '/');+ }++ @Override+ public int hashCode() {+ return path.hashCode();+ }++ @Override+ public boolean equals(Object obj) {+ if (this == obj) {+ return true;+ }+ if (obj == null) {+ return false;+ }+ if (getClass() != obj.getClass()) {+ return false;+ }++ PathKey other = (PathKey) obj;++ boolean result = path.equals(other.path);+ return result;+ }++ @Override+ public String toString() {+ return path.toString();+ }+}diff --git a/Ghidra/Framework/Help/src/main/java/help/validator/AnchorManager.java b/Ghidra/Framework/Help/src/main/java/help/validator/AnchorManager.javaindex 7de88f0ead..30e68968c6 100644--- a/Ghidra/Framework/Help/src/main/java/help/validator/AnchorManager.java+++ b/Ghidra/Framework/Help/src/main/java/help/validator/AnchorManager.java@@ -15,15 +15,24 @@*/package help.validator;-import help.validator.model.*;-import java.nio.file.Path;-import java.util.*;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.HashSet;+import java.util.Iterator;+import java.util.List;+import java.util.Map;+import java.util.Set;++import help.PathKey;+import help.validator.model.AnchorDefinition;+import help.validator.model.HREF;+import help.validator.model.IMG;public class AnchorManager {- private Map<String, AnchorDefinition> anchorsByHelpPath =- new HashMap<String, AnchorDefinition>();+ private Map<PathKey, AnchorDefinition> anchorsByHelpPath =+ new HashMap<>();private Map<String, AnchorDefinition> anchorsById = new HashMap<String, AnchorDefinition>();private Map<String, AnchorDefinition> anchorsByName = new HashMap<String, AnchorDefinition>();private Map<String, List<AnchorDefinition>> duplicateAnchorsById =@@ -35,7 +44,7 @@ public class AnchorManager {public AnchorManager() {}- public void addAnchor(Path file, String anchorName, int srcLineNo) {+ public void addAnchor(Path file, String anchorName, int srcLineNo) {AnchorDefinition anchor = new AnchorDefinition(file, anchorName, srcLineNo);String id = anchor.getId();@@ -45,8 +54,8 @@ public class AnchorManager {}anchorsById.put(id, anchor);- anchorsByHelpPath.put(anchor.getHelpPath(), anchor);-+ anchorsByHelpPath.put(new PathKey(anchor.getHelpPath()), anchor);+if (anchorName != null) {anchorsByName.put(anchorName, anchor);}@@ -71,11 +80,11 @@ public class AnchorManager {if (!anchorsByName.containsKey(anchorName)) {anchorsByName.put(anchorName, anchor);- anchorsByHelpPath.put(anchor.getHelpPath(), anchor);+ anchorsByHelpPath.put(new PathKey(anchor.getHelpPath()), anchor);}}- public Map<String, AnchorDefinition> getAnchorsByHelpPath() {+ public Map<PathKey, AnchorDefinition> getAnchorsByHelpPath() {return anchorsByHelpPath;}diff --git a/Ghidra/Framework/Help/src/main/java/help/validator/location/HelpModuleCollection.java b/Ghidra/Framework/Help/src/main/java/help/validator/location/HelpModuleCollection.javaindex a3efa33bdd..8489df7b28 100644--- a/Ghidra/Framework/Help/src/main/java/help/validator/location/HelpModuleCollection.java+++ b/Ghidra/Framework/Help/src/main/java/help/validator/location/HelpModuleCollection.java@@ -16,10 +16,21 @@package help.validator.location;import java.io.File;-import java.net.*;+import java.net.MalformedURLException;+import java.net.URISyntaxException;+import java.net.URL;import java.nio.file.Path;import java.nio.file.Paths;-import java.util.*;+import java.util.ArrayList;+import java.util.Collection;+import java.util.Collections;+import java.util.Enumeration;+import java.util.HashMap;+import java.util.HashSet;+import java.util.LinkedHashSet;+import java.util.List;+import java.util.Map;+import java.util.Set;import java.util.stream.Collectors;import javax.help.HelpSet;@@ -29,8 +40,17 @@ import javax.swing.tree.DefaultMutableTreeNode;import help.CustomTOCView.CustomTreeItemDecorator;import help.HelpBuildUtils;+import help.PathKey;import help.TOCItemProvider;-import help.validator.model.*;+import help.validator.model.AnchorDefinition;+import help.validator.model.GhidraTOCFile;+import help.validator.model.HREF;+import help.validator.model.HelpFile;+import help.validator.model.HelpTopic;+import help.validator.model.IMG;+import help.validator.model.TOCItem;+import help.validator.model.TOCItemDefinition;+import help.validator.model.TOCItemExternal;/*** A class that is meant to hold a single help <b>input</b> directory and 0 or more@@ -353,48 +373,4 @@ public class HelpModuleCollection implements TOCItemProvider {public String toString() {return helpLocations.toString();}--//==================================================================================================-// Inner Classes-//==================================================================================================-- /** A class that wraps a Path and allows map lookup for paths from different file systems */- private class PathKey {- private String path;-- PathKey(Path p) {- if (p == null) {- throw new IllegalArgumentException("Path cannot be null");- }- this.path = p.toString().replace('\\', '/');- }-- @Override- public int hashCode() {- return path.hashCode();- }-- @Override- public boolean equals(Object obj) {- if (this == obj) {- return true;- }- if (obj == null) {- return false;- }- if (getClass() != obj.getClass()) {- return false;- }-- PathKey other = (PathKey) obj;-- boolean result = path.equals(other.path);- return result;- }-- @Override- public String toString() {- return path.toString();- }- }}diff --git a/Ghidra/Framework/Help/src/main/java/help/validator/model/HelpFile.java b/Ghidra/Framework/Help/src/main/java/help/validator/model/HelpFile.javaindex 374df0bf16..e3fbc280ea 100644--- a/Ghidra/Framework/Help/src/main/java/help/validator/model/HelpFile.java+++ b/Ghidra/Framework/Help/src/main/java/help/validator/model/HelpFile.java@@ -17,11 +17,17 @@ package help.validator.model;import java.io.IOException;import java.nio.file.Path;-import java.util.*;+import java.util.Collection;+import java.util.List;+import java.util.Map;import ghidra.util.exception.AssertException;import help.HelpBuildUtils;-import help.validator.*;+import help.PathKey;+import help.validator.AnchorManager;+import help.validator.HTMLFileParser;+import help.validator.ReferenceTagProcessor;+import help.validator.TagProcessor;import help.validator.location.HelpModuleLocation;public class HelpFile {@@ -74,9 +80,10 @@ public class HelpFile {return anchorManager.getDuplicateAnchorsByID();}- public AnchorDefinition getAnchorDefinition(Path helpPath) {- Map<String, AnchorDefinition> anchorsByHelpPath = anchorManager.getAnchorsByHelpPath();- return anchorsByHelpPath.get(helpPath.toString());+ public AnchorDefinition getAnchorDefinition(Path helpPath) {+ Map<PathKey, AnchorDefinition> anchorsByHelpPath = anchorManager.getAnchorsByHelpPath();+ AnchorDefinition def = anchorsByHelpPath.get(new PathKey(helpPath));+ return def;}public Collection<AnchorDefinition> getAllAnchorDefinitions() {