Refactored bean name utils for better clarity
This commit is contained in:
@@ -308,7 +308,7 @@ public class AutowiredHoverProvider implements HoverProvider {
|
||||
}
|
||||
|
||||
private String getId(String beanTypeName) {
|
||||
return BeanUtils.getBeanName(beanTypeName);
|
||||
return BeanUtils.getBeanNameFromType(beanTypeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ComponentInjectionsHoverProvider extends AbstractInjectedIntoHoverP
|
||||
return getBeanType(beanType).toString();
|
||||
}
|
||||
|
||||
return BeanUtils.getBeanName(typeName);
|
||||
return BeanUtils.getBeanNameFromType(typeName);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user