Skip to content

Commit 48430d4

Browse files
authored
Merge pull request #17 from undeadcat/master
Fix #16, update description in plugin.xml
2 parents c6a168b + 9ce1309 commit 48430d4

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/main/kotlin/com/intellij/StyledComponents/Patterns.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.intellij.openapi.util.text.StringUtil
88
import com.intellij.patterns.ElementPattern
99
import com.intellij.patterns.PatternCondition
1010
import com.intellij.patterns.PlatformPatterns
11+
import com.intellij.psi.util.PsiTreeUtil
1112
import com.intellij.util.ProcessingContext
1213
import com.intellij.util.SmartList
1314
import com.intellij.util.containers.ContainerUtil
@@ -51,7 +52,9 @@ fun getReferenceParts(jsReferenceExpression: JSReferenceExpression): List<String
5152
val name = ref.referenceName
5253
if (StringUtil.isEmptyOrSpaces(name)) return ContainerUtil.emptyList()
5354
nameParts.add(name)
54-
ref = ref.qualifier as JSReferenceExpression?
55+
val qualifier = ref.qualifier
56+
ref = qualifier as? JSReferenceExpression
57+
?: PsiTreeUtil.findChildOfType(qualifier, JSReferenceExpression::class.java)
5558
}
5659
Collections.reverse(nameParts)
5760
return nameParts

src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin>
22
<id>com.deadlock.scsyntax</id>
33
<name>Styled Components</name>
4-
<version>1.0</version>
4+
<version>1.0.1</version>
55
<vendor email="[email protected]" url="http://www.saraya.io">Kodehouse</vendor>
66

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

1817
<change-notes><![CDATA[

src/test/InjectionTest.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.intellij.util.containers.ContainerUtil
88
import org.junit.Assert
99

1010
class InjectionTest : LightCodeInsightFixtureTestCase() {
11-
1211
fun testSimpleComponent() {
1312
doTest("const Title = styled.h1`\n" +
1413
" font-size: 1.5em;\n" +
@@ -25,8 +24,7 @@ class InjectionTest : LightCodeInsightFixtureTestCase() {
2524
" color: \${props => props.primary ? 'white' : 'palevioletred'};\n" +
2625
" " +
2726
" font-size: 1em;\n" +
28-
"`;",
29-
"div {\n" +
27+
"`;","div {\n" +
3028
" /* Adapt the colours based on primary prop */\n" +
3129
" background: EXTERNAL_FRAGMENT;\n" +
3230
" color: EXTERNAL_FRAGMENT;\n" +
@@ -47,6 +45,15 @@ class InjectionTest : LightCodeInsightFixtureTestCase() {
4745
" color: palevioletred;\n" +
4846
"}")
4947
}
48+
49+
fun testComplexExpression2() {
50+
doTest("const ContactMenuIcon = ((styled(Icon)))" +
51+
".attrs({ iconName: 'contact_card' })`\n" +
52+
" line-height: 0;\n" +
53+
"`", "div {\n" +
54+
" line-height: 0;\n" +
55+
"}")
56+
}
5057

5158
fun testKeyframes() {
5259
doTest("const rotate360 = keyframes`\n" +

webstorm-styled-components.zip

136 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)