com.intellij.psi.PsiEnumConstant Java Examples
The following examples show how to use
com.intellij.psi.PsiEnumConstant.
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: WrongRetentionDetector.java From dagger-reflect with Apache License 2.0 | 5 votes |
@NotNull private static String getQualifiedNameForValueJava( @NotNull JavaContext context, @Nullable UExpression annotationValue) { final Object evaluatedAnnotationValue = ConstantEvaluator.evaluate(context, annotationValue); if (evaluatedAnnotationValue instanceof PsiEnumConstant) { return UastLintUtils.getQualifiedName((PsiEnumConstant) evaluatedAnnotationValue); } throw new IllegalStateException("RetentionPolicy must not be null if @Retention is present"); }
Example #2
Source File: AbstractPropertiesProvider.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
/** * Get or create the update hint from the given type. * * @param collector * @param type the type. * @return the hint name. */ protected String updateHint(IPropertiesCollector collector, PsiClass type) { if (type == null) { return null; } if (type.isEnum()) { // Register Enumeration in "hints" section //String hint = ClassUtil.getJVMClassName(type); String hint = type.getQualifiedName(); if (!collector.hasItemHint(hint)) { ItemHint itemHint = collector.getItemHint(hint); itemHint.setSourceType(hint); if (type instanceof PsiClassImpl) { itemHint.setSource(Boolean.TRUE); } PsiElement[] children = type.getChildren(); for (PsiElement c : children) { if (c instanceof PsiEnumConstant) { String enumName = ((PsiEnumConstant) c).getName(); // TODO: extract Javadoc String description = null; ValueHint value = new ValueHint(); value.setValue(enumName); itemHint.getValues().add(value); } } } return hint; } return null; }
Example #3
Source File: SuggestionServiceImpl.java From component-runtime with Apache License 2.0 | 5 votes |
private Stream<Suggestion> fromConfiguration(final String family, final String configurationName, final PsiClass configClazz) { return Stream .concat(of(configClazz.getAllFields()) .filter(field -> AnnotationUtil.findAnnotation(field, OPTION) != null) .flatMap(field -> { final PsiAnnotation fOption = AnnotationUtil.findAnnotation(field, OPTION); final PsiAnnotationMemberValue fOptionValue = fOption.findAttributeValue("value"); String fieldName = removeQuotes(fOptionValue.getText()); if (fieldName.isEmpty()) { fieldName = field.getName(); } final Suggestion displayNameSuggestion = new Suggestion(configurationName + "." + fieldName + "." + DISPLAY_NAME, Suggestion.Type.Configuration); final PsiType type = field.getType(); if ("java.lang.String".equals(type.getCanonicalText())) { return Stream .of(displayNameSuggestion, new Suggestion(configurationName + "." + fieldName + "." + PLACEHOLDER, Suggestion.Type.Configuration)); } final PsiClass clazz = findClass(type); if (clazz != null && clazz.isEnum()) { return Stream .concat(Stream.of(displayNameSuggestion), Stream .of(clazz.getFields()) .filter(PsiEnumConstant.class::isInstance) .map(f -> clazz .getName() .substring(clazz.getName().lastIndexOf('.') + 1) + '.' + f.getName() + "._displayName") .map(v -> new Suggestion(v, Suggestion.Type.Configuration))); } return Stream.of(displayNameSuggestion); }), extractConfigTypes(family, configClazz)); }