Skip to content

Commit e61c7f6

Browse files
authored
Merge pull request #10
develop
2 parents f5254d2 + f77a9c2 commit e61c7f6

5 files changed

Lines changed: 33 additions & 40 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
## [1.6.0] - 2025-12-10
6+
7+
- fix css icon lose
8+
- fix completion with two dot
9+
510
## [1.5.4] - 2025-12-10
611

712
- 升级版本号到 1.5.4 并准备发布
@@ -160,7 +165,8 @@
160165
- support a little complex parents selector
161166
- support css selector has pseudo
162167

163-
[Unreleased]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.4...HEAD
168+
[Unreleased]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.6.0...HEAD
169+
[1.6.0]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.4...v1.6.0
164170
[1.5.4]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.3...v1.5.4
165171
[1.5.3]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.2...v1.5.3
166172
[1.5.2]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.1...v1.5.2

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pluginGroup = com.peppa.css
44
pluginName = CSS Modules
55
pluginRepositoryUrl = https://github.com/Q-Peppa/react-css-modules-all
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.5.4
8-
version = 1.5.4
7+
pluginVersion = 1.6.0
8+
version = 1.6.0
99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild=242
1111
# pluginUntilBuild = 242.* # for Supported all version > 231

src/main/kotlin/com/peppa/css/annotator/SimpleCssSelectorFix.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,20 @@ class SimpleCssSelectorFix(private val key: String, private val stylesheetFile:
2828
if (editor == null || file == null) return
2929

3030
val rulesetText = "\n.$key {\n\t\t\n}"
31-
val ruleset = CssElementFactory.getInstance(project).createRuleset(
32-
rulesetText,
33-
stylesheetFile.language
34-
)
31+
val ruleset = CssElementFactory.getInstance(project).createRuleset(rulesetText, stylesheetFile.language)
3532

3633
stylesheetFile.navigate(true)
3734
stylesheetFile.add(ruleset)
38-
val newEditor = FileEditorManager.getInstance(project).selectedEditor ?: return;
39-
if (newEditor is TextEditor) {
40-
newEditor.editor.caretModel.moveToLogicalPosition(
41-
LogicalPosition(newEditor.editor.document.lineCount - 2, 0)
42-
)
43-
newEditor.editor.scrollingModel.scrollTo(
44-
newEditor.editor.caretModel.logicalPosition,
45-
ScrollType.MAKE_VISIBLE
46-
)
47-
DeclarativeInlayHintsPassFactory.scheduleRecompute(editor, project)
48-
DeclarativeInlayHintsPassFactory.scheduleRecompute(newEditor.editor, project)
35+
36+
FileEditorManager.getInstance(project).selectedEditor?.let { newEditor ->
37+
if (newEditor is TextEditor) {
38+
newEditor.editor.apply {
39+
caretModel.moveToLogicalPosition(LogicalPosition(document.lineCount - 2, 0))
40+
scrollingModel.scrollTo(caretModel.logicalPosition, ScrollType.MAKE_VISIBLE)
41+
}
42+
DeclarativeInlayHintsPassFactory.scheduleRecompute(editor, project)
43+
DeclarativeInlayHintsPassFactory.scheduleRecompute(newEditor.editor, project)
44+
}
4945
}
5046
}
5147
}

src/main/kotlin/com/peppa/css/completion/CssModulesClassNameCompletionContributor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ class CssModulesClassNameCompletionContributor : CompletionContributor() {
7373
private fun convertToBracketSyntax(context: InsertionContext, lookupString: String) {
7474
val document = context.editor.document
7575
val dotOffset = context.startOffset - 1
76-
document.replaceString(dotOffset, context.tailOffset, "['$lookupString']")
77-
context.editor.caretModel.moveToOffset(dotOffset + lookupString.length + 4)
76+
document.replaceString(dotOffset, context.tailOffset, "[$lookupString]")
77+
context.editor.caretModel.moveToOffset(context.tailOffset)
7878
}
7979
}
8080

src/main/kotlin/com/peppa/css/completion/QCssModulesUtil.kt

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fun buildLookupElementHelper(
178178

179179
private fun toGetStylesheetFile(ref: PsiReference?): StylesheetFile? {
180180
// 增强解析逻辑:支持直接 resolve 到 StylesheetFile、PsiFile,或 ES6ImportedBinding,
181-
// 并尝试沿引用链继续解析,提升命中率和鲁棒性
181+
// 并尝试沿引用链继续解析,提升命中率��鲁棒性
182182
val resolved = ref?.resolve() ?: return null
183183
return when (resolved) {
184184
is StylesheetFile -> resolved
@@ -191,26 +191,17 @@ private fun toGetStylesheetFile(ref: PsiReference?): StylesheetFile? {
191191
}
192192
}
193193

194-
fun resolveStylesheetFromReference(element: PsiElement?): StylesheetFile? {
195-
if (element == null) return null
196-
197-
// 字符串字面量的情况:查找最近的引用表达式(支持多种父级结构)
198-
if (element is JSLiteralExpression) {
199-
// 优先查找索引访问 foo["bar"] 的首子表达式
200-
val indexed = PsiTreeUtil.getParentOfType(element, JSIndexedPropertyAccessExpression::class.java)
201-
val candidateRef = (indexed?.firstChild as? JSReferenceExpression)
202-
// 否则向上查找通用的 JSReferenceExpression(例如 foo.bar 或 更复杂结构)
203-
?: PsiTreeUtil.getParentOfType(element, JSReferenceExpression::class.java)
204-
205-
return toGetStylesheetFile(candidateRef?.reference)
206-
}
207-
208-
// 直接是引用表达式:优先用自身的 reference,再退回到 firstChild 的 reference(兼容旧逻辑)
209-
if (element is JSReferenceExpression) {
210-
return toGetStylesheetFile(element.reference ?: element.firstChild?.reference)
194+
fun resolveStylesheetFromReference(element: PsiElement?): StylesheetFile? = element?.let {
195+
when (it) {
196+
is JSLiteralExpression -> {
197+
val indexed = PsiTreeUtil.getParentOfType(it, JSIndexedPropertyAccessExpression::class.java)
198+
val candidateRef = (indexed?.firstChild as? JSReferenceExpression)
199+
?: PsiTreeUtil.getParentOfType(it, JSReferenceExpression::class.java)
200+
toGetStylesheetFile(candidateRef?.reference)
201+
}
202+
is JSReferenceExpression -> toGetStylesheetFile(it.reference ?: it.firstChild?.reference)
203+
else -> null
211204
}
212-
213-
return null
214205
}
215206

216207
/**

0 commit comments

Comments
 (0)