Package flex2.compiler.common

Examples of flex2.compiler.common.PathResolver


        usePathResolver(null);
    }

    public static void usePathResolver(SinglePathResolver resolver)
    {
        PathResolver pathResolver = new PathResolver();
        if (resolver != null)
        {
            pathResolver.addSinglePathResolver(resolver);
        }
        pathResolver.addSinglePathResolver( LocalFilePathResolver.getSingleton() );
        pathResolver.addSinglePathResolver( URLPathResolver.getSingleton() );
        ThreadLocalToolkit.setPathResolver(pathResolver);
    }
View Full Code Here


        {
            result = new LocalFile(FileUtil.getCanonicalFile(file));
        }
        else
        {
            PathResolver resolver = ThreadLocalToolkit.getPathResolver();
            result = resolver.resolve(path);

            if (result == null && reportError)
            {
                throw new ConfigurationException.IOError(path);
            }
View Full Code Here

  public PathResolver getPathResolver()
  {
    if (resolver == null)
    {
    resolver = new PathResolver();
    resolver.addSinglePathResolver(new Resolver(delegate != null ? delegate.getPathResolver() : null, file, pathRoot));
    resolver.addSinglePathResolver(ThreadLocalToolkit.getPathResolver());
        }

    return resolver;
View Full Code Here

    {
        VirtualFile defaultsCSSFile = mxmlConfiguration.getDefaultsCssUrl();

        if (defaultsCSSFile == null)
        {
            PathResolver resolver = ThreadLocalToolkit.getPathResolver();

            String version = mxmlConfiguration.getCompatibilityVersionString();

            if (version != null)
            {
                defaultsCSSFile = resolver.resolve("defaults-" + version + ".css");
            }

            if (defaultsCSSFile == null)
            {
                defaultsCSSFile = resolver.resolve("defaults.css");
            }
        }

        return defaultsCSSFile;
    }
View Full Code Here

        if ( args == null )
        {
            throw new ConfigurationException.CannotOpen( null, cfgval.getVar(), cfgval.getSource(), cfgval.getLine() );
        }

        PathResolver resolver = ThreadLocalToolkit.getPathResolver();

        if ( resolver == null || configResolver == null )
        {
            throw new ConfigurationException.CannotOpen( null, cfgval.getVar(), cfgval.getSource(), cfgval.getLine() );
        }
View Full Code Here

     * @param file The VirtualFile for the stylesheet or properties files.
     * @param sourcePath The 'source' attribute from the Embed's args.
     */
    private static VirtualFile resolveSource(Object owner, Source source, VirtualFile file, String sourcePath)
  {
    PathResolver context = new PathResolver();

        // paths starting with slash are either relative to a source path root or
        // fully qualified.
        if ((sourcePath != null) && (sourcePath.charAt(0) == '/'))
        {
            VirtualFile pathRoot = source.getPathRoot();

            if (pathRoot != null)
            {
                context.addSinglePathResolver(pathRoot);
            }

            if (owner instanceof SinglePathResolver)
            {
                context.addSinglePathResolver((SinglePathResolver) owner);
            }
        }
        else if (file != null)
        {
            context.addSinglePathResolver(file);
        }

        context.addSinglePathResolver(ThreadLocalToolkit.getPathResolver());

        VirtualFile result = context.resolve(sourcePath);

        if (result == null)
        {
            result = source.resolve(sourcePath);
        }
View Full Code Here

    public static Transcoder.TranscodingResults transcode(Transcoder[] transcoders,
                                                          CompilationUnit unit, SymbolTable symbolTable,
                                                          String className, Map<String, Object> args, int line, int col,
                                                          boolean generateCode)
    {
    PathResolver context = new PathResolver();
    Transcoder.TranscodingResults results = null;
        Source source = unit.getSource();

        if (!args.containsKey(Transcoder.RESOLVED_SOURCE))
        {
            String embedSource = (String) args.get(Transcoder.SOURCE);

            // paths starting with slash are either relative to a source path root or
            // fully qualified.
            if (embedSource != null && embedSource.charAt(0) == '/')
            {
                VirtualFile pathRoot = source.getPathRoot();
                if (pathRoot != null)
                {
                    context.addSinglePathResolver(pathRoot);
                }
                Object owner = source.getOwner();
                if (owner instanceof SinglePathResolver)
                {
                    context.addSinglePathResolver((SinglePathResolver) owner);
                }
            }
            else
            {
                if ( args.containsKey(Transcoder.FILE) )
                {
                  String path = (String) args.get(Transcoder.FILE);
                  String pathSep = (String) args.get(Transcoder.PATHSEP);
                  if ("true".equals(pathSep))
                  {
                    path = path.replace('/', '\\');
                  }
                 
                    VirtualFile contextFile = LocalFilePathResolver.getSingleton().resolve(path);

                    // If the contextFile is the same as the Source's file, then don't add
                    // it as a path resolver, because we'll rely on the Source's
                    // delegate/backing file.  If we don't do this, then some relative
                    // paths might incorrectly be resolved relative to the generated .as
                    // file, instead of the original mxml file.
                    if ((contextFile != null) && !contextFile.getName().equals(source.getName()))
                    {
                        context.addSinglePathResolver(contextFile);
                    }
                }

                VirtualFile backingFile = source.getBackingFile();

                if (backingFile != null)
                {
                    context.addSinglePathResolver(backingFile);
                }
            }
            context.addSinglePathResolver( ThreadLocalToolkit.getPathResolver() );
        }
        else
        {
            // This is necessary to handle FlexInit's Embeds, because
            // FlexInit is recompiled any time something changes in an
            // incremental compilation and the original document might
            // not have needed to be recompiled, so the resolved
            // VirtualFile won't be cached in the ThreadLocalToolkit.
            // The LocalFilePathResolver should be sufficient to turn
            // the resolved path into a VirtualFile.
            context.addSinglePathResolver(LocalFilePathResolver.getSingleton());
        }

    if (!unit.hasAssets() || !unit.getAssets().contains(className))
    {
            results = transcode(transcoders, symbolTable, className, args, line, col, generateCode, source, context);
View Full Code Here

    {
        VirtualFile defaultsCSSFile = mxmlConfiguration.getDefaultsCssUrl();

        if (defaultsCSSFile == null)
        {
            PathResolver resolver = ThreadLocalToolkit.getPathResolver();

            String version = mxmlConfiguration.getCompatibilityVersionString();

            if (version != null)
            {
                defaultsCSSFile = resolver.resolve("defaults-" + version + ".css");
            }

            if (defaultsCSSFile == null)
            {
                defaultsCSSFile = resolver.resolve("defaults.css");
            }
        }

        return defaultsCSSFile;
    }
View Full Code Here

        usePathResolver(null);
    }

    public static void usePathResolver(SinglePathResolver resolver)
    {
        PathResolver pathResolver = new PathResolver();
        if (resolver != null)
        {
            pathResolver.addSinglePathResolver(resolver);
        }
        pathResolver.addSinglePathResolver( LocalFilePathResolver.getSingleton() );
        pathResolver.addSinglePathResolver( URLPathResolver.getSingleton() );
        ThreadLocalToolkit.setPathResolver(pathResolver);
    }
View Full Code Here

        {
            result = new LocalFile(FileUtil.getCanonicalFile(file));
        }
        else
        {
            PathResolver resolver = ThreadLocalToolkit.getPathResolver();
            result = resolver.resolve(path);

            if (result == null && reportError)
            {
                throw new ConfigurationException.IOError(path);
            }
View Full Code Here

TOP

Related Classes of flex2.compiler.common.PathResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.