Skip to content

Commit 89b9f95

Browse files
authored
Merge pull request Haehnchen#1192 from cedricziel/2018-2-eap
Add 2018.2 to build matrix
2 parents 147d6d0 + d46aadf commit 89b9f95

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ before_install:
2222
- "export ORG_GRADLE_PROJECT_annotationPluginVersion=${ANNOTATION_PLUGIN_VERSION}"
2323

2424
env:
25+
- PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-182.2949.4" PHP_PLUGIN_VERSION="182.2949.27" TWIG_PLUGIN_VERSION="182.2757.22" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
2526
- PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2018.1" PHP_PLUGIN_VERSION="181.4203.565" TWIG_PLUGIN_VERSION="181.3741.23" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.3"
2627
- PHPSTORM_ENV="skip incomplete" IDEA_VERSION="IU-2017.3.5" PHP_PLUGIN_VERSION="173.4301.34" TWIG_PLUGIN_VERSION="173.4301.7" TOOLBOX_PLUGIN_VERSION="0.4.6" ANNOTATION_PLUGIN_VERSION="5.2.1"
2728

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
}
1010

1111
plugins {
12-
id "org.jetbrains.intellij" version "0.2.18"
12+
id "org.jetbrains.intellij" version "0.3.3"
1313
}
1414

1515
apply plugin: 'idea'
@@ -34,7 +34,6 @@ intellij {
3434

3535
patchPluginXml {
3636
sinceBuild '173'
37-
untilBuild '181.*'
3837
}
3938
}
4039

gradle.properties

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
ideaVersion = IU-2018.1
2-
phpPluginVersion = 181.4203.565
3-
twigPluginVersion = 181.3741.23
1+
ideaVersion = IU-182.2949.4
2+
phpPluginVersion = 182.2949.27
3+
twigPluginVersion = 182.2757.22
44
toolboxPluginVersion = 0.4.6
55
annotationPluginVersion = 5.3
6+
7+
#ideaVersion = IU-2018.1
8+
#phpPluginVersion = 181.4203.565
9+
#twigPluginVersion = 181.3741.23
10+
#toolboxPluginVersion = 0.4.6
11+
#annotationPluginVersion = 5.3
12+
613
#ideaVersion = IU-2017.3.5
714
#phpPluginVersion = 173.4301.34
815
#twigPluginVersion = 173.4301.7

src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlQuotedEscapedInspection.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.intellij.codeInspection.ProblemsHolder;
66
import com.intellij.psi.PsiElement;
77
import com.intellij.psi.PsiElementVisitor;
8+
import com.intellij.psi.PsiErrorElement;
89
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
910
import fr.adrienbrault.idea.symfony2plugin.util.SymfonyUtil;
1011
import org.apache.commons.lang.StringUtils;
@@ -19,30 +20,36 @@ public class YamlQuotedEscapedInspection extends LocalInspectionTool {
1920
@NotNull
2021
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {
2122

22-
if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) {
23+
if (!Symfony2ProjectComponent.isEnabled(holder.getProject())) {
2324
return super.buildVisitor(holder, isOnTheFly);
2425
}
2526

2627
return new PsiElementVisitor() {
2728
@Override
2829
public void visitElement(PsiElement element) {
29-
if(element.getNode().getElementType() == YAMLTokenTypes.SCALAR_DSTRING && SymfonyUtil.isVersionGreaterThenEquals(element.getProject(), "2.8")) {
30+
if (element.getNode().getElementType() == YAMLTokenTypes.SCALAR_DSTRING && SymfonyUtil.isVersionGreaterThenEquals(element.getProject(), "2.8")) {
3031
// "Foo\Foo" -> "Foo\\Foo"
3132
String text = StringUtils.strip(element.getText(), "\"");
3233

3334
// dont check to long strings
3435
// ascii chars that need to be escape; some @see Symfony\Component\Yaml\Unescaper
35-
if(text.length() < 255 && text.matches(".*[^\\\\]\\\\[^\\\\0abtnvfre \"/N_LPxuU].*")) {
36+
if (text.length() < 255 && text.matches(".*[^\\\\]\\\\[^\\\\0abtnvfre \"/N_LPxuU].*")) {
3637
holder.registerProblem(element, "Not escaping a backslash in a double-quoted string is deprecated", ProblemHighlightType.WEAK_WARNING);
3738
}
3839
} else if (element.getNode().getElementType() == YAMLTokenTypes.TEXT && SymfonyUtil.isVersionGreaterThenEquals(element.getProject(), "2.8")) {
3940
// @foo -> "@foo"
40-
String text = element.getText();
41-
if(text.length() > 1) {
41+
String text;
42+
if (parentIsErrorAndHasPreviousElement(element)) {
43+
text = element.getParent().getPrevSibling().getText();
44+
} else {
45+
text = element.getText();
46+
}
47+
48+
if (text.length() > 1 || (parentIsErrorAndHasPreviousElement(element) && text.length() >= 1)) {
4249
String startChar = text.substring(0, 1);
43-
if(startChar.equals("@") || startChar.equals("`") || startChar.equals("|") || startChar.equals(">")) {
50+
if (startChar.equals("@") || startChar.equals("`") || startChar.equals("|") || startChar.equals(">")) {
4451
holder.registerProblem(element, String.format("Deprecated usage of '%s' at the beginning of unquoted string", startChar), ProblemHighlightType.WEAK_WARNING);
45-
} else if(startChar.equals("%")) {
52+
} else if (startChar.equals("%")) {
4653
// deprecated in => "3.1"; but as most user will need to migrate in 2.8 let them know it already
4754
holder.registerProblem(element, "Not quoting a scalar starting with the '%' indicator character is deprecated since Symfony 3.1", ProblemHighlightType.WEAK_WARNING);
4855
}
@@ -53,4 +60,9 @@ public void visitElement(PsiElement element) {
5360
};
5461
}
5562

63+
private boolean parentIsErrorAndHasPreviousElement(@NotNull PsiElement element) {
64+
PsiElement parent = element.getParent();
65+
66+
return parent instanceof PsiErrorElement && parent.getPrevSibling() != null;
67+
}
5668
}

0 commit comments

Comments
 (0)