use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class TITANJavaBuilder method build.
@Override
protected IProject[] build(final int kind, final Map<String, String> args, final IProgressMonitor monitor) throws CoreException {
IProject project = getProject();
if (!TITANInstallationValidator.check(true)) {
return project.getReferencedProjects();
}
if (!LicenseValidator.check()) {
return project.getReferencedProjects();
}
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
final boolean reportDebugInformation = store.getBoolean(PreferenceConstants.DISPLAYDEBUGINFORMATION);
final SubMonitor progress = SubMonitor.convert(monitor);
progress.beginTask("Build", 2);
ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(project);
// TODO: this is temporary code!
sourceParser.makefileCreatingAnalyzeAll();
progress.worked(1);
BuildTimestamp timestamp = BuildTimestamp.getNewBuildCounter();
IProgressMonitor codeGeneratorMonitor = progress.newChild(1);
codeGeneratorMonitor.beginTask("Checking prerequisites", sourceParser.getModules().size() + 1);
for (Module module : sourceParser.getModules()) {
TITANDebugConsole.println("Generating code for module `" + module.getIdentifier().getDisplayName() + "'");
try {
ProjectSourceCompiler.compile(timestamp, module, reportDebugInformation);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace("While generating Java code for module " + module.getIdentifier().getDisplayName(), e);
}
codeGeneratorMonitor.worked(1);
}
TITANDebugConsole.println("Generating code for single main");
try {
ProjectSourceCompiler.generateSingleMain(project, sourceParser.getModules(), reportDebugInformation);
ProjectSourceCompiler.generateParallelMain(project, sourceParser.getModules(), reportDebugInformation);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace("While generating Java code for main module ", e);
}
codeGeneratorMonitor.worked(1);
codeGeneratorMonitor.done();
return new IProject[0];
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class ProjectSourceCompiler method generateSingleMain.
// FIXME comment
public static void generateSingleMain(final IProject project, final Collection<Module> modules, final boolean aDebug) throws CoreException {
IFolder folder = project.getFolder(DIR_GENERATED_ROOT);
IFile file = folder.getFile("Single_main.java");
createDir(folder);
StringBuilder contentBuilder = new StringBuilder();
contentBuilder.append("// This Java file was generated by the TITAN Designer eclipse plug-in\n");
contentBuilder.append("// of the TTCN-3 Test Executor version ").append(GeneralConstants.VERSION_STRING).append('\n');
contentBuilder.append("// for (").append(System.getProperty("user.name")).append('@');
try {
contentBuilder.append(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
contentBuilder.append("unknown");
}
// TODO date will need to be simplified to have optimize build time
// aSb.append(") on ").append(new Date()).append('\n');
contentBuilder.append(")\n");
contentBuilder.append('\n');
contentBuilder.append("// ").append(GeneralConstants.COPYRIGHT_STRING).append('\n');
contentBuilder.append('\n');
contentBuilder.append("// Do not edit this file unless you know what you are doing.\n");
contentBuilder.append('\n');
contentBuilder.append("package ");
contentBuilder.append(PACKAGE_GENERATED_ROOT);
contentBuilder.append(";\n\n");
contentBuilder.append(MessageFormat.format("import {0}.Module_List;\n", PACKAGE_RUNTIME_ROOT));
contentBuilder.append(MessageFormat.format("import {0}.Runtime_Single_main;\n", PACKAGE_RUNTIME_ROOT));
for (Module module : modules) {
contentBuilder.append(MessageFormat.format("import {0}.{1};\n", PACKAGE_GENERATED_ROOT, module.getIdentifier().getName()));
}
contentBuilder.append("public class Single_main {\n\n");
contentBuilder.append("public static void main( String[] args ) {\n");
contentBuilder.append("long absoluteStart = System.nanoTime();\n");
for (Module module : modules) {
contentBuilder.append(MessageFormat.format("Module_List.add_module(new {0}());\n", module.getIdentifier().getName()));
}
contentBuilder.append("Runtime_Single_main.singleMain();\n");
contentBuilder.append("System.out.println(\"Total execution took \" + (System.nanoTime() - absoluteStart) * (1e-9) + \" seconds to complete\");\n");
contentBuilder.append("}\n");
contentBuilder.append("}\n\n");
final String content = contentBuilder.toString();
if (file.exists()) {
if (needsUpdate(file, content.toString())) {
final InputStream outputStream = new ByteArrayInputStream(content.getBytes());
file.setContents(outputStream, IResource.FORCE | IResource.KEEP_HISTORY, null);
}
} else {
final InputStream outputStream = new ByteArrayInputStream(content.getBytes());
file.create(outputStream, IResource.FORCE, null);
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsChecker method doChecking.
public void doChecking() {
monitor.subTask("Semantic checking");
final BrokenPartsViaReferences brokenParts = (BrokenPartsViaReferences) selectionMethod;
if (brokenParts.getAnalyzeOnlyDefinitions()) {
final Map<Module, List<Assignment>> moduleAndBrokenDefinitions = brokenParts.getModuleAndBrokenDefs();
definitionsChecker(moduleAndBrokenDefinitions);
} else {
generalChecker();
}
monitor.subTask("Doing post semantic checks");
for (Module module : selectionMethod.getModulesToCheck()) {
module.postCheck();
}
progress.done();
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsChecker method generalChecker.
// TODO check if this can be merged with the following one
private void generalChecker() {
progress.setTaskName("Semantic check");
progress.setWorkRemaining(selectionMethod.getModulesToCheck().size());
for (Module module : selectionMethod.getModulesToSkip()) {
module.setSkippedFromSemanticChecking(true);
}
for (Module module : selectionMethod.getModulesToCheck()) {
module.setSkippedFromSemanticChecking(false);
}
// process the modules one-by-one
for (final Module module : selectionMethod.getModulesToCheck()) {
progress.subTask("Semantically checking module: " + module.getName());
module.check(compilationCounter);
progress.worked(1);
}
for (final Module module : selectionMethod.getModulesToSkip()) {
module.setSkippedFromSemanticChecking(false);
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsChecker method definitionsChecker.
private void definitionsChecker(final Map<Module, List<Assignment>> moduleAndBrokenDefs) {
progress.setTaskName("Semantic check");
progress.setWorkRemaining(moduleAndBrokenDefs.size());
for (Map.Entry<Module, List<Assignment>> entry : moduleAndBrokenDefs.entrySet()) {
final Module module = entry.getKey();
progress.subTask("Semantically checking broken parts in module: " + module.getName());
if (module instanceof TTCN3Module) {
((TTCN3Module) module).checkWithDefinitions(compilationCounter, entry.getValue());
} else {
module.check(compilationCounter);
}
progress.worked(1);
}
}
Aggregations