Chrome DevTools no longer supports displayName, use name instead Adds `name` get function to each function object when this flag is enabled, following the guidance in https://bugs.chromium.org/p/chromium/issues/detail?id=1178257. The displayName property is still set for now for backwards compatibility, and by default neither of these are set, but are hidden behind the -XmethodNameDisplayMode flag. Bug: #9735 Change-Id: I1f963607926e111cb6c67a2b2de0de9bbb3a12d3 Bug-Link: https://github.com/gwtproject/gwt/issues/9735
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java index 1eebb9d..6647795 100644 --- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java +++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
@@ -2338,8 +2338,8 @@ addMethodDefinitionStatement(method, methodDefinitionStatement); if (shouldEmitDisplayNames()) { - JsExprStmt displayNameAssignment = outputDisplayName(functionNameRef, method); - addMethodDefinitionStatement(method, displayNameAssignment); + addMethodDefinitionStatement(method, outputDisplayName(functionNameRef, method)); + addMethodDefinitionStatement(method, outputFunctionNameProperty(functionNameRef, method)); } } @@ -2359,6 +2359,21 @@ return createAssignment(displayName, displayMethodName).makeStmt(); } + private JsExprStmt outputFunctionNameProperty(JsNameRef function, JMethod method) { + String displayStringName = getDisplayName(method); + SourceInfo sourceInfo = function.getSourceInfo(); + JsStringLiteral displayMethodName = + new JsStringLiteral(sourceInfo, displayStringName); + JsObjectLiteral props = JsObjectLiteral.builder(sourceInfo) + .add(new JsStringLiteral(sourceInfo, "name"), JsObjectLiteral.builder(sourceInfo) + .add("value", displayMethodName) + .build()) + .build(); + JsExpression[] args = {function, props}; + return constructInvocation(sourceInfo, RuntimeConstants.RUNTIME_DEFINE_PROPERTIES, args) + .makeStmt(); + } + private boolean shouldEmitDisplayNames() { return methodNameMappingMode != OptionMethodNameDisplayMode.Mode.NONE; }