47
47
public class DefinitionDocumentationUtils {
48
48
private static final String SDK_LIBRARY_PATH_SIGNATURE_UNIX = "/frameworks/libs/" ;
49
49
private static final String SDK_LIBRARY_PATH_SIGNATURE_WINDOWS = "\\ frameworks\\ libs\\ " ;
50
+ private static final String LOCALE_EN_US = "locale/en_US/" ;
51
+ private static final String PLAYERGLOBAL = "playerglobal" ;
52
+ private static final String AIRGLOBAL = "airglobal" ;
53
+ private static final String RB_SWC_SUFFIX = "_rb.swc" ;
54
+ private static final String FRAMEWORKS = "frameworks" ;
55
+ private static final String FILE_EXTENSION_SWC = ".swc" ;
50
56
51
57
public static String getDocumentationForDefinition (IDefinition definition , boolean useMarkdown ,
52
58
ICompilerProject project , boolean allowDITA ) {
@@ -96,7 +102,8 @@ private static VSCodeASDocComment getCommentForDefinition(IDocumentableDefinitio
96
102
boolean useMarkdown , IWorkspace workspace , boolean allowDITA ) {
97
103
VSCodeASDocComment comment = (VSCodeASDocComment ) documentableDefinition .getExplicitSourceComment ();
98
104
String definitionFilePath = documentableDefinition .getContainingFilePath ();
99
- if (allowDITA && comment == null && definitionFilePath != null && definitionFilePath .endsWith (".swc" )) {
105
+ if (allowDITA && comment == null && definitionFilePath != null
106
+ && definitionFilePath .endsWith (FILE_EXTENSION_SWC )) {
100
107
IDITAList ditaList = null ;
101
108
File swcFile = new File (definitionFilePath );
102
109
if (swcFile .exists ()) {
@@ -105,24 +112,34 @@ private static VSCodeASDocComment getCommentForDefinition(IDocumentableDefinitio
105
112
String fileName = swcFile .getName ();
106
113
ditaList = swc .getDITAList ();
107
114
108
- // next, if it's a SDK/framework liberary , check for an
115
+ // next, if it's a SDK/framework library , check for an
109
116
// associated resource bundle .swc
110
117
if (ditaList == null && (definitionFilePath .contains (SDK_LIBRARY_PATH_SIGNATURE_UNIX )
111
118
|| definitionFilePath .contains (SDK_LIBRARY_PATH_SIGNATURE_WINDOWS ))) {
112
- String rbName = fileName .substring (0 , fileName .length () - 4 ) + "_rb.swc" ;
119
+ String swcBaseName = fileName .substring (0 , fileName .length () - 4 );
120
+ String rbName = swcBaseName + RB_SWC_SUFFIX ;
113
121
File frameworksDir = swcFile .getParentFile ();
114
- while (!frameworksDir .getName ().equals ("frameworks" )) {
122
+ while (!frameworksDir .getName ().equals (FRAMEWORKS )) {
115
123
frameworksDir = frameworksDir .getParentFile ();
116
124
}
117
- File rbSwcFile = new File (frameworksDir , "locale/en_US/" + rbName );
125
+ File rbSwcFile = new File (frameworksDir , LOCALE_EN_US + rbName );
118
126
if (rbSwcFile .exists ()) {
119
127
ISWC rbSwc = workspace .getSWCManager ().get (rbSwcFile );
120
128
ditaList = rbSwc .getDITAList ();
129
+ } else if (fileName .contains (AIRGLOBAL )) {
130
+ // airglobal_rb.swc may not exist, but
131
+ // playerglobal_rb.swc may be used as a fallback
132
+ rbName = PLAYERGLOBAL + RB_SWC_SUFFIX ;
133
+ rbSwcFile = new File (frameworksDir , LOCALE_EN_US + rbName );
134
+ if (rbSwcFile .exists ()) {
135
+ ISWC rbSwc = workspace .getSWCManager ().get (rbSwcFile );
136
+ ditaList = rbSwc .getDITAList ();
137
+ }
121
138
}
122
139
}
123
140
// finally, fall back to the bundled documentation for
124
141
// playerglobal or airglobal, if the filename matches
125
- if (ditaList == null && (fileName .contains ("playerglobal" ) || fileName .contains ("airglobal" ))) {
142
+ if (ditaList == null && (fileName .contains (PLAYERGLOBAL ) || fileName .contains (AIRGLOBAL ))) {
126
143
try {
127
144
File jarPath = new File (DefinitionDocumentationUtils .class .getProtectionDomain ().getCodeSource ()
128
145
.getLocation ().toURI ());
0 commit comments