Java Code Examples for com.intellij.psi.PsiClass#getQualifiedName()
The following examples show how to use
com.intellij.psi.PsiClass#getQualifiedName() .
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: DeployableJarRunConfigurationProducer.java From intellij with Apache License 2.0 | 6 votes |
@Override protected boolean doIsConfigFromContext( ApplicationConfiguration configuration, ConfigurationContext context) { PsiClass mainClass = configuration.getMainClass(); if (mainClass == null || mainClass.getQualifiedName() == null) { return false; } if (configuration.getVMParameters() == null) { return false; } ScObject mainObject = getMainObject(context); if (mainObject == null) { return false; } TargetInfo target = findTarget(context.getProject(), mainObject); if (target == null) { return false; } return mainClass.getQualifiedName().equals(mainObject.qualifiedName()) && configuration .getVMParameters() .endsWith(String.format("%s_deploy.jar", target.label.targetName())); }
Example 2
Source File: AbstractTypeDeclarationPropertiesProvider.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
@Override public void collectProperties(PsiModifierListOwner match, SearchContext context) { if (match instanceof PsiClass) { PsiClass type = (PsiClass) match; String className = type.getQualifiedName(); String[] names = getTypeNames(); for (String name : names) { if (name.equals(className)) { try { // Collect properties from the class name and stop the loop. processClass(type, className, context); break; } catch (Exception e) { LOGGER.error("Cannot compute MicroProfile properties for the Java class '" + className + "'.", e); } } } } }
Example 3
Source File: ProducerUtils.java From intellij with Apache License 2.0 | 6 votes |
/** * Based on {@link JUnitUtil#isTestClass}. We don't use that directly because it returns true for * all inner classes of a test class, regardless of whether they're also test classes. */ public static boolean isTestClass(PsiClass psiClass) { if (psiClass.getQualifiedName() == null) { return false; } if (JUnitUtil.isJUnit5(psiClass) && JUnitUtil.isJUnit5TestClass(psiClass, true)) { return true; } if (!PsiClassUtil.isRunnableClass(psiClass, true, true)) { return false; } if (isJUnit4Class(psiClass)) { return true; } if (isTestCaseInheritor(psiClass)) { return true; } return CachedValuesManager.getCachedValue( psiClass, () -> CachedValueProvider.Result.create( hasTestOrSuiteMethods(psiClass), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT)); }
Example 4
Source File: ClassPackagePathHeuristic.java From intellij with Apache License 2.0 | 5 votes |
private static boolean doMatchesSource(PsiClassOwner source, String targetName) { for (PsiClass psiClass : source.getClasses()) { String qualifiedName = psiClass.getQualifiedName(); if (qualifiedName == null) { continue; } String classPackagePath = psiClass.getQualifiedName().replace('.', '/'); if (targetName.contains(classPackagePath)) { return true; } } return false; }
Example 5
Source File: JavaBinaryContextProvider.java From intellij with Apache License 2.0 | 5 votes |
@Nullable private static TargetIdeInfo getTarget(Project project, PsiClass mainClass) { File mainClassFile = RunUtil.getFileForClass(mainClass); if (mainClassFile == null) { return null; } Collection<TargetIdeInfo> javaBinaryTargets = findJavaBinaryTargets(project, mainClassFile); String qualifiedName = mainClass.getQualifiedName(); String className = mainClass.getName(); if (qualifiedName == null || className == null) { // out of date psi element; just take the first match return Iterables.getFirst(javaBinaryTargets, null); } // first look for a matching main_class TargetIdeInfo match = javaBinaryTargets.stream() .filter( target -> target.getJavaIdeInfo() != null && qualifiedName.equals(target.getJavaIdeInfo().getJavaBinaryMainClass())) .findFirst() .orElse(null); if (match != null) { return match; } match = javaBinaryTargets.stream() .filter(target -> className.equals(target.getKey().getLabel().targetName().toString())) .findFirst() .orElse(null); if (match != null) { return match; } return Iterables.getFirst(javaBinaryTargets, null); }
Example 6
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 7
Source File: BlazeJUnitTestFilterFlags.java From intellij with Apache License 2.0 | 5 votes |
/** * Builds the JUnit test filter corresponding to the given class and methods.<br> * Returns null if no class name can be found. */ @Nullable private static String testFilterForClassAndMethods( PsiClass psiClass, JUnitVersion version, List<String> methodFilters, ParameterizedTestInfo parameterizedTestInfo) { String className = psiClass.getQualifiedName(); if (className == null) { return null; } return testFilterForClassAndMethods(className, version, methodFilters, parameterizedTestInfo); }
Example 8
Source File: JavaPsiUtil.java From idea-android-studio-plugin with GNU General Public License v2.0 | 5 votes |
public static boolean isInstanceOf(PsiClass instance, PsiClass interfaceExtendsClass) { String className = interfaceExtendsClass.getQualifiedName(); if(className == null) { return true; } if(className.equals(instance.getQualifiedName())) { return true; } for(PsiClassType psiClassType: PsiClassImplUtil.getExtendsListTypes(instance)) { PsiClass resolve = psiClassType.resolve(); if(resolve != null) { if(className.equals(resolve.getQualifiedName())) { return true; } } } for(PsiClass psiInterface: PsiClassImplUtil.getInterfaces(instance)) { if(className.equals(psiInterface.getQualifiedName())) { return true; } } return false; }
Example 9
Source File: PsiUtils.java From data-mediator with Apache License 2.0 | 5 votes |
public static String getNonGenericType(PsiType type) { if (type instanceof PsiClassType) { PsiClassType pct = (PsiClassType) type; final PsiClass psiClass = pct.resolve(); return psiClass != null ? psiClass.getQualifiedName() : null; } return type.getCanonicalText(); }
Example 10
Source File: HaxeSubtypesHierarchyTreeStructure.java From intellij-haxe with Apache License 2.0 | 5 votes |
private static boolean isThisTypeASubTypeOfTheSuperType(PsiClass thisType, PsiClass theSuperType) { if (!thisType.isValid()) return false; final String tcfqn = thisType.getQualifiedName(); final String pscfqn = theSuperType.getQualifiedName(); if (pscfqn.equals(tcfqn)) return false; // it's the same class in LHS & RHS final ArrayList<PsiClass> allSuperTypes = getSuperTypesAsList(thisType); for (PsiClass aSuperType : allSuperTypes) { if (pscfqn.equals(aSuperType.getQualifiedName())) { return true; } } return false; }
Example 11
Source File: ScalaTestContextProvider.java From intellij with Apache License 2.0 | 4 votes |
private static String getTestFilter(PsiClass testClass) { // TODO: may need to append '#' if implementation changes. // https://github.com/bazelbuild/rules_scala/pull/216 return testClass.getQualifiedName(); }
Example 12
Source File: MixinImplementsMixinType.java From attic-polygene-java with Apache License 2.0 | 4 votes |
@Override public final ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass, @NotNull InspectionManager manager, boolean isOnTheFly ) { // If psiClass is not an interface, ignore if( !psiClass.isInterface() ) { return null; } // If @Mixins annotation is empty, ignore List<PsiAnnotationMemberValue> mixinAnnotationValues = getMixinsAnnotationValue( psiClass ); if( mixinAnnotationValues.isEmpty() ) { return null; } // Get all valid mixin type Set<PsiClass> validMixinsType = getAllValidMixinTypes( psiClass ); if( validMixinsType.isEmpty() ) { return null; } // For each mixin List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>(); for( PsiAnnotationMemberValue mixinAnnotationValue : mixinAnnotationValues ) { PsiJavaCodeReferenceElement mixinClassReference = getMixinClassReference( mixinAnnotationValue ); // If it's not a class reference, ignore if( mixinClassReference == null ) { continue; } // If class reference can't be resolved, ignore PsiClass mixinClass = (PsiClass) mixinClassReference.resolve(); if( mixinClass == null ) { continue; } String mixinQualifiedName = mixinClass.getQualifiedName(); boolean isMixinsDeclarationValid = false; String message = ""; if( mixinClass.isInterface() ) { // Mixin can't be an interface message = message( "mixin.implements.mixin.type.error.mixin.is.an.interface", mixinQualifiedName ); } else if( isAConcern( mixinClass ) ) { // Mixin can't be a concern message = message( "mixin.implements.mixin.type.error.mixin.is.a.concern", mixinQualifiedName ); } else if( isASideEffect( mixinClass ) ) { // Mixin can't be a side effect message = message( "mixin.implements.mixin.type.error.mixin.is.a.side.effect", mixinQualifiedName ); } else { // If doesn't implement any mixin type, it's a problem if( !isImplementValidMixinType( mixinClass, validMixinsType ) ) { message = message( "mixin.implements.mixin.type.error.does.not.implement.any.mixin.type", mixinQualifiedName, psiClass.getQualifiedName() ); } else { isMixinsDeclarationValid = true; } } if( !isMixinsDeclarationValid ) { ProblemDescriptor problemDescriptor = createProblemDescriptor( manager, mixinAnnotationValue, mixinClassReference, message ); problems.add( problemDescriptor ); } } return problems.toArray( new ProblemDescriptor[problems.size()] ); }
Example 13
Source File: ReplacingConsumerTest.java From litho with Apache License 2.0 | 4 votes |
TestLookupElement(PsiClass cls) { name = cls.getQualifiedName(); mock = cls; }
Example 14
Source File: ConfigElementsUtils.java From aircon with MIT License | 4 votes |
private static String getEnumConfigImplClass(final PsiAnnotation annotation) { final PsiClass enumClass = getEnumClassAttribute(annotation); return enumClass.getQualifiedName(); }
Example 15
Source File: PsiTypeUtils.java From intellij-quarkus with Eclipse Public License 2.0 | 4 votes |
public static String getPropertyType(PsiClass psiClass, String typeName) { return psiClass != null ? psiClass.getQualifiedName() : typeName; }
Example 16
Source File: ClassFQN.java From intellij-reference-diagram with Apache License 2.0 | 4 votes |
public static ClassFQN create(PsiClass psiClass) { String className = psiClass.getQualifiedName(); return new ClassFQN(className); }
Example 17
Source File: PsiTypeUtil.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Nullable public static String getQualifiedName(@NotNull PsiType psiType) { final PsiClass psiFieldClass = PsiUtil.resolveClassInType(psiType); return psiFieldClass != null ? psiFieldClass.getQualifiedName() : null; }
Example 18
Source File: MicroProfileFaultToleranceProvider.java From intellij-quarkus with Eclipse Public License 2.0 | 4 votes |
private void collectProperties(IPropertiesCollector collector, AnnotationInfo info, PsiMember annotatedClassOrMethod, PsiAnnotation mpftAnnotation, MicroProfileFaultToleranceContext mpftContext) { String annotationName = info.getSimpleName(); String className = null; String methodName = null; boolean binary = false; String sourceType = null; String sourceMethod = null; if (annotatedClassOrMethod != null) { binary = PsiTypeUtils.isBinary(annotatedClassOrMethod); if (annotatedClassOrMethod instanceof PsiClass) { PsiClass annotatedClass = (PsiClass) annotatedClassOrMethod; className = annotatedClass.getQualifiedName(); // Check if properties has been generated for the <classname><annotation>: if (isProcessed(className, annotationName, mpftContext)) { return; } sourceType = getPropertyType(annotatedClass, className); } else if (annotatedClassOrMethod instanceof PsiMethod) { PsiMethod annotatedMethod = (PsiMethod) annotatedClassOrMethod; className = annotatedMethod.getContainingClass().getQualifiedName(); methodName = annotatedMethod.getName(); sourceType = getSourceType(annotatedMethod); sourceMethod = getSourceMethod(annotatedMethod); } } else { // Check if properties has been generated for the <annotation>: if (isProcessed(null, annotationName, mpftContext)) { return; } } String prefix = createPrefix(className, methodName, annotationName); // parameter List<AnnotationParameter> parameters = info.getParameters(); for (AnnotationParameter parameter : parameters) { String propertyName = new StringBuilder(prefix).append('/').append(parameter.getName()).toString(); String parameterType = parameter.getType(); String description = parameter.getDescription(); String defaultValue = getParameterDefaultValue(parameter, mpftAnnotation); String extensionName = null; if (annotatedClassOrMethod == null) { sourceType = parameter.getSourceType(); sourceMethod = parameter.getSourceMethod(); } // Enumerations PsiClass jdtType = parameter.getJDTType(); super.updateHint(collector, jdtType); super.addItemMetadata(collector, propertyName, parameterType, description, sourceType, null, sourceMethod, defaultValue, extensionName, binary); } }
Example 19
Source File: QuarkusConfigPropertiesProvider.java From intellij-quarkus with Eclipse Public License 2.0 | 4 votes |
private void populateConfigObject(PsiClass configPropertiesType, String prefixStr, String extensionName, Set<PsiClass> typesAlreadyProcessed, PsiAnnotation configPropertiesAnnotation, ConfigPropertiesContext configPropertiesContext, IPropertiesCollector collector) { if (typesAlreadyProcessed.contains(configPropertiesType)) { return; } typesAlreadyProcessed.add(configPropertiesType); PsiElement[] elements = configPropertiesType.getChildren(); // Loop for each fields. for (PsiElement child : elements) { if (child instanceof PsiField) { // The following code is an adaptation for JDT of // Quarkus arc code: // https://github.com/quarkusio/quarkus/blob/e8606513e1bd14f0b1aaab7f9969899bd27c55a3/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/configproperties/ClassConfigPropertiesUtil.java#L211 PsiField field = (PsiField) child; boolean useFieldAccess = false; String setterName = JavaBeanUtil.getSetterName(field.getName()); String configClassInfo = configPropertiesType.getQualifiedName(); PsiMethod setter = findMethod(configPropertiesType, setterName, field.getType()); if (setter == null) { if (!field.getModifierList().hasModifierProperty(PsiModifier.PUBLIC) || field.getModifierList().hasModifierProperty(PsiModifier.FINAL)) { LOGGER.info("Configuration properties class " + configClassInfo + " does not have a setter for field " + field + " nor is the field a public non-final field"); continue; } useFieldAccess = true; } if (!useFieldAccess && !setter.getModifierList().hasModifierProperty(PsiModifier.PUBLIC)) { LOGGER.info("Setter " + setterName + " of class " + configClassInfo + " must be public"); continue; } String name = field.getName(); // The default value is managed with assign like : 'public String suffix = "!"'; // Getting "!" value is possible but it requires to re-parse the Java file to // build a DOM CompilationUnit to extract assigned value. final String defaultValue = null; String propertyName = prefixStr + "." + convertName(name, field, configPropertiesAnnotation, configPropertiesContext); String fieldTypeName = PsiTypeUtils.getResolvedTypeName(field); PsiClass fieldClass = PsiTypeUtils.findType(field.getManager(), fieldTypeName); if (PsiTypeUtils.isSimpleFieldType(fieldClass, fieldTypeName)) { // Class type String type = PsiTypeUtils.getPropertyType(fieldClass, fieldTypeName); // Javadoc String description = null; // field and class source String sourceType = PsiTypeUtils.getSourceType(field); String sourceField = PsiTypeUtils.getSourceField(field); // Enumerations super.updateHint(collector, fieldClass); ItemMetadata metadata = super.addItemMetadata(collector, propertyName, type, description, sourceType, sourceField, null, defaultValue, extensionName, PsiTypeUtils.isBinary(field)); PsiQuarkusUtils.updateConverterKinds(metadata, field, fieldClass); } else { populateConfigObject(fieldClass, propertyName, extensionName, typesAlreadyProcessed, configPropertiesAnnotation, configPropertiesContext, collector); } } } }
Example 20
Source File: ElementUtils.java From aircon with MIT License | 4 votes |
public static String getQualifiedName(final PsiType type) { final PsiClass psiClass = PsiTypesUtil.getPsiClass(type); return psiClass != null ? psiClass.getQualifiedName() : JAVA_LANG_PACKAGE + type.getPresentableText(); }