Skip to content

Commit

Permalink
use isEmpty method in full project
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Mar 21, 2024
1 parent 0d93bd1 commit 831618e
Show file tree
Hide file tree
Showing 49 changed files with 87 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static Set<String> getPossibleServices(@NotNull Project project, @NotNull
@NotNull
public static Set<String> getPossibleServices(@NotNull PhpClass phpClass, @NotNull Map<String, ContainerService> serviceClasses) {
List<ContainerService> matchedContainer = new ArrayList<>(ServiceUtil.getServiceSuggestionForPhpClass(phpClass, serviceClasses));
if(matchedContainer.size() == 0) {
if(matchedContainer.isEmpty()) {
return Collections.emptySet();
}

Expand Down Expand Up @@ -413,7 +413,7 @@ public static void fixServiceArgument(@NotNull YAMLKeyValue yamlKeyValue) {
new ContainerCollectionResolver.LazyServiceCollector(yamlKeyValue.getProject())
);

if(yamlMissingArgumentTypes.size() == 0) {
if(yamlMissingArgumentTypes.isEmpty()) {
return;
}

Expand Down Expand Up @@ -447,7 +447,7 @@ public static void fixServiceArgument(@NotNull Project project, @NotNull List<St
List<String> items = new ArrayList<>();
for (Map.Entry<String, Set<String>> stringSetEntry : resolved.entrySet()) {
Set<String> value = stringSetEntry.getValue();
if(value.size() > 0 ) {
if(!value.isEmpty()) {
items.add(value.iterator().next());
} else {
items.add("?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void onClick(List<TranslationFileModel> files, final String keyName, fina
);
}

if (navigateTo && targets.size() > 0) {
if (navigateTo && !targets.isEmpty()) {
PsiDocumentManager.getInstance(project).commitAndRunReadAction(() ->
IdeHelper.navigateToPsiElement(targets.iterator().next())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private Collection<VirtualFile> collectWildcardDirectories(@NotNull Matcher matc
Collection<VirtualFile> 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, "/");

Expand Down Expand Up @@ -218,7 +218,7 @@ private boolean isValidFile(@NotNull VirtualFile virtualFile) {
return false;
}

if(filterExtension.size() == 0) {
if(filterExtension.isEmpty()) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public PhpType getType(PsiElement e) {
}

Collection<MethodSignatureSetting> signatures = getSignatureSettings(e);
if(signatures.size() == 0) {
if(signatures.isEmpty()) {
return null;
}

Collection<MethodSignatureSetting> matchedSignatures = getSignatureSetting(methodReference.getName(), signatures);
if(matchedSignatures.size() == 0) {
if(matchedSignatures.isEmpty()) {
return null;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public Collection<? extends PhpNamedElement> getBySignature(String expression, S

PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<? extends PhpNamedElement> phpNamedElementCollections = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature);
if(phpNamedElementCollections.size() == 0) {
if(phpNamedElementCollections.isEmpty()) {
return null;
}

Expand All @@ -149,7 +149,7 @@ public Collection<? extends PhpNamedElement> getBySignature(String expression, S
}

Collection<MethodSignatureSetting> signatures = getSignatureSettings(phpNamedElement);
if(signatures.size() == 0) {
if(signatures.isEmpty()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PsiElement> psiElements = Arrays.asList(RouteHelper.getMethodsOnControllerShortcut(psiElement.getProject(), controllerName));
if(psiElements.size() > 0) {
if(!psiElements.isEmpty()) {
return;
}

Expand All @@ -48,9 +48,9 @@ public static void inspectController(@NotNull PsiElement psiElement, @NotNull St
String routeName = lazyControllerNameResolve.getRouteName();
if(routeName != null) {
Collection<Route> routes = RouteHelper.getRoute(project, routeName);
if(routes.size() > 0) {
if(!routes.isEmpty()) {
Set<String> vars = routes.iterator().next().getVariables();
if(vars.size() > 0) {
if(!vars.isEmpty()) {

// add dollar char for vars
List<String> varsDollar = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private Map<String, CommandArg> getCommandConfigurationMap(@NotNull PhpClass php
}

Collection<PsiElement> psiElements = PhpElementsUtil.collectMethodElementsWithParents(configure, new CommandDefPsiElementFilter(methodName));
if(psiElements.size() == 0) {
if(psiElements.isEmpty()) {
return Collections.emptyMap();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement psiElement) {

@Override
public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> psiElements, @NotNull Collection<? super LineMarkerInfo<?>> result) {
if(psiElements.size() == 0) {
if(psiElements.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static void attachSubscriberEventNames(@NotNull Collection<EventDispatch
// get method name
// @TODO: support multiple method names, currently we only use method name if type hint, so first item helps for now
Collection<PsiElement> subscriberMethods = getSubscriberMethods(arrayHashElement);
if(subscriberMethods.size() > 0) {
if(!subscriberMethods.isEmpty()) {
value = subscriberMethods.iterator().next();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement element) {
@Override
public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> psiElements, @NotNull Collection<? super LineMarkerInfo<?>> results) {
// we need project element; so get it from first item
if(psiElements.size() == 0) {
if(psiElements.isEmpty()) {
return;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ private void entityClassMarker(@NotNull Project project, PsiElement psiElement,
psiFiles.add(psiFile);
}

if(psiFiles.size() == 0) {
if(psiFiles.isEmpty()) {
return;
}

Expand Down Expand Up @@ -209,7 +209,7 @@ private void repositoryClassMarker(@NotNull Project project, PsiElement psiEleme
psiFiles.add(file);
}

if(psiFiles.size() == 0) {
if(psiFiles.isEmpty()) {
return;
}

Expand Down Expand Up @@ -267,7 +267,7 @@ private void validatorClassMarker(@NotNull Project project, PsiElement psiElemen

// @TODO: validateBy alias

if(phpClasses.size() == 0) {
if(phpClasses.isEmpty()) {
return;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Collection<? extends PhpNamedElement> getBySignature(String expression, S
// search for called method
PhpIndex phpIndex = PhpIndex.getInstance(project);
Collection<? extends PhpNamedElement> phpNamedElementCollections = PhpTypeProviderUtil.getTypeSignature(phpIndex, originalSignature);
if(phpNamedElementCollections.size() == 0) {
if(phpNamedElementCollections.isEmpty()) {
return Collections.emptySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static Collection<String> createServiceCollection(@NotNull ServiceTypeHi
serviceMap
);

if(suggestions.size() == 0) {
if(suggestions.isEmpty()) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void invokeByScope(@NotNull Project project, @NotNull PsiElement psiElem
if (psiElement instanceof XmlTag) {
List<String> 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);
}
Expand All @@ -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);
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement psiElement) {

@Override
public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> psiElements, @NotNull Collection<? super LineMarkerInfo<?>> result) {
if (psiElements.size() == 0) {
if (psiElements.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement psiElement) {

@Override
public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> psiElements, @NotNull Collection<? super LineMarkerInfo<?>> result) {
if (psiElements.size() == 0) {
if (psiElements.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement element) {
@Override
public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> psiElements, @NotNull Collection<? super LineMarkerInfo<?>> results) {
// we need project element; so get it from first item
if(psiElements.size() == 0) {
if(psiElements.isEmpty()) {
return;
}

Expand Down Expand Up @@ -67,7 +67,7 @@ private void attachXmlRelationMarker(@NotNull PsiElement target, @NotNull XmlAtt
}

Collection<PhpClass> classesInterface = DoctrineMetadataUtil.getClassInsideScope(psiElement, value);
if(classesInterface.size() == 0) {
if(classesInterface.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -75,7 +75,7 @@ public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
}
}

if(phpClasses.size() == 0) {
if(phpClasses.isEmpty()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private void attachClassNames(@NotNull CompletionResultSet completionResultSet,
// foo_bar => fb
List<String> starting = new ArrayList<>();
for (String s : underscore.split("_")) {
if(s.length() > 0) {
if(!s.isEmpty()) {
starting.add(s.substring(0, 1));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public QueryBuilderScopeContext collect() {

// doctrine needs valid root with an alias, try to find one in method references or scope
Map<String, String> map = this.findRootDefinition(methodReferences);
if(map.size() > 0) {
if(!map.isEmpty()) {
Map.Entry<String, String> entry = map.entrySet().iterator().next();
qb.addTable(entry.getKey(), entry.getValue());
}
Expand All @@ -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<String, String> entry = qb.getTableMap().entrySet().iterator().next();
String className = entry.getKey();
PhpClass phpClass = PhpElementsUtil.getClassInterface(project, className);
Expand Down Expand Up @@ -219,7 +219,7 @@ private void collectParameter(QueryBuilderScopeContext qb, MethodReference metho
*/
@NotNull
private Map<String, String> findRootDefinition(@NotNull Collection<MethodReference> methodReferences) {
if(methodReferences.size() == 0) {
if(methodReferences.isEmpty()) {
return Collections.emptyMap();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static Map<String, Set<String>> getTags(@NotNull YAMLFile yamlFile) {
for(YAMLKeyValue yamlServiceKeyValue : YamlHelper.getQualifiedKeyValuesInFile(yamlFile, "services")) {
String serviceName = yamlServiceKeyValue.getName();
Set<String> serviceTagMap = YamlHelper.collectServiceTags(yamlServiceKeyValue);
if(serviceTagMap.size() > 0) {
if(!serviceTagMap.isEmpty()) {
map.put(serviceName, serviceTagMap);
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@ public static Map<String, Set<String>> getTags(@NotNull XmlFile psiFile) {
if(serviceNameId != null) {

Set<String> serviceTags = getTags(serviceTag);
if(serviceTags.size() > 0) {
if(!serviceTags.isEmpty()) {
map.put(serviceNameId, serviceTags);
}
}
Expand Down Expand Up @@ -774,7 +774,7 @@ public static Pair<String, Map<String, String>> 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))) {
Expand Down
Loading

0 comments on commit 831618e

Please sign in to comment.