use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class MarkerHandler method showAll.
/**
* Asynchronously create and show the all markers known to this
* <code>MarkerHandler</code> in eclipse.
* <p>
* This method starts a new {@link WorkspaceJob} to delete the current
* markers, and create the new ones. Note that only code smell markers are
* deleted (those of type {@link CodeSmellType#MARKER_ID}).
*/
public void showAll(final IProject project) {
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
final Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
org.eclipse.titan.designer.AST.MarkerHandler.markMarkersForRemoval(CodeSmellType.MARKER_ID, project);
for (final String moduleName : knownModuleNames) {
final Module mod = projectSourceParser.getModuleByName(moduleName);
final IResource moduleResource = mod.getLocation().getFile();
org.eclipse.titan.designer.AST.MarkerHandler.markMarkersForRemoval(CodeSmellType.MARKER_ID, moduleResource);
}
for (final IResource res : markersByResource.keySet()) {
refresh(res);
}
org.eclipse.titan.designer.AST.MarkerHandler.removeMarkedMarkers(CodeSmellType.MARKER_ID, project);
for (final String moduleName : knownModuleNames) {
final Module mod = projectSourceParser.getModuleByName(moduleName);
final IResource moduleResource = mod.getLocation().getFile();
org.eclipse.titan.designer.AST.MarkerHandler.removeMarkedMarkers(CodeSmellType.MARKER_ID, moduleResource);
}
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class CycleCheck method process.
@Override
public void process(final IProject project, final Problems problems) {
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
final Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
final List<Module> modules = new ArrayList<Module>();
for (final String moduleName : new TreeSet<String>(knownModuleNames)) {
modules.add(projectSourceParser.getModuleByName(moduleName));
}
Collections.sort(modules, new Comparator<Module>() {
@Override
public int compare(final Module o1, final Module o2) {
return o1.getName().compareTo(o2.getName());
}
});
final CycleCheck check = new CycleCheck(modules);
for (final List<Module> cycle : check.cycles) {
final StringBuilder sb = new StringBuilder("Importation cycle detected: ");
for (final Module module : cycle) {
sb.append(module.getName());
sb.append(" -> ");
}
sb.append(cycle.get(0).getName());
final String errMsg = sb.toString();
// Try to find the locations to report, i.e. the import statements.
// We handle only the case of TTCN3Module-s.
final Iterator<Module> it = cycle.iterator();
Module imported = it.next();
Module importer;
while (it.hasNext()) {
importer = it.next();
if (importer instanceof TTCN3Module) {
for (final ImportModule im : ((TTCN3Module) importer).getImports()) {
if (im.getName().equals(imported.getName())) {
problems.report(im.getLocation(), errMsg);
}
}
}
imported = importer;
}
importer = cycle.get(0);
if (importer instanceof TTCN3Module) {
for (final ImportModule im : ((TTCN3Module) importer).getImports()) {
if (im.getName().equals(imported.getName())) {
problems.report(im.getLocation(), errMsg);
}
}
}
}
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class ComponentGraphGenerator method createGraph.
@Override
protected void createGraph() {
analyzeProject();
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
final List<IProject> visitedProjects = ProjectBasedBuilder.getProjectBasedBuilder(project).getAllReachableProjects();
for (final IProject currentProject : visitedProjects) {
for (final Module module : projectSourceParser.getModules()) {
handleModule(currentProject, module);
}
}
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser 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);
}
}
}
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class TTCNPPEditor method doSave.
@Override
public void doSave(final IProgressMonitor progressMonitor) {
final IFile file = (IFile) getEditorInput().getAdapter(IFile.class);
if (file != null) {
FileSaveTracker.fileBeingSaved(file);
}
super.doSave(progressMonitor);
if (file != null && isSemanticCheckingDelayed()) {
final IReconcilingStrategy strategy = reconciler.getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
if (strategy instanceof ReconcilingStrategy) {
WorkspaceJob op = new WorkspaceJob("Reconciliation on save") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
projectSourceParser.reportOutdating(file);
TITANDebugConsole.println(" ** Full reconciliation and full semantic check on save for delayed semantic checking.(ttcnpp)");
((ReconcilingStrategy) strategy).analyze(true);
return Status.OK_STATUS;
}
};
op.setPriority(Job.LONG);
op.setSystem(true);
op.setUser(false);
op.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
op.schedule();
}
}
}
Aggregations