当前位置: 首页>>代码示例>>Java>>正文


Java UniqueNameGenerator.value方法代码示例

本文整理汇总了Java中com.intellij.util.text.UniqueNameGenerator.value方法的典型用法代码示例。如果您正苦于以下问题:Java UniqueNameGenerator.value方法的具体用法?Java UniqueNameGenerator.value怎么用?Java UniqueNameGenerator.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.text.UniqueNameGenerator的用法示例。


在下文中一共展示了UniqueNameGenerator.value方法的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:GenerateMembersUtil.java

示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:GenerateMembersUtil.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:46,代码来源:GenerateMembersUtil.java


注:本文中的com.intellij.util.text.UniqueNameGenerator.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。