Skip to content

Commit

Permalink
Merge pull request #17 from undeadcat/master
Browse files Browse the repository at this point in the history
Fix #16, update description in plugin.xml
  • Loading branch information
daedlock authored Sep 4, 2017
2 parents c6a168b + 9ce1309 commit 48430d4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/main/kotlin/com/intellij/StyledComponents/Patterns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.openapi.util.text.StringUtil
import com.intellij.patterns.ElementPattern
import com.intellij.patterns.PatternCondition
import com.intellij.patterns.PlatformPatterns
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.ProcessingContext
import com.intellij.util.SmartList
import com.intellij.util.containers.ContainerUtil
Expand Down Expand Up @@ -51,7 +52,9 @@ fun getReferenceParts(jsReferenceExpression: JSReferenceExpression): List<String
val name = ref.referenceName
if (StringUtil.isEmptyOrSpaces(name)) return ContainerUtil.emptyList()
nameParts.add(name)
ref = ref.qualifier as JSReferenceExpression?
val qualifier = ref.qualifier
ref = qualifier as? JSReferenceExpression
?: PsiTreeUtil.findChildOfType(qualifier, JSReferenceExpression::class.java)
}
Collections.reverse(nameParts)
return nameParts
Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>com.deadlock.scsyntax</id>
<name>Styled Components</name>
<version>1.0</version>
<version>1.0.1</version>
<vendor email="[email protected]" url="http://www.saraya.io">Kodehouse</vendor>

<!-- Enable plugin for all products -->
Expand All @@ -11,8 +11,7 @@
<depends>JavaScript</depends>
<depends>org.jetbrains.plugins.less</depends>
<description><![CDATA[
Language Support For React Styled Components
https://github.com/styled-components/styled-components
Language Support For <a href="https://github.com/styled-components/styled-components">React Styled Components</a>
]]></description>

<change-notes><![CDATA[
Expand Down
13 changes: 10 additions & 3 deletions src/test/InjectionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.intellij.util.containers.ContainerUtil
import org.junit.Assert

class InjectionTest : LightCodeInsightFixtureTestCase() {

fun testSimpleComponent() {
doTest("const Title = styled.h1`\n" +
" font-size: 1.5em;\n" +
Expand All @@ -25,8 +24,7 @@ class InjectionTest : LightCodeInsightFixtureTestCase() {
" color: \${props => props.primary ? 'white' : 'palevioletred'};\n" +
" " +
" font-size: 1em;\n" +
"`;",
"div {\n" +
"`;","div {\n" +
" /* Adapt the colours based on primary prop */\n" +
" background: EXTERNAL_FRAGMENT;\n" +
" color: EXTERNAL_FRAGMENT;\n" +
Expand All @@ -47,6 +45,15 @@ class InjectionTest : LightCodeInsightFixtureTestCase() {
" color: palevioletred;\n" +
"}")
}

fun testComplexExpression2() {
doTest("const ContactMenuIcon = ((styled(Icon)))" +
".attrs({ iconName: 'contact_card' })`\n" +
" line-height: 0;\n" +
"`", "div {\n" +
" line-height: 0;\n" +
"}")
}

fun testKeyframes() {
doTest("const rotate360 = keyframes`\n" +
Expand Down
Binary file modified webstorm-styled-components.zip
Binary file not shown.

0 comments on commit 48430d4

Please sign in to comment.