@@ -16,21 +16,23 @@ abstract class TypeScriptToKotlinBase(
16
16
17
17
open val defaultAnnotations: List <KtAnnotation > = listOf ()
18
18
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 ) {
20
20
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 ))
22
22
}
23
23
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 ) {
25
25
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 ))
27
27
}
28
28
29
29
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
+ }
34
36
}
35
37
}
36
38
@@ -42,6 +44,14 @@ abstract class TypeScriptToKotlinBase(
42
44
return node.modifiers?.arr?.any { it.kind == SyntaxKind .ReadonlyKeyword } == true
43
45
}
44
46
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
+
45
55
// TODO
46
56
open fun visitList (node : typescriptServices.ts.Node ) {
47
57
forEachChild(this , node)
0 commit comments