Search in sources :

Example 1 with TypecheckInternalException

use of org.absmodels.abs.plugin.internal.TypecheckInternalException in project abstools by abstools.

the class AbsNature method addPackagesForTypeChecking.

/**
 * Add ABS package dependencies to {@link AbsNature#modelbuilder} for type checking
 * @throws TypecheckInternalException
 */
private void addPackagesForTypeChecking() throws TypecheckInternalException {
    try {
        Main m = new Main();
        m.setWithStdLib(true);
        List<CompilationUnit> units = new ArrayList<CompilationUnit>();
        for (PackageEntry entry : packageContainer.getPackages()) {
            File file = new File(entry.getPath());
            if (isABSPackage(file)) {
                units.addAll(m.parseABSPackageFile(file));
            }
        }
        modelbuilder.addCompilationUnits(units);
    } catch (IOException e) {
        throw new TypecheckInternalException(e);
    } catch (NoModelException e) {
    // ignore
    }
}
Also used : CompilationUnit(abs.frontend.ast.CompilationUnit) NoModelException(org.absmodels.abs.plugin.internal.NoModelException) PackageEntry(org.absmodels.abs.plugin.editor.outline.PackageEntry) TypecheckInternalException(org.absmodels.abs.plugin.internal.TypecheckInternalException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Main(abs.frontend.parser.Main) PackageAbsFile(org.absmodels.abs.plugin.editor.outline.PackageAbsFile) File(java.io.File)

Example 2 with TypecheckInternalException

use of org.absmodels.abs.plugin.internal.TypecheckInternalException in project abstools by abstools.

the class AbsNature method typeCheckModel.

/**
 * takes the properties from the project preference store for location type checking and location type precision. Typeckecks
 * the current model in the current model builder.
 * Note that your model must be sufficiently "complete" and not have any semantic errors .
 * @param monitor
 * @throws CoreException {@link IResource#deleteMarkers(String, boolean, int)} does not handle exceptions thrown by
 * #createMarker(SemanticError) and #createMarker(TypecheckInternalException)
 */
void typeCheckModel(IProgressMonitor monitor) throws CoreException {
    getProject().deleteMarkers(TYPECHECK_MARKER_TYPE, true, IResource.DEPTH_INFINITE);
    getProject().deleteMarkers(LOCATION_TYPE_INFERENCE_MARKER_TYPE, true, IResource.DEPTH_INFINITE);
    boolean dolocationtypecheck = getProjectPreferenceStore().getBoolean(LOCATION_TYPECHECK);
    String defaultlocationtype = getProjectPreferenceStore().getString(DEFAULT_LOCATION_TYPE);
    String defaultlocationtypeprecision = getProjectPreferenceStore().getString(LOCATION_TYPE_PRECISION);
    boolean checkProducts = getProjectPreferenceStore().getBoolean(PRODUCT_TYPECHECK);
    try {
        addPackagesForTypeChecking();
        final SemanticConditionList typeerrors = modelbuilder.typeCheckModel(monitor, dolocationtypecheck, defaultlocationtype, defaultlocationtypeprecision, checkProducts);
        createMarkers(typeerrors);
        if (dolocationtypecheck) {
            createLocationTypeInferenceMarker();
        }
    } catch (NoModelException e) {
        // ignore
        return;
    } catch (TypecheckInternalException e) {
        /* Internal error caught. Log, and turn into an error marker */
        Activator.logException(e);
        createMarker(e);
        return;
    }
}
Also used : NoModelException(org.absmodels.abs.plugin.internal.NoModelException) SemanticConditionList(abs.frontend.analyser.SemanticConditionList) TypecheckInternalException(org.absmodels.abs.plugin.internal.TypecheckInternalException)

Aggregations

NoModelException (org.absmodels.abs.plugin.internal.NoModelException)2 TypecheckInternalException (org.absmodels.abs.plugin.internal.TypecheckInternalException)2 SemanticConditionList (abs.frontend.analyser.SemanticConditionList)1 CompilationUnit (abs.frontend.ast.CompilationUnit)1 Main (abs.frontend.parser.Main)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 PackageAbsFile (org.absmodels.abs.plugin.editor.outline.PackageAbsFile)1 PackageEntry (org.absmodels.abs.plugin.editor.outline.PackageEntry)1