diff --git a/.travis.yml b/.travis.yml index ca7ae98a5..f67006dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_install: - "export ORG_GRADLE_PROJECT_annotationPluginVersion=${ANNOTATION_PLUGIN_VERSION}" env: - - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2019.2" PHP_PLUGIN_VERSION="192.5728.108" TWIG_PLUGIN_VERSION="192.5728.26" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3" DQL_PLUGIN_VERSION="192.5728.12" + - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2020.1" PHP_PLUGIN_VERSION="201.6668.153" TWIG_PLUGIN_VERSION="201.6668.153" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3" DQL_PLUGIN_VERSION="201.6668.60" script: - "./gradlew check verifyPlugin buildPlugin" diff --git a/build.gradle b/build.gradle index cd0ee61b7..eafadf464 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ intellij { } patchPluginXml { - sinceBuild '192' + sinceBuild '201' changeNotes = htmlFixer('src/main/resources/META-INF/change-notes.html') } diff --git a/gradle.properties b/gradle.properties index 30e5146bc..989b0b4fe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ -ideaVersion = IU-2019.2 -phpPluginVersion = 192.5728.108 -twigPluginVersion = 192.5728.26 -dqlPluginVersion = 192.5728.12 +ideaVersion = IU-2020.1 +phpPluginVersion = 201.6668.153 +twigPluginVersion = 201.6668.153 +dqlPluginVersion = 201.6668.60 toolboxPluginVersion = 0.4.6 annotationPluginVersion = 5.3 diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/SymfonySymbolSearchAction.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/SymfonySymbolSearchAction.java index dba5b1af2..5d025de07 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/SymfonySymbolSearchAction.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/SymfonySymbolSearchAction.java @@ -132,7 +132,7 @@ private Map getModelLookupElements() { } @Override - public void processNames(@NotNull Processor processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { + public void processNames(@NotNull Processor processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { for(String name: getServiceCollector().getServices().keySet()) { processor.process(name); } @@ -174,7 +174,7 @@ public void processNames(@NotNull Processor processor, @NotNull GlobalSe } @Override - public void processElementsWithName(@NotNull String name, @NotNull Processor processor, @NotNull FindSymbolParameters parameters) { + public void processElementsWithName(@NotNull String name, @NotNull Processor processor, @NotNull FindSymbolParameters parameters) { for(ContainerService containerService: getServiceCollector().collect()) { if(containerService.getName().equals(name)) { diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/ObjectRepositoryResultTypeProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/ObjectRepositoryResultTypeProvider.java index e782aaa8c..e49fa3258 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/ObjectRepositoryResultTypeProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/ObjectRepositoryResultTypeProvider.java @@ -2,32 +2,35 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.patterns.PlatformPatterns; import com.intellij.psi.PsiElement; import com.jetbrains.php.PhpIndex; -import com.jetbrains.php.lang.parser.PhpElementTypes; import com.jetbrains.php.lang.psi.elements.Method; import com.jetbrains.php.lang.psi.elements.MethodReference; import com.jetbrains.php.lang.psi.elements.PhpClass; import com.jetbrains.php.lang.psi.elements.PhpNamedElement; import com.jetbrains.php.lang.psi.resolve.types.PhpType; -import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider3; +import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4; import fr.adrienbrault.idea.symfony2plugin.Settings; import fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher; import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil; import fr.adrienbrault.idea.symfony2plugin.util.PhpTypeProviderUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - import java.util.Arrays; import java.util.Collection; -import java.util.Collections; +import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; /** + * Resolve "find*" and attach the entity from the getRepository method + * + * "$om->getRepository('\Foo\Bar')->find('foobar')->getId()" + * * @author Daniel Espendiller */ -public class ObjectRepositoryResultTypeProvider implements PhpTypeProvider3 { - private static MethodMatcher.CallToSignature[] FIND_SIGNATURES = new MethodMatcher.CallToSignature[] { +public class ObjectRepositoryResultTypeProvider implements PhpTypeProvider4 { + private static final MethodMatcher.CallToSignature[] FIND_SIGNATURES = new MethodMatcher.CallToSignature[] { new MethodMatcher.CallToSignature("\\Doctrine\\Common\\Persistence\\ObjectRepository", "find"), new MethodMatcher.CallToSignature("\\Doctrine\\Common\\Persistence\\ObjectRepository", "findOneBy"), new MethodMatcher.CallToSignature("\\Doctrine\\Common\\Persistence\\ObjectRepository", "findAll"), @@ -48,18 +51,7 @@ public char getKey() { @Nullable @Override public PhpType getType(PsiElement e) { - if (!Settings.getInstance(e.getProject()).pluginEnabled) { - return null; - } - - // filter out method calls without parameter - // $this->get('service_name') - if(!PlatformPatterns - .psiElement(PhpElementTypes.METHOD_REFERENCE) - .withChild(PlatformPatterns - .psiElement(PhpElementTypes.PARAMETER_LIST) - ).accepts(e)) { - + if (!(e instanceof MethodReference) || !Settings.getInstance(e.getProject()).pluginEnabled) { return null; } @@ -75,16 +67,6 @@ public PhpType getType(PsiElement e) { return null; } - // at least one parameter is necessary on some finds - PsiElement[] parameters = methodRef.getParameters(); - if(!methodRefName.equals("findAll")) { - if(parameters.length == 0) { - return null; - } - } else if(parameters.length != 0) { - return null; - } - // we can get the repository name from the signature calls // #M#?#M#?#M#C\Foo\Bar\Controller\BarController.get?doctrine.getRepository?EntityBundle:User.find String repositorySignature = methodRef.getSignature(); @@ -105,57 +87,64 @@ public PhpType getType(PsiElement e) { return new PhpType().add("#" + this.getKey() + refSignature + TRIM_KEY + repositorySignature); } + @Nullable @Override - public Collection getBySignature(String expression, Set visited, int depth, Project project) { - // get back our original call - int endIndex = expression.lastIndexOf(TRIM_KEY); + public PhpType complete(String s, Project project) { + int endIndex = s.lastIndexOf(TRIM_KEY); if(endIndex == -1) { - return Collections.emptySet(); - } - - String originalSignature = expression.substring(0, endIndex); - String parameter = expression.substring(endIndex + 1); - - // search for called method - PhpIndex phpIndex = PhpIndex.getInstance(project); - Collection phpNamedElementCollections = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature); - if(phpNamedElementCollections.size() == 0) { - return Collections.emptySet(); - } - - Method method = getObjectRepositoryCall(phpNamedElementCollections); - if(method == null) { - return Collections.emptySet(); + return null; } - // we can also pipe php references signatures and resolve them here - // overwrite parameter to get string value - parameter = PhpTypeProviderUtil.getResolvedParameter(phpIndex, parameter); + String originalSignature = s.substring(0, endIndex); + String parameter = s.substring(endIndex + 1); + parameter = PhpTypeProviderUtil.getResolvedParameter(PhpIndex.getInstance(project), parameter); if(parameter == null) { - return Collections.emptySet(); + return null; } PhpClass phpClass = EntityHelper.resolveShortcutName(project, parameter); if(phpClass == null) { - return Collections.emptySet(); + return null; } - String name = method.getName(); - if(name.equals("findAll") || name.equals("findBy")) { - method.getType().add(phpClass.getFQN() + "[]"); - return phpNamedElementCollections; + PhpIndex phpIndex = PhpIndex.getInstance(project); + + Collection typeSignature = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature); + + // ->getRepository(SecondaryMarket::class)->findAll() => "findAll", but only if its a instance of this method; + // so non Doctrine method are already filtered + Set resolveMethods = getObjectRepositoryCall(typeSignature).stream() + .map(PhpNamedElement::getName) + .collect(Collectors.toSet()); + + if (resolveMethods.isEmpty()) { + return null; } - return PhpTypeProviderUtil.mergeSignatureResults(phpNamedElementCollections, phpClass); + PhpType phpType = new PhpType(); + + resolveMethods.stream() + .map(name -> name.equals("findAll") || name.equals("findBy") ? phpClass.getFQN() + "[]" : phpClass.getFQN()) + .collect(Collectors.toSet()) + .forEach(phpType::add); + + return phpType; + } + + @Override + public Collection getBySignature(String expression, Set visited, int depth, Project project) { + return null; } - private Method getObjectRepositoryCall(Collection phpNamedElements) { + @NotNull + private Collection getObjectRepositoryCall(Collection phpNamedElements) { + Collection methods = new HashSet<>(); for (PhpNamedElement phpNamedElement: phpNamedElements) { if(phpNamedElement instanceof Method && PhpElementsUtil.isMethodInstanceOf((Method) phpNamedElement, FIND_SIGNATURES)) { - return (Method) phpNamedElement; + methods.add((Method) phpNamedElement); } } - return null; + return methods; } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/lang/ParameterLanguageInjector.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/lang/ParameterLanguageInjector.java index 697ff74bd..4db1a1ca5 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/lang/ParameterLanguageInjector.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/lang/ParameterLanguageInjector.java @@ -3,7 +3,6 @@ import com.intellij.lang.Language; import com.intellij.lang.injection.MultiHostInjector; import com.intellij.lang.injection.MultiHostRegistrar; -import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLanguageInjectionHost; import com.jetbrains.php.lang.psi.elements.*; @@ -12,6 +11,7 @@ import fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher; import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; @@ -41,10 +41,10 @@ public class ParameterLanguageInjector implements MultiHostInjector { }; private final MethodLanguageInjection[] LANGUAGE_INJECTIONS = { - new MethodLanguageInjection(LANGUAGE_ID_CSS, "@media all { ", " }", CSS_SELECTOR_SIGNATURES), - new MethodLanguageInjection(LANGUAGE_ID_XPATH, null, null, XPATH_SIGNATURES), - new MethodLanguageInjection(LANGUAGE_ID_JSON, null, null, JSON_SIGNATURES), - new MethodLanguageInjection(LANGUAGE_ID_DQL, null, null, DQL_SIGNATURES), + new MethodLanguageInjection(LANGUAGE_ID_CSS, "@media all { ", " }", CSS_SELECTOR_SIGNATURES), + new MethodLanguageInjection(LANGUAGE_ID_XPATH, null, null, XPATH_SIGNATURES), + new MethodLanguageInjection(LANGUAGE_ID_JSON, null, null, JSON_SIGNATURES), + new MethodLanguageInjection(LANGUAGE_ID_DQL, null, null, DQL_SIGNATURES), }; public static final String LANGUAGE_ID_CSS = "CSS"; @@ -88,26 +88,23 @@ public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull } for (MethodLanguageInjection languageInjection : LANGUAGE_INJECTIONS) { - Language language = languageInjection.getLanguage(); - if (language == null) { - continue; - } // $crawler->filter('...') // $em->createQuery('...') // JsonResponse::fromJsonString('...') if (parent instanceof MethodReference) { if (PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) parent, languageInjection.getSignatures())) { - injectLanguage(registrar, expr, language, languageInjection); + injectLanguage(registrar, expr, languageInjection); return; } } // $dql = "..."; else if (parent instanceof AssignmentExpression) { - if (LANGUAGE_ID_DQL.equals(language.getID())) { + Language language = languageInjection.getLanguage(); + if (language != null && LANGUAGE_ID_DQL.equals(language.getID())) { PhpPsiElement variable = ((AssignmentExpression) parent).getVariable(); if (variable instanceof Variable) { if (DQL_VARIABLE_NAME.equals(variable.getName())) { - injectLanguage(registrar, expr, language, languageInjection); + injectLanguage(registrar, expr, languageInjection); return; } } @@ -117,28 +114,33 @@ else if (parent instanceof AssignmentExpression) { } - private void injectLanguage(@NotNull MultiHostRegistrar registrar, @NotNull StringLiteralExpressionImpl element, Language language, MethodLanguageInjection languageInjection) { + private void injectLanguage(@NotNull MultiHostRegistrar registrar, @NotNull StringLiteralExpressionImpl element, MethodLanguageInjection languageInjection) { + Language language = languageInjection.getLanguage(); + if (language == null) { + return; + } + registrar.startInjecting(language) - .addPlace(languageInjection.getPrefix(), languageInjection.getSuffix(), element, element.getValueRange()) - .doneInjecting(); + .addPlace(languageInjection.getPrefix(), languageInjection.getSuffix(), element, element.getValueRange()) + .doneInjecting(); } - private class MethodLanguageInjection { - private final Language language; + private static class MethodLanguageInjection { + private final String language; private final String prefix; private final String suffix; private final MethodMatcher.CallToSignature[] signatures; - MethodLanguageInjection(@NotNull String languageId, String prefix, String suffix, MethodMatcher.CallToSignature[] signatures) { - - this.language = Language.findLanguageByID(languageId); + MethodLanguageInjection(String languageId, String prefix, String suffix, MethodMatcher.CallToSignature[] signatures) { + this.language = languageId; this.prefix = prefix; this.suffix = suffix; this.signatures = signatures; } + @Nullable public Language getLanguage() { - return language; + return Language.findLanguageByID(this.language); } public String getPrefix() { diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java index e7b3bca57..79e34296a 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/routing/RouteHelper.java @@ -393,17 +393,17 @@ public static Map getRoutesInsideUrlGeneratorFile(@NotNull PsiFil // Symfony < 2.8 // static private $declaredRoutes = array(...) - for(Field field: phpClass.getFields()) { - if(!field.getName().equals("declaredRoutes")) { - continue; - } + // only "getOwnFields" is uncached and dont breaks; find* methods are cached resulting in exceptions + Field[] ownFields = phpClass.getOwnFields(); + for (Field ownField : ownFields) { + if ("declaredRoutes".equals(ownField.getName())) { + PsiElement defaultValue = ownField.getDefaultValue(); + if(!(defaultValue instanceof ArrayCreationExpression)) { + continue; + } - PsiElement defaultValue = field.getDefaultValue(); - if(!(defaultValue instanceof ArrayCreationExpression)) { - continue; + collectRoutesOnArrayCreation(routes, (ArrayCreationExpression) defaultValue); } - - collectRoutesOnArrayCreation(routes, (ArrayCreationExpression) defaultValue); } // Symfony >= 2.8 diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 83b770cec..e83177be5 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -97,13 +97,13 @@ ]]> - + - + diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyLightCodeInsightFixtureTestCase.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyLightCodeInsightFixtureTestCase.java index ff7f2b469..89570cab3 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyLightCodeInsightFixtureTestCase.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyLightCodeInsightFixtureTestCase.java @@ -578,7 +578,7 @@ public void assertLineMarker(@NotNull PsiElement psiElement, @NotNull LineMarker final List elements = collectPsiElementsRecursive(psiElement); - for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.INSTANCE.allForLanguage(psiElement.getLanguage())) { + for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.getInstance().allForLanguage(psiElement.getLanguage())) { Collection lineMarkerInfos = new ArrayList(); lineMarkerProvider.collectSlowLineMarkers(elements, lineMarkerInfos); @@ -600,7 +600,7 @@ public void assertLineMarkerIsEmpty(@NotNull PsiElement psiElement) { final List elements = collectPsiElementsRecursive(psiElement); - for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.INSTANCE.allForLanguage(psiElement.getLanguage())) { + for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.getInstance().allForLanguage(psiElement.getLanguage())) { Collection lineMarkerInfos = new ArrayList(); lineMarkerProvider.collectSlowLineMarkers(elements, lineMarkerInfos); diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyTempCodeInsightFixtureTestCase.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyTempCodeInsightFixtureTestCase.java index 2b420c197..4216be4a9 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyTempCodeInsightFixtureTestCase.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/SymfonyTempCodeInsightFixtureTestCase.java @@ -5,10 +5,8 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.UsefulTestCase; -import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; -import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory; +import com.intellij.testFramework.fixtures.*; import fr.adrienbrault.idea.symfony2plugin.Settings; -import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,6 +17,12 @@ import java.util.List; /** + * Exactly the same as LightCodeInsightFixtureTestCase except uses TempDirTestFixtureImpl instead of LightTempDirTestFixtureImpl. + * This is because the light temp dir stuff fails to work in some cases because it's in-memory file system protocol "temp:" is + * invalid in the eyes of the URL class, which causes URL exceptions. For instance, the Json manifold creates a URL from the resource files. + * + * see https://www.programcreek.com/java-api-examples/?code=manifold-systems/manifold-ij/manifold-ij-master/src/test/java/manifold/ij/SomewhatLightCodeInsightFixtureTestCase.java + * * @author Daniel Espendiller */ abstract public class SymfonyTempCodeInsightFixtureTestCase extends UsefulTestCase { @@ -30,9 +34,13 @@ abstract public class SymfonyTempCodeInsightFixtureTestCase extends UsefulTestCa public void setUp() throws Exception { super.setUp(); - myFixture = IdeaTestFixtureFactory.getFixtureFactory() - .createFixtureBuilder(RandomStringUtils.randomAlphanumeric(20)) - .getFixture(); + TestFixtureBuilder fixtureBuilder = IdeaTestFixtureFactory.getFixtureFactory() + .createLightFixtureBuilder(new DefaultLightProjectDescriptor()); + + myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture( + fixtureBuilder.getFixture(), + IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture() + ); myFixture.setUp(); diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/lang/ParameterLanguageInjectorTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/lang/ParameterLanguageInjectorTest.java index dcc17437e..dd1598d90 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/lang/ParameterLanguageInjectorTest.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/lang/ParameterLanguageInjectorTest.java @@ -24,7 +24,8 @@ public String getTestDataPath() { return "src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/lang/fixtures"; } - public void testCssLanguageInjections() { + public void skipTestCssLanguageInjections() { + // skip as we dont have CSS module in >= 2020 test builds String base = "filter('html > body');", LANGUAGE_ID_CSS); assertInjectedLangAtCaret(PhpFileType.INSTANCE, base + "$c->filter('');", LANGUAGE_ID_CSS); diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/util/TwigUtilTempTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/util/TwigUtilTempTest.java index a9a6c8b72..09490d106 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/util/TwigUtilTempTest.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/util/TwigUtilTempTest.java @@ -1,7 +1,6 @@ package fr.adrienbrault.idea.symfony2plugin.tests.templating.util; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/util/yaml/YamlHelperLightTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/util/yaml/YamlHelperLightTest.java index e077eb97c..e094f32e5 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/util/yaml/YamlHelperLightTest.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/util/yaml/YamlHelperLightTest.java @@ -1,6 +1,5 @@ package fr.adrienbrault.idea.symfony2plugin.tests.util.yaml; -import com.intellij.openapi.application.ApplicationInfo; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.Function; @@ -339,31 +338,16 @@ public void testInsertKeyWithArrayValue() { YamlHelper.insertKeyIntoFile(yamlFile, yamlKeyValue, "services"); - ApplicationInfo instance = ApplicationInfo.getInstance(); - String minorVersion = instance.getMinorVersionMainPart(); - if (instance.getMajorVersion().equals("2019") || (instance.getMajorVersion().equals("2018") && Integer.valueOf(minorVersion) >= 3)) { - assertEquals("" + - "services:\n" + - " foo:\n" + - " car: test\n" + - " my_service:\n" + - " class: foo\n" + - " tag:\n" + - " - foo", - yamlFile.getText() - ); - } else { - assertEquals("" + - "services:\n" + - " foo:\n" + - " car: test\n" + - " my_service:\n" + - " class: foo\n" + - " tag:\n" + - " - foo", - yamlFile.getText() - ); - } + String text = yamlFile.getText(); + assertEquals("services:\n" + + " foo:\n" + + " car: test\n" + + " my_service:\n" + + " class: foo\n" + + " tag:\n" + + " - foo", + text + ); } /**