private void AnalyzeDeclarationStatement(IStatement source, int idx) { // We don't need to analyze injected declarations (e.g. withQualifier or qualifier declarations) if (source.IsInjectedForDScript()) { return; } switch (source.Kind) { case SyntaxKind.InterfaceDeclaration: AnalyzeInterfaceDeclaration(source.Cast <IInterfaceDeclaration>()); break; case SyntaxKind.ImportDeclaration: AnalyzeImportDeclaration(source.Cast <IImportDeclaration>()); break; case SyntaxKind.ExportDeclaration: AnalyzeExportDeclaration(source.Cast <IExportDeclaration>()); break; case SyntaxKind.ModuleDeclaration: AnalyzeNamespaceDeclaration(source.Cast <IModuleDeclaration>()); break; case SyntaxKind.VariableStatement: AnalyzeTopLevelVariableDeclarations( source.Cast <IVariableStatement>().DeclarationList, GetModifiers(source.Cast <IVariableStatement>()), idx); break; case SyntaxKind.FunctionDeclaration: AnalyzeFunctionDeclaration(source.Cast <IFunctionDeclaration>()); break; case SyntaxKind.EnumDeclaration: AnalyzeEnumDeclaration(source.Cast <IEnumDeclaration>()); break; case SyntaxKind.TypeAliasDeclaration: AnalyzeTypeAlias(source.Cast <ITypeAliasDeclaration>()); break; } }
private bool ShouldKeepStatement(IStatement statement) { if (statement.IsInjectedForDScript()) { return(false); } var result = (statement.Kind == TypeScript.Net.Types.SyntaxKind.ModuleDeclaration) || // Modules are automatically exported in DScript (statement.Kind == TypeScript.Net.Types.SyntaxKind.ImportDeclaration) || // Import and (statement.Kind == TypeScript.Net.Types.SyntaxKind.ExportDeclaration) || // export declarations are always kept to make references work (statement.Kind == TypeScript.Net.Types.SyntaxKind.InterfaceDeclaration) || // Interfaces, (statement.Kind == TypeScript.Net.Types.SyntaxKind.TypeAliasDeclaration) || // Types, (statement.Kind == TypeScript.Net.Types.SyntaxKind.EnumDeclaration) || // and Enums are kept regardless visibility so we don't need to analyze type-related declarations. TODO: this can be optimized (statement.Flags & NodeFlags.Export) != NodeFlags.None; // anything else that is explicitly exported if (result) { m_keptNodes.Add(statement); } return(result); }