From 831618e7ea92cd1fed0258d754e2ae28a24cdcce Mon Sep 17 00:00:00 2001 From: Daniel Espendiller Date: Thu, 21 Mar 2024 18:39:02 +0100 Subject: [PATCH] use isEmpty method in full project --- .../idea/symfony2plugin/action/ServiceActionUtil.java | 6 +++--- .../action/TwigExtractLanguageAction.java | 2 +- .../symfony2plugin/asset/AssetDirectoryReader.java | 4 ++-- .../signature/MethodSignatureTypeProvider.java | 8 ++++---- .../symfony2plugin/codeInspection/InspectionUtil.java | 6 +++--- .../command/PhpCommandGotoCompletionRegistrar.java | 2 +- .../config/ConfigLineMarkerProvider.java | 2 +- .../config/EventDispatcherSubscriberUtil.java | 2 +- .../idea/symfony2plugin/config/PhpClassReference.java | 2 +- .../config/ServiceLineMarkerProvider.java | 10 +++++----- .../dic/SymfonyContainerTypeProvider.java | 2 +- .../suggestion/utils/ServiceSuggestionUtil.java | 2 +- .../dic/inspection/ContainerConstantInspection.java | 4 ++-- .../dic/inspection/YamlClassInspection.java | 2 +- .../dic/intention/PhpServiceArgumentIntention.java | 6 +++--- .../dic/linemarker/XmlLineMarkerProvider.java | 2 +- .../dic/linemarker/YamlLineMarkerProvider.java | 2 +- .../metadata/DoctrineMetadataLineMarkerProvider.java | 4 ++-- .../ObjectRepositoryFindGotoCompletionRegistrar.java | 4 ++-- .../QueryBuilderCompletionContributor.java | 2 +- .../QueryBuilderMethodReferenceParser.java | 6 +++--- .../form/FormOptionGotoCompletionRegistrar.java | 2 +- .../completion/FormClassConstantsLookupElement.java | 2 +- .../idea/symfony2plugin/form/util/FormUtil.java | 6 +++--- .../intentions/yaml/YamlQuotedEscapedInspection.java | 2 +- .../intentions/yaml/YamlServiceArgumentInspection.java | 2 +- .../intentions/yaml/YamlServiceTagIntention.java | 4 ++-- .../yaml/dict/YamlUpdateArgumentServicesCallback.java | 2 +- .../symfony2plugin/profiler/utils/ProfilerUtil.java | 2 +- .../stubs/ContainerCollectionResolver.java | 10 +++++----- .../templating/TwigLineMarkerProvider.java | 8 ++++---- .../templating/dict/TwigCreateContainer.java | 2 +- .../templating/dict/TwigExtensionLookupElement.java | 6 +++--- .../variable/collector/IncludeVariableCollector.java | 6 +++--- .../templating/variable/dict/PsiVariable.java | 2 +- .../variable/resolver/FormFieldResolver.java | 2 +- .../templating/variable/resolver/FormVarsResolver.java | 2 +- .../symfony2plugin/translation/TranslationIndex.java | 2 +- .../TranslationKeyIntentionAndQuickFixAction.java | 2 +- .../symfony2plugin/twig/icon/TwigIconProvider.java | 4 ++-- .../symfony2plugin/util/AnnotationBackportUtil.java | 4 ++-- .../util/DocHashTagReferenceContributor.java | 2 +- .../util/EventDispatcherTypeProvider.java | 2 +- .../idea/symfony2plugin/util/PhpElementsUtil.java | 6 +++--- .../idea/symfony2plugin/util/PhpIndexUtil.java | 2 +- .../util/PhpSerializerLineMarkerProvider.java | 2 +- .../idea/symfony2plugin/util/PhpTypeProviderUtil.java | 2 +- .../idea/symfony2plugin/util/StringUtils.java | 4 ++-- .../symfony2plugin/tests/routing/RouteHelperTest.java | 2 +- 49 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ServiceActionUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ServiceActionUtil.java index 10c95d770..0dae8bf7e 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ServiceActionUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ServiceActionUtil.java @@ -146,7 +146,7 @@ public static Set getPossibleServices(@NotNull Project project, @NotNull @NotNull public static Set getPossibleServices(@NotNull PhpClass phpClass, @NotNull Map serviceClasses) { List matchedContainer = new ArrayList<>(ServiceUtil.getServiceSuggestionForPhpClass(phpClass, serviceClasses)); - if(matchedContainer.size() == 0) { + if(matchedContainer.isEmpty()) { return Collections.emptySet(); } @@ -413,7 +413,7 @@ public static void fixServiceArgument(@NotNull YAMLKeyValue yamlKeyValue) { new ContainerCollectionResolver.LazyServiceCollector(yamlKeyValue.getProject()) ); - if(yamlMissingArgumentTypes.size() == 0) { + if(yamlMissingArgumentTypes.isEmpty()) { return; } @@ -447,7 +447,7 @@ public static void fixServiceArgument(@NotNull Project project, @NotNull List items = new ArrayList<>(); for (Map.Entry> stringSetEntry : resolved.entrySet()) { Set value = stringSetEntry.getValue(); - if(value.size() > 0 ) { + if(!value.isEmpty()) { items.add(value.iterator().next()); } else { items.add("?"); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/TwigExtractLanguageAction.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/TwigExtractLanguageAction.java index e1511d1ca..1f4adebad 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/TwigExtractLanguageAction.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/action/TwigExtractLanguageAction.java @@ -197,7 +197,7 @@ public void onClick(List files, final String keyName, fina ); } - if (navigateTo && targets.size() > 0) { + if (navigateTo && !targets.isEmpty()) { PsiDocumentManager.getInstance(project).commitAndRunReadAction(() -> IdeHelper.navigateToPsiElement(targets.iterator().next()) ); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetDirectoryReader.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetDirectoryReader.java index 918b39590..c7c503223 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetDirectoryReader.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetDirectoryReader.java @@ -190,7 +190,7 @@ private Collection collectWildcardDirectories(@NotNull Matcher matc Collection files = new HashSet<>(); String pathName = matcher.group(1); - String fileExtension = matcher.group(2).length() > 0 ? matcher.group(2) : null; + String fileExtension = !matcher.group(2).isEmpty() ? matcher.group(2) : null; pathName = StringUtils.stripEnd(pathName, "/"); @@ -218,7 +218,7 @@ private boolean isValidFile(@NotNull VirtualFile virtualFile) { return false; } - if(filterExtension.size() == 0) { + if(filterExtension.isEmpty()) { return true; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/signature/MethodSignatureTypeProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/signature/MethodSignatureTypeProvider.java index 14d61014a..bd9fe44e6 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/signature/MethodSignatureTypeProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/signature/MethodSignatureTypeProvider.java @@ -45,12 +45,12 @@ public PhpType getType(PsiElement e) { } Collection signatures = getSignatureSettings(e); - if(signatures.size() == 0) { + if(signatures.isEmpty()) { return null; } Collection matchedSignatures = getSignatureSetting(methodReference.getName(), signatures); - if(matchedSignatures.size() == 0) { + if(matchedSignatures.isEmpty()) { return null; } @@ -138,7 +138,7 @@ public Collection getBySignature(String expression, S PhpIndex phpIndex = PhpIndex.getInstance(project); Collection phpNamedElementCollections = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature); - if(phpNamedElementCollections.size() == 0) { + if(phpNamedElementCollections.isEmpty()) { return null; } @@ -149,7 +149,7 @@ public Collection getBySignature(String expression, S } Collection signatures = getSignatureSettings(phpNamedElement); - if(signatures.size() == 0) { + if(signatures.isEmpty()) { return null; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/InspectionUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/InspectionUtil.java index 8101395e7..b461cb065 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/InspectionUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/InspectionUtil.java @@ -24,7 +24,7 @@ public class InspectionUtil { public static void inspectController(@NotNull PsiElement psiElement, @NotNull String controllerName, @NotNull ProblemsHolder holder, final @NotNull LazyControllerNameResolve lazyControllerNameResolve) { List psiElements = Arrays.asList(RouteHelper.getMethodsOnControllerShortcut(psiElement.getProject(), controllerName)); - if(psiElements.size() > 0) { + if(!psiElements.isEmpty()) { return; } @@ -48,9 +48,9 @@ public static void inspectController(@NotNull PsiElement psiElement, @NotNull St String routeName = lazyControllerNameResolve.getRouteName(); if(routeName != null) { Collection routes = RouteHelper.getRoute(project, routeName); - if(routes.size() > 0) { + if(!routes.isEmpty()) { Set vars = routes.iterator().next().getVariables(); - if(vars.size() > 0) { + if(!vars.isEmpty()) { // add dollar char for vars List varsDollar = new ArrayList<>(); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/command/PhpCommandGotoCompletionRegistrar.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/command/PhpCommandGotoCompletionRegistrar.java index 249ce95d8..54fb9d0b5 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/command/PhpCommandGotoCompletionRegistrar.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/command/PhpCommandGotoCompletionRegistrar.java @@ -153,7 +153,7 @@ private Map getCommandConfigurationMap(@NotNull PhpClass php } Collection psiElements = PhpElementsUtil.collectMethodElementsWithParents(configure, new CommandDefPsiElementFilter(methodName)); - if(psiElements.size() == 0) { + if(psiElements.isEmpty()) { return Collections.emptyMap(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ConfigLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ConfigLineMarkerProvider.java index d8555fa78..7abf92e26 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ConfigLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ConfigLineMarkerProvider.java @@ -36,7 +36,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> result) { - if(psiElements.size() == 0) { + if(psiElements.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/EventDispatcherSubscriberUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/EventDispatcherSubscriberUtil.java index 3bef45379..52daa0c68 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/EventDispatcherSubscriberUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/EventDispatcherSubscriberUtil.java @@ -101,7 +101,7 @@ private static void attachSubscriberEventNames(@NotNull Collection subscriberMethods = getSubscriberMethods(arrayHashElement); - if(subscriberMethods.size() > 0) { + if(!subscriberMethods.isEmpty()) { value = subscriberMethods.iterator().next(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/PhpClassReference.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/PhpClassReference.java index a6d5f00a2..efe1abf41 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/PhpClassReference.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/PhpClassReference.java @@ -99,7 +99,7 @@ public Object[] getVariants() { if(this.useInterfaces) { for (String name : phpIndex.getAllInterfaceNames()) { - if(this.classFQN.length() > 0 && !name.toLowerCase().contains(this.classFQN.toLowerCase())) { + if(!this.classFQN.isEmpty() && !name.toLowerCase().contains(this.classFQN.toLowerCase())) { continue; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ServiceLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ServiceLineMarkerProvider.java index df90af44c..08d3ece27 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ServiceLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/config/ServiceLineMarkerProvider.java @@ -57,7 +57,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> results) { // we need project element; so get it from first item - if(psiElements.size() == 0) { + if(psiElements.isEmpty()) { return; } @@ -181,7 +181,7 @@ private void entityClassMarker(@NotNull Project project, PsiElement psiElement, psiFiles.add(psiFile); } - if(psiFiles.size() == 0) { + if(psiFiles.isEmpty()) { return; } @@ -209,7 +209,7 @@ private void repositoryClassMarker(@NotNull Project project, PsiElement psiEleme psiFiles.add(file); } - if(psiFiles.size() == 0) { + if(psiFiles.isEmpty()) { return; } @@ -267,7 +267,7 @@ private void validatorClassMarker(@NotNull Project project, PsiElement psiElemen // @TODO: validateBy alias - if(phpClasses.size() == 0) { + if(phpClasses.isEmpty()) { return; } @@ -296,7 +296,7 @@ private void constraintValidatorClassMarker(@NotNull Project project, PsiElement PhpElementsUtil.getClassesInterface(project, fqn.substring(0, fqn.length() - "Validator".length())) ); - if(phpClasses.size() == 0) { + if(phpClasses.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/SymfonyContainerTypeProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/SymfonyContainerTypeProvider.java index bc530a24c..96843b3d0 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/SymfonyContainerTypeProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/SymfonyContainerTypeProvider.java @@ -70,7 +70,7 @@ public Collection getBySignature(String expression, S // search for called method PhpIndex phpIndex = PhpIndex.getInstance(project); Collection phpNamedElementCollections = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature); - if(phpNamedElementCollections.size() == 0) { + if(phpNamedElementCollections.isEmpty()) { return Collections.emptySet(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/suggestion/utils/ServiceSuggestionUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/suggestion/utils/ServiceSuggestionUtil.java index bd07f868f..c8d4ea20d 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/suggestion/utils/ServiceSuggestionUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/container/suggestion/utils/ServiceSuggestionUtil.java @@ -23,7 +23,7 @@ private static Collection createServiceCollection(@NotNull ServiceTypeHi serviceMap ); - if(suggestions.size() == 0) { + if(suggestions.isEmpty()) { return Collections.emptyList(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/ContainerConstantInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/ContainerConstantInspection.java index 764901fb9..6ca95481c 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/ContainerConstantInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/ContainerConstantInspection.java @@ -45,7 +45,7 @@ private void visitYamlElement(@NotNull YAMLScalar psiElement, @NotNull ProblemsH String textValue = psiElement.getTextValue(); if(textValue.startsWith("!php/const:")) { String constantName = textValue.substring(11); - if(StringUtils.isNotBlank(constantName) && ServiceContainerUtil.getTargetsForConstant(holder.getProject(), constantName).size() == 0) { + if(StringUtils.isNotBlank(constantName) && ServiceContainerUtil.getTargetsForConstant(holder.getProject(), constantName).isEmpty()) { holder.registerProblem(psiElement, MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } @@ -66,7 +66,7 @@ private void visitXmlElement(@NotNull PsiElement psiElement, @NotNull ProblemsHo return; } - if(ServiceContainerUtil.getTargetsForConstant(holder.getProject(), value).size() == 0) { + if(ServiceContainerUtil.getTargetsForConstant(holder.getProject(), value).isEmpty()) { holder.registerProblem(xmlText, MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/YamlClassInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/YamlClassInspection.java index f39f7a832..75d6b9bc0 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/YamlClassInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/inspection/YamlClassInspection.java @@ -66,7 +66,7 @@ private void invoke(@NotNull final PsiElement psiElement, @NotNull ProblemsHolde if (YamlHelper.isValidParameterName(className)) { String resolvedParameter = ContainerCollectionResolver.resolveParameter(project, className); - if (resolvedParameter != null && PhpIndex.getInstance(project).getAnyByFQN(resolvedParameter).size() > 0) { + if (resolvedParameter != null && !PhpIndex.getInstance(project).getAnyByFQN(resolvedParameter).isEmpty()) { return; } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/intention/PhpServiceArgumentIntention.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/intention/PhpServiceArgumentIntention.java index 0f2c8968d..8efb9e210 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/intention/PhpServiceArgumentIntention.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/intention/PhpServiceArgumentIntention.java @@ -73,7 +73,7 @@ private void invokeByScope(@NotNull Project project, @NotNull PsiElement psiElem if (psiElement instanceof XmlTag) { List args = ServiceActionUtil.getXmlMissingArgumentTypes((XmlTag) psiElement, true, new ContainerCollectionResolver.LazyServiceCollector(psiElement.getProject())); - success = args.size() > 0; + success = !args.isEmpty(); if (success) { ServiceActionUtil.fixServiceArgument(args, (XmlTag) psiElement); } @@ -85,7 +85,7 @@ private void invokeByScope(@NotNull Project project, @NotNull PsiElement psiElem new ContainerCollectionResolver.LazyServiceCollector(psiElement.getProject()) ); - success = args.size() > 0; + success = !args.isEmpty(); if (success) { ServiceActionUtil.fixServiceArgument((YAMLKeyValue) psiElement); } @@ -107,7 +107,7 @@ private void invokeByScope(@NotNull Project project, @NotNull PsiElement psiElem @Override public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) { - return psiElement.getLanguage().equals(PhpLanguage.INSTANCE) && getServicesInScope(project, psiElement).size() > 0; + return psiElement.getLanguage().equals(PhpLanguage.INSTANCE) && !getServicesInScope(project, psiElement).isEmpty(); } @Nls diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/XmlLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/XmlLineMarkerProvider.java index 89a0fbc80..ed6307922 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/XmlLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/XmlLineMarkerProvider.java @@ -33,7 +33,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> result) { - if (psiElements.size() == 0) { + if (psiElements.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/YamlLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/YamlLineMarkerProvider.java index 3a25bce45..aa40a9e6e 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/YamlLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/dic/linemarker/YamlLineMarkerProvider.java @@ -33,7 +33,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> result) { - if (psiElements.size() == 0) { + if (psiElements.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/DoctrineMetadataLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/DoctrineMetadataLineMarkerProvider.java index f2ac10f86..24f1510ac 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/DoctrineMetadataLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/DoctrineMetadataLineMarkerProvider.java @@ -34,7 +34,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> results) { // we need project element; so get it from first item - if(psiElements.size() == 0) { + if(psiElements.isEmpty()) { return; } @@ -67,7 +67,7 @@ private void attachXmlRelationMarker(@NotNull PsiElement target, @NotNull XmlAtt } Collection classesInterface = DoctrineMetadataUtil.getClassInsideScope(psiElement, value); - if(classesInterface.size() == 0) { + if(classesInterface.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/ObjectRepositoryFindGotoCompletionRegistrar.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/ObjectRepositoryFindGotoCompletionRegistrar.java index ac88c59f4..0d082e1a0 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/ObjectRepositoryFindGotoCompletionRegistrar.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/ObjectRepositoryFindGotoCompletionRegistrar.java @@ -58,7 +58,7 @@ public void register(@NotNull GotoCompletionRegistrarParameter registrar) { // resolve every direct repository instance $this->findBy() // or direct repository instance $repository->findBy() - if(phpClasses.size() == 0) { + if(phpClasses.isEmpty()) { PhpExpression classReference = methodReference.getClassReference(); if(classReference != null) { PhpType type = classReference.getType(); @@ -75,7 +75,7 @@ public void register(@NotNull GotoCompletionRegistrarParameter registrar) { } } - if(phpClasses.size() == 0) { + if(phpClasses.isEmpty()) { return null; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java index 89d06a614..6dca66446 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderCompletionContributor.java @@ -486,7 +486,7 @@ private void attachClassNames(@NotNull CompletionResultSet completionResultSet, // foo_bar => fb List starting = new ArrayList<>(); for (String s : underscore.split("_")) { - if(s.length() > 0) { + if(!s.isEmpty()) { starting.add(s.substring(0, 1)); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderMethodReferenceParser.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderMethodReferenceParser.java index d43508453..7cef602ee 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderMethodReferenceParser.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/querybuilder/QueryBuilderMethodReferenceParser.java @@ -54,7 +54,7 @@ public QueryBuilderScopeContext collect() { // doctrine needs valid root with an alias, try to find one in method references or scope Map map = this.findRootDefinition(methodReferences); - if(map.size() > 0) { + if(!map.isEmpty()) { Map.Entry entry = map.entrySet().iterator().next(); qb.addTable(entry.getKey(), entry.getValue()); } @@ -70,7 +70,7 @@ public QueryBuilderScopeContext collect() { } // first tableMap entry is root, we add several initial data - if(qb.getTableMap().size() > 0) { + if(!qb.getTableMap().isEmpty()) { Map.Entry entry = qb.getTableMap().entrySet().iterator().next(); String className = entry.getKey(); PhpClass phpClass = PhpElementsUtil.getClassInterface(project, className); @@ -219,7 +219,7 @@ private void collectParameter(QueryBuilderScopeContext qb, MethodReference metho */ @NotNull private Map findRootDefinition(@NotNull Collection methodReferences) { - if(methodReferences.size() == 0) { + if(methodReferences.isEmpty()) { return Collections.emptyMap(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/FormOptionGotoCompletionRegistrar.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/FormOptionGotoCompletionRegistrar.java index 89acf6fe8..24d19492b 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/FormOptionGotoCompletionRegistrar.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/FormOptionGotoCompletionRegistrar.java @@ -118,7 +118,7 @@ private GotoCompletionProvider getMatchingOption(ParameterList parameterList, @N } // fallback to form - if(formTypeNames.size() == 0) { + if(formTypeNames.isEmpty()) { formTypeNames.add("form"); // old Symfony systems formTypeNames.add("Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType"); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/completion/FormClassConstantsLookupElement.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/completion/FormClassConstantsLookupElement.java index 7b63a05d5..b0e428b83 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/completion/FormClassConstantsLookupElement.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/completion/FormClassConstantsLookupElement.java @@ -37,7 +37,7 @@ public void renderElement(LookupElementPresentation presentation) { tailsText.add(getParent); } - if(tailsText.size() > 0) { + if(!tailsText.isEmpty()) { presentation.setTailText("(" + StringUtils.join(tailsText, ",") + ")", true); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/util/FormUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/util/FormUtil.java index f6f373733..37a9c2158 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/util/FormUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/form/util/FormUtil.java @@ -294,7 +294,7 @@ public static Map> getTags(@NotNull YAMLFile yamlFile) { for(YAMLKeyValue yamlServiceKeyValue : YamlHelper.getQualifiedKeyValuesInFile(yamlFile, "services")) { String serviceName = yamlServiceKeyValue.getName(); Set serviceTagMap = YamlHelper.collectServiceTags(yamlServiceKeyValue); - if(serviceTagMap.size() > 0) { + if(!serviceTagMap.isEmpty()) { map.put(serviceName, serviceTagMap); } } @@ -336,7 +336,7 @@ public static Map> getTags(@NotNull XmlFile psiFile) { if(serviceNameId != null) { Set serviceTags = getTags(serviceTag); - if(serviceTags.size() > 0) { + if(!serviceTags.isEmpty()) { map.put(serviceNameId, serviceTags); } } @@ -774,7 +774,7 @@ public static Pair> getGuessedFormFieldParameters(@N } else if (phpClass != null && phpClass.isEnum()) { typeClass = "\\Symfony\\Component\\Form\\Extension\\Core\\Type\\EnumType"; options.put("class", phpClass.getFQN()); - } else if (phpClass != null && DoctrineMetadataUtil.findMetadataFiles(project, StringUtils.stripStart(phpClass.getFQN(), "\\")).size() > 0) { + } else if (phpClass != null && !DoctrineMetadataUtil.findMetadataFiles(project, StringUtils.stripStart(phpClass.getFQN(), "\\")).isEmpty()) { typeClass = "\\Symfony\\Bridge\\Doctrine\\Form\\Type\\EntityType"; options.put("class", phpClass.getFQN()); } else if (phpType.isConvertibleFrom(project, PhpType.from(PhpType.INT))) { diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlQuotedEscapedInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlQuotedEscapedInspection.java index ec4eac761..f0a4a0826 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlQuotedEscapedInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlQuotedEscapedInspection.java @@ -47,7 +47,7 @@ public void visitElement(@NotNull PsiElement element) { text = element.getText(); } - if (text.length() > 1 || (parentIsErrorAndHasPreviousElement(element) && text.length() >= 1)) { + if (text.length() > 1 || (parentIsErrorAndHasPreviousElement(element) && !text.isEmpty())) { String startChar = text.substring(0, 1); if (startChar.equals("@") || startChar.equals("`") || startChar.equals("|") || startChar.equals(">")) { holder.registerProblem(element, String.format("Deprecated usage of '%s' at the beginning of unquoted string", startChar), ProblemHighlightType.WEAK_WARNING); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java index 50b7571f5..b6f8285c6 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceArgumentInspection.java @@ -60,7 +60,7 @@ public void visitElement(@NotNull PsiElement element) { getLazyServiceCollector(problemsHolder.getProject()) ); - if (yamlMissingArgumentTypes.size() > 0) { + if (!yamlMissingArgumentTypes.isEmpty()) { problemsHolder.registerProblem(yamlKeyValue.getFirstChild(), "Missing argument", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new YamlArgumentQuickfix()); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceTagIntention.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceTagIntention.java index 688b33c77..a75e2f57c 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceTagIntention.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/YamlServiceTagIntention.java @@ -58,7 +58,7 @@ public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement } Set phpClassServiceTags = invoke.getSecond(); - if(phpClassServiceTags.size() == 0) { + if(phpClassServiceTags.isEmpty()) { IdeHelper.showErrorHintIfAvailable(editor, "Ops, no possible Tag found"); return; } @@ -170,7 +170,7 @@ private static Pair> invoke(@NotNull Project project, @Not Set phpClassServiceTags = ServiceUtil.getPhpClassServiceTags(resolvedClassDefinition); Set strings = YamlHelper.collectServiceTags(serviceKeyValue); - if(strings.size() > 0) { + if(!strings.isEmpty()) { for (String s : strings) { if(phpClassServiceTags.contains(s)) { phpClassServiceTags.remove(s); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/dict/YamlUpdateArgumentServicesCallback.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/dict/YamlUpdateArgumentServicesCallback.java index 4b48435c5..73d4d0b1f 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/dict/YamlUpdateArgumentServicesCallback.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/intentions/yaml/dict/YamlUpdateArgumentServicesCallback.java @@ -50,7 +50,7 @@ public void insert(List items) { // we wound array List yamlArguments = YamlHelper.getYamlArrayOnSequenceOrArrayElements((YAMLCompoundValue) yamlCompoundValue); - if(yamlArguments != null && yamlArguments.size() > 0) { + if(yamlArguments != null && !yamlArguments.isEmpty()) { appendEndOffset = yamlArguments.get(yamlArguments.size() - 1).getTextRange().getEndOffset(); List arrayList = new ArrayList<>(); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java index e1d409c04..684aceb8e 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/profiler/utils/ProfilerUtil.java @@ -360,7 +360,7 @@ private Map getRequestAttributes() { if(twigContent != null) { ApplicationManager.getApplication().runReadAction(() -> { Map templates = getRenderedElementTwigTemplates(project, twigContent); - if(templates.size() > 0) { + if(!templates.isEmpty()) { requestAttributes.put("_template", templates.keySet().iterator().next()); } }); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/ContainerCollectionResolver.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/ContainerCollectionResolver.java index 566aff063..69046af9a 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/ContainerCollectionResolver.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/ContainerCollectionResolver.java @@ -214,7 +214,7 @@ public Map getServices() { collectorEx.collectServices(parameter); } - if(exps.size() > 0) { + if(!exps.isEmpty()) { exps.forEach(service -> services.put(service.getId(), new ContainerService(service, null))); } @@ -226,7 +226,7 @@ public Map getServices() { // fake empty service, case which is not allowed by catch it List servicesValues = entry.getValue(); - if(services.size() == 0) { + if(services.isEmpty()) { services.put(serviceName, new ContainerService(serviceName, null, true)); continue; } @@ -279,11 +279,11 @@ public Map getServices() { } // replace alias with main service - if(aliases.size() > 0) { + if(!aliases.isEmpty()) { services.putAll(collectAliases(aliases, services)); } - if(decorated.size() > 0) { + if(!decorated.isEmpty()) { services.putAll(collectDecorated(decorated, services)); } @@ -483,7 +483,7 @@ private Map getParameters() { // setParameter("foo") for ContainerBuilder for (ContainerBuilderCall call : FileBasedIndex.getInstance().getValues(ContainerBuilderStubIndex.KEY, "setParameter", GlobalSearchScope.allScope(project))) { Collection parameters = call.getParameter(); - if(parameters == null || parameters.size() == 0) { + if(parameters == null || parameters.isEmpty()) { continue; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/TwigLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/TwigLineMarkerProvider.java index 3944aa513..c1287ae07 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/TwigLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/TwigLineMarkerProvider.java @@ -56,7 +56,7 @@ public class TwigLineMarkerProvider implements LineMarkerProvider { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> results) { - if(psiElements.size() == 0 || !Symfony2ProjectComponent.isEnabled(psiElements.get(0))) { + if(psiElements.isEmpty() || !Symfony2ProjectComponent.isEnabled(psiElements.get(0))) { return; } @@ -126,7 +126,7 @@ private void attachController(@NotNull TwigFile twigFile, @NotNull Collection> result) { Collection uxComponentsClasses = UxUtil.getComponentClassesForTemplateFile(twigFile.getProject(), twigFile); - if (uxComponentsClasses.size() > 0) { + if (!uxComponentsClasses.isEmpty()) { NavigationGutterIconBuilder builder = NavigationGutterIconBuilder.create(Symfony2Icons.SYMFONY) .setTargets(uxComponentsClasses) .setTooltipText("Navigate to UX Component"); @@ -162,7 +162,7 @@ private LineMarkerInfo attachIncludes(@NotNull TwigFile twigFile) { ); // stop on first target, we load them lazily afterwards - if(containingFiles.size() > 0) { + if(!containingFiles.isEmpty()) { found = true; break; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigCreateContainer.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigCreateContainer.java index be5157df1..3d3611556 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigCreateContainer.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigCreateContainer.java @@ -34,7 +34,7 @@ public void addBlock(@NotNull String block) { @Nullable public String getExtend() { Map extendsMap = getExtends(); - return extendsMap.size() > 0 ? extendsMap.keySet().iterator().next() : null; + return !extendsMap.isEmpty() ? extendsMap.keySet().iterator().next() : null; } @NotNull diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigExtensionLookupElement.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigExtensionLookupElement.java index b09514ea0..15a6395ed 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigExtensionLookupElement.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/dict/TwigExtensionLookupElement.java @@ -74,7 +74,7 @@ private void buildTailText(@NotNull LookupElementPresentation presentation) { } Collection phpNamedElements = PhpIndex.getInstance(this.project).getBySignature(signature); - if(phpNamedElements.size() == 0) { + if(phpNamedElements.isEmpty()) { return; } @@ -82,11 +82,11 @@ private void buildTailText(@NotNull LookupElementPresentation presentation) { if(function instanceof Function) { List parameters = new LinkedList<>(Arrays.asList(((Function) function).getParameters())); - if(this.twigExtension.getOption("needs_context") != null && parameters.size() > 0) { + if(this.twigExtension.getOption("needs_context") != null && !parameters.isEmpty()) { parameters.remove(0); } - if(this.twigExtension.getOption("needs_environment") != null && parameters.size() > 0) { + if(this.twigExtension.getOption("needs_environment") != null && !parameters.isEmpty()) { parameters.remove(0); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/collector/IncludeVariableCollector.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/collector/IncludeVariableCollector.java index 2e2513bc4..2ffa87ad2 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/collector/IncludeVariableCollector.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/collector/IncludeVariableCollector.java @@ -44,7 +44,7 @@ public void collectPsiVariables(@NotNull final TwigFileVariableCollectorParamete } Collection files = getImplements((TwigFile) psiFile); - if(files.size() == 0) { + if(files.isEmpty()) { return; } @@ -112,7 +112,7 @@ private void collectIncludeContextVars(IElementType iElementType, PsiElement tag } // we dont need to collect foreign file variables - if(!addContextVar && varAliasMap.size() == 0) { + if(!addContextVar && varAliasMap.isEmpty()) { return; } @@ -124,7 +124,7 @@ private void collectIncludeContextVars(IElementType iElementType, PsiElement tag } // add alias vars - if(varAliasMap.size() > 0) { + if(!varAliasMap.isEmpty()) { for(Map.Entry entry: varAliasMap.entrySet()) { if(stringPsiVariableHashMap.containsKey(entry.getValue())) { variables.put(entry.getKey(), stringPsiVariableHashMap.get(entry.getValue())); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/dict/PsiVariable.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/dict/PsiVariable.java index 8f72c474b..bbdb77afd 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/dict/PsiVariable.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/dict/PsiVariable.java @@ -41,7 +41,7 @@ public Set getTypes() { @Nullable public PsiElement getElement() { - if (psiElements.size() > 0) { + if (!psiElements.isEmpty()) { return psiElements.iterator().next(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormFieldResolver.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormFieldResolver.java index b3a2acc28..db0e8f43d 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormFieldResolver.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormFieldResolver.java @@ -28,7 +28,7 @@ public class FormFieldResolver implements TwigTypeResolver { public void resolve(Collection targets, Collection previousElement, String typeName, Collection> previousElements, @Nullable Collection psiVariables) { - if (targets.size() == 0 || psiVariables == null || psiVariables.size() == 0 || previousElements == null || previousElements.size() != 0) { + if (targets.isEmpty() || psiVariables == null || psiVariables.isEmpty() || previousElements == null || !previousElements.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormVarsResolver.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormVarsResolver.java index a476a51ef..6b8b0c41c 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormVarsResolver.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/variable/resolver/FormVarsResolver.java @@ -15,7 +15,7 @@ */ public class FormVarsResolver implements TwigTypeResolver { public void resolve(Collection targets, Collection previousElement, String typeName, Collection> previousElements, @Nullable Collection psiVariables) { - if(!"vars".equals(typeName) || previousElements.size() == 0) { + if(!"vars".equals(typeName) || previousElements.isEmpty()) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java index 7e9b60b70..12a9b8b6b 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationIndex.java @@ -49,7 +49,7 @@ synchronized static public TranslationStringMap getTranslationMap(@NotNull Proje Collection translationDirectories = getTranslationRoot(project); TranslationStringMap translationStringMap; - if (translationDirectories.size() > 0) { + if (!translationDirectories.isEmpty()) { translationStringMap = TranslationStringMap.create(project, translationDirectories); } else { translationStringMap = TranslationStringMap.createEmpty(); diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationKeyIntentionAndQuickFixAction.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationKeyIntentionAndQuickFixAction.java index 2a3d30e85..d19b699bd 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationKeyIntentionAndQuickFixAction.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/translation/TranslationKeyIntentionAndQuickFixAction.java @@ -96,7 +96,7 @@ public void applyFix(@NotNull Project project, @NotNull PsiFile psiFile, @Nullab } } - if(files.size() == 0) { + if(files.isEmpty()) { IdeHelper.showErrorHintIfAvailable(editor, "Ops, no domain file found"); return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/twig/icon/TwigIconProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/twig/icon/TwigIconProvider.java index 0dc8e595a..6c800d591 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/twig/icon/TwigIconProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/twig/icon/TwigIconProvider.java @@ -68,7 +68,7 @@ private boolean hasFileExtendsTag(@NotNull PsiElement element) { } private boolean hasController(@NotNull TwigFile twigFile) { - return TwigUtil.findTwigFileController(twigFile).size() > 0 - || TwigUtil.getTwigFileMethodUsageOnIndex(twigFile).size() > 0; + return !TwigUtil.findTwigFileController(twigFile).isEmpty() + || !TwigUtil.getTwigFileMethodUsageOnIndex(twigFile).isEmpty(); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/AnnotationBackportUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/AnnotationBackportUtil.java index 8288759f5..283bb772f 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/AnnotationBackportUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/AnnotationBackportUtil.java @@ -197,7 +197,7 @@ public static String getRouteByMethod(@NotNull Method method) { org.apache.commons.lang3.StringUtils.isNotBlank(s) && !"controller".equalsIgnoreCase(s) ); - if(filter.size() == 0) { + if(filter.isEmpty()) { return null; } @@ -231,7 +231,7 @@ public static Method getMethodScope(@NotNull PhpDocTag phpDocTag) { @Nullable public static String getClassNameReference(PhpDocTag phpDocTag, Map useImports) { - if(useImports.size() == 0) { + if(useImports.isEmpty()) { return null; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/DocHashTagReferenceContributor.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/DocHashTagReferenceContributor.java index 168516080..f521df2c4 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/DocHashTagReferenceContributor.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/DocHashTagReferenceContributor.java @@ -230,7 +230,7 @@ public boolean isValid() { } } - return phpDocParamTags.size() > 0; + return !phpDocParamTags.isEmpty(); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/EventDispatcherTypeProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/EventDispatcherTypeProvider.java index 9efb92e0d..a4c6af2e7 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/EventDispatcherTypeProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/EventDispatcherTypeProvider.java @@ -106,7 +106,7 @@ public Collection getBySignature(String expression, S // search for called method PhpIndex phpIndex = PhpIndex.getInstance(project); Collection phpNamedElementCollections = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature); - if(phpNamedElementCollections.size() == 0) { + if(phpNamedElementCollections.isEmpty()) { return Collections.emptySet(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java index b87a626e7..4dce6154e 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpElementsUtil.java @@ -706,7 +706,7 @@ static public ElementPattern getMethodReturnPattern() { @Nullable static public String getMethodReturnAsString(@NotNull PhpClass phpClass, @NotNull String methodName) { final Collection values = getMethodReturnAsStrings(phpClass, methodName); - if(values.size() == 0) { + if(values.isEmpty()) { return null; } @@ -765,7 +765,7 @@ static public PhpClass getInterface(PhpIndex phpIndex, String className) { @Nullable static public PhpClass getClassInterface(Project project, @NotNull String className) { Collection phpClasses = PhpIndex.getInstance(project).getAnyByFQN(className); - return phpClasses.size() == 0 ? null : phpClasses.iterator().next(); + return phpClasses.isEmpty() ? null : phpClasses.iterator().next(); } /** @@ -1326,7 +1326,7 @@ public interface ClassForCompletionVisitor { @Deprecated public static PhpClass getNewExpressionPhpClass(@NotNull NewExpression newExpression) { Collection newExpressionPhpClasses = getNewExpressionPhpClasses(newExpression); - if (newExpressionPhpClasses.size() > 0) { + if (!newExpressionPhpClasses.isEmpty()) { return newExpressionPhpClasses.iterator().next(); } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpIndexUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpIndexUtil.java index 0538aea4f..db94ac51e 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpIndexUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpIndexUtil.java @@ -57,6 +57,6 @@ public static boolean hasNamespace(@NotNull Project project, @NotNull String nam namespaceName = "\\" + namespaceName; } - return PhpIndex.getInstance(project).getChildNamespacesByParentName(namespaceName + "\\").size() > 0; + return !PhpIndex.getInstance(project).getChildNamespacesByParentName(namespaceName + "\\").isEmpty(); } } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpSerializerLineMarkerProvider.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpSerializerLineMarkerProvider.java index 2ea46dec9..32c19d50c 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpSerializerLineMarkerProvider.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpSerializerLineMarkerProvider.java @@ -28,7 +28,7 @@ public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) { @Override public void collectSlowLineMarkers(@NotNull List psiElements, @NotNull Collection> lineMarkerInfos) { - if(psiElements.size() == 0 || !Symfony2ProjectComponent.isEnabled(psiElements.get(0))) { + if(psiElements.isEmpty() || !Symfony2ProjectComponent.isEnabled(psiElements.get(0))) { return; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpTypeProviderUtil.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpTypeProviderUtil.java index dc986be3c..0c0ee11aa 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpTypeProviderUtil.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/PhpTypeProviderUtil.java @@ -97,7 +97,7 @@ public static String getResolvedParameter(@NotNull PhpIndex phpIndex, @NotNull S // get psi element from signature Collection signTypes = phpIndex.getBySignature(parameter, null, 0); - if(signTypes.size() == 0) { + if(signTypes.isEmpty()) { return null; } diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/StringUtils.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/StringUtils.java index 78f11ba49..fa01da57c 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/StringUtils.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/StringUtils.java @@ -32,7 +32,7 @@ public static String underscore(String camelCasedWord) { } public static String ucfirst(String chaine){ - if(chaine.length() < 1) { + if(chaine.isEmpty()) { return chaine; } return chaine.substring(0, 1).toUpperCase() + chaine.substring(1); @@ -40,7 +40,7 @@ public static String ucfirst(String chaine){ @NotNull public static String lcfirst(@NotNull String input){ - if(input.length() < 1) { + if(input.isEmpty()) { return input; } diff --git a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/routing/RouteHelperTest.java b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/routing/RouteHelperTest.java index 475bb0704..fb346b9cc 100644 --- a/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/routing/RouteHelperTest.java +++ b/src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/routing/RouteHelperTest.java @@ -525,7 +525,7 @@ public void testGetMethodsForPathWithPlaceholderMatch() { * @see fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper#getRoute */ public void testGetRoute() { - assertTrue(RouteHelper.getRoute(getProject(), "my_car_foo_stuff").size() > 0); + assertTrue(!RouteHelper.getRoute(getProject(), "my_car_foo_stuff").isEmpty()); } @NotNull