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


Java PsiNameHelper类代码示例

本文整理汇总了Java中com.intellij.psi.PsiNameHelper的典型用法代码示例。如果您正苦于以下问题:Java PsiNameHelper类的具体用法?Java PsiNameHelper怎么用?Java PsiNameHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiNameHelper类属于com.intellij.psi包,在下文中一共展示了PsiNameHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFile

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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;
}
 
开发者ID:menshele,项目名称:smcplugin,代码行数:18,代码来源:CreateFsmFileAction.java

示例2: indexStub

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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");
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaClassReferenceListElementType.java

示例3: indexStub

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaClassElementType.java

示例4: _commit

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BindToNewBeanStep.java

示例5: updateControls

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:NewActionDialog.java

示例6: _commit

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:BindToNewBeanStep.java

示例7: getBuilderClassName

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:17,代码来源:BuilderHandler.java

示例8: fromString

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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;
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:19,代码来源:EjbNameConverter.java

示例9: hasAcceptablePackage

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:JavaFileManagerImpl.java

示例10: validateData

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:EncapsulateFieldsDialog.java

示例11: validateOKButton

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:EditMigrationEntryDialog.java

示例12: canRun

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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");
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:ReplaceConstructorWithBuilderDialog.java

示例13: getErrorMessage

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:PsiPackageRenameValidator.java

示例14: doAction

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:MoveInstanceMethodDialog.java

示例15: selectDestination

import com.intellij.psi.PsiNameHelper; //导入依赖的package包/类
@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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:MoveClassesOrPackagesDialog.java


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