mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Help build fix
This commit is contained in:
parent
c8790828f4
commit
89f9e6f8d5
4 changed files with 119 additions and 62 deletions
65
Ghidra/Framework/Help/src/main/java/help/PathKey.java
Normal file
65
Ghidra/Framework/Help/src/main/java/help/PathKey.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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 =
|
||||
|
@ -45,7 +54,7 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
@ -75,8 +81,9 @@ public class HelpFile {
|
|||
}
|
||||
|
||||
public AnchorDefinition getAnchorDefinition(Path helpPath) {
|
||||
Map<String, AnchorDefinition> anchorsByHelpPath = anchorManager.getAnchorsByHelpPath();
|
||||
return anchorsByHelpPath.get(helpPath.toString());
|
||||
Map<PathKey, AnchorDefinition> anchorsByHelpPath = anchorManager.getAnchorsByHelpPath();
|
||||
AnchorDefinition def = anchorsByHelpPath.get(new PathKey(helpPath));
|
||||
return def;
|
||||
}
|
||||
|
||||
public Collection<AnchorDefinition> getAllAnchorDefinitions() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue