Skip to content

Commit e897370

Browse files
committed
java language level feature migration
1 parent 4f55627 commit e897370

File tree

112 files changed

+465
-584
lines changed

Some content is hidden

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

112 files changed

+465
-584
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ tasks {
7272
version.set(properties("pluginVersion"))
7373
sinceBuild.set(properties("pluginSinceBuild"))
7474
untilBuild.set(properties("pluginUntilBuild"))
75-
changeNotes.set(file("src/main/resources/META-INF/change-notes.html").readText().replace("<html>", "").replace("</html>", ""));
75+
changeNotes.set(file("src/main/resources/META-INF/change-notes.html").readText().replace("<html>", "").replace("</html>", ""))
7676

7777
// Get the latest available change notes from the changelog file
7878
// changeNotes.set(provider {

src/main/java/fr/adrienbrault/idea/symfony2plugin/Symfony2ProjectComponent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import fr.adrienbrault.idea.symfony2plugin.extension.PluginConfigurationExtension;
1212
import fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoader;
1313
import fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoaderParameter;
14-
import fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper;
1514
import fr.adrienbrault.idea.symfony2plugin.util.IdeHelper;
1615
import fr.adrienbrault.idea.symfony2plugin.util.ProjectUtil;
1716
import fr.adrienbrault.idea.symfony2plugin.util.service.ServiceXmlParserFactory;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ public static Set<String> getPossibleServices(@NotNull PhpClass phpClass, @NotNu
157157
matchedContainer.sort(new SymfonyCreateService.ContainerServicePriorityNameComparator());
158158

159159
matchedContainer.sort((o1, o2) ->
160-
((Integer)ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o2.getName()))
161-
.compareTo(ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o1.getName()))
160+
Integer.compare(ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o2.getName()), ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o1.getName()))
162161
);
163162

