Skip to content

Commit d09fcde

Browse files
committed
drop annotations plugins deprecations
1 parent d66a697 commit d09fcde

File tree

6 files changed

+9
-149
lines changed

6 files changed

+9
-149
lines changed

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/PhpTwigTemplateUsageStubIndex.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.jetbrains.php.lang.psi.elements.MethodReference;
1616
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
1717
import com.jetbrains.php.lang.psi.stubs.indexes.PhpConstantNameIndex;
18+
import de.espend.idea.php.annotation.util.AnnotationUtil;
1819
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
1920
import fr.adrienbrault.idea.symfony2plugin.TwigHelper;
2021
import fr.adrienbrault.idea.symfony2plugin.stubs.dict.TemplateUsage;
@@ -122,7 +123,7 @@ private void visitPhpDocTag(@NotNull PhpDocTag phpDocTag) {
122123
return;
123124
}
124125

125-
String template = AnnotationBackportUtil.getPropertyValueOrDefault(phpDocTag, "template");
126+
String template = AnnotationUtil.getPropertyValueOrDefault(phpDocTag, "template");
126127
if(template != null && template.endsWith(".html.twig")) {
127128
Method methodScope = AnnotationBackportUtil.getMethodScope(phpDocTag);
128129
if(methodScope != null) {

src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/visitor/AnnotationRouteElementWalkingVisitor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.jetbrains.php.lang.psi.elements.PhpClass;
1414
import com.jetbrains.php.lang.psi.elements.PhpPsiElement;
1515
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
16+
import de.espend.idea.php.annotation.util.AnnotationUtil;
1617
import fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper;
1718
import fr.adrienbrault.idea.symfony2plugin.stubs.dict.StubIndexedRoute;
1819
import fr.adrienbrault.idea.symfony2plugin.util.AnnotationBackportUtil;
@@ -77,7 +78,7 @@ private void visitPhpDocTag(@NotNull PhpDocTag phpDocTag) {
7778
return;
7879
}
7980

80-
String routeName = AnnotationBackportUtil.getPropertyValue(phpDocTag, "name");
81+
String routeName = AnnotationUtil.getPropertyValue(phpDocTag, "name");
8182
if(routeName == null) {
8283
routeName = AnnotationBackportUtil.getRouteByMethod(phpDocTag);
8384
}
@@ -145,7 +146,7 @@ private String getRouteNamePrefix(@NotNull PhpDocTag phpDocTag) {
145146
}
146147

147148
// extract "name" property
148-
String annotationRouteName = AnnotationBackportUtil.getPropertyValue(docTag, "name");
149+
String annotationRouteName = AnnotationUtil.getPropertyValue(docTag, "name");
149150
if(StringUtils.isNotBlank(annotationRouteName)) {
150151
return annotationRouteName;
151152
}

src/fr/adrienbrault/idea/symfony2plugin/templating/util/TwigUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.jetbrains.twig.TwigLanguage;
2525
import com.jetbrains.twig.TwigTokenTypes;
2626
import com.jetbrains.twig.elements.*;
27+
import de.espend.idea.php.annotation.util.AnnotationUtil;
2728
import fr.adrienbrault.idea.symfony2plugin.TwigHelper;
2829
import fr.adrienbrault.idea.symfony2plugin.action.comparator.ValueComparator;
2930
import fr.adrienbrault.idea.symfony2plugin.stubs.dict.TemplateUsage;
@@ -34,7 +35,6 @@
3435
import fr.adrienbrault.idea.symfony2plugin.templating.path.TwigPath;
3536
import fr.adrienbrault.idea.symfony2plugin.templating.path.TwigPathIndex;
3637
import fr.adrienbrault.idea.symfony2plugin.templating.variable.dict.PsiVariable;
37-
import fr.adrienbrault.idea.symfony2plugin.util.AnnotationBackportUtil;
3838
import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil;
3939
import fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils;
4040
import fr.adrienbrault.idea.symfony2plugin.util.SymfonyBundleUtil;
@@ -130,7 +130,7 @@ public static String[] getControllerMethodShortcut(@NotNull Method method) {
130130
*/
131131
@Nullable
132132
public static Pair<String, PsiElement[]> getTemplateAnnotationFiles(@NotNull PhpDocTag phpDocTag) {
133-
String template = AnnotationBackportUtil.getPropertyValueOrDefault(phpDocTag, "template");
133+
String template = AnnotationUtil.getPropertyValueOrDefault(phpDocTag, "template");
134134
if(template == null) {
135135
return null;
136136
}

src/fr/adrienbrault/idea/symfony2plugin/util/AnnotationBackportUtil.java

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -234,92 +234,6 @@ public static Method getMethodScope(@NotNull PhpDocTag phpDocTag) {
234234
return (Method) method;
235235
}
236236

237-
/**
238-
* Extract property value or fallback on default annotation pattern
239-
*
240-
* TODO: Migrate to AnnotationUtil until plugin when all got the new API
241-
*
242-
* "@Template("foobar.html.twig")"
243-
* "@Template(template="foobar.html.twig")"
244-
*
245-
* @see de.espend.idea.php.annotation.util.AnnotationUtil#getPropertyValueOrDefault
246-
*/
247-
@Nullable
248-
@Deprecated
249-
public static String getPropertyValueOrDefault(@NotNull PhpDocTag phpDocTag, @NotNull String property) {
250-
PhpPsiElement attributeList = phpDocTag.getFirstPsiChild();
251-
if(attributeList == null || attributeList.getNode().getElementType() != PhpDocElementTypes.phpDocAttributeList) {
252-
return null;
253-
}
254-
255-
String contents = null;
256-
PsiElement lParen = attributeList.getFirstChild();
257-
if(lParen == null) {
258-
return null;
259-
}
260-
261-
PsiElement defaultValue = lParen.getNextSibling();
262-
if(defaultValue instanceof StringLiteralExpression) {
263-
// @Template("foobar.html.twig")
264-
contents = ((StringLiteralExpression) defaultValue).getContents();
265-
} else {
266-
// @Template(template="foobar.html.twig")
267-
PsiElement psiProperty = Arrays.stream(attributeList.getChildren())
268-
.filter(psiElement1 -> getPropertyIdentifierValue(property).accepts(psiElement1))
269-
.findFirst()
270-
.orElse(null);
271-
272-
if(psiProperty instanceof StringLiteralExpression) {
273-
contents = ((StringLiteralExpression) psiProperty).getContents();
274-
}
275-
}
276-
277-
if(StringUtils.isNotBlank(contents)) {
278-
return contents;
279-
}
280-
281-
return contents;
282-
}
283-
284-
/**
285-
* Get the property value by given name
286-
*
287-
* "@Template(template="foobar.html.twig")"
288-
*
289-
* TODO: Migrate to AnnotationUtil until plugin when all got the new API
290-
*
291-
* @see de.espend.idea.php.annotation.util.AnnotationUtil#getPropertyValue
292-
*/
293-
@Nullable
294-
@Deprecated
295-
public static String getPropertyValue(@NotNull PhpDocTag phpDocTag, @NotNull String property) {
296-
PhpPsiElement attributeList = phpDocTag.getFirstPsiChild();
297-
if(attributeList == null || attributeList.getNode().getElementType() != PhpDocElementTypes.phpDocAttributeList) {
298-
return null;
299-
}
300-
301-
PsiElement lParen = attributeList.getFirstChild();
302-
if(lParen == null) {
303-
return null;
304-
}
305-
306-
PsiElement psiProperty = Arrays.stream(attributeList.getChildren())
307-
.filter(psiElement1 -> getPropertyIdentifierValue(property).accepts(psiElement1))
308-
.findFirst()
309-
.orElse(null);
310-
311-
if(!(psiProperty instanceof StringLiteralExpression)) {
312-
return null;
313-
}
314-
315-
String contents = ((StringLiteralExpression) psiProperty).getContents();
316-
if(StringUtils.isNotBlank(contents)) {
317-
return contents;
318-
}
319-
320-
return null;
321-
}
322-
323237
@Nullable
324238
public static String getClassNameReference(PhpDocTag phpDocTag, Map<String, String> useImports) {
325239

@@ -355,19 +269,4 @@ public static String getClassNameReference(PhpDocTag phpDocTag, Map<String, Stri
355269

356270
return annotationFqnName;
357271
}
358-
359-
/**
360-
* matches "@Callback(propertyName="<value>")"
361-
*/
362-
private static PsiElementPattern.Capture<StringLiteralExpression> getPropertyIdentifierValue(String propertyName) {
363-
return PlatformPatterns.psiElement(StringLiteralExpression.class)
364-
.afterLeafSkipping(
365-
PlatformPatterns.or(
366-
PlatformPatterns.psiElement(PsiWhiteSpace.class),
367-
PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText("=")
368-
),
369-
PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText(propertyName)
370-
)
371-
.withParent(PlatformPatterns.psiElement(PhpDocElementTypes.phpDocAttributeList));
372-
}
373272
}

tests/fr/adrienbrault/idea/symfony2plugin/tests/util/AnnotationBackportUtilTest.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

travis.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ else
9898
fi
9999

100100
rm -f $travisCache/php-annotation.jar
101-
download "http://phpstorm.espend.de/files/proxy/plugins/php-annotation.jar"
102-
cp $travisCache/php-annotation.jar ./plugins
101+
download "http://phpstorm.espend.de/files/proxy/plugins/php-annotation-5.2.jar"
102+
cp $travisCache/php-annotation-5.2.jar ./plugins/php-annotation.jar
103103

104104
rm -f $travisCache/php-toolbox.jar
105105
download "http://phpstorm.espend.de/files/proxy/plugins/php-toolbox.jar"

0 commit comments

Comments
 (0)