use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class MaudeJob method runJob.
public IStatus runJob(IProgressMonitor monitor) {
abort = false;
boolean failed = false;
StringBuffer output = new StringBuffer();
AbsNature nature = getAbsNature(project);
if (nature == null) {
return new Status(IStatus.INFO, PLUGIN_ID, "Could not compile current selection. Project is not an ABS project.");
}
// Compile Maude Code
monitor.subTask("Compiling ABS model to Maude");
try {
if (!abort)
compileMaude(monitor, nature);
} catch (CoreException e1) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while compilig", e1);
} catch (IOException e2) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while compilig", e2);
} catch (ParseException e4) {
return new Status(IStatus.INFO, PLUGIN_ID, MAUDE_ERROR, "Could not compile current selection. Code has parse errors.", e4);
} catch (TypeCheckerException e5) {
return new Status(IStatus.INFO, PLUGIN_ID, MAUDE_ERROR, "Could not compile current selection. Code has type errors.", e5);
} catch (WrongProgramArgumentException e) {
return new Status(IStatus.ERROR, PLUGIN_ID, MAUDE_ERROR, "Could not compile current selection.", e);
} catch (DeltaModellingException e) {
return new Status(IStatus.ERROR, PLUGIN_ID, MAUDE_ERROR, "Could not compile current selection.", e);
} catch (NoModelException e) {
return new Status(IStatus.INFO, PLUGIN_ID, "No ABS model in project");
}
monitor.worked(5);
// Execute generated Maude code
monitor.subTask("Executing generated Maude code");
if (exec) {
try {
if (!abort)
failed = !executeMaude(output);
} catch (IOException e1) {
return new Status(IStatus.INFO, PLUGIN_ID, MAUDE_ERROR_MAUDE_PATH, "Encountered IOException while executing Maude (probably misconfigured location of maude executable)", e1);
} catch (InterruptedException e2) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while executing Maude", e2);
} finally {
if (!monitor.isCanceled()) {
monitor.worked(5);
monitor.done();
}
}
}
// If an error was encountered during Maude execution, the info code of the status is set to ERROR_MAUDE, otherwise MAUDE_INFO.
if (!abort) {
if (failed) {
return new Status(IStatus.OK, PLUGIN_ID, MAUDE_ERROR_MAUDE, output.toString(), null);
} else {
if (exec) {
return new Status(IStatus.OK, PLUGIN_ID, MAUDE_INFO, output.toString(), null);
} else {
return new Status(IStatus.OK, PLUGIN_ID, MAUDE_OK, output.toString(), null);
}
}
} else {
monitor.setCanceled(true);
return new Status(IStatus.INFO, PLUGIN_ID, MAUDE_USER_ABORT, null, null);
}
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class AbstractTab method fillProductDropDownMenue.
/**
* Lists all products in the current project's module, incl. a "<base>" product if
* no particular product is selected.
* @param preSelected The product that should be preselected, or null for <base>.
*/
protected void fillProductDropDownMenue(String preSelected) {
productDropDown.removeAll();
productDropDown.add("<base>");
IProject proj = getSelectedProject();
if (proj == null) {
return;
}
AbsNature n = UtilityFunctions.getAbsNature(proj);
Model m = n.getCompleteModel();
if (m == null)
return;
Collection<ProductDecl> prods = m.getProductDecls();
if (prods == null)
return;
int i = 1;
/* base comes first */
int selected = 0;
for (ProductDecl p : prods) {
final String name = p.getName();
productDropDown.add(name);
if (name.equals(preSelected)) {
selected = i;
}
i++;
}
productDropDown.select(selected);
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class FileAddLocationHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
Object firstElement = selection.getFirstElement();
if (firstElement instanceof IFile) {
IFile file = (IFile) firstElement;
IProject project = file.getProject();
AbsNature nature = UtilityFunctions.getAbsNature(project);
if (nature == null)
return null;
IPersistentPreferenceStore projectStore = nature.getProjectPreferenceStore();
boolean locationTypecheckingEnabled = projectStore.getBoolean(Constants.LOCATION_TYPECHECK);
if (!locationTypecheckingEnabled) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Locationtypechecking", "Location type checking is disabled. Please enable for this function to work!");
return null;
}
UtilityFunctions.saveEditor(file, false);
Map<LocationTypeVariable, LocationType> locationTypeInferrerResult = nature.getLocationTypeInferrerResult();
if (locationTypeInferrerResult != null) {
Map<LocationTypeVariable, LocationType> filteredResults = new HashMap<LocationTypeVariable, LocationType>();
ASTNode<?> node;
CompilationUnit cu;
for (Entry<LocationTypeVariable, LocationType> entry : locationTypeInferrerResult.entrySet()) {
node = entry.getKey().getNode();
if (node == null)
continue;
cu = node.getCompilationUnit();
if (cu == null)
continue;
if (file.getLocation().toFile().getAbsolutePath().equals(cu.getFileName())) {
filteredResults.put(entry.getKey(), entry.getValue());
}
}
InferMain inferMain = new InferMain();
String commandId = event.getCommand().getId();
if ("org.abs-models.abs.plugin.fileaddalllocations".equals(commandId)) {
inferMain.setConfig(InferMain.Config.values());
} else if ("org.abs-models.abs.plugin.fileaddclasslocations".equals(commandId)) {
inferMain.setConfig(InferMain.Config.CLASSES);
} else if ("org.abs-models.abs.plugin.fileaddfieldlocations".equals(commandId)) {
inferMain.setConfig(InferMain.Config.FIELDS);
} else if ("org.abs-models.abs.plugin.fileaddfunctionlocations".equals(commandId)) {
inferMain.setConfig(InferMain.Config.FUNCTIONS);
} else if ("org.abs-models.abs.plugin.fileaddinterfacelocations".equals(commandId)) {
inferMain.setConfig(InferMain.Config.INTERFACES);
}
try {
inferMain.writeInferenceResultsBack(filteredResults);
try {
file.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
Activator.logException(e);
}
} catch (IOException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Error while inserting locations", "An error occurred while inserting locations!\n" + e.getLocalizedMessage());
}
}
}
return null;
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class ABSUnitTestExecutionJob method run.
protected IStatus run(IProgressMonitor monitor) {
AbsNature nature = getAbsNature(project);
if (nature == null) {
return new Status(IStatus.INFO, PLUGIN_ID, "Could not compile current selection. Project is not an ABS project.");
}
monitor.beginTask("ABSUnit Test Execution", 112);
// Parsing and Type Checking ABS model
monitor.subTask("Generating Test Runner");
try {
if (!abort)
generateTestRunner(monitor, nature);
} catch (CoreException e1) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while generating test runner", e1);
} catch (IOException e2) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while generating test runner", e2);
} catch (ParseException e4) {
return new Status(IStatus.INFO, PLUGIN_ID, ABSUNIT_TEST_ERROR, "Could not generating test runnern. Code has parse errors.", e4);
} catch (TypeCheckerException e5) {
return new Status(IStatus.INFO, PLUGIN_ID, ABSUNIT_TEST_ERROR, "Could not generating test runner. Code has type errors.", e5);
}
monitor.worked(12);
try {
// make sure the generated testrunner file is parsed:
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
} catch (CoreException e) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while compiling tests", e);
}
monitor.subTask("Executing ABSUnit tests");
IStatus status = null;
try {
status = executeTest(monitor);
} catch (CoreException e) {
return new Status(IStatus.ERROR, PLUGIN_ID, "Fatal error while executing tests", e);
}
if (abort) {
monitor.setCanceled(true);
return new Status(IStatus.INFO, PLUGIN_ID, ABSUNIT_TEST_USER_ABORT, null, null);
}
return new Status(IStatus.OK, PLUGIN_ID, ABSUNIT_TEST_OK, status.getMessage(), null);
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class ModuleDecorator method checkModulePath.
private void checkModulePath(IDecoration decoration, ModulePath m) {
AbsNature nature = m.getNature();
Model model = nature.getCompleteModel();
if (model != null) {
for (ModuleDecl mod : model.getModuleDecls()) {
if (mod.getName().startsWith(m.getModulePath() + ".")) {
if (hasModuleDeclErrors(mod, nature)) {
addErrorOverlay(decoration);
return;
}
}
}
}
}
Aggregations