File tree Expand file tree Collapse file tree 7 files changed +58
-16
lines changed
main/java/fr/adrienbrault/idea/symfony2plugin
test/java/fr/adrienbrault/idea/symfony2plugin/tests/util/yaml Expand file tree Collapse file tree 7 files changed +58
-16
lines changed Original file line number Diff line number Diff line change 2525 - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-183.2153.8" PHP_PLUGIN_VERSION="183.2153.44" TWIG_PLUGIN_VERSION="183.2153.44" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
2626 - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2018.2.5" PHP_PLUGIN_VERSION="182.4892.16" TWIG_PLUGIN_VERSION="182.3458.35" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
2727 - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2018.2" PHP_PLUGIN_VERSION="182.3684.42" TWIG_PLUGIN_VERSION="182.3458.35" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
28- - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2018.3" PHP_PLUGIN_VERSION="183.4284.150 " TWIG_PLUGIN_VERSION="183.3795.24" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
28+ - PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2018.3.6 " PHP_PLUGIN_VERSION="183.5429.47 " TWIG_PLUGIN_VERSION="183.3795.24" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
2929
3030script :
3131- " ./gradlew check verifyPlugin buildPlugin"
Original file line number Diff line number Diff line change @@ -16,9 +16,12 @@ plugins {
1616def htmlFixer = { htmlFile -> file(htmlFile). text. replace(' <html>' , ' ' ). replace(' </html>' , ' ' ) }
1717
1818apply plugin : ' idea'
19- apply plugin : ' org.jetbrains.intellij '
19+
2020apply plugin : ' java'
21+ sourceCompatibility = 1.8
22+ targetCompatibility = 1.8
2123
24+ apply plugin : ' org.jetbrains.intellij'
2225intellij {
2326 version ideaVersion
2427 updateSinceUntilBuild false
Original file line number Diff line number Diff line change 44# toolboxPluginVersion = 0.4.6
55# annotationPluginVersion = 5.3
66
7- ideaVersion = IU-2018.3
8- phpPluginVersion = 183.4284.150
7+ ideaVersion = IU-2018.3.6
8+ phpPluginVersion = 183.5429.47
99twigPluginVersion = 183.3795.24
1010toolboxPluginVersion = 0.4.6
1111annotationPluginVersion = 5.3
Original file line number Diff line number Diff line change 1+ # Sun Apr 28 18:02:14 CEST 2019
12distributionBase =GRADLE_USER_HOME
23distributionPath =wrapper/dists
3- distributionUrl =https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
44zipStoreBase =GRADLE_USER_HOME
55zipStorePath =wrapper/dists
6+ distributionUrl =https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Original file line number Diff line number Diff line change 1212import org .jetbrains .yaml .psi .YAMLCompoundValue ;
1313import org .jetbrains .yaml .psi .YAMLKeyValue ;
1414
15+ import static fr .adrienbrault .idea .symfony2plugin .util .VersionUtil .productVersionGreaterThanOrEqual ;
16+
1517/**
1618 * @author Daniel Espendiller <daniel@espendiller.net>
1719 */
@@ -39,7 +41,7 @@ private static class MyPsiElementVisitor extends PsiElementVisitor {
3941 public void visitElement (PsiElement element ) {
4042 // every array element implements this interface
4143 // check for inside "foo: <foo: foo>"
42- if (!(element instanceof YAMLCompoundValue ) || element . getNode (). getElementType () != YAMLElementTypes . COMPOUND_VALUE ) {
44+ if (!isIllegalColonExpression (element ) ) {
4345 super .visitElement (element );
4446 return ;
4547 }
@@ -67,5 +69,14 @@ public void visitElement(PsiElement element) {
6769
6870 super .visitElement (element );
6971 }
72+
73+ private boolean isIllegalColonExpression (PsiElement element ) {
74+
75+ if (productVersionGreaterThanOrEqual (2018 , 3 )) {
76+ return (element instanceof YAMLCompoundValue ) && element .getNode ().getElementType () == YAMLElementTypes .MAPPING ;
77+ }
78+
79+ return (element instanceof YAMLCompoundValue ) && element .getNode ().getElementType () == YAMLElementTypes .COMPOUND_VALUE ;
80+ }
7081 }
7182}
Original file line number Diff line number Diff line change 1+ package fr .adrienbrault .idea .symfony2plugin .util ;
2+
3+ import com .intellij .openapi .application .ApplicationInfo ;
4+
5+ public class VersionUtil {
6+ public static boolean productVersionGreaterThanOrEqual (int major , int minor ) {
7+ ApplicationInfo instance = ApplicationInfo .getInstance ();
8+
9+ return Integer .valueOf (instance .getMajorVersion ()) > major || (Integer .valueOf (instance .getMajorVersion ()).equals (major ) && Integer .valueOf (instance .getMinorVersionMainPart ()) >= minor );
10+ }
11+ }
Original file line number Diff line number Diff line change 11package fr .adrienbrault .idea .symfony2plugin .tests .util .yaml ;
22
3+ import com .intellij .openapi .application .ApplicationInfo ;
34import com .intellij .psi .PsiElement ;
45import com .intellij .util .Function ;
56import com .intellij .util .containers .ContainerUtil ;
@@ -336,16 +337,31 @@ public void testInsertKeyWithArrayValue() {
336337
337338 YamlHelper .insertKeyIntoFile (yamlFile , yamlKeyValue , "services" );
338339
339- assertEquals ("" +
340- "services:\n " +
341- " foo:\n " +
342- " car: test\n " +
343- " my_service:\n " +
344- " class: foo\n " +
345- " tag:\n " +
346- " - foo" ,
347- yamlFile .getText ()
348- );
340+ ApplicationInfo instance = ApplicationInfo .getInstance ();
341+ String minorVersion = instance .getMinorVersionMainPart ();
342+ if (instance .getMajorVersion ().equals ("2019" ) || (instance .getMajorVersion ().equals ("2018" ) && Integer .valueOf (minorVersion ) >= 3 )) {
343+ assertEquals ("" +
344+ "services:\n " +
345+ " foo:\n " +
346+ " car: test\n " +
347+ " my_service:\n " +
348+ " class: foo\n " +
349+ " tag:\n " +
350+ " - foo" ,
351+ yamlFile .getText ()
352+ );
353+ } else {
354+ assertEquals ("" +
355+ "services:\n " +
356+ " foo:\n " +
357+ " car: test\n " +
358+ " my_service:\n " +
359+ " class: foo\n " +
360+ " tag:\n " +
361+ " - foo" ,
362+ yamlFile .getText ()
363+ );
364+ }
349365 }
350366
351367 /**
You can’t perform that action at this time.
0 commit comments