Java 类com.intellij.psi.PsiNameHelper 实例源码

项目:smcplugin    文件:CreateFsmFileAction.java   
@Nullable
@Override
protected SmcFile createFile(String name, String templateName, PsiDirectory dir) {
    String aPackageName = getPackageName(dir);
    boolean validName = PsiNameHelper.getInstance(dir.getProject()).isQualifiedName(name);
    String shortClassName = StringUtils.capitalize(PsiNameHelper.getShortClassName(name));
    String smClassName = validName ? shortClassName + STATE_MACHINE_SUFFIX : "";
    String smContextClassName = validName ?  shortClassName + CONTEXT_SUFFIX : "";
    if (validName && !DO_NOT_CREATE_CONTEXT_KIND.equals(templateName)) {
        JavaDirectoryService.getInstance().createClass(dir, smContextClassName, templateName, true);
    }
    String nameWithExtension = name + DOT_EXTENSION;
    SmcFile newFile = SmcElementFactory.createNewFile(dir.getProject(), nameWithExtension, aPackageName,
            smClassName, smContextClassName);
    dir.add(newFile);
    return newFile;
}
项目:intellij-ce-playground    文件:JavaClassReferenceListElementType.java   
@Override
public void indexStub(@NotNull PsiClassReferenceListStub stub, @NotNull IndexSink sink) {
  PsiReferenceList.Role role = stub.getRole();
  if (role == PsiReferenceList.Role.EXTENDS_LIST || role == PsiReferenceList.Role.IMPLEMENTS_LIST) {
    String[] names = stub.getReferencedNames();
    for (String name : names) {
      String shortName = PsiNameHelper.getShortClassName(name);
      if (!StringUtil.isEmptyOrSpaces(shortName)) {
        sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, shortName);
      }
    }

    if (role == PsiReferenceList.Role.EXTENDS_LIST) {
      StubElement parentStub = stub.getParentStub();
      if (parentStub instanceof PsiClassStub) {
        PsiClassStub psiClassStub = (PsiClassStub)parentStub;
        if (psiClassStub.isEnum()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Enum");
        }
        if (psiClassStub.isAnnotationType()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Annotation");
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:JavaClassElementType.java   
@Override
public void indexStub(@NotNull final PsiClassStub stub, @NotNull final IndexSink sink) {
  boolean isAnonymous = stub.isAnonymous();
  if (isAnonymous) {
    String baseRef = stub.getBaseClassReferenceText();
    if (baseRef != null) {
      sink.occurrence(JavaStubIndexKeys.ANONYMOUS_BASEREF, PsiNameHelper.getShortClassName(baseRef));
    }
  }
  else {
    final String shortName = stub.getName();
    if (shortName != null) {
      sink.occurrence(JavaStubIndexKeys.CLASS_SHORT_NAMES, shortName);
    }

    final String fqn = stub.getQualifiedName();
    if (fqn != null) {
      sink.occurrence(JavaStubIndexKeys.CLASS_FQN, fqn.hashCode());
    }
  }
}
项目:intellij-ce-playground    文件:BindToNewBeanStep.java   
public void _commit(boolean finishChosen) throws CommitStepException {
  // Stop editing if any
  final TableCellEditor cellEditor = myTable.getCellEditor();
  if(cellEditor != null){
    cellEditor.stopCellEditing();
  }

  // Check that all included fields are bound to valid bean properties
  final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myData.myProject);
  for(int i = 0; i <myData.myBindings.length; i++){
    final FormProperty2BeanProperty binding = myData.myBindings[i];
    if(binding.myBeanProperty == null){
      continue;
    }

    if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)){
      throw new CommitStepException(
        UIDesignerBundle.message("error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName)
      );
    }
  }

  myData.myGenerateIsModified = myChkIsModified.isSelected();
}
项目:intellij-ce-playground    文件:NewActionDialog.java   
private void updateControls() {
  setOKActionEnabled(myActionIdEdit.getText().length() > 0 &&
                     myActionNameEdit.getText().length() > 0 &&
                     myActionTextEdit.getText().length() > 0 &&
                     (!myActionNameEdit.isEditable() || PsiNameHelper.getInstance(myProject).isIdentifier(myActionNameEdit.getText())));

  myAnchorBeforeRadio.setEnabled(myActionList.getSelectedValue() != null);
  myAnchorAfterRadio.setEnabled(myActionList.getSelectedValue() != null);

  boolean enabled = myFirstKeystrokeEdit.getDocument().getLength() > 0;
  myClearFirstKeystroke.setEnabled(enabled);
  mySecondKeystrokeEdit.setEnabled(enabled);
  myClearSecondKeystroke.setEnabled(enabled);

  enabled = enabled && mySecondKeystrokeEdit.getDocument().getLength() > 0;
  myClearSecondKeystroke.setEnabled(enabled);
}
项目:tools-idea    文件:JavaClassReferenceListElementType.java   
@Override
public void indexStub(@NotNull PsiClassReferenceListStub stub, @NotNull IndexSink sink) {
  PsiReferenceList.Role role = stub.getRole();
  if (role == PsiReferenceList.Role.EXTENDS_LIST || role == PsiReferenceList.Role.IMPLEMENTS_LIST) {
    String[] names = stub.getReferencedNames();
    for (String name : names) {
      String shortName = PsiNameHelper.getShortClassName(name);
      if (!StringUtil.isEmptyOrSpaces(shortName)) {
        sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, shortName);
      }
    }

    if (role == PsiReferenceList.Role.EXTENDS_LIST) {
      StubElement parentStub = stub.getParentStub();
      if (parentStub instanceof PsiClassStub) {
        PsiClassStub psiClassStub = (PsiClassStub)parentStub;
        if (psiClassStub.isEnum()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Enum");
        }
        if (psiClassStub.isAnnotationType()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Annotation");
        }
      }
    }
  }
}
项目:tools-idea    文件:JavaClassElementType.java   
@Override
public void indexStub(@NotNull final PsiClassStub stub, @NotNull final IndexSink sink) {
  boolean isAnonymous = stub.isAnonymous();
  if (isAnonymous) {
    String baseRef = stub.getBaseClassReferenceText();
    if (baseRef != null) {
      sink.occurrence(JavaStubIndexKeys.ANONYMOUS_BASEREF, PsiNameHelper.getShortClassName(baseRef));
    }
  }
  else {
    final String shortName = stub.getName();
    if (shortName != null) {
      sink.occurrence(JavaStubIndexKeys.CLASS_SHORT_NAMES, shortName);
    }

    final String fqn = stub.getQualifiedName();
    if (fqn != null) {
      sink.occurrence(JavaStubIndexKeys.CLASS_FQN, fqn.hashCode());
    }
  }
}
项目:tools-idea    文件:BindToNewBeanStep.java   
public void _commit(boolean finishChosen) throws CommitStepException {
  // Stop editing if any
  final TableCellEditor cellEditor = myTable.getCellEditor();
  if(cellEditor != null){
    cellEditor.stopCellEditing();
  }

  // Check that all included fields are bound to valid bean properties
  final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myData.myProject).getNameHelper();
  for(int i = 0; i <myData.myBindings.length; i++){
    final FormProperty2BeanProperty binding = myData.myBindings[i];
    if(binding.myBeanProperty == null){
      continue;
    }

    if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)){
      throw new CommitStepException(
        UIDesignerBundle.message("error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName)
      );
    }
  }

  myData.myGenerateIsModified = myChkIsModified.isSelected();
}
项目:lombok-intellij-plugin    文件:BuilderHandler.java   
@NotNull
public String getBuilderClassName(@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @Nullable PsiMethod psiMethod) {
  final String builderClassName = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, ANNOTATION_BUILDER_CLASS_NAME);
  if (!StringUtil.isEmptyOrSpaces(builderClassName)) {
    return builderClassName;
  }

  String rootBuilderClassName = psiClass.getName();
  if (null != psiMethod && !psiMethod.isConstructor()) {
    final PsiType psiMethodReturnType = psiMethod.getReturnType();
    if (null != psiMethodReturnType) {
      rootBuilderClassName = PsiNameHelper.getQualifiedClassName(psiMethodReturnType.getPresentableText(), false);
    }
  }
  return StringUtil.capitalize(rootBuilderClassName + BUILDER_CLASS_NAME);
}
项目:consulo-ui-designer    文件:BindToNewBeanStep.java   
public void _commit(boolean finishChosen) throws CommitStepException {
  // Stop editing if any
  final TableCellEditor cellEditor = myTable.getCellEditor();
  if(cellEditor != null){
    cellEditor.stopCellEditing();
  }

  // Check that all included fields are bound to valid bean properties
  final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myData.myProject).getNameHelper();
  for(int i = 0; i <myData.myBindings.length; i++){
    final FormProperty2BeanProperty binding = myData.myBindings[i];
    if(binding.myBeanProperty == null){
      continue;
    }

    if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)){
      throw new CommitStepException(
        UIDesignerBundle.message("error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName)
      );
    }
  }

  myData.myGenerateIsModified = myChkIsModified.isSelected();
}
项目:consulo-javaee    文件:EjbNameConverter.java   
public String fromString(final String s, final ConvertContext context) {
  if (s == null) {
    final DomElement domElement = context.getInvocationElement();
    final EjbBase ejb = ((EjbBase)domElement.getParent());
    final PsiClass aClass = ejb.getEjbClass().getValue();
    if (aClass != null) {
      return aClass.getName();
    }
    else {
      final String aClassString = ejb.getEjbClass().getStringValue();
      if (aClassString != null) {
        return PsiNameHelper.getShortClassName(aClassString);
      }
    }
    return "unknown";
  }
  return s;
}
项目:consulo-java    文件:JavaFileManagerImpl.java   
private boolean hasAcceptablePackage(@NotNull VirtualFile vFile)
{
    if(vFile.getFileType() == JavaClassFileType.INSTANCE)
    {
        // See IDEADEV-5626
        final VirtualFile root = ProjectRootManager.getInstance(myManager.getProject()).getFileIndex().getClassRootForFile(vFile);
        VirtualFile parent = vFile.getParent();
        final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myManager.getProject());
        while(parent != null && !Comparing.equal(parent, root))
        {
            if(!nameHelper.isIdentifier(parent.getName()))
            {
                return false;
            }
            parent = parent.getParent();
        }
    }

    return true;
}
项目:consulo-java    文件:EncapsulateFieldsDialog.java   
/**
 * @return error string if errors were found, or null if everything is ok
 */
