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


Java NamesValidator.isIdentifier方法代码示例

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


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

示例1: isAvailable

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project,
                           @NotNull PsiFile file,
                           @NotNull PsiElement startElement,
                           @NotNull PsiElement endElement) {
  if (!startElement.isValid()) {
    return false;
  }
  final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(file.getLanguage());
  return namesValidator != null && namesValidator.isIdentifier(myNewName, project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:RenameElementFix.java

示例2: buildVisitor

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder,
                                      final boolean isOnTheFly,
                                      @NotNull LocalInspectionToolSession session) {
  return new XmlElementVisitor() {
    @Override
    public void visitXmlFile(XmlFile file) {
      if (!JavaFxFileTypeFactory.isFxml(file)) return;
      super.visitXmlFile(file);
    }

    @Override
    public void visitXmlAttribute(XmlAttribute attribute) {
      if (FxmlConstants.FX_ID.equals(attribute.getName())) {
        final XmlAttributeValue valueElement = attribute.getValueElement();
        if (valueElement != null && valueElement.getTextLength() > 0) {
          final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(attribute.getContainingFile());
          if (controllerClass != null) {
            final PsiReference reference = valueElement.getReference();
            if (reference instanceof JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef && ((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef)reference).isUnresolved()) {
              final PsiClass fieldClass =
                checkContext(((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef)reference).getXmlAttributeValue());
              if (fieldClass != null) {
                final String text = reference.getCanonicalText();
                final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(fieldClass.getLanguage());
                boolean validName = namesValidator != null && namesValidator.isIdentifier(text, fieldClass.getProject());
                holder.registerProblem(reference.getElement(), reference.getRangeInElement(), "Unresolved fx:id reference",
                                       isOnTheFly && validName ? new LocalQuickFix[]{new CreateFieldFromUsageQuickFix(text)} : LocalQuickFix.EMPTY_ARRAY);
              }
            }
          }
        }
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaFxUnresolvedFxIdReferenceInspection.java

示例3: isAvailable

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, @Nullable Editor editor, PsiFile file) {
  if (!myElement.isValid()) {
    return false;
  }
  final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(file.getLanguage());
  return namesValidator != null && namesValidator.isIdentifier(myNewName, project);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:RenameElementFix.java

示例4: isAvailable

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@Nonnull Project project,
                           @Nonnull PsiFile file,
                           @Nonnull PsiElement startElement,
                           @Nonnull PsiElement endElement) {
  if (!startElement.isValid()) {
    return false;
  }
  final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(file.getLanguage());
  return namesValidator != null && namesValidator.isIdentifier(myNewName, project);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:RenameElementFix.java

示例5: isIdentifier

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
protected boolean isIdentifier(final String newName, final Language language) {
  final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(language);
  return namesValidator == null || namesValidator.isIdentifier(newName, myProject);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:InplaceRefactoring.java

示例6: isNameValid

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
public boolean isNameValid(final String name, final Project project) {
  final NamesValidator validator = LanguageNamesValidation.INSTANCE.forLanguage(PythonLanguage.getInstance());
  return (name != null) &&
         (validator.isIdentifier(name, project)) &&
         !(validator.isKeyword(name, project));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PyChangeSignatureDialog.java

示例7: buildVisitor

import com.intellij.lang.refactoring.NamesValidator; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, final boolean isOnTheFly, @NotNull LocalInspectionToolSession session)
{
	return new XmlElementVisitor()
	{
		@Override
		public void visitXmlFile(XmlFile file)
		{
			if(!JavaFxFileTypeFactory.isFxml(file))
			{
				return;
			}
			super.visitXmlFile(file);
		}

		@Override
		public void visitXmlAttribute(XmlAttribute attribute)
		{
			if(FxmlConstants.FX_ID.equals(attribute.getName()))
			{
				final XmlAttributeValue valueElement = attribute.getValueElement();
				if(valueElement != null && valueElement.getTextLength() > 0)
				{
					final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(attribute.getContainingFile());
					if(controllerClass != null)
					{
						final PsiReference reference = valueElement.getReference();
						if(reference instanceof JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef && ((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef) reference).isUnresolved())
						{
							final PsiClass fieldClass = checkContext(((JavaFxFieldIdReferenceProvider.JavaFxControllerFieldRef) reference).getXmlAttributeValue());
							if(fieldClass != null)
							{
								final String text = reference.getCanonicalText();
								final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(fieldClass.getLanguage());
								boolean validName = namesValidator != null && namesValidator.isIdentifier(text, fieldClass.getProject());
								holder.registerProblem(reference.getElement(), reference.getRangeInElement(), "Unresolved fx:id reference", isOnTheFly && validName ? new LocalQuickFix[]{new
										CreateFieldFromUsageQuickFix(text)} : LocalQuickFix.EMPTY_ARRAY);
							}
						}
					}
				}
			}
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-javafx,代码行数:47,代码来源:JavaFxUnresolvedFxIdReferenceInspection.java


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