Skip to content

Commit

Permalink
[styled-components] Initialize StyledComponentsInjector patterns lazily
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 17dde4d0a0374c4ca620fac98b2a0c827b178698
  • Loading branch information
jreznot authored and intellij-monorepo-bot committed Aug 8, 2022
1 parent 72efbb3 commit 27ad232
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const val COMPONENT_PROPS_PREFIX = "div {"
const val COMPONENT_PROPS_SUFFIX = "}"

class StyledComponentsInjector : MultiHostInjector {
companion object {
private object Holder {
private val styledPattern = withNameStartingWith(listOf("styled"))
private val builtinPlaces: List<PlaceInfo> = listOf(
PlaceInfo(taggedTemplate(PlatformPatterns.or(styledPattern,
Expand Down Expand Up @@ -48,7 +48,7 @@ class StyledComponentsInjector : MultiHostInjector {
if (injectionHost !is PsiLanguageInjectionHost) return

val injectionLanguage = Language.findLanguageByID("LESS") ?: CSSLanguage.INSTANCE
val acceptedPattern = matchInjectionTarget(injectionHost) ?: return
val acceptedPattern = Holder.matchInjectionTarget(injectionHost) ?: return
val stringPlaces = getInjectionPlaces(injectionHost)
if (stringPlaces.isEmpty())
return
Expand Down

0 comments on commit 27ad232

Please sign in to comment.