mapstruct / mapstruct-idea

An IntelliJ IDEA plugin for working with MapStruct
Other
141 stars 38 forks source link

Code completion for annotation parameters like @Mapping is not working #191

Closed UnclePi979 closed 7 months ago

UnclePi979 commented 7 months ago

As mentioned in issue https://github.com/mapstruct/mapstruct-idea/issues/182, I have similar issues.

I have even disabled lombok plugin I have even disabled all downloaded plugins. Even using mapstruct-examples still doesn't work.

Problems encountered follows.

Effective features:

  1. Jump to the specified field
  2. Highlight Unmapped property: xxx
  3. Auto-implement mapper interface

Broken features:

  1. Annotation auto-completion, like @Mapping @Mappings, etc.

Configurations

OS: MacOS Pro Apple M1 14.2.1 (23C71) IDEA: IntelliJ IDEA 2023.3.5 (Ultimate Edition) IntelliJ IDEA 2024.1 (Ultimate Edition) pom.xml: https://github.com/mapstruct/mapstruct-examples/blob/main/mapstruct-field-mapping/pom.xml

Gif for screen recording

Apr-11-2024 00-02-50

IDEA plugins follows.

GenerateAllSetter (2.8.4) Go (233.14808.21) Go Template (233.11799.172) Grep Console (12.25.0-IJ2023.3) Jakarta EE: Web Services (JAX-WS) (233.13135.65) MapStruct Support (1.6.1) Maven Helper (4.28.0-IJ2022.2) POJO to JSON (2.0.2) Spring WebSocket (233.11799.196) Translation (3.5.4) Maven (233.14808.21) Maven Extension (233.14808.21) Code Coverage for Java (233.14808.21) Database Tools and SQL (233.14808.21) Docker (233.14808.21) FTP/SFTP/WebDAV Connectivity (233.14808.21) Jakarta EE: Application Servers (233.14808.21) Kubernetes (233.14808.21) Tomcat and TomEE (233.14808.21) Settings Sync (233.14808.21) JavaScript and TypeScript (233.14808.21) JavaScript Debugger (233.14808.21) JSONPath (233.14808.21) Node.js (233.14808.21) Node.js Remote Interpreter (233.14808.21) Polymer & Web Components (233.14808.21) Prettier (233.14808.21) Styled Components & Styled JSX (233.14808.21) AOP Pointcut Language (233.14808.21) Hibernate (233.14808.21) Jakarta EE Platform (233.14808.21) Jakarta EE: Bean Validation (233.14808.21) Jakarta EE: Contexts and Dependency Injection (CDI) (233.14808.21) Jakarta EE: Expression Language (EL) (233.14808.21) Jakarta EE: Messaging (JMS) (233.14808.21) Jakarta EE: Persistence (JPA) (233.14808.21) Jakarta EE: RESTful Web Services (JAX-RS) (233.14808.21) Jakarta EE: Web/Servlets (233.14808.21) JVM Microservices Frameworks (233.14808.21) Lombok (233.14808.21) Micronaut (233.14808.21) Persistence Frameworks (233.14808.21) Reactive Streams (233.14808.21) Spring (233.14808.21) Spring Boot (233.14808.21) Spring Cloud (233.14808.21) Spring Data (233.14808.21) Spring Initializr (233.14808.21) Spring Integration Patterns (233.14808.21) Spring Messaging (233.14808.21) Spring Security (233.14808.21) Spring Web (233.14808.21) NetBeans Keymap (233.14808.21) Visual Studio Keymap (233.14808.21) Gherkin (233.14808.21) Groovy (233.14808.21) Kotlin (233.14808.21-IJ) Markdown (233.14808.21) Properties (233.14808.21) Shell Script (233.14808.21) Toml (233.14808.21) YAML (233.14808.21) Endpoints (233.14808.21) HTTP Client (233.14808.21) OpenAPI Specifications (233.14808.21) CSS (233.14808.21) Less (233.14808.21) PostCSS (233.14808.21) Sass (233.14808.21) Tailwind CSS (233.14808.21) UI Designer (233.14808.21) Apache Velocity (233.14808.21) FreeMarker (233.14808.21) Jakarta EE: Server Pages (JSP) (233.14808.21) Cucumber for Java (233.14808.21) JUnit (233.14808.21) TestNG (233.14808.21) Git (233.14808.21) GitHub (233.14808.21) GitLab (233.14808.21) Mercurial (233.14808.21) Perforce Helix Core (233.14808.21) Subversion (233.14808.21) Bytecode Viewer (233.14808.21) Copyright (233.14808.21) Dependency Structure Matrix (233.14808.21) Diagrams (233.14808.21) EditorConfig (233.14808.21) Grazie Lite (233.14808.21) In-Editor Performance Hints (233.14808.21) IntelliLang (233.14808.21) Java Bytecode Decompiler (233.14808.21) Java Internationalization (233.14808.21) Java Stream Debugger (233.14808.21) Local Productivity Statistics (233.14808.21) Performance Testing (233.14808.21) Shared Project Indexes (233.14808.21) Task Management (233.14808.21) Terminal (233.14808.21) TextMate Bundles (233.14808.21) Time Tracking (233.14808.21) WebP Support (233.14808.21)

thunderhook commented 7 months ago

We would really like to help but were not able to reproduce this yet.

Do you have JUnit in your project? Could you try to check if the code completion of JUnit works? To narrow down the problem if it is related to the MapStruct plugin or IntelliJ itself.

import java.util.Arrays;
import java.util.List;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

public class DemoTest {

    public static List<String> someNames() {
        return Arrays.asList( "Alex", "Peter" );
    }

    @ParameterizedTest
    @MethodSource("someNames") // code-completion should work here
    void testSomeNames(String name) {
        // no-op
    }

}
UnclePi979 commented 7 months ago

Thank you for your reply. I used the example you provided to test the code completion, and it indeed does not work. The issue seems to be with Intellij, not mapstruct-idea.

Gif following

Apr-22-2024 20-48-53

UnclePi979 commented 7 months ago

Oh my goodness, it turns out to be because the shortcut key for switching input methods in Mac OS conflicts with the shortcut key for code completion. lol 😂😂

UnclePi979 commented 7 months ago

Thanks again to @thunderhook, I think this issue can be closed.

thunderhook commented 7 months ago

You're welcome, I'm glad you found it! 👍

YangAoLib commented 2 months ago

Is it only possible to use auto-completion in the parameters of annotations by using shortcut keys? Can it be directly completed like in code blocks during input? @thunderhook

thunderhook commented 2 months ago

Is it only possible to use auto-completion in the parameters of annotations by using shortcut keys? Can it be directly completed like in code blocks during input? @thunderhook

@YangAoLib I'm sorry, I don't understand. Can you provide some screenshots or even a gif animation?

YangAoLib commented 2 months ago

thanks for you answer. @thunderhook the test project https://github.com/mapstruct/mapstruct-examples/tree/main/mapstruct-field-mapping recording

thunderhook commented 2 months ago

Can it be directly completed like in code blocks during input? @thunderhook

That is what I don't understand. What direct completion do you mean?