use of abs.common.WrongProgramArgumentException in project abstools by abstools.
the class IncrementalModelBuilder method typeCheckModel.
public synchronized SemanticConditionList typeCheckModel(IProgressMonitor monitor, boolean locationTypeChecking, String defaultloctype, String locationTypePrecision, boolean checkProducts) throws NoModelException, TypecheckInternalException {
if (model == null)
throw new NoModelException();
if (model.hasParserErrors())
// don't typecheck if the model has parsererrors
return new SemanticConditionList();
// throw new TypecheckInternalException(new Exception("Model has parser errors!"));
// model.flushCache();
flushAll(model);
model.getTypeExt().clearTypeSystemExtensions();
if (locationTypeChecking) {
LocationType defaultLocType = LocationType.createFromName(defaultloctype);
LocationTypeInferrerExtension ltie = new LocationTypeInferrerExtension(model);
this.ltie = ltie;
ltie.setDefaultType(defaultLocType);
ltie.setLocationTypingPrecision(LocationTypingPrecision.valueOf(locationTypePrecision));
model.registerTypeSystemExtension(ltie);
}
try {
SemanticConditionList semerrors = model.getErrors();
/* Don't typecheck with semerrors, it might trip up. */
if (!semerrors.containsErrors())
semerrors = model.typeCheck();
/* Check products for errors.
* Only the first error is reported (if any), on the product AST-node.
* TODO: May be time-consuming for large projects, hence the checkProducts-switch.
* Also could use a timer to switch off if it becomes excessive.
* TODO: Use Eclipse's nested markers to show ALL contained errors?
* TODO: The outline could indicate the broken product as well.
*/
if (!semerrors.containsErrors() && checkProducts) {
// arbitrary value
monitor = new SubProgressMonitor(monitor, 10);
monitor.beginTask("Checking products", model.getProductDecls().size());
for (ProductDecl p : model.getProductDecls()) {
monitor.subTask("Checking " + p.getName());
Model m2 = model.treeCopyNoTransform();
m2.flushTreeCache();
try {
m2.flattenForProduct(p);
SemanticConditionList p_errs = m2.typeCheck();
if (p_errs.containsErrors()) {
// Only show first error, on product
semerrors.add(new SemanticError(p, ErrorMessage.ERROR_IN_PRODUCT, p.getName(), p_errs.getFirstError().getMessage()));
}
} catch (WrongProgramArgumentException e) {
semerrors.add(new SemanticError(p, ErrorMessage.ERROR_IN_PRODUCT, p.getName(), e.getMessage()));
} catch (DeltaModellingException e) {
/* We we have a better location for error reporting? */
final ASTNode<?> loc;
if (e instanceof DeltaModellingWithNodeException)
loc = ((DeltaModellingWithNodeException) e).getNode();
else
loc = p;
if (e.getDelta() == null)
semerrors.add(new SemanticError(loc, ErrorMessage.ERROR_IN_PRODUCT, p.getName(), e.getMessage()));
else
semerrors.add(new SemanticError(loc, ErrorMessage.ERROR_IN_PRODUCT_WITH_DELTA, p.getName(), e.getDelta().getName(), e.getMessage()));
}
}
monitor.done();
}
return semerrors;
} catch (TypeCheckerException e) {
return new SemanticConditionList(e);
} catch (RuntimeException e) {
throw new TypecheckInternalException(e);
}
}
use of abs.common.WrongProgramArgumentException in project abstools by abstools.
the class AbstractTab method updateErrors.
/**
* Don't recommend to start projects which have errors.
* TODO: manipulating the error message here does not cooperate well with isValid().
*/
protected boolean updateErrors() {
boolean res = true;
String projectName = getSelectedProjectName();
String prod = getSelectedProductName();
if (this.lastProjectName != null && this.lastProd != null && this.lastProjectName.equals(projectName) && this.lastProd.equals(prod)) {
// every time something changes in the run configuration dialog
return lastResult;
}
if (projectName != null) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
try {
AbsNature nat = UtilityFunctions.getAbsNature(project);
assert nat != null;
synchronized (nat.modelLock) {
Model model = nat.getCompleteModel();
/* E.g. errors in the project */
if (model == null)
return false;
/* Check product if any */
// work on a copy:
model = model.treeCopyNoTransform();
model.flushTreeCache();
if (prod != null) {
model.flattenForProduct(prod);
/* Type check again */
// #335, see IncrementalModelBuilder#flushAll()
model.flushCache();
}
SemanticConditionList errs = model.getErrors();
// TODO: check for warnings also
if (errs != null && errs.containsErrors()) {
createMarkers(nat, errs);
throw new AbsJobException(new TypeCheckerException(errs));
}
errs = model.typeCheck();
// TODO: check for warnings also
if (errs != null && errs.containsErrors()) {
createMarkers(nat, errs);
throw new AbsJobException(new TypeCheckerException(errs));
}
}
setErrorMessage(null);
} catch (AbsJobException e) {
setErrorMessage(e.getMessage());
res = false;
} catch (WrongProgramArgumentException e) {
setErrorMessage(e.getMessage());
res = false;
} catch (DeltaModellingException e) {
setErrorMessage(e.getMessage());
res = false;
}
getLaunchConfigurationDialog().updateMessage();
}
// cache the result
lastProd = prod;
lastProjectName = projectName;
lastResult = res;
return res;
}
use of abs.common.WrongProgramArgumentException in project abstools by abstools.
the class JavaRunConfiguration method launch.
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
JavaLaunchConfig launchConfig = new JavaLaunchConfig(config);
IAction action = createNewAction(launchConfig);
IProject project = ActionUtils.getProject(config);
IFile file = null;
ActionUtils.saveDirtyEditors(project);
JavaJob job = new JavaJob(JavaJob.RUN_JOB, action, project, file);
String product = launchConfig.getProductName();
if (product != null) {
try {
Model model = JavaJob.getModelFromProject(project);
job.setProduct(model.findProduct(product));
} catch (WrongProgramArgumentException e) {
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Launch failed", e));
} catch (AbsJobException e) {
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Launch failed", e));
}
}
if (launchConfig.getTestExecution()) {
List<String> obs = launchConfig.getDebuggerObserverList();
obs.add(ABSTestObserver.class.getName());
}
modifyDebuggerArguments(launchConfig, job);
if (launchConfig.getTestExecution()) {
// execution of unit tests
Job testJob = new ABSUnitTestJavaExecutionJob(project, product, job);
testJob.schedule();
} else {
// normal execution
job.schedule();
}
}
Aggregations