This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the plugin
./gradlew buildPlugin
# Run all tests
./gradlew check
# Run a single test class (use --tests with fully-qualified class name)
./gradlew test --tests "com.peppa.css.css.CssModulesClassNameCompletionContributorTest"
# Run plugin verification
./gradlew verifyPlugin
# Show plugin version
./gradlew properties --property version --quiet --console=plainAll commands use the Gradle wrapper (./gradlew). JVM 21 is required (set via kotlin.jvmToolchain(21)).
This is an IntelliJ Platform plugin that provides CSS Modules intelligence for JavaScript/TypeScript files. It adds four IDE capabilities, each implemented as a standard IntelliJ extension point registered in src/main/resources/META-INF/plugin.xml:
Entry: CssModulesIndexedStylesVarPsiReferenceContributor — matches JSLiteralExpression inside JSIndexedPropertyAccessExpression (i.e., styles['className'] bracket syntax). For each match it creates a CssModuleClassReference, which dynamically resolves the class name against the imported stylesheet via restoreAllSelector().
Key file: src/main/kotlin/com/peppa/css/psi/CssModulesUnknownClassPsiReference.kt — CssModuleClassReference uses modificationStamp-based caching to avoid re-parsing the CSS on every resolve call. The caching can be toggled off via constructor parameter for testing.
Entry: CssModulesClassNameCompletionContributor — two providers:
IndexAccessCompletionProviderfor bracket syntax (styles['...']) — matches literal inside indexed accessDotAccessCompletionProviderfor dot syntax (styles.className) — matches reference expressions preceded by.; auto-converts hyphenated names to bracket syntax on insertion
Entry: SimpleDocumentationProvider — renders the CSS ruleset content when hovering over a class name in JS/TS.
src/main/kotlin/com/peppa/css/completion/QCssModulesUtil.kt is the central utility file:
restoreAllSelector(stylesheetFile)— parses a stylesheet and returns a map of class name → pointer to CSS ruleset. Handles nested selector expansion viaprocessAmpersandSelectors, plain class selectors viaprocessAllSelectorSuffixes, and recursively resolves CSS@importstatements.findReferenceStyleFile(element)— resolves a JS expression back to theStylesheetFileit imports (handles direct imports, default imports, re-exports).generateLookupElementList(stylesheetFile)— builds completionLookupElements from the parsed selector map.
JS literal/reference → findReferenceStyleFile() → StylesheetFile
→ restoreAllSelector() → Map<className, CssRuleset pointer>
→ CssModuleClassReference.resolve()
- Plugin ID:
react.css.module.all - Group:
com.peppa.css - Since-build: 242 (IntelliJ 2024.2+)
- Dependencies:
JavaScript(bundled plugin),com.intellij.css - Targets WebStorm 2024.2 for dependencies
Tests extend BasePlatformTestCase and use fixture files under src/test/resources/. The pattern is:
- Copy CSS files to project with
myFixture.copyFileToProject() - Configure a JS file with
myFixture.configureByFile() - Trigger IDE features (
myFixture.complete(), etc.) - Assert on results
Test categories: completion (basic, media queries, mixins, tag selectors), reference caching/performance.