private String validateData() {
  PsiManager manager = PsiManager.getInstance(myProject);
  for (int idx = 0; idx < myFields.length; idx++) {
    if (myCheckedMarks[idx]) {
      String name;
      if (isToEncapsulateGet()) {
        name = myGetterNames[idx];
        if (!PsiNameHelper.getInstance(manager.getProject()).isIdentifier(name)) {
          return RefactoringMessageUtil.getIncorrectIdentifierMessage(name);
        }
      }
      if (!myFinalMarks[idx] && isToEncapsulateSet()) {
        name = mySetterNames[idx];
        if (!PsiNameHelper.getInstance(manager.getProject()).isIdentifier(name)) {
          return RefactoringMessageUtil.getIncorrectIdentifierMessage(name);
        }
      }
    }
  }
  return null;
}
项目:consulo-java    文件:EditMigrationEntryDialog.java   
private void validateOKButton()
{
    boolean isEnabled = true;
    String text = myOldNameField.getText();
    text = text.trim();
    PsiManager manager = PsiManager.getInstance(myProject);
    if(!PsiNameHelper.getInstance(manager.getProject()).isQualifiedName(text))
    {
        isEnabled = false;
    }
    text = myNewNameField.getText();
    text = text.trim();
    if(!PsiNameHelper.getInstance(manager.getProject()).isQualifiedName(text))
    {
        isEnabled = false;
    }
    setOKActionEnabled(isEnabled);
}
项目:consulo-java    文件:ReplaceConstructorWithBuilderDialog.java   
@Override
protected void canRun() throws ConfigurationException {
  final PsiNameHelper nameHelper = PsiNameHelper.getInstance(myProject);
  for (ParameterData parameterData : myParametersMap.values()) {
    if (!nameHelper.isIdentifier(parameterData.getFieldName())) throw new ConfigurationException("\'" + parameterData.getFieldName() + "\' is not a valid field name");
    if (!nameHelper.isIdentifier(parameterData.getSetterName())) throw new ConfigurationException("\'" + parameterData.getSetterName() + "\' is not a valid setter name");
  }
  if (myCreateBuilderClassRadioButton.isSelected()) {
    final String className = myNewClassName.getText().trim();
    if (className.length() == 0 || !nameHelper.isQualifiedName(className)) throw new ConfigurationException("\'" + className + "\' is invalid builder class name");
    final String packageName = myPackageTextField.getText().trim();
    if (packageName.length() > 0 && !nameHelper.isQualifiedName(packageName)) throw new ConfigurationException("\'" + packageName + "\' is invalid builder package name");
  } else {
    final String qualifiedName = myExistentClassTF.getText().trim();
    if (qualifiedName.length() == 0 || !nameHelper.isQualifiedName(qualifiedName)) throw new ConfigurationException("\'" + qualifiedName + "\' is invalid builder qualified class name");
  }
}
项目:consulo-java    文件:PsiPackageRenameValidator.java   
@Nullable
@Override
public String getErrorMessage(String newName, Project project) {
  if (FileTypeManager.getInstance().isFileIgnored(newName)) {
    return "Trying to create a package with ignored name, result will not be visible";
  }
  if (newName.length() > 0) {
    if (!PsiNameHelper.getInstance(project).isQualifiedName(newName)) {
      return "Not a valid package name";
    }
    if (!PsiNameHelper.getInstance(project).isIdentifier(newName)) {
      return "Not a valid identifier name";
    }
  }
  return null;
}
项目:consulo-java    文件:MoveInstanceMethodDialog.java   
protected void doAction() {
  Map<PsiClass, String> parameterNames = new LinkedHashMap<PsiClass, String>();
  for (final PsiClass aClass : myThisClassesMap.keySet()) {
    EditorTextField field = myOldClassParameterNameFields.get(aClass);
    if (field.isEnabled()) {
      String parameterName = field.getText().trim();
      if (!PsiNameHelper.getInstance(myMethod.getProject()).isIdentifier(parameterName)) {
        Messages
          .showErrorDialog(getProject(), RefactoringBundle.message("move.method.enter.a.valid.name.for.parameter"), myRefactoringName);
        return;
      }
      parameterNames.put(aClass, parameterName);
    }
  }

  final PsiVariable targetVariable = (PsiVariable)myList.getSelectedValue();
  if (targetVariable == null) return;
  final MoveInstanceMethodProcessor processor = new MoveInstanceMethodProcessor(myMethod.getProject(),
                                                                                myMethod, targetVariable,
                                                                                myVisibilityPanel.getVisibility(),
                                                                                parameterNames);
  if (!verifyTargetClass(processor.getTargetClass())) return;
  invokeRefactoring(processor);
}
项目:consulo-java    文件:MoveClassesOrPackagesDialog.java   
@Nullable
private MoveDestination selectDestination() {
  final String packageName = getTargetPackage().trim();
  if (packageName.length() > 0 && !PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(packageName)) {
    Messages.showErrorDialog(myProject, RefactoringBundle.message("please.enter.a.valid.target.package.name"),
                             RefactoringBundle.message("move.title"));
    return null;
  }
  RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, packageName);
  PackageWrapper targetPackage = new PackageWrapper(myManager, packageName);
  if (!targetPackage.exists()) {
    final int ret = Messages.showYesNoDialog(myProject, RefactoringBundle.message("package.does.not.exist", packageName),
                                             RefactoringBundle.message("move.title"), Messages.getQuestionIcon());
    if (ret != 0) return null;
  }

  return ((DestinationFolderComboBox)myDestinationFolderCB).selectDirectory(targetPackage, mySuggestToMoveToAnotherRoot);
}
项目:consulo-java    文件:MakeParameterizedStaticDialog.java   
private void updateControls() {
  if (isMakeClassParameter()) {
    String classParameterName = getClassParameterName();
    if (classParameterName == null) {
      setOKActionEnabled(false);
    }
    else {
      setOKActionEnabled(PsiNameHelper.getInstance(myProject).isIdentifier(classParameterName.trim()));
    }
  }
  else
    setOKActionEnabled(true);

  if(myClassParameterNameInputField != null) {
    myClassParameterNameInputField.setEnabled(isMakeClassParameter());
  }

  if(myParameterPanel != null) {
    myParameterPanel.setEnabled(myMakeFieldParameters.isSelected());
  }
}
项目:json2java4idea    文件:JavaConverterFactory.java   
@Inject
public JavaConverterFactory(@Nonnull Provider<PsiNameHelper> nameHelperProvider,
                            @Nonnull @Named("FieldName") Provider<NamePolicy> fieldNamePolicyProvider,
                            @Nonnull @Named("MethodName") Provider<NamePolicy> methodNamePolicyProvider,
                            @Nonnull @Named("ParameterName") Provider<NamePolicy> parameterNamePolicyProvider) {
    this.nameHelperProvider = nameHelperProvider;
    this.fieldNamePolicyProvider = fieldNamePolicyProvider;
    this.methodNamePolicyProvider = methodNamePolicyProvider;
    this.parameterNamePolicyProvider = parameterNamePolicyProvider;
}
项目:json2java4idea    文件:ClassSuffixValidatorTest.java   
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    final Json2JavaBundle bundle = Json2JavaBundle.getInstance();
    final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
    underTest = new ClassSuffixValidator(bundle, nameHelper);
}
项目:json2java4idea    文件:ClassPrefixValidatorTest.java   
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    final Json2JavaBundle bundle = Json2JavaBundle.getInstance();
    final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
    underTest = new ClassPrefixValidator(bundle, nameHelper);
}
项目:json2java4idea    文件:ClassNamePolicyTest.java   
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    nameHelper = PsiNameHelper.getInstance(project);
}
项目:RIBs    文件:GenerateAction.java   
/**
 * Checks if a Java package exists for a directory.
 *
 * @param directory to check.
 * @return {@code true} when a package exists, {@code false} when it does not.
 */
