Refactored bean name utils for better clarity

This commit is contained in:
nsingh@pivotal.io
2018-12-28 04:04:55 -08:00
parent e82e122bd7
commit 8b5c90de36
6 changed files with 10 additions and 10 deletions

View File

@@ -308,7 +308,7 @@ public class AutowiredHoverProvider implements HoverProvider {
}
private String getId(String beanTypeName) {
return BeanUtils.getBeanName(beanTypeName);
return BeanUtils.getBeanNameFromType(beanTypeName);
}
@Override

View File

@@ -14,16 +14,16 @@ import org.springframework.ide.vscode.commons.util.StringUtil;
public class BeanUtils {
public static String getBeanName(String beanName) {
if (StringUtil.hasText(beanName) && beanName.length() > 0 && Character.isUpperCase(beanName.charAt(0))) {
public static String getBeanNameFromType(String typeName) {
if (StringUtil.hasText(typeName) && typeName.length() > 0 && Character.isUpperCase(typeName.charAt(0))) {
// PT 162740382 - Special case: If more than one character is upper case, do not
// convert bean name to starting lower case. only convert if name has one character
// or the second character in the name is not upper case
if (beanName.length() == 1 || !Character.isUpperCase(beanName.charAt(1))) {
beanName = Character.toLowerCase(beanName.charAt(0)) + beanName.substring(1);
if (typeName.length() == 1 || !Character.isUpperCase(typeName.charAt(1))) {
typeName = Character.toLowerCase(typeName.charAt(0)) + typeName.substring(1);
}
}
return beanName;
return typeName;
}
}

View File

@@ -95,7 +95,7 @@ public class ComponentSymbolProvider implements SymbolProvider {
TypeDeclaration type = (TypeDeclaration) parent;
String beanName = type.getName().toString();
return BeanUtils.getBeanName(beanName);
return BeanUtils.getBeanNameFromType(beanName);
}
return null;
}

View File

@@ -129,7 +129,7 @@ public class DataRepositorySymbolProvider implements SymbolProvider {
private static String getBeanName(TypeDeclaration typeDeclaration) {
String beanName = typeDeclaration.getName().toString();
return BeanUtils.getBeanName(beanName);
return BeanUtils.getBeanNameFromType(beanName);
}
@Override

View File

@@ -83,7 +83,7 @@ public class ComponentInjectionsHoverProvider extends AbstractInjectedIntoHoverP
return getBeanType(beanType).toString();
}
return BeanUtils.getBeanName(typeName);
return BeanUtils.getBeanNameFromType(typeName);
});
}

View File

@@ -85,7 +85,7 @@ public class FunctionUtils {
protected static String getBeanName(TypeDeclaration typeDeclaration) {
String beanName = typeDeclaration.getName().toString();
return BeanUtils.getBeanName(beanName);
return BeanUtils.getBeanNameFromType(beanName);
}
protected static boolean isAbstractClass(TypeDeclaration typeDeclaration, ITypeBinding resolvedType) {