There is an issue with the com.intellij.project.converterProvider extension point

Answered

I used the ConverterProvider extension point to make my plugin compatible with old configuration data, but there are a few issues: 

 

1. I created a new class, LegacyHistoryConverterProvider, which extends the ConverterProvider class and implements the getConversionDescription() and createConverter() methods. However, I encountered an issue when running the plugin. 

2024-11-27 16:40:06,465 [   1528] SEVERE - #c.i.o.p.i.ProjectFrameAllocator - @NotNull method com/intellij/impl/ConversionServiceImpl.getProviderId must not return null
java.lang.IllegalStateException: @NotNull method com/intellij/impl/ConversionServiceImpl.getProviderId must not return null
	at com.intellij.impl.ConversionServiceImpl.$$$reportNull$$$0(ConversionServiceImpl.java)
	at com.intellij.impl.ConversionServiceImpl.getProviderId(ConversionServiceImpl.java:164)
	at com.intellij.impl.ConversionServiceImpl.lambda$isConversionNeeded$1(ConversionServiceImpl.java:144)
	at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processIdentifiableImplementations(ExtensionPointImpl.java:331)
	at com.intellij.impl.ConversionServiceImpl.isConversionNeeded(ConversionServiceImpl.java:143)
	at com.intellij.impl.ConversionServiceImpl.convert(ConversionServiceImpl.java:82)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl.prepareProject(ProjectManagerExImpl.kt:334)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl.access$prepareProject(ProjectManagerExImpl.kt:56)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl$doOpenAsync$1.invoke(ProjectManagerExImpl.kt:127)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl$doOpenAsync$1.invoke(ProjectManagerExImpl.kt:56)
	at com.intellij.openapi.project.impl.ProjectUiFrameAllocator$run$progressRunner$1.apply(ProjectFrameAllocator.kt:96)
	at com.intellij.openapi.project.impl.ProjectUiFrameAllocator$run$progressRunner$1.apply(ProjectFrameAllocator.kt:72)

 

LegacyHistoryConverterProvider:

public class LegacyHistoryConverterProvider extends ConverterProvider {

    @Override
    public @NotNull String getConversionDescription() {
        return "Support older versions?";
    }

    @Override
    public @Nls(capitalization = Nls.Capitalization.Sentence) @NotNull ProjectConverter createConverter(@NotNull ConversionContext context) {
        return new LegacyHistoryProjectConverter(context);
    }
}

 

 

2. Then, I added a constructor to the LegacyHistoryConverterProvider class to pass an ID to the ConverterProvider class (I am not sure what value this ID should be assigned), but I found that this extension point does not work.

 

LegacyHistoryConverterProvider:

public class LegacyHistoryConverterProvider extends ConverterProvider {

    protected LegacyHistoryConverterProvider() {
        super(JsonAssistantPlugin.PLUGIN_ID + ":" + JsonAssistantPlugin.getVersion());
    }

    @Override
    public @NotNull String getConversionDescription() {
        return "Support older versions?";
    }

    @Override
    public @Nls(capitalization = Nls.Capitalization.Sentence) @NotNull ProjectConverter createConverter(@NotNull ConversionContext context) {
        return new LegacyHistoryProjectConverter(context);
    }
}

 

 

Current plugin running environment:

platformVersion = 2022.1.4

 

plugin.xml:

<project.converterProvider implementation="cn.memoryzy.json.extension.configurable.LegacyHistoryConverterProvider"/>

 

Version 2022.1.4 of the ConverterProvider class:

public abstract class ConverterProvider {
  public static final ExtensionPointName<ConverterProvider> EP_NAME = new ExtensionPointName<>("com.intellij.project.converterProvider");
  private String myId;

  /**
   * @deprecated Set id as part of extension definition.
   */
  @Deprecated
  protected ConverterProvider(@NotNull @NonNls String id) {
    myId = id;
  }

  protected ConverterProvider() {
  }

  public final String getDeprecatedId() {
    return myId;
  }

  @NlsContexts.DialogMessage
  @NotNull
  public abstract String getConversionDescription();

  @Nls(capitalization = Nls.Capitalization.Sentence)
  @NotNull
  public abstract ProjectConverter createConverter(@NotNull ConversionContext context);
}

 

How can I solve these problems?

0
4 comments

I understand that when my project does not meet the condition (projectPath.toString().endsWith(".ipr")), the value of the ConversionContextImpl.myStorageScheme property will be StorageScheme.DIRECTORY_BASED. Therefore, it does not satisfy the condition (myContext.getStorageScheme() == StorageScheme.DEFAULT) in the ConversionRunner#isConversionNeeded() method. How can I use the com.intellij.project.converterProvider extension point?

 

 

 

0

Hi,

Please try adding the id attribute in extension registration:

<project.converterProvider id="ID HERE" implementation="cn.memoryzy.json.extension.configurable.LegacyHistoryConverterProvider"/>
0

Yes, through you give tips, I solved the first problem, but the second problem still exists (myContext. GetStorageScheme () = = StorageScheme. The DEFAULT)

0

I'm sorry, but I don't understand the second problem.

It seems to me that you are debugging it and asking about low-level code conditions and evaluation flows. It's quite hard to help here.

0

Please sign in to leave a comment.