mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
'unknown' source root type, IDEA-CR-62863 review follow-up (IDEA-235292)
GitOrigin-RevId: ac27d18035894c847822e535787fae9927a8563f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f406834d7c
commit
a7e93ea1d1
@@ -370,32 +370,4 @@ public class ModuleRootsExternalizationTest extends JavaModuleTestCase {
|
||||
final String substituted = map.substitute(path, false);
|
||||
assertEquals(path, substituted);
|
||||
}
|
||||
|
||||
//public void testLoadRegisteredSaveUnknown() {
|
||||
//
|
||||
// Element loadedXml = new Element(JpsModuleRootModelSerializer.SOURCE_FOLDER_TAG);
|
||||
// loadedXml.setAttribute(JpsModuleRootModelSerializer.PACKAGE_PREFIX_ATTRIBUTE, "package-prefix");
|
||||
// loadedXml.setAttribute(JpsJavaModelSerializerExtension.IS_GENERATED_ATTRIBUTE, Boolean.TRUE.toString());
|
||||
//
|
||||
// JpsElementFactory.getInstance().createModuleSourceRoot("file://someFile", JavaSourceRootType.SOURCE, JpsJavaExtensionService.getInstance().createSourceRootProperties("package_prefix", true));
|
||||
//
|
||||
// JpsModuleSourceRootPropertiesSerializer<? extends JpsElement> javaSerializer = null;
|
||||
// for (JpsModelSerializerExtension ext : JpsModelSerializerExtension.getExtensions()) {
|
||||
// javaSerializer = ext.getModuleSourceRootPropertiesSerializers().stream().filter(serializer -> JavaSourceRootType.SOURCE.equals(serializer.getType())).findFirst().orElse(null);
|
||||
// if (javaSerializer != null) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// assertNotNull(javaSerializer);
|
||||
//
|
||||
// //JavaSourceRootProperties properties = JpsJavaExtensionService.getInstance().createSourceRootProperties("package_prefix", true);
|
||||
//
|
||||
// JpsElement javaProperties = javaSerializer.loadProperties(loadedXml);
|
||||
//
|
||||
// UnknownSourceRootPropertiesSerializer unknownTypeSerializer =
|
||||
// UnknownSourceRootPropertiesSerializer.forType(javaSerializer.getTypeId(), JavaSourceRootType.SOURCE.isForTests());
|
||||
//
|
||||
// Element savedXml = new Element(JpsModuleRootModelSerializer.SOURCE_FOLDER_TAG);
|
||||
// //unknownTypeSerializer.saveProperties();
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.roots;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SourceRootPropertiesTest extends TestCase {
|
||||
|
||||
|
||||
}
|
||||
@@ -10,11 +10,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class UnknownSourceRootType extends JpsElementTypeBase<UnknownSourceRootTypeProperties<?>> implements JpsModuleSourceRootType<UnknownSourceRootTypeProperties<?>> {
|
||||
private static final Map<String, UnknownSourceRootType> ourTypeNameToInstanceMap = new ConcurrentHashMap<>();
|
||||
private final String myUnknownTypeId;
|
||||
private final boolean myForTests;
|
||||
|
||||
private UnknownSourceRootType(String unknownTypeId, boolean forTests) {
|
||||
private UnknownSourceRootType(String unknownTypeId) {
|
||||
myUnknownTypeId = unknownTypeId;
|
||||
myForTests = forTests;
|
||||
}
|
||||
|
||||
public String getUnknownTypeId() {
|
||||
@@ -23,7 +21,7 @@ public class UnknownSourceRootType extends JpsElementTypeBase<UnknownSourceRootT
|
||||
|
||||
@Override
|
||||
public boolean isForTests() {
|
||||
return myForTests;
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -32,7 +30,7 @@ public class UnknownSourceRootType extends JpsElementTypeBase<UnknownSourceRootT
|
||||
return new UnknownSourceRootTypeProperties<>(null);
|
||||
}
|
||||
|
||||
public static UnknownSourceRootType getInstance(String typeId, boolean forTests) {
|
||||
return ourTypeNameToInstanceMap.computeIfAbsent((forTests? "tst:" : "src:") + typeId, id -> new UnknownSourceRootType(typeId, forTests));
|
||||
public static UnknownSourceRootType getInstance(String typeId) {
|
||||
return ourTypeNameToInstanceMap.computeIfAbsent(typeId, id -> new UnknownSourceRootType(id));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -177,9 +177,8 @@ public class JpsModuleRootModelSerializer {
|
||||
@NotNull
|
||||
private static JpsModuleSourceRootPropertiesSerializer<?> getSourceRootPropertiesSerializer(@NotNull Element sourceElement) {
|
||||
String typeAttribute = sourceElement.getAttributeValue(SOURCE_ROOT_TYPE_ATTRIBUTE);
|
||||
boolean forTests = Boolean.parseBoolean(sourceElement.getAttributeValue(IS_TEST_SOURCE_ATTRIBUTE));
|
||||
if (typeAttribute == null) {
|
||||
typeAttribute = forTests ? JAVA_TEST_ROOT_TYPE_ID : JAVA_SOURCE_ROOT_TYPE_ID;
|
||||
typeAttribute = Boolean.parseBoolean(sourceElement.getAttributeValue(IS_TEST_SOURCE_ATTRIBUTE))? JAVA_TEST_ROOT_TYPE_ID : JAVA_SOURCE_ROOT_TYPE_ID;
|
||||
}
|
||||
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
|
||||
for (JpsModuleSourceRootPropertiesSerializer<?> serializer : extension.getModuleSourceRootPropertiesSerializers()) {
|
||||
@@ -189,7 +188,7 @@ public class JpsModuleRootModelSerializer {
|
||||
}
|
||||
}
|
||||
LOG.warn("Unknown module source root type " + typeAttribute);
|
||||
return UnknownSourceRootPropertiesSerializer.forType(UnknownSourceRootType.getInstance(typeAttribute, forTests));
|
||||
return UnknownSourceRootPropertiesSerializer.forType(UnknownSourceRootType.getInstance(typeAttribute));
|
||||
}
|
||||
|
||||
public static void saveRootModel(JpsModule module, Element rootModelElement) {
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ public class UnknownSourceRootPropertiesSerializer extends JpsModuleSourceRootPr
|
||||
}
|
||||
}
|
||||
|
||||
public static UnknownSourceRootPropertiesSerializer forType(String unknownTypeId, boolean isTests) {
|
||||
return forType(UnknownSourceRootType.getInstance(unknownTypeId, isTests));
|
||||
public static UnknownSourceRootPropertiesSerializer forType(String unknownTypeId) {
|
||||
return forType(UnknownSourceRootType.getInstance(unknownTypeId));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -46,7 +46,7 @@ public final class JpsIdePluginManagerImpl extends JpsPluginManager {
|
||||
//todo[nik] get rid of this check: currently this class is used in intellij.platform.jps.build tests instead of JpsPluginManagerImpl because intellij.platform.ide.impl module is added to classpath via testFramework
|
||||
if (rootArea.hasExtensionPoint(JpsPluginBean.EP_NAME)) {
|
||||
final Ref<Boolean> initial = new Ref<>(Boolean.TRUE);
|
||||
JpsPluginBean.EP_NAME.getPoint(null).addExtensionPointListener(new ExtensionPointListener<JpsPluginBean>() {
|
||||
JpsPluginBean.EP_NAME.getPoint().addExtensionPointListener(new ExtensionPointListener<JpsPluginBean>() {
|
||||
@Override
|
||||
public void extensionAdded(@NotNull JpsPluginBean extension, @NotNull PluginDescriptor pluginDescriptor) {
|
||||
if (initial.get()) {
|
||||
@@ -162,7 +162,7 @@ public final class JpsIdePluginManagerImpl extends JpsPluginManager {
|
||||
if (removedSerializer != null) {
|
||||
changeType(
|
||||
folder,
|
||||
UnknownSourceRootPropertiesSerializer.forType(removedSerializer.getTypeId(), folder.getRootType().isForTests()),
|
||||
UnknownSourceRootPropertiesSerializer.forType(removedSerializer.getTypeId()),
|
||||
serializeProperties(folder, removedSerializer)
|
||||
);
|
||||
shouldCommit = true;
|
||||
|
||||
+1
-1
@@ -520,7 +520,7 @@ class LegacyBridgeModulesTest {
|
||||
val contentEntry = ModuleRootManager.getInstance(module).contentEntries.single()
|
||||
val sourceFolder = contentEntry.sourceFolders.single()
|
||||
|
||||
assertSame(UnknownSourceRootType.getInstance("unsupported-custom-source-root-type", false), sourceFolder.rootType)
|
||||
assertSame(UnknownSourceRootType.getInstance("unsupported-custom-source-root-type"), sourceFolder.rootType)
|
||||
assertTrue(sourceFolder.jpsElement.properties is UnknownSourceRootTypeProperties<*>)
|
||||
|
||||
val customRoot = WorkspaceModel.getInstance(project).entityStore.current.entities(CustomSourceRootPropertiesEntity::class.java)
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ internal class SourceFolderViaTypedEntity(private val entry: ContentEntryViaType
|
||||
if (it.typeId == entity.rootType) return it.type
|
||||
}
|
||||
}
|
||||
return UnknownSourceRootType.getInstance(entity.rootType, entity.tests)
|
||||
return UnknownSourceRootType.getInstance(entity.rootType)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user