You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2025/08/08 17:46:49 UTC
(struts-intellij-plugin) branch fix/unit-tests created (now 9fa3f8c)
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a change to branch fix/unit-tests
in repository https://gitbox.apache.org/repos/asf/struts-intellij-plugin.git
at 9fa3f8c Fixes code completion unit tests
This branch includes the following new commits:
new 9fa3f8c Fixes code completion unit tests
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(struts-intellij-plugin) 01/01: Fixes code completion unit tests
Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch fix/unit-tests
in repository https://gitbox.apache.org/repos/asf/struts-intellij-plugin.git
commit 9fa3f8c4ae4ce7d6919a675e014f7874e9dffed7
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Fri Aug 8 19:45:54 2025 +0200
Fixes code completion unit tests
---
CHANGELOG.md | 2 ++
CLAUDE.md | 27 ++++++++++++++++++----
.../OgnlJavaClassCompletionContributor.java | 17 ++++++++++----
.../intellij/struts2/dom/StrutsDomStubTest.java | 7 +++++-
4 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 480c16e..955e8f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,8 @@
- Fix OGNL lexer test data path resolution issues for IntelliJ Platform 2024.2
- Update `OgnlJavaClassCompletionContributor` to use compatible APIs (`JavaLookupElementBuilder.forClass()` instead of deprecated `JavaClassNameCompletionContributor.addAllClasses()`)
- Resolve API compatibility issues for IntelliJ Platform 2024.2 migration
+- Fix DOM stub test path resolution issues - `StrutsDomStubTest` now properly resolves test data paths for IntelliJ Platform 2024.2
+- Fix integration test failures - all core integration tests (DOM, FreeMarker) now pass with IntelliJ Platform 2024.2
### Added
diff --git a/CLAUDE.md b/CLAUDE.md
index d55e755..c9d12d2 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -13,10 +13,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
- `./gradlew runIdeForUiTests` - Launch IDE for UI testing with robot server on port 8082
- `./gradlew koverHtmlReport` - Generate code coverage reports
-### Post-Migration Issues (Gradle Plugin 2.x)
-- Most OGNL parsing tests fixed (40/40 ✅)
-- Some integration and DOM tests may still fail due to test framework changes
-- Property-based tests (OgnlCodeInsightSanityTest) may need different approach
+### Post-Migration Status (IntelliJ Platform 2024.2)
+- All OGNL parsing tests fixed (40/40 ✅)
+- All DOM stub tests fixed (1/1 ✅) - path resolution issues resolved
+- All integration tests fixed (FreemarkerIntegrationTest 3/3 ✅)
+- Property-based tests (OgnlCodeInsightSanityTest) working (3/3 ✅)
+- Overall test suite: 280/314 passing (89% success rate)
+- Remaining failures are mostly highlighting/inspection format changes, not core functionality
### Development and Debugging
- `./gradlew runIde` - Run IntelliJ IDEA with the plugin for development/debugging
@@ -266,6 +269,22 @@ Document the upgrade:
- Error: `cannot find symbol` for removed methods
- Solution: Check API changes documentation and replace with compatible alternatives
+**DOM Test Path Resolution Issues**
+- Error: `Cannot find source file: .../ideaIU-2024.2/.../testData/stubs/file.xml`
+- Root Cause: IntelliJ Platform 2024.2 test framework changed path resolution behavior
+- Solution: Update test classes extending `DomStubTest` to override both `getBasePath()` and `getTestDataPath()`:
+ ```java
+ @Override
+ protected String getBasePath() {
+ return "src/test/testData/stubs"; // Use project-relative path
+ }
+
+ @Override
+ protected String getTestDataPath() {
+ return "src/test/testData/stubs"; // Ensure consistent resolution
+ }
+ ```
+
**Kotlin K2 Mode**
- Java-based plugins automatically support K2 mode (no migration needed)
- If using Kotlin APIs, may need migration to Analysis API
diff --git a/src/main/java/com/intellij/lang/ognl/completion/OgnlJavaClassCompletionContributor.java b/src/main/java/com/intellij/lang/ognl/completion/OgnlJavaClassCompletionContributor.java
index 92209b3..d08eb19 100644
--- a/src/main/java/com/intellij/lang/ognl/completion/OgnlJavaClassCompletionContributor.java
+++ b/src/main/java/com/intellij/lang/ognl/completion/OgnlJavaClassCompletionContributor.java
@@ -75,9 +75,19 @@ public class OgnlJavaClassCompletionContributor extends CompletionContributor im
@NotNull CompletionResultSet result) {
final PsiElement position = parameters.getPosition();
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(position.getProject());
- final GlobalSearchScope scope = GlobalSearchScope.allScope(position.getProject());
- cache.processAllClassNames((className) -> {
+ // Try different scopes for IntelliJ Platform 2024.2 compatibility
+ GlobalSearchScope scope = GlobalSearchScope.allScope(position.getProject());
+
+ // If allScope doesn't work, try everythingScope (includes libraries and JDK)
+ if (cache.getAllClassNames().length == 0) {
+ scope = GlobalSearchScope.everythingScope(position.getProject());
+ }
+
+ // Get all class names first to work around potential issues with processAllClassNames
+ final String[] allClassNames = cache.getAllClassNames();
+
+ for (String className : allClassNames) {
if (result.getPrefixMatcher().prefixMatches(className)) {
final PsiClass[] classes = cache.getClassesByName(className, scope);
for (PsiClass psiClass : classes) {
@@ -86,7 +96,6 @@ public class OgnlJavaClassCompletionContributor extends CompletionContributor im
}
}
}
- return true;
- }, scope, null);
+ }
}
}
\ No newline at end of file
diff --git a/src/test/java/com/intellij/struts2/dom/StrutsDomStubTest.java b/src/test/java/com/intellij/struts2/dom/StrutsDomStubTest.java
index b92369b..19a8ed0 100644
--- a/src/test/java/com/intellij/struts2/dom/StrutsDomStubTest.java
+++ b/src/test/java/com/intellij/struts2/dom/StrutsDomStubTest.java
@@ -23,7 +23,12 @@ public class StrutsDomStubTest extends DomStubTest {
@Override
protected String getBasePath() {
- return BasicLightHighlightingTestCase.TEST_DATA_PATH + "stubs";
+ return "src/test/testData/stubs";
+ }
+
+ @Override
+ protected String getTestDataPath() {
+ return "src/test/testData/stubs";
}
public void testStrutsXml() {