-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
somewhat better default display names
- Loading branch information
Showing
5 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
library/coreGeneric/src/main/scala/japgolly/scalajs/react/component/DerivedDisplayName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package japgolly.scalajs.react.component | ||
|
||
import sourcecode.FullName | ||
|
||
trait DerivedDisplayName { | ||
protected def derivedDisplayName(implicit name: FullName): String = { | ||
// Heuristic to split the name into package and class name | ||
val parts = name.value.split('.') | ||
val (packageName, className) = parts.span(_.headOption.forall(_.isLower)) | ||
className.mkString(".") + Some(packageName).filter(_.nonEmpty).fold("")(_.mkString(" (", ".", ")")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters