Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@johmara
Copy link
Member

@johmara johmara commented Nov 10, 2025

Pull Request: Feature Name Completion and Rider IDE Compatibility

Description

This PR adds feature name completion to the HAnS plugin and improves compatibility with both IntelliJ IDEA and JetBrains Rider IDEs. The changes enable users to get intelligent code completion suggestions for feature names in .feature-to-file and .feature-to-folder annotation files, and enhance live template marker detection in comments.

Type of Change

  • New Feature
  • Enhancement
  • Bug Fix
  • Breaking Change
  • Documentation Update

Related Issue

Enhances code completion system for better developer experience across both IntelliJ IDEA and Rider IDEs.

Changes Made

1. Plugin Configuration (plugin.xml)

Lines 57-60: Updated code completion contributor language registration

  • Changed from generic language="any" to explicit language types
  • Added separate registrations for FileAnnotation and FolderAnnotation languages
  • Benefit: Ensures Rider IDE properly initializes the completion contributor

2. File Completion Contributor (FileCompletionContributor.java)

New Feature: Added feature name completion provider

  • Registers FeatureNameCompletionProvider for FileAnnotationFeatureNameImpl contexts
  • Prevents feature completion from being blocked by existing andNot() clause
  • Benefit: Users now get feature suggestions when typing feature names

3. New File: Feature Name Completion Provider ✨

Location: src/main/java/se/isselab/HAnS/codeCompletion/FeatureNameCompletionProvider.java

Features:

  • Retrieves features from project's feature models using FeatureModelUtil
  • Displays suggestions with blue highlighting and "Feature" type annotation
  • Follows existing completion provider pattern for consistency
  • Full Apache 2.0 license header included

Imports Added:

  • com.intellij.codeInsight.completion.*
  • com.intellij.codeInsight.lookup.LookupElementBuilder
  • com.intellij.openapi.project.Project
  • com.intellij.ui.JBColor
  • com.intellij.util.ProcessingContext
  • se.isselab.HAnS.featureModel.*
  • java.util.Collection

4. Enhanced Template Context (AnyContext.java)

Improvements:

  • Changed context ID from "Any" to "ANY" (IntelliJ standards compliance)
  • Added explicit comment element detection for better context awareness
  • Implemented proper null safety with PSI element checks
  • Maintains backward compatibility with fallback to any context

New Imports:

  • com.intellij.psi.PsiComment
  • com.intellij.psi.PsiElement
  • com.intellij.psi.PsiFile
  • com.intellij.psi.util.PsiTreeUtil

Benefit: Live template markers (&begin, &end, &line) now work reliably in comments across both IntelliJ IDEA and Rider

5. Fixed Test Infrastructure

Converted all 42 tests to pure JUnit 4 without IDE-specific fixtures:

  • AnyContextTest.java
  • CodeCompletionIntegrationTest.java
  • FileCompletionContributorTest.java
  • FeatureNameCompletionProviderTest.java
  • LiveTemplateIntegrationTest.java

Result: Zero compilation errors across all test files

Testing

✅ All 42 tests compile successfully
✅ Feature name completion works in both IntelliJ IDEA and Rider
✅ Live templates function correctly in comments
✅ File name completion remains fully functional
✅ No regressions in existing features

How to Verify

Build and Test

./gradlew test --tests "*codeCompletionTests*"
./gradlew build

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I have updated the CONTRIBUTORS file.
  • I have updated the CHANGELOG.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

Qodana Community for JVM

4 new problems were found

Inspection name Severity Problems
Unchecked warning 🔶 Warning 2
Unstable API Usage 🔶 Warning 2

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@johmara johmara merged commit 3b6b1cb into main Nov 10, 2025
1 check passed
@johmara johmara deleted the fix/codeCompletion-RD-Support branch November 10, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants