Package org.apache.flex.compiler.internal.scopes

Examples of org.apache.flex.compiler.internal.scopes.ASProjectScope


    public IClassDefinition[] getAlternativeClasses(ICompilerProject project, Version version)
    {
        AlternativeInformation[] alternatives = getAlternatives();
        List<IClassDefinition> result = new ArrayList<IClassDefinition>(alternatives.length);

        ASProjectScope projectScope = (ASProjectScope)project.getScope();

        for (AlternativeInformation alternative : alternatives)
        {
            Version alternativeSinceVersion = alternative.getSinceVersion();
            if (alternativeSinceVersion.compareBugFixVersionTo(version) >= 0)
            {
                String replacement = alternative.getReplacement();
                IDefinition def = projectScope.findDefinitionByName(replacement);

                // replacements should only point to classes, so ignore anything which
                // isn't a class
                if (!(def instanceof IClassDefinition))
                    continue;
View Full Code Here


       
        if (project instanceof FlexProject)
        {
            final String normalizedBundleName = QNameNormalization.normalize(bundleName);
            final FlexProject flexProject = (FlexProject)project;
            final ASProjectScope scope = flexProject.getScope();
            final Collection<String> locales = flexProject.getLocales();
           
            if(locales.size() == 0)
            {
                //If the project's locale is empty, then don't try to resolve this
                //node because the referenced bundle won't go into swf or swc anyways.
                return Collections.emptyMap();
            }
           
            Collection<String> unresolvedLocales = new ArrayList<String>(locales);
            for(String locale : locales)
            {  
                //resolve the generated qualified name for the bundle name referenced in this metadata tag and this locale
                String qualifiedName = ResourceBundleUtils.getQualifiedName(locale, normalizedBundleName);
               
                //find the compilation units for this qualified name
                IDefinition def = scope.findDefinitionByName(qualifiedName);
                if(def != null)
                {
                    ICompilationUnit compUnit = scope.getCompilationUnitForDefinition(def);

                    if (isValidCompilationUnit(compUnit, project, bundleName))
                    {
                        compilationUnits.put(def.getQualifiedName(), compUnit);
                        unresolvedLocales.remove(locale);
                    }                
                }
            }
          
            if (unresolvedLocales.size() > 0 || locales.size() == 0)
            {
                //If we are at this point, it means that either project's locale is empty or
                //we could not resolve the resource bundle for some or all locales.
                //The last thing we can check is to see whether we can resolve it using the
                //pure bundle name (not the generated name that contains locale$..._properties)
                //This is also acceptable because "mx.managers.SystemManager" uses the same logic
                //to find a resource bundle. First, it searches for the generated class name and then the pure bundle name.
                IDefinition def = scope.findDefinitionByName(normalizedBundleName);
                if(def != null)
                {
                    ICompilationUnit compUnit = scope.getCompilationUnitForDefinition(def);

                    if (isValidCompilationUnit(compUnit, project, bundleName))
                    {
                        //This means we resolved the reference by using pure bundle name which will apply
                        //to all locales during runtime, therefore return from this method.
View Full Code Here

            assert ((NodeBase)ast).verify() : "AST failed verification";
    }

    protected final void addScopeToProjectScope(ASFileScope[] scopes)
    {
        ASProjectScope projectScope = project.getScope();
        for (ASFileScope scope : scopes)
        {
            assert scope.verify() : "Scope failed verification";
            projectScope.addScopeForCompilationUnit(this, scope);
        }
    }
View Full Code Here

     *
     * @param fna IFileNodeAccumulator
     */
    protected void startParsingImports(IFileNodeAccumulator fna)
    {
        ASProjectScope projectScope = getProject().getScope();
        List<IImportNode> importNodes = fna.getImportNodes();
        Set<ICompilationUnit> compilationUnits = new HashSet<ICompilationUnit>();
        for (IImportNode importNode : importNodes)
        {
            if (!importNode.isWildcardImport())
            {
                String importName = importNode.getImportName();
                int index = importName.lastIndexOf('.');
                if (index != -1)
                {
                    String className = importName.substring(index + 1);
                    compilationUnits.addAll(projectScope.getCompilationUnitsByDefinitionName(className));
                }
            }
        }

        // Now that we have the compilation units from the imports,
View Full Code Here

        startProfile(Operation.GET_SEMANTIC_PROBLEMS);

        SetMultimap<String,DependencyType> dependencies = script.getDependencies();
        addAssetTagDependencies(dependencies);

        ASProjectScope projectScope = getProject().getScope();
        final Collection<ICompilerProblem> problems = new LinkedList<ICompilerProblem>();
        for (final Map.Entry<String, Collection<DependencyType>> dependencyEntry : dependencies.asMap().entrySet())
        {
            IDefinition[] defs = projectScope.findAllDefinitionsByName(Multiname.crackDottedQName(getProject(), dependencyEntry.getKey(), true));
            if (defs == null || defs.length == 0)
            {
                ICompilerProblem problem = new NoDefinitionForSWCDependencyProblem(
                    getRootFileSpecification().getPath(), getAbsoluteFilename(), dependencyEntry.getKey(),
                    script.getDefinitions().iterator().next());
                problems.add(problem);
            }
            else
            {
                assert (defs != null && defs.length <= 1) : "Lookups using a fully qualified name should find at most 1 definition";
                ICompilationUnit referencedCU = projectScope.getCompilationUnitForScope(defs[0].getContainingScope());
                DependencyTypeSet dependencyTypes = DependencyTypeSet.copyOf(dependencyEntry.getValue());
                getProject().addDependency(this, referencedCU, dependencyTypes, defs[0].getQualifiedName());
            }
        }
View Full Code Here

       
        final Collection<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
        Map<ITag, ITag> extraTags = new HashMap<ITag, ITag>();
        FXGSymbolClass symbolClass = null;
        FileNode fileNode = null;
        ASProjectScope projectScope = getProject().getScope();
       
        try
        {
            FXGSyntaxTreeRequestResult syntaxTreeResult = (FXGSyntaxTreeRequestResult)getSyntaxTreeRequest().get();
            IFXGNode tree = syntaxTreeResult.getRootNode();

            FlexFXG2SWFTranscoder transcoder = new FlexFXG2SWFTranscoder(getProject());          
            transcoder.setResourceResolver(new FXGFileResolver(FilenameUtils.getFullPath(getRootFileSpecification().getPath())));         

            symbolClass = transcoder.transcode(tree,
                    Multiname.getPackageNameForQName(qname), Multiname.getBaseNameForQName(qname), extraTags, problems);

           
            //Add dependencies to the classes required by the FXG processed by this compilation unit
            for (ITypeDefinition definition : transcoder.getDependencies())
            {
                getProject().addDependency(this, projectScope.getCompilationUnitForDefinition(definition),
                        DependencyType.EXPRESSION, definition.getQualifiedName());
            }

            StringBuilder sb = new StringBuilder(symbolClass.getGeneratedSource());
            if (symbolClass.getAdditionalSymbolClasses() != null)
            {
                for (FXGSymbolClass symbol : symbolClass.getAdditionalSymbolClasses())
                {
                    sb.append(symbol.getGeneratedSource());
                }
            }

            IFileSpecification virtualSymbolSource = new GeneratedSourceFileSpecfication(qname, sb.toString());
            fileNode = ASParser.parseFile(virtualSymbolSource, getProject().getWorkspace());
            fileNode.runPostProcess(EnumSet.of(PostProcessStep.POPULATE_SCOPE));

            projectScope.addScopeForCompilationUnit(this, fileNode.getFileScope());
           
            updateEmbedCompilationUnitDependencies(fileNode.getEmbedNodes(), problems);
        }
        catch (Exception e)
        {
View Full Code Here

     * Init the project scope.  Allow subclasses to contribute their own if needed.  Default will create a new {@link ASProjectScope}
     * @param project the project to build the scope from
     * @return a new {@link ASProjectScope}
     */
    protected ASProjectScope initProjectScope(CompilerProject project) {
        return new ASProjectScope(project);
    }
View Full Code Here

    {
        ITypeDefinition definition = dependencies.get(qname);
       
        if(definition == null)
        {
            ASProjectScope scope = (ASProjectScope)project.getScope();
            definition = (ITypeDefinition)scope.findDefinitionByName(Multiname.crackDottedQName(project, qname , true), true);
           
            if(definition == null)
            {
                problems.add(new FXGDefinitionNotFoundProblem(qname));
                return null;
View Full Code Here

        final ImmutableList.Builder<ICompilerProblem> problems =
            ImmutableList.<ICompilerProblem>builder();
       
        compilationUnits.add(factoryClassCompilationUnit);
       
        final ASProjectScope projectScope = flexProject.getScope();
       
        final FlexDelegate delegate = getDelegate();
       
        resolveReferenceToCompilationUnit(delegate.iModuleFactoryReference,
                projectScope,
View Full Code Here

        final Iterable<ICompilationUnit> includeLibrariesCompilationUnits =
            getIncludeLibrariesCompilationUnits();
        compilationUnits.addAll(includeLibrariesCompilationUnits);
       
        final FlexDelegate delegate = getDelegate();
        final ASProjectScope projectScope = flexProject.getScope();
       
        if (delegate.getGenerateSystemManagerAndFlexInit())
        {
            resolveReferenceToCompilationUnit(delegate.generateCSSStyleDeclarationsReference,
                    projectScope,
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.scopes.ASProjectScope

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.