Package flex2.compiler

Examples of flex2.compiler.Source


            // 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 main = null;

        for (int i = 0, length = units.size(); i < length; i++)
        {
            CompilationUnit u = units.get(i);
            Source s = u.getSource();
            String path = s.getName();

          if (!u.isRoot())
          {
            // C: should also setup dependencies based on CompilationUnit.inheritance...
            //    it still works because the list is already sorted and this is a SimpleMovie!
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

                // 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

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

        Source transSource = transform(source, translations);

        if (ThreadLocalToolkit.errorCount() > 0)
        {
            return null;
        }
View Full Code Here

        {
          ThreadLocalToolkit.logError(ioe.toString());
        }
      }
     
      return new Source(new TextFile(code.toString(), name, source.getParent(),
                       MimeMappings.AS, source.getLastModified()), source);
    }
View Full Code Here

                return null;
            }

            for (Map.Entry<String, Source> entry : classes.entrySet())
            {
                Source source = entry.getValue();
                String namespaceURI = source.getRelativePath().replace('/', '.');
                String localPart = source.getShortName();
                Source swcSource = (swcContext != null) ? swcContext.getSource(namespaceURI, localPart) : null;
               
                // No sense recompiling the same source file again.
                if ((swcSource != null) &&
                    ((source.getLastModified() == swcSource.getLastModified()) &&
                     ((source.getCompilationUnit() == null) ||
                      (!source.getCompilationUnit().hasTypeInfo))))
                {
                    classes.put(entry.getKey(), swcSource);
                }
View Full Code Here

    {
      data.swcDefSignatureChecksums = new HashMap<QName, Long>();
      for (Iterator iter = units.iterator(); iter.hasNext();)
      {
        CompilationUnit unit = (CompilationUnit)iter.next();
        Source source = unit == null ? null : unit.getSource();
        if (source != null && source.isSwcScriptOwner() && !source.isInternal())
        {
          addSignatureChecksumToData(data, unit);
        }
      }
    }
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.