use of org.eclipse.titan.designer.parsers.ProjectStructureDataCollector in project titan.EclipsePlug-ins by eclipse.
the class ModuleGraphGenerator method createGraph.
@Override
protected void createGraph() {
// analyze the project if needed
final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(project);
if (sourceParser.getLastTimeChecked() == null) {
WorkspaceJob job = sourceParser.analyzeAll();
while (job == null) {
try {
Thread.sleep(500);
job = sourceParser.analyzeAll();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("Error while waiting for analyzis result", e);
}
}
try {
job.join();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("Error while parsing the project", e);
}
}
final List<IProject> visitedProjects = ProjectBasedBuilder.getProjectBasedBuilder(project).getAllReachableProjects();
final Map<String, Identifier> globalKnownModules = new HashMap<String, Identifier>();
for (int i = 0; i < visitedProjects.size(); ++i) {
final IProject currentProject = visitedProjects.get(i);
final ProjectStructureDataCollector collector = GlobalProjectStructureTracker.getDataCollector(currentProject);
collector.evaulateMissingModules();
// adding known modules
for (final Identifier moduleName : collector.knownModules.values()) {
final NodeDescriptor actNode = new NodeDescriptor(moduleName.getDisplayName(), moduleName.getName(), currentProject, false, moduleName.getLocation());
globalKnownModules.put(moduleName.getName(), moduleName);
if (!graph.containsVertex(actNode)) {
graph.addVertex(actNode);
labels.put(actNode.getName(), actNode);
}
}
// adding missing modules
for (final Identifier moduleName : collector.missingModules.values()) {
if (!globalKnownModules.containsKey(moduleName.getName())) {
final NodeDescriptor actNode = new NodeDescriptor(moduleName.getDisplayName(), moduleName.getName(), currentProject, true, moduleName.getLocation());
if (!graph.containsVertex(actNode)) {
graph.addVertex(actNode);
labels.put(actNode.getName(), actNode);
}
}
}
// building edges
for (final String from : collector.importations.keySet()) {
for (final String to : collector.importations.get(from)) {
final EdgeDescriptor edge = new EdgeDescriptor(from + "->" + to, Color.black);
// if(!graph.containsEdge(edge))
graph.addEdge(edge, labels.get(from), labels.get(to), EdgeType.DIRECTED);
}
}
}
}
Aggregations