intellij-plugin-v4 icon indicating copy to clipboard operation
intellij-plugin-v4 copied to clipboard

live templates stopped to work

Open tbabczynski opened this issue 1 year ago • 5 comments

After IntelliJ update (to 2024.1) live templates stopped to work in .g4 editor. More, in settings for the live templates, they are not associated to anything and "no applicable contexts." warning appear. BTW. Should they be grouped in generic "user" group?

tbabczynski avatar Apr 04 '24 14:04 tbabczynski

Here, I discovered that it is not only the update issue but also the new Jetbrains' view. The live templates for ANTLR 2023.1.6 don't work in new UI but they work in the old one. The ANTLR doesn't appear on the context list. (I didn't check all versions between them.)

EDIT: In 2023.2.6 it doesn't work. In 2023.1.6 on my laptop it works in classic UI view, doesn't work in the new one. On the laptop of one of my students, who had this version and never had any newer, the live templates worked in both views. I don't know why. I discovered that even in the newest version the live templates work if one choose the "other" checkbox in the context define dialogue. Just the ANTLR context disappeared in the 2.6 version. Something must have changed in the editor registration process and the way the plugin used to do it stopped working.

tbabczynski avatar Apr 08 '24 21:04 tbabczynski

Maybe it will help. I checked the com.intellij.codeInsight.template.TemplateContextType in the jetbrains repository. It has a bunch of @deprecated marks in methods you used in the plugin, e.g. public boolean isInContext(@NotNull PsiFile file, int offset) - * @deprecated use {@link #isInContext(TemplateActionContext)}

public OutsideRuleContext() {
	super("ANTLR_OUTSIDE", "Outside rule", ANTLRGenericContext.class);
}
/**  @deprecated Set contextId and baseContextId in plugin.xml instead */
@Deprecated
  protected TemplateContextType( String id,  String presentableName,  
    Class<? extends TemplateContextType> baseContextType)

They were deprecated in 2022 but maybe now they work no longer.

tbabczynski avatar Apr 10 '24 20:04 tbabczynski

The new method still delegates to the old one that we override, so I don't think the problem is there. I made changes recently to fix compatibility with 2024.1, but it's possible I missed something. I'll look into it.

bjansen avatar Apr 11 '24 12:04 bjansen

Wouldn't be better to put templates to "ANTLR" group instead of "user"? And contextID also "ANTLR" or "ANTLRLex", "ANTLRv4"? I don't know how IntelliJ plugins work, never have written any, but I have a little experience with eclipse plugins, so I understand the key ideas behind the process. Unfortunately I have critical low disk space on my laptop so I cannot compile plugin from github. Do you have any nightly build snapshot available to test?

tbabczynski avatar Apr 11 '24 12:04 tbabczynski