use of com.synopsys.integration.bdio.graph.MutableDependencyGraph in project hub-detect by blackducksoftware.
the class CodeLocationAssembler method generateCodeLocation.
public DetectCodeLocation generateCodeLocation(final Forge defaultForge, final File rootDir, final List<Dependency> bdioComponents) {
final MutableDependencyGraph dependencyGraph = populateGraph(bdioComponents);
final ExternalId externalId = externalIdFactory.createPathExternalId(defaultForge, rootDir.toString());
return new DetectCodeLocation.Builder(DetectCodeLocationType.CLANG, rootDir.toString(), externalId, dependencyGraph).build();
}
use of com.synopsys.integration.bdio.graph.MutableDependencyGraph in project hub-detect by blackducksoftware.
the class Rebar3TreeParser method parseRebarTreeOutput.
public RebarParseResult parseRebarTreeOutput(final List<String> dependencyTreeOutput, final String sourcePath) {
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
final DependencyHistory history = new DependencyHistory();
Dependency project = null;
for (final String line : dependencyTreeOutput) {
if (!line.contains(HORIZONTAL_SEPARATOR_CHARACTER)) {
continue;
}
final Dependency currentDependency = createDependencyFromLine(line);
final int lineLevel = getDependencyLevelFromLine(line);
try {
history.clearDependenciesDeeperThan(lineLevel);
} catch (final IllegalStateException e) {
logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage()));
}
if (history.isEmpty() && isProject(line)) {
project = currentDependency;
} else if (history.getLastDependency().equals(project)) {
graph.addChildToRoot(currentDependency);
} else if (history.isEmpty()) {
graph.addChildToRoot(currentDependency);
} else {
graph.addChildWithParents(currentDependency, history.getLastDependency());
}
history.add(currentDependency);
}
if (project == null) {
final ExternalId projectExternalId = externalIdFactory.createPathExternalId(Forge.HEX, sourcePath);
project = new Dependency("", "", projectExternalId);
}
final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.HEX, project.name, project.version);
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.HEX, sourcePath, externalId, graph).build();
return new RebarParseResult(project.name, project.version, codeLocation);
}
use of com.synopsys.integration.bdio.graph.MutableDependencyGraph in project hub-detect by blackducksoftware.
the class VndrParser method parseVendorConf.
public DependencyGraph parseVendorConf(final List<String> vendorConfContents) {
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
// TODO test against moby
vendorConfContents.forEach(line -> {
if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
final String[] parts = line.split(" ");
final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]);
final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId);
graph.addChildToRoot(dependency);
}
});
return graph;
}
use of com.synopsys.integration.bdio.graph.MutableDependencyGraph in project hub-detect by blackducksoftware.
the class CpanListParser method parse.
public DependencyGraph parse(final List<String> cpanListText, final List<String> directDependenciesText) {
final Map<String, String> nameVersionMap = createNameVersionMap(cpanListText);
final List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
for (final String moduleName : directModuleNames) {
final String version = nameVersionMap.get(moduleName);
if (null != version) {
final String name = moduleName.replace("::", "-");
final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.CPAN, name, version);
final Dependency dependency = new Dependency(name, version, externalId);
graph.addChildToRoot(dependency);
} else {
logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
}
}
return graph;
}
use of com.synopsys.integration.bdio.graph.MutableDependencyGraph in project hub-detect by blackducksoftware.
the class AggregateBdioCreator method createAggregateDependencyGraph.
private DependencyGraph createAggregateDependencyGraph(File sourcePath, final List<DetectCodeLocation> codeLocations) {
final MutableDependencyGraph aggregateDependencyGraph = simpleBdioFactory.createMutableDependencyGraph();
for (final DetectCodeLocation detectCodeLocation : codeLocations) {
final Dependency codeLocationDependency = createAggregateDependency(sourcePath, detectCodeLocation);
aggregateDependencyGraph.addChildrenToRoot(codeLocationDependency);
aggregateDependencyGraph.addGraphAsChildrenToParent(codeLocationDependency, detectCodeLocation.getDependencyGraph());
}
return aggregateDependencyGraph;
}
Aggregations