mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
framework detection: @NotNull and assertions added to find problematic plugin which incorrectly returns null from FacetBasedFrameworkDetector#getFacetType (EA-78816)
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.framework.detection;
|
||||
|
||||
import com.intellij.facet.*;
|
||||
import com.intellij.framework.FrameworkType;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -36,6 +37,8 @@ import java.util.Set;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class FacetBasedFrameworkDetector<F extends Facet, C extends FacetConfiguration> extends FrameworkDetector {
|
||||
private static final Logger LOG = Logger.getInstance(FacetBasedFrameworkDetector.class);
|
||||
|
||||
protected FacetBasedFrameworkDetector(String detectorId) {
|
||||
super(detectorId);
|
||||
}
|
||||
@@ -44,6 +47,7 @@ public abstract class FacetBasedFrameworkDetector<F extends Facet, C extends Fac
|
||||
super(detectorId, detectorVersion);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract FacetType<F, C> getFacetType();
|
||||
|
||||
/**
|
||||
@@ -83,7 +87,10 @@ public abstract class FacetBasedFrameworkDetector<F extends Facet, C extends Fac
|
||||
|
||||
@Override
|
||||
public FrameworkType getFrameworkType() {
|
||||
return createFrameworkType(getFacetType());
|
||||
FacetType<F, C> type = getFacetType();
|
||||
//noinspection ConstantConditions todo[nik] remove later: this is added to find implementations which incorrectly return 'null' from 'getFacetType'
|
||||
LOG.assertTrue(type != null, "'getFacetType' returns 'null' in " + getClass());
|
||||
return createFrameworkType(type);
|
||||
}
|
||||
|
||||
static FrameworkType createFrameworkType(final FacetType<?, ?> facetType) {
|
||||
@@ -104,7 +111,7 @@ public abstract class FacetBasedFrameworkDetector<F extends Facet, C extends Fac
|
||||
private final FacetType<?, ?> myFacetType;
|
||||
private final Icon myIcon;
|
||||
|
||||
public FacetBasedFrameworkType(FacetType<?, ?> facetType) {
|
||||
public FacetBasedFrameworkType(@NotNull FacetType<?, ?> facetType) {
|
||||
super(facetType.getStringId());
|
||||
myFacetType = facetType;
|
||||
final Icon icon = myFacetType.getIcon();
|
||||
|
||||
@@ -39,6 +39,7 @@ public class AppEngineFrameworkDetector extends FacetBasedFrameworkDetector<AppE
|
||||
super("appengine-java");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FacetType<AppEngineFacet, AppEngineFacetConfiguration> getFacetType() {
|
||||
return FacetType.findInstance(AppEngineFacetType.class);
|
||||
|
||||
@@ -80,6 +80,7 @@ public class PythonFacetType extends FacetType<PythonFacet, PythonFacetConfigura
|
||||
super("python");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FacetType<PythonFacet, PythonFacetConfiguration> getFacetType() {
|
||||
return PythonFacetType.getInstance();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BuildoutFrameworkDetector extends FacetBasedFrameworkDetector<Build
|
||||
super("buildout-python");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FacetType<BuildoutFacet, BuildoutFacetConfiguration> getFacetType() {
|
||||
return BuildoutFacetType.getInstance();
|
||||
|
||||
Reference in New Issue
Block a user