use of abs.frontend.typechecker.TypeCheckerException in project abstools by abstools.
the class ProposalFactory method addToplevelProposals.
/**
* add proposals for all visible names.
* @param node the node under the cursor
*/
private void addToplevelProposals(ASTNode<?> node) {
ProposalComparator comp = new ProposalComparator();
ArrayList<ICompletionProposal> tempNonqual = new ArrayList<ICompletionProposal>();
ArrayList<ICompletionProposal> tempQual = new ArrayList<ICompletionProposal>();
ModuleDecl moddecl = node.getModuleDecl();
if (moddecl == null) {
return;
}
try {
Map<KindedName, ResolvedName> visibleNames = moddecl.getVisibleNames();
for (Entry<KindedName, ResolvedName> kentry : visibleNames.entrySet()) {
KindedName kname = kentry.getKey();
if (qualifierIsPrefixOf(kname.getName())) {
CompletionProposal proposal = makeVisibleNameProposal(kentry.getValue(), kname);
if (kname.isQualified()) {
tempQual.add(proposal);
} else {
tempNonqual.add(proposal);
}
}
}
Collections.sort(tempNonqual, comp);
proposals.addAll(tempNonqual);
Collections.sort(tempQual, comp);
proposals.addAll(tempQual);
} catch (TypeCheckerException e) {
// ignore all type check exceptions
}
}
use of abs.frontend.typechecker.TypeCheckerException 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);
}
}
Aggregations