private boolean checkPackageExists(PsiDirectory directory) {
  PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(directory);
  if (pkg == null) {
    return false;
  }

  String name = pkg.getQualifiedName();
  return StringUtil.isEmpty(name)
      || PsiNameHelper.getInstance(directory.getProject()).isQualifiedName(name);
}
项目:intellij-ce-playground    文件:PsiNameHelperImpl.java   
public static PsiNameHelper getInstance() {
  return new PsiNameHelperImpl() {
    @NotNull
    @Override
    protected LanguageLevel getLanguageLevel() {
      return LanguageLevel.HIGHEST;
    }
  };
}
项目:intellij-ce-playground    文件:TypeInfo.java   
@NotNull
public String getShortTypeText() {
  if (text == null) return "";
  String name = PsiNameHelper.getShortClassName(text);
  if (arrayCount > 0) {
    name += StringUtil.repeat("[]", arrayCount);
  }
  return name;
}
项目:intellij-ce-playground    文件:PackageNameUtil.java   
public static boolean containsNonIdentifier(PsiNameHelper nameHelper, String packageName) {

        final StringTokenizer tokenizer = new StringTokenizer(packageName, ".");
        while(tokenizer.hasMoreTokens())
        {
            final String component = tokenizer.nextToken();
            if (!nameHelper.isIdentifier(component)) {
                return true;
            }
        }
        return false;
    }
