本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
}
}
}
}
};
}