Ejemplo n.º 1
0
        public void CreateMasterDeclarationsIndex(string outputPath = null)
        {
            var declaredSymbols = new List <DeclaredSymbolInfo>();

            ////var declaredTypes = new List<DeclaredSymbolInfo>();

            using (Measure.Time("Merging declared symbols"))
            {
                ushort assemblyNumber = 0;
                foreach (var project in this.projects)
                {
                    foreach (var symbolInfo in project.DeclaredSymbols.Values)
                    {
                        symbolInfo.AssemblyNumber = assemblyNumber;
                        declaredSymbols.Add(symbolInfo);

                        ////if (SymbolKindText.IsType(symbolInfo.Kind))
                        ////{
                        ////    declaredTypes.Add(symbolInfo);
                        ////}
                    }

                    assemblyNumber++;
                }
            }

            Serialization.WriteDeclaredSymbols(declaredSymbols, outputPath ?? SolutionDestinationFolder);
            ////NamespaceExplorer.WriteNamespaceExplorer(declaredTypes, outputPath ?? rootPath);
        }
Ejemplo n.º 2
0
        public void Generate(IEnumerable <string> typeScriptFiles)
        {
            if (typeScriptFiles == null || !typeScriptFiles.Any())
            {
                return;
            }

            declarations = new List <string>();
            references   = new Dictionary <string, List <Reference> >(StringComparer.OrdinalIgnoreCase);
            SymbolIDToListOfLocationsMap = new Dictionary <string, List <Tuple <string, long> > >();

            var    list    = new List <string>();
            string libFile = null;

            foreach (var file in typeScriptFiles)
            {
                if (!alreadyProcessed.Contains(file))
                {
                    if (libFile == null && string.Equals(Path.GetFileName(file), "lib.d.ts", StringComparison.OrdinalIgnoreCase))
                    {
                        libFile = file;
                    }
                    else
                    {
                        list.Add(file);
                    }
                }
            }

            if (libFile == null)
            {
                libFile = Path.Combine(Common.Paths.BaseAppFolder, "TypeScriptSupport", "lib.d.ts");
            }

            try
            {
                GenerateCore(list, libFile);
            }
            catch (Exception ex)
            {
                Log.Exception(ex, "Error when generating TypeScript files");
                return;
            }

            ProjectGenerator.GenerateReferencesDataFilesToAssembly(
                Paths.SolutionDestinationFolder,
                Constants.TypeScriptFiles,
                references);

            declarations.Sort();

            Serialization.WriteDeclaredSymbols(
                ProjectDestinationFolder,
                declarations);

            ProjectGenerator.GenerateSymbolIDToListOfDeclarationLocationsMap(
                ProjectDestinationFolder,
                SymbolIDToListOfLocationsMap);
        }
Ejemplo n.º 3
0
        private void GenerateDeclarations()
        {
            Log.Write("Declarations...");

            var lines = new List <string>();

            if (DeclaredSymbols != null)
            {
                foreach (var declaredSymbol in DeclaredSymbols
                         .OrderBy(s => SymbolIdService.GetName(s.Key))
                         .ThenBy(s => s.Value))
                {
                    lines.Add(string.Join(";",
                                          SymbolIdService.GetName(declaredSymbol.Key),                                   // symbol name
                                          declaredSymbol.Value,                                                          // 8-byte symbol ID
                                          SymbolKindText.GetSymbolKind(declaredSymbol.Key),                              // kind (e.g. "class")
                                          Markup.EscapeSemicolons(SymbolIdService.GetDisplayString(declaredSymbol.Key)), // symbol full name and signature
                                          SymbolIdService.GetGlyphNumber(declaredSymbol.Key)));                          // icon number
                }
            }

            if (OtherFiles != null)
            {
                foreach (var document in OtherFiles.OrderBy(d => d))
                {
                    lines.Add(string.Join(";",
                                          Path.GetFileName(document),
                                          SymbolIdService.GetId(document),
                                          "file",
                                          Markup.EscapeSemicolons(document),
                                          Serialization.GetIconForExtension(document)));
                }
            }

            Serialization.WriteDeclaredSymbols(ProjectDestinationFolder, lines);
        }