• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LanguageNamesValidation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addSeenWord

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
protected void addSeenWord(HashSet<String> seenNames, String word, Language language) {
  final String lowerWord = word.toLowerCase();
  if (globalSeenNames.contains(lowerWord)) {
    return;
  }

  final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(language);
  if (namesValidator != null && namesValidator.isKeyword(word, myProject)) {
    return;
  }

  globalSeenNames.add(lowerWord);
  if (mySpellCheckerManager.hasProblem(lowerWord)){
    seenNames.add(lowerWord);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SpellCheckerDictionaryGenerator.java


示例2: isValidName

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public static boolean isValidName(final Project project, final PsiElement psiElement, final String newName) {
  if (newName == null || newName.length() == 0) {
    return false;
  }
  final Condition<String> inputValidator = RenameInputValidatorRegistry.getInputValidator(psiElement);
  if (inputValidator != null) {
    return inputValidator.value(newName);
  }
  if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) {
    return newName.indexOf('\\') < 0 && newName.indexOf('/') < 0;
  }
  if (psiElement instanceof PomTargetPsiElement) {
    return !StringUtil.isEmptyOrSpaces(newName);
  }

  final PsiFile file = psiElement.getContainingFile();
  final Language elementLanguage = psiElement.getLanguage();

  final Language fileLanguage = file == null ? null : file.getLanguage();
  Language language = fileLanguage == null ? elementLanguage : fileLanguage.isKindOf(elementLanguage) ? fileLanguage : elementLanguage;

  return LanguageNamesValidation.INSTANCE.forLanguage(language).isIdentifier(newName.trim(), project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RenameUtil.java


示例3: IntroduceParameterDialog

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public IntroduceParameterDialog(XPathExpression expression, int numberOfExpressions, boolean forceDefault) {
    super(expression.getProject(), LanguageNamesValidation.INSTANCE.forLanguage(expression.getLanguage()));
    myForceDefault = forceDefault;
    init(expression, numberOfExpressions, TITLE);

    getOKAction().addPropertyChangeListener(new PropertyChangeListener() {
        @SuppressWarnings({"AutoUnboxing"})
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("enabled")) {
                myPreviewAction.setEnabled(((Boolean)evt.getNewValue()) && !myCreateWithDefault.isSelected());
            }
        }
    });
    if (forceDefault) {
        myCreateWithDefault.setSelected(true);
        myCreateWithDefault.setVisible(false);
    } else {
        myCreateWithDefault.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                myPreviewAction.setEnabled(getOKAction().isEnabled() && !myCreateWithDefault.isSelected());
            }
        });
    }
    myPreviewAction.setEnabled(false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:IntroduceParameterDialog.java


示例4: handleElementRenameInternal

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
@RequiredReadAction
PsiElement handleElementRenameInternal(String newElementName) throws IncorrectOperationException
{
	final int i = newElementName.lastIndexOf('.');
	if(i != -1)
	{
		newElementName = newElementName.substring(0, i);
	}
	if(!LanguageNamesValidation.INSTANCE.forLanguage(JavaScriptLanguage.INSTANCE).isIdentifier(newElementName, null))
	{
		throw new IncorrectOperationException("Invalid javascript element name:" + newElementName);
	}
	final PsiElement parent = getParent();
	if(parent instanceof JSClass || parent instanceof JSFunction)
	{
		final PsiElement node = ((JSNamedElement) parent).getNameIdentifier();
		if(node != null && node == this)
		{
			return this; // JSNamedElement.setName will care of things
		}
	}
	JSChangeUtil.doIdentifierReplacement(this, getNameElement(), newElementName);
	return getParent();
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:JSReferenceExpressionImpl.java


示例5: isAvailable

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例6: assignId

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
/**
 * Assign a suitable new and unique id to the given component. The set of
 * existing id's is provided in the given list.
 */
@NotNull
public String assignId(RadViewComponent component, Collection<String> idList) {
  String idValue = StringUtil.decapitalize(component.getMetaModel().getTag());

  XmlTag tag = component.getTag();
  Module module = AndroidPsiUtils.getModuleSafely(tag);
  if (module != null) {
    idValue = ResourceHelper.prependResourcePrefix(module, idValue);
  }

  String nextIdValue = idValue;
  int index = 0;

  // Ensure that we don't create something like "switch" as an id, which won't compile when used
  // in the R class
  NamesValidator validator = LanguageNamesValidation.INSTANCE.forLanguage(JavaLanguage.INSTANCE);

  Project project = tag.getProject();
  while (idList.contains(nextIdValue) || validator != null && validator.isKeyword(nextIdValue, project)) {
    ++index;
    if (index == 1 && (validator == null || !validator.isKeyword(nextIdValue, project))) {
      nextIdValue = idValue;
    } else {
      nextIdValue = idValue + Integer.toString(index);
    }
  }

  String newId = NEW_ID_PREFIX + idValue + (index == 0 ? "" : Integer.toString(index));
  tag.setAttribute(ATTR_ID, ANDROID_URI, newId);
  return newId;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:IdManager.java


示例7: buildVisitor

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例8: isAvailable

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例9: createId

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public String createId(RadViewComponent component) {
  String idValue = StringUtil.decapitalize(component.getMetaModel().getTag());

  XmlTag tag = component.getTag();
  Module module = CordovaPsiUtils.getModuleSafely(tag);

  String nextIdValue = idValue;
  int index = 0;

  // Ensure that we don't create something like "switch" as an id, which won't compile when used
  // in the R class
  NamesValidator validator = LanguageNamesValidation.INSTANCE.forLanguage(JavaLanguage.INSTANCE);

  Project project = tag.getProject();
  while (myIdList.contains(nextIdValue) || validator != null && validator.isKeyword(nextIdValue, project)) {
    ++index;
    if (index == 1 && (validator == null || !validator.isKeyword(nextIdValue, project))) {
      nextIdValue = idValue;
    } else {
      nextIdValue = idValue + Integer.toString(index);
    }
  }

  myIdList.add(nextIdValue);
  String newId = idValue + (index == 0 ? "" : Integer.toString(index));
  tag.setAttribute(ATTR_ID, CORDOVASTUDIO_URI, newId);
  return newId;
}
 
开发者ID:chrimm,项目名称:cordovastudio,代码行数:29,代码来源:IdManager.java


示例10: isAvailable

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例11: isValidIdentifier

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
private static boolean isValidIdentifier(String typeString, PsiElement context)
{
	if(typeString == null)
	{
		return false;
	}
	Language language = context.getContainingFile().getLanguage();
	return LanguageNamesValidation.INSTANCE.forLanguage(language).isIdentifier(typeString, context.getProject());
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:10,代码来源:JSBaseIntroduceDialog.java


示例12: isIdentifier

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例13: isNameValid

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例14: getNamesValidator

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public NamesValidator getNamesValidator() {
    if (myNamesValidator == null) {
        myNamesValidator = LanguageNamesValidation.INSTANCE.forLanguage(XPathFileType.XPATH.getLanguage());
    }
    return myNamesValidator;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:XsltDeclarationInspection.java


示例15: isInputValid

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public boolean isInputValid(String newName, PsiElement element, ProcessingContext context) {
  return LanguageNamesValidation.INSTANCE.forLanguage(XPathFileType.XPATH.getLanguage())
    .isIdentifier(newName, element.getProject());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XsltRenameInputValidator.java


示例16: IntroduceVariableDialog

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public IntroduceVariableDialog(XPathExpression expression, int numberOfExpressions) {
    super(expression.getProject(), LanguageNamesValidation.INSTANCE.forLanguage(expression.getLanguage()));
    init(expression, numberOfExpressions, TITLE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:IntroduceVariableDialog.java


示例17: buildVisitor

import com.intellij.lang.LanguageNamesValidation; //导入依赖的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


示例18: NameColumnInfo

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
public NameColumnInfo(Language lang, Project project) {
  super("Name");
  myNameValidator = (paramName) -> LanguageNamesValidation.INSTANCE.forLanguage(lang).isIdentifier(paramName, project);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:5,代码来源:AbstractParameterTablePanel.java


示例19: isValidName

import com.intellij.lang.LanguageNamesValidation; //导入依赖的package包/类
private boolean isValidName(final String name)
{
	final PsiFile containingFile = myMainOccurence.getContainingFile();
	return LanguageNamesValidation.INSTANCE.forLanguage(containingFile.getLanguage()).isIdentifier(name, myProject);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:6,代码来源:JSBaseIntroduceDialog.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ITransientValueService类代码示例发布时间:2022-05-22
下一篇:
Java DOMReader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap