Search in sources :

Example 1 with PathMetaOrNonExistant

use of ast.ErrorMessage.PathMetaOrNonExistant in project L42 by ElvisResearchGroup.

the class Abstract method checkPrivacyCoupuled.

static void checkPrivacyCoupuled(ClassB cbFull, ClassB cbClear, List<Ast.C> path) {
    //start from a already cleared out of private states
    //check if all private nested classes are USED using IsUsed on cbClear
    //this also verify that no private nested classes are used as
    //type in public methods of public classes.
    //collect all PublicPath.privateMethod
    //use main->introspection.FindUsage
    List<Path> prPath = ExtractInfo.collectPrivatePathsAndSubpaths(cbFull, path);
    List<PathMx> prMeth = ExtractInfo.collectPrivateMethodsOfPublicPaths(cbFull, path);
    List<Path> coupuledPaths = new ArrayList<>();
    for (Path pi : prPath) {
        Set<Path> used = ExtractInfo.IsUsed.of(cbClear, pi);
        if (used.isEmpty()) {
            continue;
        }
        coupuledPaths.add(pi);
    }
    List<PathMx> ordered = new ArrayList<>();
    try {
        //FindUsage.of(Program.empty(),prMeth, cbClear);
        Set<PathMx> usedPrMeth = findUsage(prMeth, cbClear);
        if (coupuledPaths.isEmpty() && usedPrMeth.isEmpty()) {
            return;
        }
        ordered.addAll(usedPrMeth);
    } catch (PathMetaOrNonExistant pne) {
        assert !coupuledPaths.isEmpty();
    }
    Collections.sort(ordered, (px1, px2) -> px1.toString().compareTo(px2.toString()));
    throw Errors42.errorPrivacyCoupuled(coupuledPaths, ordered);
}
Also used : Path(ast.Ast.Path) PathMx(ast.Util.PathMx) ArrayList(java.util.ArrayList) PathMetaOrNonExistant(ast.ErrorMessage.PathMetaOrNonExistant)

Aggregations

Path (ast.Ast.Path)1 PathMetaOrNonExistant (ast.ErrorMessage.PathMetaOrNonExistant)1 PathMx (ast.Util.PathMx)1 ArrayList (java.util.ArrayList)1