@@ -16,21 +16,23 @@ abstract class TypeScriptToKotlinBase(
1616
1717 open val defaultAnnotations: List <KtAnnotation > = listOf ()
1818
19- open fun addVariable (symbol : Symbol ? , name : String , type : KtType , extendsType : KtType ? = null, typeParams : List <KtTypeParam >? = null, isVar : Boolean = true, isAbstract : Boolean = false, needsNoImpl : Boolean = !isAbstract, additionalAnnotations : List <KtAnnotation > = listOf(), isOverride : Boolean = false) {
19+ open fun addVariable (symbol : Symbol ? , name : String , type : KtType , extendsType : KtType ? = null, typeParams : List <KtTypeParam >? = null, isVar : Boolean = true, isAbstract : Boolean = false, needsNoImpl : Boolean = !isAbstract, additionalAnnotations : List <KtAnnotation > = listOf(), isOverride : Boolean = false, accessModifier : AccessModifier = AccessModifier . PUBLIC ) {
2020 val annotations = defaultAnnotations + additionalAnnotations
21- addDeclaration(symbol, KtVariable (KtName (name), KtTypeAnnotation (type), extendsType?.let { KtHeritageType (it) }, annotations, typeParams, isVar = isVar, needsNoImpl = needsNoImpl, isInInterface = isInterface, isOverride = isOverride, hasOpenModifier = hasMembersOpenModifier && ! isAbstract, isAbstract = isAbstract))
21+ addDeclaration(symbol, KtVariable (KtName (name), KtTypeAnnotation (type), extendsType?.let { KtHeritageType (it) }, annotations, typeParams, isVar = isVar, needsNoImpl = needsNoImpl, isInInterface = isInterface, isOverride = isOverride, hasOpenModifier = hasMembersOpenModifier && ! isAbstract, isAbstract = isAbstract, accessModifier = accessModifier ))
2222 }
2323
24- open fun addFunction (symbol : Symbol ? , name : String , callSignature : KtCallSignature , extendsType : KtType ? = null, needsNoImpl : Boolean = true, additionalAnnotations : List <KtAnnotation > = listOf(), isOverride : Boolean = false, isOperator : Boolean = false, isAbstract : Boolean = false) {
24+ open fun addFunction (symbol : Symbol ? , name : String , callSignature : KtCallSignature , extendsType : KtType ? = null, needsNoImpl : Boolean = true, additionalAnnotations : List <KtAnnotation > = listOf(), isOverride : Boolean = false, isOperator : Boolean = false, isAbstract : Boolean = false, accessModifier : AccessModifier = AccessModifier . PUBLIC ) {
2525 val annotations = defaultAnnotations + additionalAnnotations
26- addDeclaration(symbol, KtFunction (KtName (name), callSignature, extendsType?.let { KtHeritageType (it) }, annotations, needsNoImpl = needsNoImpl, isOverride = isOverride, hasOpenModifier = hasMembersOpenModifier && ! isAbstract, isOperator = isOperator, isAbstract = isAbstract))
26+ addDeclaration(symbol, KtFunction (KtName (name), callSignature, extendsType?.let { KtHeritageType (it) }, annotations, needsNoImpl = needsNoImpl, isOverride = isOverride, hasOpenModifier = hasMembersOpenModifier && ! isAbstract, isOperator = isOperator, isAbstract = isAbstract, accessModifier = accessModifier ))
2727 }
2828
2929 protected fun addDeclaration (symbol : Symbol ? , declaration : KtMember ) {
30- declarations + = declaration
31- if (symbol != null ) {
32- val values = declarationsBySymbol.getOrPut(symbol) { mutableListOf () }
33- values + = declaration
30+ if (declaration.accessModifier.usable) {
31+ declarations + = declaration
32+ if (symbol != null ) {
33+ val values = declarationsBySymbol.getOrPut(symbol) { mutableListOf () }
34+ values + = declaration
35+ }
3436 }
3537 }
3638
@@ -42,6 +44,14 @@ abstract class TypeScriptToKotlinBase(
4244 return node.modifiers?.arr?.any { it.kind == SyntaxKind .ReadonlyKeyword } == true
4345 }
4446
47+ fun getAccessModifier (node : Node ): AccessModifier {
48+ return when {
49+ node.modifiers?.arr?.any { it.kind == SyntaxKind .ProtectedKeyword } == true -> AccessModifier .PROTECTED
50+ node.modifiers?.arr?.any { it.kind == SyntaxKind .PrivateKeyword } == true -> AccessModifier .PRIVATE
51+ else -> AccessModifier .PUBLIC
52+ }
53+ }
54+
4555 // TODO
4656 open fun visitList (node : typescriptServices.ts.Node ) {
4757 forEachChild(this , node)
0 commit comments