Exemplo n.º 1
0
        public override List <TypeElement> Analyze(AssemblyContext ac, List <string> sources)
        {
            List <TypeElement> result = new List <TypeElement>();

            // parse sources, yielding a list of CompilationUnits.
            List <CompilationUnit> cus = ParseSources(sources);

            // create a set of type names that are defined in the sources
            Set <string> typeNames = ExtractDefinedTypeNames(cus);

            // resolve referenced types
            foreach (CompilationUnit cu in cus)
            {
                //	Console.WriteLine("Analyzing {0}...", cu.FileName);

                NamespaceContext context = new NamespaceContext(ac, cu.FileName, cu.Package, typeNames);
                foreach (string import in cu.Imports)
                {
                    if (import.EndsWith(".*"))
                    {
                        string ns = import.Substring(0, import.Length - 2);
                        context.AddNamespaceImport(ns);
                    }
                    else
                    {
                        context.AddSpecificImport(import);
                    }
                }

                // always import java.lang.*
                context.AddNamespaceImport("java.lang");

                List <TypeElement> types = CreateTypeElements(context, cu.DefinedTypes);
                result.AddRange(types);
            }

            return(result);
        }