Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tasks {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
changeNotes.set(file("src/main/resources/META-INF/change-notes.html").readText().replace("<html>", "").replace("</html>", ""));
changeNotes.set(file("src/main/resources/META-INF/change-notes.html").readText().replace("<html>", "").replace("</html>", ""))

// Get the latest available change notes from the changelog file
// changeNotes.set(provider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import fr.adrienbrault.idea.symfony2plugin.extension.PluginConfigurationExtension;
import fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoader;
import fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoaderParameter;
import fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper;
import fr.adrienbrault.idea.symfony2plugin.util.IdeHelper;
import fr.adrienbrault.idea.symfony2plugin.util.ProjectUtil;
import fr.adrienbrault.idea.symfony2plugin.util.service.ServiceXmlParserFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ public static Set<String> getPossibleServices(@NotNull PhpClass phpClass, @NotNu
matchedContainer.sort(new SymfonyCreateService.ContainerServicePriorityNameComparator());

matchedContainer.sort((o1, o2) ->
((Integer)ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o2.getName()))
.compareTo(ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o1.getName()))
Integer.compare(ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o2.getName()), ServiceContainerUtil.getServiceUsage(phpClass.getProject(), o1.getName()))
);

return matchedContainer.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ protected void run(@NotNull Result result) throws Throwable {
PsiElement bundleFile = null;
try {

bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, "command", "Command\\" + finalClassName, new HashMap<String, String>() {{
bundleFile = PhpBundleFileFactory.createBundleFile(phpClass, "command", "Command\\" + finalClassName, new HashMap<>() {{
String name = phpClass.getName();
if(name.endsWith("Bundle")) {
if (name.endsWith("Bundle")) {
name = name.substring(0, name.length() - "Bundle".length());
}
put("name", StringUtils.underscore(name) + ":" + StringUtils.underscore(finalClassName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void run(@NotNull Result result) throws Throwable {
PsiElement bundleFile = null;
try {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void run(@NotNull Result result) throws Throwable {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public boolean isCellEditable(ServiceParameter modelParameter) {
public TableCellEditor getEditor(ServiceParameter modelParameter) {

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

return new DefaultCellEditor(comboBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private List<String> getParameters(List<MethodParameter.MethodModelParameter> me
List<String> methodCalls = new ArrayList<>();

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

for(MethodParameter.MethodModelParameter methodModelParameter: methodModelParameters) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,11 @@ private void updateTask() {
method.getName();
}

modelParameters.sort((o1, o2) -> {
int i = o1.getName().compareTo(o2.getName());
if (i != 0) {
return i;
}

return Integer.valueOf(o1.getIndex()).compareTo(o2.getIndex());
});
modelParameters.sort(
Comparator
.comparing(MethodParameter.MethodModelParameter::getName)
.thenComparingInt(MethodParameter.MethodModelParameter::getIndex)
);

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

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

return new DefaultCellEditor(comboBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
}
}

return psiElements.toArray(new PsiElement[psiElements.size()]);
return psiElements.toArray(new PsiElement[0]);
}

private String[] findValidAssetFilter(PsiElement psiElement) {
Expand All @@ -72,14 +72,11 @@ private String[] getFileExtensionFilterIfValidTag(PsiElement psiElement) {
continue;
}

switch (tag) {
case "stylesheets":
return TwigUtil.CSS_FILES_EXTENSIONS;
case "javascripts":
return TwigUtil.JS_FILES_EXTENSIONS;
default:
return null;
}
return switch (tag) {
case "stylesheets" -> TwigUtil.CSS_FILES_EXTENSIONS;
case "javascripts" -> TwigUtil.JS_FILES_EXTENSIONS;
default -> null;
};
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static String[] getReferenceProvider(Project project) {
contributorAliases.add(referenceProvider.getAlias());
}

return contributorAliases.toArray(new String[contributorAliases.size()]);
return contributorAliases.toArray(new String[0]);
}

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

return contributorAliases.toArray(new String[contributorAliases.size()]);
return contributorAliases.toArray(new String[0]);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class CompletionContributor extends com.intellij.codeInsight.completion.CompletionContributor {

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

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

GotoCompletionProviderLookupArguments arguments = null;
Collection<GotoCompletionContributor> contributors = GotoCompletionUtil.getContributors(psiElement);
for(GotoCompletionContributor contributor: contributors) {
for (GotoCompletionContributor contributor : contributors) {
GotoCompletionProviderInterface formReferenceCompletionContributor = contributor.getProvider(psiElement);
if(formReferenceCompletionContributor != null) {
if (formReferenceCompletionContributor != null) {
completionResultSet.addAllElements(
formReferenceCompletionContributor.getLookupElements()
);
}

// extension to provide full argument pipes
if(formReferenceCompletionContributor instanceof GotoCompletionProviderInterfaceEx) {
if(arguments == null) {
if (formReferenceCompletionContributor instanceof GotoCompletionProviderInterfaceEx) {
if (arguments == null) {
arguments = new GotoCompletionProviderLookupArguments(completionParameters, processingContext, completionResultSet);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Edit
}
}

return psiTargets.toArray(new PsiElement[psiTargets.size()]);
return psiTargets.toArray(new PsiElement[0]);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -129,11 +130,10 @@ private static class LazyConfigTreeSignatures {

@NotNull
public Map<String, Collection<String>> value() {
if(this.treeSignatures == null) {
return this.treeSignatures = ConfigUtil.getTreeSignatures(project);
}

return this.treeSignatures;
return Objects.requireNonNullElseGet(
this.treeSignatures,
() -> this.treeSignatures = ConfigUtil.getTreeSignatures(project)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public ResolveResult[] multiResolve(boolean incompleteCode) {
this.attachPhpClassResolveResults(phpIndex.getInterfacesByFQN(classFQN.startsWith("\\") ? classFQN : "\\" + classFQN), results);
}

return results.toArray(new ResolveResult[results.size()]);
return results.toArray(new ResolveResult[0]);
}

private void attachPhpClassResolveResults(Collection<PhpClass> phpClasses, List<ResolveResult> results) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.intellij.patterns.PlatformPatterns;
import com.intellij.psi.*;
import com.intellij.util.ProcessingContext;
import com.jetbrains.php.lang.PhpLanguage;
import com.jetbrains.php.lang.psi.elements.*;
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
import fr.adrienbrault.idea.symfony2plugin.dic.ConstraintPropertyReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ResolveResult[] multiResolve(boolean incompleteCode) {
resolveResults.add(new PsiElementResolveResult(psiElement));
}

return resolveResults.toArray(new ResolveResult[resolveResults.size()]);
return resolveResults.toArray(new ResolveResult[0]);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.ProcessingContext;
import com.jetbrains.php.lang.PhpLanguage;
import com.jetbrains.php.lang.psi.elements.*;
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
import fr.adrienbrault.idea.symfony2plugin.config.PhpClassReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class PhpMessageSubscriberGotoCompletionRegistrar implements GotoCompleti
PlatformPatterns.or(
PlatformPatterns.psiElement(ArrayHashElement.class)
.withParent(PlatformPatterns.psiElement(ArrayCreationExpression.class).withParent(PhpReturn.class))
.with(new PatternCondition<ArrayHashElement>("Key Type") {
.with(new PatternCondition<>("Key Type") {
@Override
public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingContext context) {
PhpPsiElement keyElement = arrayHashElement.getKey();
Expand All @@ -53,7 +53,7 @@ public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingCon
}
}),
PlatformPatterns.psiElement(ArrayHashElement.class)
.with(new PatternCondition<ArrayHashElement>("Key Text") {
.with(new PatternCondition<>("Key Text") {
@Override
public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingContext context) {
PhpPsiElement keyElement = arrayHashElement.getKey();
Expand All @@ -68,7 +68,7 @@ public boolean accepts(@NotNull ArrayHashElement arrayHashElement, ProcessingCon
.withParent(
PlatformPatterns.psiElement(ArrayCreationExpression.class).withParent(
PlatformPatterns.psiElement(PhpYield.class)
.with(new PatternCondition<PhpYield>("Yield Key Type") {
.with(new PatternCondition<>("Yield Key Type") {
@Override
public boolean accepts(@NotNull PhpYield phpYield, ProcessingContext context) {
PsiElement keyElement = phpYield.getArgument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Objects;

/**
* @author Daniel Espendiller <daniel@espendiller.net>
Expand Down Expand Up @@ -54,11 +55,11 @@ public void visitFile(PsiFile file) {
}

private ContainerCollectionResolver.LazyServiceCollector getLazyServiceCollector(XmlTag xmlTag) {
if(this.lazyServiceCollector != null) {
return this.lazyServiceCollector;
}
return Objects.requireNonNullElseGet(
this.lazyServiceCollector,
() -> this.lazyServiceCollector = new ContainerCollectionResolver.LazyServiceCollector(xmlTag.getProject())
);

return this.lazyServiceCollector = new ContainerCollectionResolver.LazyServiceCollector(xmlTag.getProject());
}

private void visitService(XmlTag xmlTag, @NotNull ProblemsHolder holder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ public class YamlCompletionContributor extends CompletionContributor {
put("exclude", ">= 2.8");
}});

private static final Map<String, String> ROUTE_KEYS = Collections.unmodifiableMap(new HashMap<>() {{
put("pattern", "deprecated");
put("defaults", "(bool)");
put("path", "(string)");
put("requirements", "(array)");
put("methods", "(array|string)");
put("condition", "(string / expression)");
put("resource", "(string)");
put("prefix", "(string)");
put("schemes", "(array|string)");
put("host", "(string)");
put("controller", "(string)");
}});
private static final Map<String, String> ROUTE_KEYS = Map.ofEntries(
Map.entry("pattern", "deprecated"),
Map.entry("defaults", "(bool)"),
Map.entry("path", "(string)"),
Map.entry("requirements", "(array)"),
Map.entry("methods", "(array|string)"),
Map.entry("condition", "(string / expression)"),
Map.entry("resource", "(string)"),
Map.entry("prefix", "(string)"),
Map.entry("schemes", "(array|string)"),
Map.entry("host", "(string)"),
Map.entry("controller", "(string)")
);

public YamlCompletionContributor() {

Expand Down
Loading