getSourceForComponent returns the 'original' name for a component in a flattened DevWorkspace. Given a component, it returns the name of the plugin component that imported it if the component came via a plugin, and the actual component name otherwise. Returned name is prefixed with "component " -- e
(component dw.Component)
| 219 | // The purpose of this function is mainly to enable providing better messages to end-users, as a component name may |
| 220 | // not match the name of the plugin in the original DevWorkspace. |
| 221 | func getSourceForComponent(component dw.Component) string { |
| 222 | if component.Attributes.Exists(constants.PluginSourceAttribute) { |
| 223 | var err error |
| 224 | componentName := component.Attributes.GetString(constants.PluginSourceAttribute, &err) |
| 225 | if err == nil { |
| 226 | return fmt.Sprintf("component %s", componentName) |
| 227 | } |
| 228 | } |
| 229 | return fmt.Sprintf("component %s", component.Name) |
| 230 | } |
no test coverage detected