本文整理汇总了Java中com.intellij.util.text.UniqueNameGenerator.addExistingName方法的典型用法代码示例。如果您正苦于以下问题:Java UniqueNameGenerator.addExistingName方法的具体用法?Java UniqueNameGenerator.addExistingName怎么用?Java UniqueNameGenerator.addExistingName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.text.UniqueNameGenerator
的用法示例。
在下文中一共展示了UniqueNameGenerator.addExistingName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: overriddenParameters
import com.intellij.util.text.UniqueNameGenerator; //导入方法依赖的package包/类
public static PsiParameter[] overriddenParameters(PsiParameter[] parameters,
@NotNull JVMElementFactory factory,
@NotNull JavaCodeStyleManager codeStyleManager,
@NotNull PsiSubstitutor substitutor,
PsiElement target) {
PsiParameter[] result = new PsiParameter[parameters.length];
UniqueNameGenerator generator = new UniqueNameGenerator();
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
final PsiType parameterType = parameter.getType();
final PsiType substituted = substituteType(substitutor, parameterType, (PsiMethod)parameter.getDeclarationScope());
String paramName = parameter.getName();
boolean isBaseNameGenerated = true;
final boolean isSubstituted = substituted.equals(parameterType);
if (!isSubstituted && isBaseNameGenerated(codeStyleManager, TypeConversionUtil.erasure(parameterType), paramName)) {
isBaseNameGenerated = false;
}
if (paramName == null ||
isBaseNameGenerated && !isSubstituted && isBaseNameGenerated(codeStyleManager, parameterType, paramName) ||
!factory.isValidParameterName(paramName)) {
String[] names = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, substituted).names;
if (names.length > 0) {
paramName = generator.generateUniqueName(names[0]);
}
else {
paramName = generator.generateUniqueName("p");
}
}
else if (!generator.value(paramName)) {
paramName = generator.generateUniqueName(paramName);
}
generator.addExistingName(paramName);
result[i] = factory.createParameter(paramName, substituted, target);
}
return result;
}
示例2: substituteParameters
import com.intellij.util.text.UniqueNameGenerator; //导入方法依赖的package包/类
private static void substituteParameters(@NotNull JVMElementFactory factory,
@NotNull JavaCodeStyleManager codeStyleManager,
@NotNull PsiParameterList sourceParameterList,
@NotNull PsiParameterList targetParameterList,
@NotNull PsiSubstitutor substitutor, PsiElement target) {
PsiParameter[] parameters = sourceParameterList.getParameters();
UniqueNameGenerator generator = new UniqueNameGenerator();
for (PsiParameter parameter : parameters) {
final PsiType parameterType = parameter.getType();
final PsiType substituted = substituteType(substitutor, parameterType, (PsiMethod)parameter.getDeclarationScope());
@NonNls String paramName = parameter.getName();
boolean isBaseNameGenerated = true;
final boolean isSubstituted = substituted.equals(parameterType);
if (!isSubstituted && isBaseNameGenerated(codeStyleManager, TypeConversionUtil.erasure(parameterType), paramName)) {
isBaseNameGenerated = false;
}
if (paramName == null ||
isBaseNameGenerated && !isSubstituted && isBaseNameGenerated(codeStyleManager, parameterType, paramName) ||
!factory.isValidParameterName(paramName)) {
String[] names = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, substituted).names;
if (names.length > 0) {
paramName = generator.generateUniqueName(names[0]);
}
else {
paramName = generator.generateUniqueName("p");
}
}
else if (!generator.value(paramName)) {
paramName = generator.generateUniqueName(paramName);
}
generator.addExistingName(paramName);
final PsiParameter newParameter = factory.createParameter(paramName, substituted, target);
copyOrReplaceModifierList(parameter, newParameter);
targetParameterList.add(newParameter);
}
}
示例3: overriddenParameters
import com.intellij.util.text.UniqueNameGenerator; //导入方法依赖的package包/类
public static PsiParameter[] overriddenParameters(PsiParameter[] parameters,
@NotNull JVMElementFactory factory,
@NotNull JavaCodeStyleManager codeStyleManager,
@NotNull PsiSubstitutor substitutor,
PsiElement target)
{
PsiParameter[] result = new PsiParameter[parameters.length];
UniqueNameGenerator generator = new UniqueNameGenerator();
for(int i = 0; i < parameters.length; i++)
{
PsiParameter parameter = parameters[i];
final PsiType parameterType = parameter.getType();
final PsiType substituted = substituteType(substitutor, parameterType, (PsiMethod) parameter.getDeclarationScope());
String paramName = parameter.getName();
boolean isBaseNameGenerated = true;
final boolean isSubstituted = substituted.equals(parameterType);
if(!isSubstituted && isBaseNameGenerated(codeStyleManager, TypeConversionUtil.erasure(parameterType), paramName))
{
isBaseNameGenerated = false;
}
if(paramName == null ||
isBaseNameGenerated && !isSubstituted && isBaseNameGenerated(codeStyleManager, parameterType, paramName) ||
!factory.isValidParameterName(paramName))
{
String[] names = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, substituted).names;
if(names.length > 0)
{
paramName = generator.generateUniqueName(names[0]);
}
else
{
paramName = generator.generateUniqueName("p");
}
}
else if(!generator.value(paramName))
{
paramName = generator.generateUniqueName(paramName);
}
generator.addExistingName(paramName);
result[i] = factory.createParameter(paramName, substituted, target);
}
return result;
}