com.intellij.lang.refactoring.NamesValidator Java Examples
The following examples show how to use
com.intellij.lang.refactoring.NamesValidator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenameElementFix.java From consulo with Apache License 2.0 | 5 votes |
@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); }
Example #2
Source File: IntroduceVariableDialog.java From CppTools with Apache License 2.0 | 5 votes |
static void setupNameValidation(final Project project, final NameSuggestionsField myNewVarName, final Action okAction) { final NameSuggestionsField.DataChanged dataChangedListener = new NameSuggestionsField.DataChanged() { public void dataChanged() { final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(CppSupportLoader.CPP_FILETYPE.getLanguage()); okAction.setEnabled( namesValidator.isIdentifier(myNewVarName.getEnteredName(), project) ); } }; myNewVarName.addDataChangedListener(dataChangedListener); dataChangedListener.dataChanged(); }
Example #3
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 4 votes |
protected boolean isIdentifier(final String newName, final Language language) { final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(language); return namesValidator == null || namesValidator.isIdentifier(newName, myProject); }