Issue: Dot Operator Not Clickable and Lightbulb Icon Appearing in IntelliJ

已回答

I'm currently working on a Java Spring project and trying to add elements to a List<String> using the .add() method. However, when I type the dot (.) after declaring my list, IntelliJ doesn't recognize the dot operator. Instead of allowing me to call methods like .add(), a lightbulb icon appears next to the line, and the tooltip suggests "Not a statement."

@Bean
public Subjects Msub() {
    Subjects subj = new Subjects();
    List<String> subjList = new ArrayList<>();
    
    // Issue occurs here when I try to use the .add() method
    subjList.add("Math");  // The dot operator is not clickable, and IntelliJ shows a lightbulb.
    
    return subj;
}`

I ensured that my list was initialized properly and checked for syntax errors, but the issue persists.

Troubleshooting Attempts:

  • Checked imports: I verified that java.util.List and java.util.ArrayList are imported correctly.
  • Rebuilt the project: I tried rebuilding the project to ensure all dependencies were loaded.
  • Invalidated caches and restarted IntelliJ: This didn’t resolve the issue.
  • Used IntelliJ suggestions (Alt/Option + Enter): IntelliJ offers no helpful suggestions, just stating "Not a statement."
  • but when I directly copy and paste the code, it works
0

Please share the sample code where the issue occurs or a screenshot showing where in the file you type it.

You can upload a project/file via https://uploads.jetbrains.com and provide the ID here.

0

Upload id: 2024_09_17_26xkeY1bSYgtRq1pHMduHs (file: Screenshot 2024-09-17 at 8.51.58 PM.png)

0

Variable name List clashes with the class name List. You need to name it differently, for example, myList, then press dot after the variable name. Does it help?

0

It's still not working.

0

Please upload a video of the issue.

1

Upload id: 2024_09_18_uns5jKRD2LqY5XskK2Vhd3 (file: Screen Recording 2024-09-18 at 10.37.19 AM.mov)

 

0

It behaves like the dot symbol cannot be typed at all. Can you type it in the IDE if you create a new .txt file?

Did you assign the dot character to some action in Settings | Keymap by accident? Try resetting the keymap to the default or use the search by shortcut and type the dot symbol.

If nothing helps, try File | Manage IDE Settings | Restore Default Settings…

In case the issue still persists with the default settings, contact support at https://intellij-support.jetbrains.com/hc/requests/new and attach a sample project to reproduce the issue. Also, attach the logs via Help | Collect Logs and Diagnostic Data.

1

ok got it…thanks for helping me.

0

请先登录再写评论。