Skip to content

Commit 530529f

Browse files
authored
Merge pull request #2373 from Haehnchen/feature/language-features
some language feature migration and code related code cleanup
2 parents 41d9e05 + e5f6841 commit 530529f

File tree

54 files changed

+102
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+102
-194
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ServiceActionUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import fr.adrienbrault.idea.symfony2plugin.stubs.ContainerCollectionResolver;
2727
import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil;
2828
import fr.adrienbrault.idea.symfony2plugin.util.dict.ServiceUtil;
29-
import fr.adrienbrault.idea.symfony2plugin.util.psi.PhpBundleFileFactory;
3029
import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper;
3130
import org.apache.commons.lang3.StringUtils;
3231
import org.jetbrains.annotations.NotNull;

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/ServiceArgumentSelectionDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public String valueOf(ServiceParameter modelParameter) {
170170
int i = classFqn.lastIndexOf("\\");
171171
if(i > 0) {
172172
String ns = classFqn.substring(0, i);
173-
String clazz = classFqn.substring(i + 1, classFqn.length());
173+
String clazz = classFqn.substring(i + 1);
174174
classFqn = String.format("%s [%s]", clazz, ns);
175175
}
176176

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/ServiceBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private List<String> getParameters(List<MethodParameter.MethodModelParameter> me
117117

118118
}
119119

120-
if(!hasCall || methodCalls.isEmpty()) {
120+
if(!hasCall) {
121121
return null;
122122
}
123123

src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetFile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.intellij.openapi.vfs.VfsUtil;
44
import com.intellij.openapi.vfs.VirtualFile;
55
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
67

78
/**
89
* @author Daniel Espendiller <daniel@espendiller.net>
@@ -14,7 +15,7 @@ public class AssetFile {
1415
@NotNull
1516
private final AssetEnum.Position assetPosition;
1617

17-
@NotNull
18+
@Nullable
1819
private VirtualFile relativeFolder;
1920

2021
private String prefix = "";
@@ -58,6 +59,6 @@ public AssetEnum.Position getAssetPosition() {
5859
public String toString() {
5960
return this.string != null
6061
? this.string
61-
: this.prefix + VfsUtil.getRelativePath(assetFile, relativeFolder, '/');
62+
: this.prefix + (relativeFolder != null ? VfsUtil.getRelativePath(assetFile, relativeFolder, '/') : "");
6263
}
6364
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetGoToDeclarationHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private String[] findValidAssetFilter(PsiElement psiElement) {
5959

6060
// asset / absolute_url dont have pre filter
6161
if(TwigPattern.getPrintBlockOrTagFunctionPattern("asset", "absolute_url").accepts(psiElement)) {
62-
return (String[]) ArrayUtils.addAll(TwigUtil.CSS_FILES_EXTENSIONS, TwigUtil.JS_FILES_EXTENSIONS);
62+
return ArrayUtils.addAll(TwigUtil.CSS_FILES_EXTENSIONS, TwigUtil.JS_FILES_EXTENSIONS);
6363
}
6464

6565
return null;

src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/xml/XmlGotoCompletionRegistrar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public Collection<LookupElement> getLookupElements() {
248248
for (PhpClass phpClass : phpClasses) {
249249
lookupElements.addAll(PhpElementsUtil.getClassPublicMethod(phpClass).stream()
250250
.map(PhpLookupElement::new)
251-
.collect(Collectors.toList())
251+
.toList()
252252
);
253253
}
254254

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/yaml/completion/ConfigCompletionProvider.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,6 @@ private Map<String, String> getNodeCommentVars(@Nullable Node node) {
303303
if(node == null) return comments;
304304

305305
Node previousSibling = node.getPreviousSibling();
306-
if(previousSibling == comments) {
307-
return comments;
308-
}
309306

310307
// get variable decl: "foo: test"
311308
Pattern compile = Pattern.compile("^\\s*([\\w_-]+)\\s*:\\s*(.*?)$");

src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/ServiceMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ServiceMap {
1616
private Collection<String> ids;
1717

1818
ServiceMap() {
19-
this.services = Collections.unmodifiableCollection(Collections.emptyList());
19+
this.services = Collections.emptyList();
2020
}
2121

2222
ServiceMap(@NotNull Collection<ServiceInterface> services) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/DoctrineAnnotationReferencedColumnReferences.java

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,36 @@ public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotati
5050
PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(element, PhpDocComment.class);
5151
if(phpDocComment != null) {
5252
PhpDocCommentAnnotation phpDocCommentAnnotationContainer = AnnotationUtil.getPhpDocCommentAnnotationContainer(phpDocComment);
53-
54-
if(phpDocCommentAnnotationContainer != null) {
55-
56-
PhpDocTagAnnotation phpDocTagAnnotation = phpDocCommentAnnotationContainer.getFirstPhpDocBlock(
57-
"\\Doctrine\\ORM\\Mapping\\ManyToOne",
58-
"\\Doctrine\\ORM\\Mapping\\ManyToMany",
59-
"\\Doctrine\\ORM\\Mapping\\OneToOne",
60-
"\\Doctrine\\ORM\\Mapping\\OneToMany"
61-
);
62-
63-
if(phpDocTagAnnotation != null) {
64-
65-
PhpPsiElement phpDocAttrList = phpDocTagAnnotation.getPhpDocTag().getFirstPsiChild();
66-
67-
// @TODO: remove nested on Annotation plugin update
68-
if(phpDocAttrList != null) {
69-
if(phpDocAttrList.getNode().getElementType() == PhpDocElementTypes.phpDocAttributeList) {
70-
PhpPsiElement phpPsiElement = phpDocAttrList.getFirstPsiChild();
71-
if(phpPsiElement instanceof StringLiteralExpression) {
72-
PhpClass phpClass = de.espend.idea.php.annotation.util.PhpElementsUtil.getClassInsideAnnotation(((StringLiteralExpression) phpPsiElement));
73-
if(phpClass != null) {
74-
Collection<DoctrineModelField> lists = EntityHelper.getModelFields(phpClass);
75-
if(!lists.isEmpty()) {
76-
return new PsiReference[] {
77-
new EntityReference((StringLiteralExpression) element, lists)
78-
};
79-
}
53+
PhpDocTagAnnotation phpDocTagAnnotation = phpDocCommentAnnotationContainer.getFirstPhpDocBlock(
54+
"\\Doctrine\\ORM\\Mapping\\ManyToOne",
55+
"\\Doctrine\\ORM\\Mapping\\ManyToMany",
56+
"\\Doctrine\\ORM\\Mapping\\OneToOne",
57+
"\\Doctrine\\ORM\\Mapping\\OneToMany"
58+
);
59+
60+
if(phpDocTagAnnotation != null) {
61+
62+
PhpPsiElement phpDocAttrList = phpDocTagAnnotation.getPhpDocTag().getFirstPsiChild();
63+
64+
// @TODO: remove nested on Annotation plugin update
65+
if(phpDocAttrList != null) {
66+
if(phpDocAttrList.getNode().getElementType() == PhpDocElementTypes.phpDocAttributeList) {
67+
PhpPsiElement phpPsiElement = phpDocAttrList.getFirstPsiChild();
68+
if(phpPsiElement instanceof StringLiteralExpression) {
69+
PhpClass phpClass = de.espend.idea.php.annotation.util.PhpElementsUtil.getClassInsideAnnotation(((StringLiteralExpression) phpPsiElement));
70+
if(phpClass != null) {
71+
Collection<DoctrineModelField> lists = EntityHelper.getModelFields(phpClass);
72+
if(!lists.isEmpty()) {
73+
return new PsiReference[] {
74+
new EntityReference((StringLiteralExpression) element, lists)
75+
};
8076
}
8177
}
8278
}
8379
}
84-
85-
8680
}
87-
8881
}
89-
9082
}
91-
9283
}
9384

9485
return new PsiReference[0];

src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/DoctrineUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static Collection<Pair<String, String>> getClassRepositoryPair(@NotNull
8484

8585
Collection<Pair<String, String>> pairs = new ArrayList<>();
8686

87-
for (XmlTag xmlTag : (XmlTag[]) ArrayUtils.addAll(rootTag.findSubTags("document"), rootTag.findSubTags("entity"))) {
87+
for (XmlTag xmlTag : ArrayUtils.addAll(rootTag.findSubTags("document"), rootTag.findSubTags("entity"))) {
8888

8989
XmlAttribute attr = xmlTag.getAttribute("name");
9090
if(attr == null) {

0 commit comments

Comments
 (0)