项目:intellij-ce-playground    文件:NamedObjectPanel.java   
@NotNull
private String validateName() {
  if (myCurrentObject == null) {
    return "";
  }
  String newName = myObjectName.getText();
  if (!PsiNameHelper.getInstance(myProject).isIdentifier(newName, LanguageLevel.JDK_1_7)) {
    myNameWarning.setText("Name must be a valid Java identifier");
    newName = myCurrentObject.getName();
  }
  else {
    myNameWarning.setText(" ");
  }
return newName;
}
项目:intellij-ce-playground    文件:ClassToBindRenderer.java   
public void customize(final String value){
  final String className = PsiNameHelper.getShortClassName(value);
  if(value.length() == className.length()){ // class in default package
    setText(className);
  }
  else{
    final String packageName = value.substring(0, value.length() - className.length() - 1);
    setText(UIDesignerBundle.message("class.in.package", className, packageName));
  }
}
项目:intellij-ce-playground    文件:GrReferenceListElementType.java   
@Override
public void indexStub(@NotNull GrReferenceListStub stub, @NotNull IndexSink sink) {
  for (String name : stub.getBaseClasses()) {
    if (name != null) {
      sink.occurrence(GrDirectInheritorsIndex.KEY, PsiNameHelper.getShortClassName(name));
    }
  }
}
项目:intellij-ce-playground    文件:GrStubUtils.java   
@NotNull
public static String getShortTypeText(@Nullable String text) {
  if (text == null) {
    return "";
  }
  int i = text.length();
  while (i - 2 >= 0 && text.charAt(i - 2) == '[' && text.charAt(i - 1) == ']') {
    i -= 2;
  }
  return PsiNameHelper.getShortClassName(text.substring(0, i)) + text.substring(i);
}
项目:smogen    文件:MatcherGeneratorOptionsPanel.java   
public ValidationInfo doValidate() {
    String className = classNameTextField.getText().trim();
    if (StringUtil.isEmpty(className)) {
        return new ValidationInfo("Class name is empty", classNameTextField);
    }

    if (!PsiNameHelper.getInstance(dataSource.getProject()).isIdentifier(className)) {
        return new ValidationInfo("Class name is not a valid identifier", classNameTextField);
    }

    return null;
}
项目:tools-idea    文件:PsiNameHelperImpl.java   
public static PsiNameHelper getInstance() {
  return new PsiNameHelperImpl() {
    @Override
    protected LanguageLevel getLanguageLevel() {
      return LanguageLevel.HIGHEST;
    }
  };
}
项目:tools-idea    文件:TypeInfo.java   
@NotNull
public String getShortTypeText() {
  if (text == null) return "";
  String name = PsiNameHelper.getShortClassName(text.getString());
  if (arrayCount > 0) {
    name += StringUtil.repeat("[]", arrayCount);
  }
  return name;
}
项目:tools-idea    文件:PackageNameUtil.java   
public static boolean containsNonIdentifier(PsiNameHelper nameHelper, String packageName) {

        final StringTokenizer tokenizer = new StringTokenizer(packageName, ".");
        while(tokenizer.hasMoreTokens())
        {
            final String component = tokenizer.nextToken();
            if (!nameHelper.isIdentifier(component)) {
                return true;
            }
        }
        return false;
    }
