本文整理汇总了Java中com.intellij.lang.refactoring.NamesValidator类的典型用法代码示例。如果您正苦于以下问题:Java NamesValidator类的具体用法?Java NamesValidator怎么用?Java NamesValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NamesValidator类属于com.intellij.lang.refactoring包,在下文中一共展示了NamesValidator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSeenWord
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的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);
}
}
示例2: 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);
}
示例3: assignId
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的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;
}
示例4: 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
示例5: 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);
}
示例6: createId
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的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;
}
示例7: 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);
}
示例8: MyTokenConsumer
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的package包/类
public MyTokenConsumer(SpellCheckerManager manager, ProblemsHolder holder, NamesValidator namesValidator) {
myManager = manager;
myHolder = holder;
myNamesValidator = namesValidator;
}
示例9: 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);
}
示例10: 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));
}
示例11: getNamesValidator
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的package包/类
public NamesValidator getNamesValidator() {
if (myNamesValidator == null) {
myNamesValidator = LanguageNamesValidation.INSTANCE.forLanguage(XPathFileType.XPATH.getLanguage());
}
return myNamesValidator;
}
示例12: NameValidator
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的package包/类
public NameValidator(Project project, NamesValidator namesValidator) {
myProject = project;
myNamesValidator = namesValidator;
}
示例13: BaseIntroduceDialog
import com.intellij.lang.refactoring.NamesValidator; //导入依赖的package包/类
public BaseIntroduceDialog(Project project, NamesValidator validator) {
super(project, false);
myInputValidator = new NameValidator(project, validator);
}
示例14: 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);
}
}
}
}
}
}
};
}