Changeset 13711


Ignore:
Timestamp:
Oct 9, 2019 10:55:10 AM (2 months ago)
Author:
molsson
Message:

#5843 Fixed NullPointerException when compile target is null. Replaced some File objects with Path.

Location:
branches/dev-mo-2265/Compiler/ModelicaCompiler/src/jastadd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mo-2265/Compiler/ModelicaCompiler/src/jastadd/ModelicaCompiler.jrag

    r13696 r13711  
    20202020    }
    20212021   
    2022     public FClass ModelicaCompiler.doCompileModel(String name[], String cl, TargetObject target, String compileTo)
    2023           throws ModelicaException, FileNotFoundException, IOException, beaver.Parser.Exception {
    2024         return doCompileModel(stringsToPaths(name), cl, target, compileTo == null ? null : Paths.get(compileTo));
    2025     }
    2026    
    20272022   
    20282023    public FClass ModelicaCompiler.doCompileModel(Path name[], String cl, TargetObject target, Path compileTo)
     
    20512046            UtilInterface util = icl.root().getUtilInterface();
    20522047            if (compileTo != null) {
    2053                 File unitFile = makePackagingDirs(cl, compileTo.toFile(), target);
     2048                Path unitFile = makePackagingDirs(cl, compileTo, target);
    20542049                util.setCompilationOutputPath(unitFile);
    20552050            }
     
    21982193    protected Path ModelicaCompiler.packUnit(String className,
    21992194            TargetObject target, FClass fClass) throws PackingFailedException {
    2200         Path unitFile = fClass.root().getUtilInterface().getCompilationOutputPath().toPath();
     2195        Path unitFile = fClass.root().getUtilInterface().getCompilationOutputPath();
    22012196       
    22022197        hookPackFmu(fClass, outDir);
     
    22512246    /**
    22522247     * Calculates the destination directory for a packaged unit. If the specified destination is a file its directory
    2253      * is chosen as destination. If the destination does not exist, it is created (using {@link File#mkdirs()}).
     2248     * is chosen as destination. If the destination does not exist, it is created (using {@link Filed#createDirectories()}).
    22542249     *
    22552250     * @param className
     
    22602255     *          A {@link TargetObject} containing information about the target.
    22612256     * @return
    2262      *          the path to the destination directory of the packaged unit.
     2257     *          the path to the destination file of the packaged unit.
    22632258     */
    2264     private File ModelicaCompiler.makePackagingDirs(String className, File destination, TargetObject target) {
    2265         File dest = new File(destination.getAbsolutePath());
    2266         if (dest.isDirectory()) {
     2259    private Path ModelicaCompiler.makePackagingDirs(String className, Path destination, TargetObject target)
     2260            throws IOException {
     2261        Path dest = destination.toAbsolutePath();
     2262        if (Files.isDirectory(dest)) {
    22672263            String mangledName = FClass.convertClassNameToUnderscore(className);
    2268             dest = new File(dest, mangledName + "." + target.getUnitSuffix());
     2264            dest = dest.resolve(mangledName + "." + target.getUnitSuffix());
    22692265        } else {
    2270             File destDir = dest.getParentFile();
    2271             if (destDir != null && !destDir.isDirectory()) {
    2272                 dest.getParentFile().mkdirs();
     2266            Path destDir = dest.getParent();
     2267            if (destDir != null && !Files.isDirectory(destDir)) {
     2268                Files.createDirectories(dest.getParent());
    22732269            }
    22742270        }
     
    22842280    private String ModelicaCompiler.computeFlatName(Path compileTo, UtilInterface util) {
    22852281        String flatName = null;
    2286         if (!Files.isDirectory(compileTo)) {
     2282        if (compileTo != null && !Files.isDirectory(compileTo)) {
    22872283            flatName = compileTo.getFileName().toString();
    22882284            int i = flatName.lastIndexOf('.');
  • branches/dev-mo-2265/Compiler/ModelicaCompiler/src/jastadd/UtilInterface.jrag

    r13673 r13711  
    7272        private ExternalFunctionCache efc;
    7373        private GUIDManager guidManager;
    74         private File compilationOutputPath;
     74        private Path compilationOutputPath;
    7575       
    76         protected UtilInterface(ModelicaCompiler mc, OptionRegistry options, IErrorHandler eh, ExternalFunctionCache efc, File compilationOutputPath) {
     76        protected UtilInterface(ModelicaCompiler mc, OptionRegistry options, IErrorHandler eh, ExternalFunctionCache efc, Path compilationOutputPath) {
    7777            this.mc = mc;
    7878            this.options = options;
     
    110110        }
    111111       
    112         public File getCompilationOutputPath() {
     112        public Path getCompilationOutputPath() {
    113113            return compilationOutputPath;
    114114        }
    115115       
    116         public void setCompilationOutputPath(File compilationOutputPath) {
     116        public void setCompilationOutputPath(Path compilationOutputPath) {
    117117            this.compilationOutputPath = compilationOutputPath;
    118118        }
Note: See TracChangeset for help on using the changeset viewer.