项目:tools-idea    文件:ClassToBindRenderer.java   
public void customize(final String value){
  final String className = PsiNameHelper.getShortClassName(value);
  if(value.length() == className.length()){ // class in default package
    setText(className);
  }
  else{
    final String packageName = value.substring(0, value.length() - className.length() - 1);
    setText(UIDesignerBundle.message("class.in.package", className, packageName));
  }
}
项目:tools-idea    文件:GrReferenceListElementType.java   
public void indexStub(@NotNull GrReferenceListStub stub, @NotNull IndexSink sink) {
  for (String name : stub.getBaseClasses()) {
    if (name != null) {
      sink.occurrence(GrDirectInheritorsIndex.KEY, PsiNameHelper.getShortClassName(name));
    }
  }
}
项目:tools-idea    文件:GrStubUtils.java   
@NotNull
public static String getShortTypeText(@Nullable String text) {
  if (text == null) {
    return "";
  }
  int i = text.length();
  while (i - 2 >= 0 && text.charAt(i - 2) == '[' && text.charAt(i - 1) == ']') {
    i -= 2;
  }
  return PsiNameHelper.getShortClassName(text.substring(0, i)) + text.substring(i);
}
项目:lombok-intellij-plugin    文件:BuilderHandler.java   
private boolean validateBuilderClassName(@NotNull String builderClassName, @NotNull Project project, @NotNull ProblemBuilder builder) {
  final PsiNameHelper psiNameHelper = PsiNameHelper.getInstance(project);
  if (!psiNameHelper.isIdentifier(builderClassName)) {
    builder.addError("%s is not a valid identifier", builderClassName);
    return false;
  }
  return true;
}
项目:consulo-ui-designer    文件:ClassToBindRenderer.java   
public void customize(final String value){
  final String className = PsiNameHelper.getShortClassName(value);
  if(value.length() == className.length()){ // class in default package
    setText(className);
  }
  else{
    final String packageName = value.substring(0, value.length() - className.length() - 1);
    setText(UIDesignerBundle.message("class.in.package", className, packageName));
  }
}