Package flex2.compiler

Examples of flex2.compiler.Source


        {
            classInfo = classInfoMap.get( qName.toString() );

            if (classInfo == null)
            {
                Source source = symbolTable.findSourceByQName(qName);

                assert source != null : "no source for qname '" + qName + "', even though multiname was resolved";

                CompilationUnit compilationUnit = source.getCompilationUnit();

                AbcClass abcClass = compilationUnit.classTable.get( qName.toString() );

                if (abcClass != null)
                {
View Full Code Here


    {
        QName qName = findQName(multiName);

        if (qName != null)
        {
            Source source = symbolTable.findSourceByQName(qName);

            InterfaceInfo baseInterfaceInfo = interfaceInfoMap.get( qName.toString() );

            if (baseInterfaceInfo == null)
            {
                CompilationUnit compilationUnit = source.getCompilationUnit();

                AbcClass abcClass = null;

                if (compilationUnit != null)
                {
View Full Code Here

     *
     */
    private Source createSource(String fileName, String shortName, long lastModified,
                  PathResolver resolver, SourceCodeBuffer sourceCodeBuffer)
    {
        Source result = null;

        if (sourceCodeBuffer.getBuffer() != null)
        {
            String sourceCode = sourceCodeBuffer.toString();

            if (generatedOutputDirectory != null)
            {
                try
                {
                    FileUtil.writeFile(generatedOutputDirectory + File.separatorChar + fileName, sourceCode);
                }
                catch (IOException e)
                {
                    ThreadLocalToolkit.log(new VelocityException.UnableToWriteGeneratedFile(fileName, e.getMessage()));
                }
            }

      VirtualFile generatedFile = new TextFile(sourceCode, fileName, null, MimeMappings.AS, lastModified);

            result = new Source(generatedFile,
                                "",
                                shortName,
                                null,
                                false,
                                false,
                                false);
            result.setPathResolver(resolver);
        }

        return result;
    }
View Full Code Here

        String className = dataBindingInfo.getWatcherSetupUtilClassName();
        String shortName = className.substring(className.lastIndexOf(DOT) + 1);
        String fileName = className.replace('.', File.separatorChar) + DOT_AS;
        VirtualFile emptyFile = new TextFile(EMPTY_STRING, fileName, null, MimeMappings.AS,
                                             compilationUnit.getSource().getLastModified());
        Source result = new Source(emptyFile, EMPTY_STRING, shortName, null, false, false, false);

        Context cx = AbstractSyntaxTreeUtil.generateContext(symbolTable.perCompileData, result,
                                                            symbolTable.emitter, defines);
        NodeFactory nodeFactory = cx.getNodeFactory();

        HashSet<String> configNamespaces = new HashSet<String>();
        StatementListNode configVars = AbstractSyntaxTreeUtil.parseConfigVars(cx, configNamespaces);
        ProgramNode program = AbstractSyntaxTreeUtil.generateProgram(cx, configVars, EMPTY_STRING);
        StatementListNode programStatementList = program.statements;

        String[] watcherImports = compilationUnit.getStandardDefs().getImports();
        for (int i = 0; i < watcherImports.length; i++)
        {
            ImportDirectiveNode importDirective = AbstractSyntaxTreeUtil.generateImport(cx, watcherImports[i]);
            programStatementList = nodeFactory.statementList(programStatementList, importDirective);
        }

        MetaDataNode metaDataNode = AbstractSyntaxTreeUtil.generateMetaData(nodeFactory, EXCLUDE_CLASS);
        programStatementList = nodeFactory.statementList(programStatementList, metaDataNode);

        ClassDefinitionNode classDefinition = generateClassDefinition(cx, configNamespaces, shortName,
                                                                      dataBindingInfo, compilationUnit.getStandardDefs());
        programStatementList = nodeFactory.statementList(programStatementList, classDefinition);
        program.statements = programStatementList;

        PackageDefinitionNode packageDefinition = nodeFactory.finishPackage(cx, null);
        nodeFactory.statementList(programStatementList, packageDefinition);

    CompilerContext context = new CompilerContext();
    context.setAscContext(cx);
    result.newCompilationUnit(program, context).setSyntaxTree(program);

        // Useful when comparing abstract syntax trees
        //flash.swf.tools.SyntaxTreeDumper.dump(program, "/tmp/" + className + "New.xml");

        As3Compiler.cleanNodeFactory(nodeFactory);
View Full Code Here

  public static Source getResourceBundleSource(String packageName, String className, ResourceBundlePath bundlePath,
                                               SourcePath sourcePath, CompilerSwcContext swcContext)
      throws CompilerException
  {
    // look for className.properties
    Source s = bundlePath.findSource(packageName, className);

    if (s == null)
    {
      // continue our search for a .properties file by looking in the SWCs for className_properties
      s = swcContext.getSource(packageName, className + CLASS_SUFFIX);
View Full Code Here

                                                          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);
                }
View Full Code Here

            // Create a new Source for the node.
            VirtualFile virtualFile = new TextFile("", unit.getSource().getName() + "$" + className,
                                                   unit.getSource().getName(), unit.getSource().getParent(),
                                                   MimeMappings.MXML, unit.getSource().getLastModified());
            Source source = new Source(virtualFile, unit.getSource(), className, false, false);

            // Set the Source's syntax tree to the DocumentNode
            // equivalent of the grandchild, so that the text
            // representation won't have to be recreated and reparsed.
            DocumentNode inlineDocumentNode =
                DocumentNode.inlineDocumentNode(componentRoot.getNamespace(), componentRoot.getLocalPart(),
                        NameFormatter.toDot(docInfo.getPackageName(), docInfo.getClassName()));

            inlineDocumentNode.beginLine = componentRoot.beginLine;
            inlineDocumentNode.beginColumn = componentRoot.beginColumn;
            inlineDocumentNode.endLine = componentRoot.endLine;
            inlineDocumentNode.endColumn = componentRoot.endColumn;
            inlineDocumentNode.image = componentRoot.image;
           
            // Inline components are line inner classes, so there need to be suppressed in the asdoc.
            if(generateAst)
            {
                inlineDocumentNode.comment = "<description><![CDATA[]]></description><private><![CDATA[]]></private>";   
            }
            else
            {
                inlineDocumentNode.comment = "@private";
            }
           
            componentRoot.copy(inlineDocumentNode);
            inlineDocumentNode.setLocalClassMappings(docInfo.getLocalClassMappings());
            inlineDocumentNode.setLanguageNamespace(docInfo.getLanguageNamespace());
            inlineDocumentNode.setVersion(docInfo.getVersion());

            addExcludeClassNode(inlineDocumentNode, componentRoot);
           
            source.addSourceFragment(AttrInlineComponentSyntaxTree, inlineDocumentNode, null);

            unit.addGeneratedSource(classQName, source);
        }
View Full Code Here

            // Create a new Source for the node.
            VirtualFile virtualFile = new TextFile("", unit.getSource().getName() + "$" + className,
                                                   unit.getSource().getName(), unit.getSource().getParent(),
                                                  MimeMappings.MXML, unit.getSource().getLastModified());
            Source source = new Source(virtualFile, unit.getSource(), className, false, false);

            // Set the Source's syntax tree to the DocumentNode
            // equivalent of the grandchild, so that the text
            // representation won't have to be recreated and reparsed.
            DocumentNode definitionDocumentNode = new DocumentNode(definitionRoot.getNamespace(), definitionRoot.getLocalPart());
            definitionDocumentNode.beginLine = definitionRoot.beginLine;
            definitionDocumentNode.beginColumn = definitionRoot.beginColumn;
            definitionDocumentNode.endLine = definitionRoot.endLine;
            definitionDocumentNode.endColumn = definitionRoot.endColumn;
            definitionDocumentNode.image = definitionRoot.image;
            // anything defined using the Library Definition is only accesible within the class. So it should always have a private comment.
            if(generateAst)
            {
                definitionDocumentNode.comment = "<description><![CDATA[]]></description><private><![CDATA[]]></private>";   
            }
            else
            {
                definitionDocumentNode.comment = "@private";
            }
           
            definitionRoot.copy(definitionDocumentNode);
            definitionDocumentNode.setLocalClassMappings(docInfo.getLocalClassMappings());
            definitionDocumentNode.setLanguageNamespace(docInfo.getLanguageNamespace());
            definitionDocumentNode.setVersion(docInfo.getVersion());

            source.addSourceFragment(AttrInlineComponentSyntaxTree, definitionDocumentNode, null);

            unit.addGeneratedSource(classQName, source);
        }
View Full Code Here

            compilationUnit.mixins.add(className);

            // Determine whether we need to regenerate the style source based
            // on whether any new style definitions were included
            String genFileName = generateStyleSourceName(packageName, className);
            Source styleSource = resources.findSource(genFileName);
            if (styleSource != null)
            {
                if (styleSource.getCompilationUnit() == null)
                {
                    // if no compilationUnit, then we need to generate source so we can recompile.
                    styleSource = null;
                }
                else
View Full Code Here

  }

    private Source generateFontFaceRules(ResourceContainer resources)
    {
      String genFileName = generateFontFaceRuleSourceName();
      Source styleSource = resources.findSource(genFileName);
      if (styleSource != null)
      {
            if (styleSource.getCompilationUnit() == null)
            {
                // if no compilationUnit, then we need to generate source so we can recompile.
                styleSource = null;
            }
            else
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.