Restore emitting source mapping for the exports of generated JS header files
@@ -73,7 +73,14 @@ public class JavaScriptHeaderGenerator extends JavaScriptGenerator {
sourceBuilder.appendLines(
"const " + className + " = goog.require('" + implementationPath + "');");
sourceBuilder.newLine();
- sourceBuilder.append("exports = " + className + ";");
+
+ // Emit a source-mapping for the exports statement back to the original Java file. Kythe models
+ // imports using goog.require as an alias to the exports symbol of the goog.module file being
+ // imported. This mapping will help kythe understand that the exports symbol is really just
+ // the Java class.
+ // TODO(b/150152766): Verify that this gets indexed properly by kythe.
+ sourceBuilder.emitWithMapping(type.getSourcePosition(), () -> sourceBuilder.append("exports"));
+ sourceBuilder.append(" = " + className + ";");
return sourceBuilder.build();
}
