Package flex2.compiler

Examples of flex2.compiler.Source


        {
            // We used to resolve the icon here, but that was moved
            // upstream to SyntaxTreeEvaluator.processIconFileMetaData(),
            // so we don't have to hang on to the PathResolver until now.
            VirtualFile iconFile = unit.iconFile;
            Source source = unit.getSource();

            // If the source came from a SWC, try looking for the icon in the SWC.
            if ((iconFile == null) && source.isSwcScriptOwner())
            {
                for (int i = 0, s = unit.topLevelDefinitions.size();i < s; i++)
                {
                    String def = unit.topLevelDefinitions.get(i).toString();
                    if (components.containsKey(def))
                    {
                        String swcIcon = components.get(def).getIcon();
                        if (swcIcon != null)
                        {
                            iconFile = (((SwcScript) source.getOwner()).getLibrary().getSwc().getFile(swcIcon));
                            if (iconFile != null)
                            {
                                // we then put the resolved file into an InMemoryFile so that we can changed its name
                                VirtualFile inMemFile = new InMemoryFile(iconFile.getInputStream(), swcIcon,
                                                                         MimeMappings.getMimeType(swcIcon),
                                                                         iconFile.getLastModified());
                                archive.putFile( inMemFile );
                                return;
                            }
                        }
                    }
                }

                // It seems like this will never be true, because if
                // the icon was missing when the original SWC was
                // created, a MissingIconFile would have been thrown.
                if (iconFile == null)
                {
                    return;
                }
            }

            if (iconFile == null)
            {
                throw new SwcException.MissingIconFile(unit.icon, sourceName);
            }

            // yes using both toDot and toColon here feels very wacky
            String workingSourceName = NameFormatter.toColon(NameFormatter.toDot(sourceName, '/'));
            SwcComponent comp = components.get(workingSourceName);
            String rel = source.getRelativePath();
            String iconName = (rel == null || rel.length() == 0) ? unit.icon : rel + "/" + unit.icon;
            if (comp != null)
            {
                comp.setIcon(iconName);
            }
View Full Code Here


        CompilationUnit cssCompilationUnit = source.newCompilationUnit(null, context);

        VirtualFile generatedFile = generateSourceCodeFile(cssCompilationUnit, styleModule);

        Source generatedSource = new Source(generatedFile, source);

        // when building a SWC, we want to locate all the asset sources and ask compc to put them in the SWC.
        Collection<AtEmbed> atEmbeds = styleModule.getAtEmbeds();
        if (atEmbeds != null && configuration.archiveClassesAndAssets())
        {
View Full Code Here

        String genFileName = (configuration.getGeneratedDirectory() +
                              File.separatorChar +
                              styleModule.getName() +
                              "-generated.as");

        Source source = compilationUnit.getSource();

        DualModeLineNumberMap lineNumberMap = new DualModeLineNumberMap(source.getNameForReporting(), genFileName);
        styleModule.setLineNumberMap(lineNumberMap);

        try
        {
            VelocityUtil velocityUtil = new VelocityUtil(TEMPLATE_PATH, configuration.debug(),
View Full Code Here

    {
      if (name instanceof flex2.compiler.util.QName)
      {
        flex2.compiler.util.QName qName = (flex2.compiler.util.QName) name;

        Source s = symbolTable.findSourceByQName(qName);
        CompilationUnit u = s.getCompilationUnit();
        if (unit == u)
        {
          continue;
        }
       
        ObjectValue frame = u.typeInfo;

        if (frame != null && !processed.contains(s.getName()))
        {
          //ThreadLocalToolkit.logDebug("import: " + s.getName() + " --> " + target);
          FlowAnalyzer.inheritContextSlots(frame, node.frame, node.frame.builder, cx);
          processed.add(s.getName());
        }
      }
    }
  }
View Full Code Here

    {
      if (name instanceof flex2.compiler.util.QName)
      {
        flex2.compiler.util.QName qName = (flex2.compiler.util.QName) name;

        Source s = symbolTable.findSourceByQName(qName);
        CompilationUnit u = s.getCompilationUnit();       
        if (unit == u)
        {
          continue;
        }
       
        ObjectValue frame = u.typeInfo;

        if (frame != null && !processed.contains(s.getName()))
        {
          //ThreadLocalToolkit.logDebug("import: " + s.getName() + " --> " + target);
          FlowAnalyzer.inheritContextSlots(frame, node.frame, node.frame.builder, cx);
          processed.add(s.getName());
        }
      }
    }
  }
View Full Code Here

    }
   
    public void parse2(CompilationUnit unit, SymbolTable symbolTable)
    {
    DocumentInfo docInfo = (DocumentInfo) unit.getContext().getAttribute(MxmlCompiler.DOCUMENT_INFO);
        Source source = unit.getSource();

        //  get parsed superclass info - NOTE may be null in case of error
        ClassInfo baseClassInfo = getClassInfo(source, symbolTable, docInfo.getQualifiedSuperClassName());
        if (baseClassInfo == null && docInfo.getQualifiedSuperClassName() != null)
        {
            String qualifiedClassName = NameFormatter.toDot(docInfo.getPackageName(), docInfo.getClassName());
            ThreadLocalToolkit.log(new BaseClassNotFound(qualifiedClassName, docInfo.getQualifiedSuperClassName()), source);
            return;
        }

        //  InterfaceAnalyzer will collect items to be included in generated interface code, and add them to info
        InterfaceAnalyzer analyzer = new InterfaceAnalyzer(unit, docInfo, baseClassInfo, mxmlConfiguration.getGenerateAbstractSyntaxTree());
        DocumentNode app = (DocumentNode) unit.getContext().getAttribute(DOCUMENT_NODE);
        app.analyze(analyzer);

        if (ThreadLocalToolkit.errorCount() > 0)
        {
            return;
        }

    //  generate AS for the interface (i.e., public signature) of our class. This will include
    //  - superclass, interface and metadata declarations, as specified in the MXML
    //  - public var declarations for id-attributed children of the MXML
    //  - user-supplied script code
    LineNumberMap map = new LineNumberMap(source.getName());
    Source newSource;
    Logger original = ThreadLocalToolkit.getLogger();

    if (mxmlConfiguration.getGenerateAbstractSyntaxTree())
    {
      Logger adapter = new AbstractSyntaxTreeLogAdapter(original);
      ThreadLocalToolkit.setLogger(adapter);
      newSource = generateSkeletonAST(docInfo, analyzer.bogusImports, source, symbolTable);
    }
    else
    {
      MxmlLogAdapter adapter = new MxmlLogAdapter(original, map);
      adapter.addLineNumberMaps(unit.getSource().getSourceFragmentLineMaps());
      ThreadLocalToolkit.setLogger(adapter);
      newSource = generateSkeleton(docInfo, analyzer.bogusImports, map, source);

      if (newSource == null)
      {
        ThreadLocalToolkit.setLogger(original);
        return;
      }

      map.setNewName(newSource.getName());
    }

    //  use ASC to produce new CU for generated interface source. Will be managed by "outer" MXML CU
    CompilationUnit interfaceUnit = compileInterface(newSource, source, docInfo, map, symbolTable);
View Full Code Here

        TranscodingResults result = null;

        if (generateSource)
        {
            String skinClassName = (String) args.get(Transcoder.SKINCLASS);
            Source skinSource = symbolTable.findSourceByQName(new QName(NameFormatter.toColon(skinClassName)));

            if (skinSource == null)
            {
                throw new SkinClassNotFound(skinClassName);
            }
View Full Code Here

                // Normalize line endings as a temporary work around for bug 149821
                String generated = out.toString().replaceAll("\r\n", "\n");
                String filename = writeGenerated(info, generated);
         TextFile textFile = new TextFile(generated, filename, source.getParent(),
                          MimeMappings.AS, source.getLastModified());
         return new Source(textFile, source);
            }
            catch (ResourceNotFoundException ex)
            {
                ThreadLocalToolkit.logError(path, FileUtil.getExceptionMessage(ex));
            }
View Full Code Here

    String fileName = MxmlCompiler.getGeneratedName(mxmlConfiguration, info.getPackageName(),
                            info.getClassName(), "-interface.as");
    TextFile textFile = new TextFile(EMPTY_STRING, fileName, source.getName(), source.getParent(),
                     MimeMappings.MXML, source.getLastModified());

    Source result = new Source(textFile, source);

    InterfaceGenerator interfaceGenerator = new InterfaceGenerator(info, bogusImports,
                                     symbolTable.perCompileData,
                                     result,
                                     symbolTable.emitter,
                                                                       ascConfiguration.getDefine());

    CompilerContext context = new CompilerContext();
    context.setAscContext(interfaceGenerator.getContext());

    Object syntaxTree = interfaceGenerator.getSyntaxTree();
    result.newCompilationUnit(syntaxTree, context).setSyntaxTree(syntaxTree);

    return result;
  }
View Full Code Here

            for (Name name : dependencies)
            {
                if (name instanceof QName)
                {
                    Source dependent = symbolTable.findSourceByQName((QName) name);

                    if ((dependent != null) && dependent.isSwcScriptOwner())
                    {
                        SwcScript swcScript = (SwcScript) dependent.getOwner();
                        Swc swc = swcScript.getLibrary().getSwc();
                       
                        // Make sure each dependency's minimum
                        // supported version is less than or equal to
                        // the compatibility version.
                        if (highestMinimumSupportedVersion < swc.getVersions().getMinimumVersion() &&
                            configuration.getCompilerConfiguration().enableSwcVersionFiltering())
                        {
                            highestMinimumSupportedVersion = swc.getVersions().getMinimumVersion();

                            if (isMinimumSupportedVersionConfigured &&
                                configuration.getMinimumSupportedVersion() < highestMinimumSupportedVersion)
                            {
                                HigherMinimumSupportedVersionRequired message =
                                    new HigherMinimumSupportedVersionRequired(swc.getLocation(),
                                                                              swc.getVersions().getMinimumVersionString());
                                ThreadLocalToolkit.log(message, u.getSource());
                            }
                        }
                    }
                }
            }

            // Warn about linked in dependent SWC's, which have style
            // defaults.  Linking in dependent SWC's pulls in
            // definitions without their associated style defaults and
            // their dependencies.  This can lead to missing skins at
            // runtime for applications, which compile against the
            // output SWC.  Merging the style defaults isn't enough,
            // because styles can bring in additional dependencies, so
            // in order to get a complete dependency set, we would
            // have to compile the style defaults and our current
            // design requires deferring that until application
            // compile time.  Therefore the best option is to
            // recommend that the user put the dependent SWC in the
            // external-library-path of the output SWC compilation and
            // in the library-path of downstream application
            // compilations.
            Source source = u.getSource();

            if (source.isSwcScriptOwner() &&
                !PreLink.isCompilationUnitExternal(u, externs) &&
                !source.isInternal() && !hidePotentialMissingSkinsWarning)
            {
                SwcScript swcScript = (SwcScript) source.getOwner();
                Swc swc = swcScript.getLibrary().getSwc();
                String location = swc.getLocation();

                if (!processedSwcs.contains(location))
                {
View Full Code Here

TOP

Related Classes of flex2.compiler.Source

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.