@@ -60,6 +60,8 @@ public String generateDtsContent(List<JavaClass> javaClasses) {
60
60
JavaClass currClass = javaClasses .get (i );
61
61
currentFileClassname = currClass .getClassName ();
62
62
63
+ String simpleClassName = getSimpleClassname (currClass );
64
+
63
65
if (currentFileClassname .startsWith ("java.util.function" ) ||
64
66
currentFileClassname .startsWith ("android.support.v4.media.routing.MediaRouterJellybeanMr1" ) ||
65
67
currentFileClassname .startsWith ("android.support.v4.media.routing.MediaRouterJellybeanMr2" ) ||
@@ -84,13 +86,15 @@ public String generateDtsContent(List<JavaClass> javaClasses) {
84
86
List <JavaClass > interfaces = getInterfaces (currClass );
85
87
String extendsLine = getExtendsLine (superClass , interfaces );
86
88
87
- if (getSimpleClassname ( currClass ) .equals ("AccessibilityDelegate" )) {
89
+ if (simpleClassName .equals ("AccessibilityDelegate" )) {
88
90
sbContent .appendln (tabs + "export class " + getFullClassNameConcatenated (currClass ) + extendsLine + " {" );
89
91
} else {
90
- sbContent .appendln (tabs + "export" + (isAbstract && !isInterface ? " abstract " : " " ) + "class " + getSimpleClassname ( currClass ) + extendsLine + " {" );
92
+ sbContent .appendln (tabs + "export" + (isAbstract && !isInterface ? " abstract " : " " ) + "class " + simpleClassName + extendsLine + " {" );
91
93
}
92
94
// process member scope
93
95
96
+ mapNameMethod = new HashMap <String , Method >();
97
+
94
98
// process constructors for interfaces
95
99
if (isInterface ) {
96
100
List <JavaClass > allInterfaces = getAllInterfaces (currClass );
@@ -175,7 +179,7 @@ private String getExtendsLine(JavaClass superClass, List<JavaClass> interfaces)
175
179
176
180
for (JavaClass clazz : interfaces ) {
177
181
String implementedInterface = clazz .getClassName ().replaceAll ("\\ $" , "\\ ." );
178
- if (!typeBelongsInCurrentTopLevelNamespace (implementedInterface )) {
182
+ if (!typeBelongsInCurrentTopLevelNamespace (implementedInterface )) {
179
183
implementedInterface = getAliasedClassName (implementedInterface );
180
184
}
181
185
@@ -187,7 +191,7 @@ private String getExtendsLine(JavaClass superClass, List<JavaClass> interfaces)
187
191
}
188
192
189
193
String extendedClass = superClass .getClassName ().replaceAll ("\\ $" , "\\ ." );
190
- if (!typeBelongsInCurrentTopLevelNamespace (extendedClass )) {
194
+ if (!typeBelongsInCurrentTopLevelNamespace (extendedClass )) {
191
195
extendedClass = getAliasedClassName (extendedClass );
192
196
}
193
197
@@ -441,6 +445,8 @@ private Set<Field> getAllInterfacesFields(List<JavaClass> interfaces) {
441
445
private void processMethod (Method m , JavaClass clazz , boolean isInterface , Set <String > methodsSet ) {
442
446
String name = m .getName ();
443
447
448
+ if (isPrivateGoogleApiMember (name )) return ;
449
+
444
450
if (m .isSynthetic () || (!m .isPublic () && !m .isProtected ())) {
445
451
return ;
446
452
}
@@ -498,10 +504,9 @@ private void writeMethods(Set<String> methodsSet) {
498
504
}
499
505
500
506
private void cacheMethodBySignature (Method m ) {
501
- mapNameMethod = new HashMap <String , Method >();
502
- String currMethodSig = getMethodFullSignature (m );
503
- if (!mapNameMethod .containsKey (currMethodSig )) {
504
- mapNameMethod .put (currMethodSig , m );
507
+ String methodName = m .getName ();
508
+ if (!mapNameMethod .containsKey (methodName )) {
509
+ mapNameMethod .put (methodName , m );
505
510
}
506
511
}
507
512
@@ -613,6 +618,10 @@ private String getMethodParamSignature(JavaClass clazz, Method m) {
613
618
614
619
//field related
615
620
private void processField (Field f , JavaClass clazz ) {
621
+ String fieldName = f .getName ();
622
+
623
+ if (isPrivateGoogleApiMember (fieldName )) return ;
624
+
616
625
String tabs = getTabs (this .indent + 1 );
617
626
sbContent .append (tabs + "public " );
618
627
if (f .isStatic ()) {
@@ -652,7 +661,7 @@ private String getTypeScriptTypeFromJavaType(JavaClass clazz, Type type) {
652
661
convertToTypeScriptType (type , sb );
653
662
tsType = sb .toString ();
654
663
655
- if (tsType .startsWith ("java.util.function" )) {
664
+ if (tsType .startsWith ("java.util.function" ) || isPrivateGoogleApiClass ( tsType ) ) {
656
665
tsType = "any /* " + tsType + "*/" ;
657
666
}
658
667
}
@@ -691,7 +700,7 @@ private void convertToTypeScriptType(Type type, StringBuilder tsType) {
691
700
typeName = typeName .replaceAll ("\\ $" , "\\ ." );
692
701
}
693
702
694
- if (!typeBelongsInCurrentTopLevelNamespace (typeName ) && !typeName .startsWith ("java.util.function." )) {
703
+ if (!typeBelongsInCurrentTopLevelNamespace (typeName ) && !typeName .startsWith ("java.util.function." ) && ! isPrivateGoogleApiClass ( typeName ) ) {
695
704
tsType .append (getAliasedClassName (typeName ));
696
705
} else {
697
706
tsType .append (typeName );
@@ -763,6 +772,15 @@ private String getTabs(int count) {
763
772
return tabs ;
764
773
}
765
774
775
+ private boolean isPrivateGoogleApiMember (String memberName ) {
776
+ return memberName .startsWith ("zz" );
777
+ }
778
+
779
+ private boolean isPrivateGoogleApiClass (String name ) {
780
+ String [] classNameParts = name .replace ('$' , '.' ).split ("\\ ." );
781
+ return classNameParts .length > 0 && classNameParts [classNameParts .length - 1 ].startsWith ("zz" );
782
+ }
783
+
766
784
private void overrideFieldComparator () {
767
785
BCELComparator cmp = Field .getComparator ();
768
786
0 commit comments