164163
return matchedContainer.stream()

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/bundle/NewBundleCommandAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ protected void run(@NotNull Result result) throws Throwable {
3737
PsiElement bundleFile = null;
3838
try {
3939

40-
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, "command", "Command\\" + finalClassName, new HashMap<String, String>() {{
40+
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, "command", "Command\\" + finalClassName, new HashMap<>() {{
4141
String name = phpClass.getName();
42-
if(name.endsWith("Bundle")) {
42+
if (name.endsWith("Bundle")) {
4343
name = name.substring(0, name.length() - "Bundle".length());
4444
}
4545
put("name", StringUtils.underscore(name) + ":" + StringUtils.underscore(finalClassName));

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/bundle/NewBundleFormAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected void run(@NotNull Result result) throws Throwable {
3838
PsiElement bundleFile = null;
3939
try {
4040

41-
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, fileTemplate, "Form\\" + className, new HashMap<String, String>() {{
41+
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, fileTemplate, "Form\\" + className, new HashMap<>() {{
4242
put("name", fr.adrienbrault.idea.symfony2plugin.util.StringUtils.underscore(phpClass.getName() + className));
4343
}});
4444

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/bundle/NewBundleTwigExtensionAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected void run(@NotNull Result result) throws Throwable {
3636
}
3737

3838
final String finalName = name;
39-
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, "twig_extension", "Twig\\Extension\\" + className, new HashMap<String, String>() {{
39+
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, "twig_extension", "Twig\\Extension\\" + className, new HashMap<>() {{
4040
put("name", fr.adrienbrault.idea.symfony2plugin.util.StringUtils.underscore(finalName));
4141
}});
4242

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
@@ -206,7 +206,7 @@ public boolean isCellEditable(ServiceParameter modelParameter) {
206206
public TableCellEditor getEditor(ServiceParameter modelParameter) {
207207

208208
Set<String> sorted = modelParameter.getPossibleServices();
209-
ComboBox comboBox = new ComboBox(sorted.toArray(new String[sorted.size()] ), 200);
209+
ComboBox comboBox = new ComboBox(sorted.toArray(new String[0]), 200);
210210
comboBox.setEditable(true);
211211

212212
return new DefaultCellEditor(comboBox);

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
@@ -98,7 +98,7 @@ private List<String> getParameters(List<MethodParameter.MethodModelParameter> me
9898
List<String> methodCalls = new ArrayList<>();
9999

100100
// sort by indexes parameter
101-
methodModelParameters.sort((o1, o2) -> ((Integer) o1.getIndex()).compareTo(o2.getIndex()));
101+
methodModelParameters.sort(Comparator.comparingInt(MethodParameter.MethodModelParameter::getIndex));
102102

103103
for(MethodParameter.MethodModelParameter methodModelParameter: methodModelParameters) {
104104

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,11 @@ private void updateTask() {
380380
method.getName();
381381
}
382382

383-
modelParameters.sort((o1, o2) -> {
384-
int i = o1.getName().compareTo(o2.getName());
385-
if (i != 0) {
386-
return i;
387-
}
388-
389-
return Integer.valueOf(o1.getIndex()).compareTo(o2.getIndex());
390-
});
383+
modelParameters.sort(
384+
Comparator
385+
.comparing(MethodParameter.MethodModelParameter::getName)
386+
.thenComparingInt(MethodParameter.MethodModelParameter::getIndex)
387+
);
391388

392389
while(this.modelList.getRowCount() > 0) {
393390
this.modelList.removeRow(0);
@@ -466,7 +463,7 @@ public boolean isCellEditable(MethodParameter.MethodModelParameter modelParamete
466463
public TableCellEditor getEditor(MethodParameter.MethodModelParameter modelParameter) {
467464

468465
Set<String> sorted = modelParameter.getPossibleServices();
469-
ComboBox comboBox = new ComboBox(sorted.toArray(new String[sorted.size()] ), 200);
466+
ComboBox comboBox = new ComboBox(sorted.toArray(new String[0]), 200);
470467
comboBox.setEditable(true);
471468

472469
return new DefaultCellEditor(comboBox);

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
4646
}
4747
}
4848

49-
return psiElements.toArray(new PsiElement[psiElements.size()]);
49+
return psiElements.toArray(new PsiElement[0]);
5050
}
5151

5252
private String[] findValidAssetFilter(PsiElement psiElement) {
@@ -72,14 +72,11 @@ private String[] getFileExtensionFilterIfValidTag(PsiElement psiElement) {
7272
continue;
7373
}
7474

75-
switch (tag) {
76-
case "stylesheets":
77-
return TwigUtil.CSS_FILES_EXTENSIONS;
78-
case "javascripts":
79-
return TwigUtil.JS_FILES_EXTENSIONS;
80-
default:
81-
return null;
82-
}
75+
return switch (tag) {
76+
case "stylesheets" -> TwigUtil.CSS_FILES_EXTENSIONS;
77+
case "javascripts" -> TwigUtil.JS_FILES_EXTENSIONS;
78+
default -> null;
79+
};
8380
}
8481

8582
return null;

src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/reference/AssistantReferenceUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static String[] getReferenceProvider(Project project) {
2626
contributorAliases.add(referenceProvider.getAlias());
2727
}
2828

29-
return contributorAliases.toArray(new String[contributorAliases.size()]);
29+
return contributorAliases.toArray(new String[0]);
3030
}
3131

3232
public static String[] getContributorProvider(Project project) {
@@ -36,7 +36,7 @@ public static String[] getContributorProvider(Project project) {
3636
contributorAliases.add(assistantReferenceContributor.getAlias());
3737
}
3838

39-
return contributorAliases.toArray(new String[contributorAliases.size()]);
39+
return contributorAliases.toArray(new String[0]);
4040
}
4141

4242
@Nullable

src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInsight/completion/CompletionContributor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class CompletionContributor extends com.intellij.codeInsight.completion.CompletionContributor {
2424

2525
public CompletionContributor() {
26-
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<CompletionParameters>() {
26+
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider<>() {
2727
@Override
2828
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
2929

@@ -34,17 +34,17 @@ protected void addCompletions(@NotNull CompletionParameters completionParameters
3434

3535
GotoCompletionProviderLookupArguments arguments = null;
3636
Collection<GotoCompletionContributor> contributors = GotoCompletionUtil.getContributors(psiElement);
37-
for(GotoCompletionContributor contributor: contributors) {
37+
for (GotoCompletionContributor contributor : contributors) {
3838
GotoCompletionProviderInterface formReferenceCompletionContributor = contributor.getProvider(psiElement);
39-
if(formReferenceCompletionContributor != null) {
39+
if (formReferenceCompletionContributor != null) {
4040
completionResultSet.addAllElements(
4141
formReferenceCompletionContributor.getLookupElements()
4242
);
4343
}
4444

4545
// extension to provide full argument pipes
46-
if(formReferenceCompletionContributor instanceof GotoCompletionProviderInterfaceEx) {
47-
if(arguments == null) {
46+
if (formReferenceCompletionContributor instanceof GotoCompletionProviderInterfaceEx) {
47+
if (arguments == null) {
4848
arguments = new GotoCompletionProviderLookupArguments(completionParameters, processingContext, completionResultSet);
4949
}
5050

src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInsight/navigation/GotoHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
3535
}
3636
}
3737

38-
return psiTargets.toArray(new PsiElement[psiTargets.size()]);
38+
return psiTargets.toArray(new PsiElement[0]);
3939
}
4040

4141
@Nullable

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ConfigLineMarkerProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Collection;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.Objects;
2425
import java.util.function.Supplier;
2526

2627
/**
@@ -129,11 +130,10 @@ private static class LazyConfigTreeSignatures {
129130

130131
@NotNull
131132
public Map<String, Collection<String>> value() {
132-
if(this.treeSignatures == null) {
133-
return this.treeSignatures = ConfigUtil.getTreeSignatures(project);
134-
}
135-
136-
return this.treeSignatures;
133+
return Objects.requireNonNullElseGet(
134+
this.treeSignatures,
135+
() -> this.treeSignatures = ConfigUtil.getTreeSignatures(project)
136+
);
137137
}
138138
}
139139
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/PhpClassReference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public ResolveResult[] multiResolve(boolean incompleteCode) {
6464
this.attachPhpClassResolveResults(phpIndex.getInterfacesByFQN(classFQN.startsWith("\\") ? classFQN : "\\" + classFQN), results);
6565
}
6666

67-
return results.toArray(new ResolveResult[results.size()]);
67+
return results.toArray(new ResolveResult[0]);
6868
}
6969

7070
private void attachPhpClassResolveResults(Collection<PhpClass> phpClasses, List<ResolveResult> results) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/SymfonyPhpReferenceContributor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.intellij.patterns.PlatformPatterns;
44
import com.intellij.psi.*;
55
import com.intellij.util.ProcessingContext;
6-
import com.jetbrains.php.lang.PhpLanguage;
76
import com.jetbrains.php.lang.psi.elements.*;
87
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
98
import fr.adrienbrault.idea.symfony2plugin.dic.ConstraintPropertyReference;

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/dic/EventDispatcherEventReference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public ResolveResult[] multiResolve(boolean incompleteCode) {
3838
resolveResults.add(new PsiElementResolveResult(psiElement));
3939
}
4040

41-
return resolveResults.toArray(new ResolveResult[resolveResults.size()]);
41+
return resolveResults.toArray(new ResolveResult[0]);
4242
}
4343

4444
@NotNull

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/php/PhpConfigReferenceContributor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.intellij.psi.*;
55
import com.intellij.psi.util.PsiTreeUtil;
66
import com.intellij.util.ProcessingContext;
7-
import com.jetbrains.php.lang.PhpLanguage;
87
import com.jetbrains.php.lang.psi.elements.*;
98
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
109
import fr.adrienbrault.idea.symfony2plugin.config.PhpClassReference;

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/php/PhpMessageSubscriberGotoCompletionRegistrar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class PhpMessageSubscriberGotoCompletionRegistrar implements GotoCompleti
4444
PlatformPatterns.or(
4545
PlatformPatterns.psiElement(ArrayHashElement.class)
4646
.withParent(PlatformPatterns.psiElement(ArrayCreationExpression.class).withParent(PhpReturn.class))
47-
.with(new PatternCondition<ArrayHashElement>("Key Type") {
47+
.with(new PatternCondition<>("Key Type") {
4848
@Override
4949
public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingContext context) {
5050
PhpPsiElement keyElement = arrayHashElement.getKey();
@@ -53,7 +53,7 @@ public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingCon
5353
}
5454
}),
5555
PlatformPatterns.psiElement(ArrayHashElement.class)
56-
.with(new PatternCondition<ArrayHashElement>("Key Text") {
56+
.with(new PatternCondition<>("Key Text") {
5757
@Override
5858
public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingContext context) {
5959
PhpPsiElement keyElement = arrayHashElement.getKey();
@@ -68,7 +68,7 @@ public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingCon
6868
.withParent(
6969
PlatformPatterns.psiElement(ArrayCreationExpression.class).withParent(
7070
PlatformPatterns.psiElement(PhpYield.class)
71-
.with(new PatternCondition<PhpYield>("Yield Key Type") {
71+
.with(new PatternCondition<>("Yield Key Type") {
7272
@Override
7373
public boolean accepts(@NotNull PhpYield phpYield, ProcessingContext context) {
7474
PsiElement keyElement = phpYield.getArgument();

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/xml/inspection/XmlServiceArgumentInspection.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.jetbrains.annotations.NotNull;
1818

1919
import java.util.List;
20+
import java.util.Objects;
2021

2122
/**
2223
* @author Daniel Espendiller <daniel@espendiller.net>
@@ -54,11 +55,11 @@ public void visitFile(PsiFile file) {
5455
}
5556

5657
private ContainerCollectionResolver.LazyServiceCollector getLazyServiceCollector(XmlTag xmlTag) {
57-
if(this.lazyServiceCollector != null) {
58-
return this.lazyServiceCollector;
59-
}
58+
return Objects.requireNonNullElseGet(
59+
this.lazyServiceCollector,
60+
() -> this.lazyServiceCollector = new ContainerCollectionResolver.LazyServiceCollector(xmlTag.getProject())
61+
);
6062

61-
return this.lazyServiceCollector = new ContainerCollectionResolver.LazyServiceCollector(xmlTag.getProject());
6263
}
6364

6465
private void visitService(XmlTag xmlTag, @NotNull ProblemsHolder holder) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/config/yaml/YamlCompletionContributor.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ public class YamlCompletionContributor extends CompletionContributor {
105105
put("exclude", ">= 2.8");
106106
}});
107107

108-
private static final Map<String, String> ROUTE_KEYS = Collections.unmodifiableMap(new HashMap<>() {{
109-
put("pattern", "deprecated");
110-
put("defaults", "(bool)");
111-
put("path", "(string)");
112-
put("requirements", "(array)");
113-
put("methods", "(array|string)");
114-
put("condition", "(string / expression)");
115-
put("resource", "(string)");
116-
put("prefix", "(string)");
117-
put("schemes", "(array|string)");
118-
put("host", "(string)");
119-
put("controller", "(string)");
120-
}});
108+
private static final Map<String, String> ROUTE_KEYS = Map.ofEntries(
109+
Map.entry("pattern", "deprecated"),
110+
Map.entry("defaults", "(bool)"),
111+
Map.entry("path", "(string)"),
112+
Map.entry("requirements", "(array)"),
113+
Map.entry("methods", "(array|string)"),
114+
Map.entry("condition", "(string / expression)"),
115+
Map.entry("resource", "(string)"),
116+
Map.entry("prefix", "(string)"),
117+
Map.entry("schemes", "(array|string)"),
118+
Map.entry("host", "(string)"),
119+
Map.entry("controller", "(string)")
120+
);
121121

122122
public YamlCompletionContributor() {
123123

0 commit comments

Comments
 (0)