Package com.intellij.codeInspection

Examples of com.intellij.codeInspection.ProblemDescriptor


        unregisterEventListener();
        break;
      case NEW_BUG_INSTANCE:
        final BugInstance bugInstance = event.getBugInstance();
        if (bugInstance != null) {
          final ProblemDescriptor problemDescriptor = createProblemDescriptor(bugInstance);
          if (problemDescriptor != null) {
            _problems.add(problemDescriptor);
          }
        }
        break;
View Full Code Here


        // If @Concerns declared in class, suggest remove @Concerns annotation
        if( !psiClass.isInterface() )
        {
            String message = message( "concerns.annotation.declared.correctly.error.annotation.declared.in.class" );
            RemoveConcernsAnnotationFix fix = new RemoveConcernsAnnotationFix( concernsAnnotation );
            ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( concernsAnnotation, message, fix,
                                                                                   GENERIC_ERROR_OR_WARNING );
            return new ProblemDescriptor[]{ problemDescriptor };
        }

        // If @Concerns annotation is empty, ignore
        List<PsiAnnotationMemberValue> concernsAnnotationValue = getConcernsAnnotationValue( concernsAnnotation );
        if( concernsAnnotationValue.isEmpty() )
        {
            return null;
        }

        // If ConcernOfClass is not resolved, ignore
        Project project = psiClass.getProject();
        GlobalSearchScope searchScope = determineSearchScope( psiClass );
        PsiClass concernOfClass = getConcernOfClass( project, searchScope );
        if( concernOfClass == null )
        {
            return null;
        }

        List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
        for( PsiAnnotationMemberValue concernClassAnnotationValue : concernsAnnotationValue )
        {
            PsiJavaCodeReferenceElement concernClassReference = getConcernClassReference( concernClassAnnotationValue );

            // If it's not a class reference, ignore
            if( concernClassReference == null )
            {
                continue;
            }

            // If class reference can't be resolved, ignore
            PsiClass concernClass = (PsiClass) concernClassReference.resolve();
            if( concernClass == null )
            {
                continue;
            }

            // If concern class does not inherit concern class, suggest remove that reference.
            if( !concernClass.isInheritor( concernOfClass, true ) )
            {
                String message = Qi4jResourceBundle.message(
                    "concerns.annotation.declared.correctly.error.concern.class.does.not.extend.ConcernOf",
                    concernClass.getQualifiedName()
                );

                RemoveInvalidConcernClassReferenceFix fix = new RemoveInvalidConcernClassReferenceFix(
                    concernClassAnnotationValue, concernClassReference
                );
                ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
                    concernClassAnnotationValue, message, fix, GENERIC_ERROR_OR_WARNING );
                problems.add( problemDescriptor );
            }
            else
            {
View Full Code Here

            return null;
        }

        String message = message( "mixins.annotation.declared.on.mixin.type.error.declared.on.class" );
        RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix( mixinsAnnotation );
        ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( mixinsAnnotation, message, fix,
                                                                               GENERIC_ERROR_OR_WARNING );
        return new ProblemDescriptor[]{ problemDescriptor };

    }
View Full Code Here

                }
            }

            if( !isMixinsDeclarationValid )
            {
                ProblemDescriptor problemDescriptor = createProblemDescriptor(
                    manager, mixinAnnotationValue, mixinClassReference, message );
                problems.add( problemDescriptor );
            }
        }
View Full Code Here

        {
            // Suggest remove applies to
            String message = message(
                "applies.to.annotation.declared.correctly.error.annotation.must.be.declared.on.class"
            );
            ProblemDescriptor problemDescriptor = createRemoveAppliesToFilterProblemDescriptor(
                manager, message, appliesToAnnotation );
            return new ProblemDescriptor[]{ problemDescriptor };
        }

        // If @AppliesTo annotation is empty, ignore
        List<PsiAnnotationMemberValue> appliesToAnnotationValues = getAppliesToAnnotationValue( appliesToAnnotation );
        if( appliesToAnnotationValues.isEmpty() )
        {
            return null;
        }

        // If AppliesToFilter is not resolved, ignore
        Project project = psiClass.getProject();
        GlobalSearchScope searchScope = determineSearchScope( psiClass );
        PsiClass appliesToFilterClass = getAppliesToFilterClass( project, searchScope );
        if( appliesToFilterClass == null )
        {
            return null;
        }

        boolean classIsAConcern = isAConcern( psiClass );
        boolean classIsASideEffect = isASideEffect( psiClass );
        boolean classIsAGenericConcern = classIsAConcern && isAGenericConcern( psiClass );
        boolean classIsAGenericSideEffect = classIsASideEffect && isAGenericSideEffect( psiClass );
        boolean classIsAMixin = !classIsAConcern && !classIsASideEffect;
        boolean classIsAGenericMixin = classIsAMixin && isImplementsInvocationHandler( psiClass );

        List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
        for( PsiAnnotationMemberValue appliesToAnnotationValue : appliesToAnnotationValues )
        {
            PsiJavaCodeReferenceElement appliesToValueClassReference =
                getAppliesToValueClassReference( appliesToAnnotationValue );

            // If it's not a class reference, ignore
            if( appliesToValueClassReference == null )
            {
                continue;
            }

            // If class reference can't be resolved, ignore
            PsiClass appliesToValueClass = (PsiClass) appliesToValueClassReference.resolve();
            if( appliesToValueClass == null )
            {
                continue;
            }

            String appliesToValueQualifiedName = appliesToValueClass.getQualifiedName();
            boolean appliesToValueIsAnAnnotation = appliesToValueClass.isAnnotationType();
            boolean appliesToValueIsImplementingAppliesToFilter =
                appliesToValueClass.isInheritor( appliesToFilterClass, true );

            String message = null;
            if( appliesToValueIsAnAnnotation && classIsAMixin )
            {
                // If Class is a mixin and appliesToValueClass is an annotation
                message = message(
                    "applies.to.annotation.declared.correctly.error.value.is.invalid.for.mixin",
                    appliesToValueQualifiedName
                );
            }
            else if( appliesToValueIsAnAnnotation || appliesToValueIsImplementingAppliesToFilter )
            {
                if( classIsAConcern && !classIsAGenericConcern )
                {
                    // If psiClass is a concern but not generic concern
                    message = message(
                        "applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericConcern",
                        appliesToValueQualifiedName, classQualifiedName
                    );
                }
                else if( classIsASideEffect && !classIsAGenericSideEffect )
                {
                    // If psiClass a side effect but not a generic side effect
                    message = message(
                        "applies.to.annotation.declared.correctly.error.value.requires.class.to.extends.GenericSideEffect",
                        appliesToValueQualifiedName, classQualifiedName
                    );
                }
                else if( appliesToValueIsImplementingAppliesToFilter && !classIsAGenericMixin )
                {
                    message = message(
                        "applies.to.annotation.declared.correctly.error.value.requires.class.to.implements.InvocationHandler",
                        appliesToValueQualifiedName, classQualifiedName
                    );
                }
            }
            else if( appliesToValueClass.isInterface() )
            {
                if( !psiClass.isInheritor( appliesToValueClass, true ) &&
                    !( classIsAGenericConcern || classIsAGenericSideEffect ) )
                {
                    // If psiClass does not implement that interface and it's not a generic concern or generic side effect
                    if( classIsAConcern )
                    {
                        message = message(
                            "applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericConcern",
                            appliesToValueQualifiedName, classQualifiedName );
                    }
                    else if( classIsASideEffect )
                    {
                        message = message(
                            "applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.interface.or.extends.GenericSideEffect",
                            appliesToValueQualifiedName, classQualifiedName );
                    }
                    else
                    {
                        message = message(
                            "applies.to.annotation.declared.correctly.error.value.requires.class.to.implement.value.interface.or.implements.InvocationHandler",
                            appliesToValueQualifiedName, classQualifiedName );
                    }
                }
            }
            else
            {
                if( classIsAMixin )
                {
                    message = message(
                        "applies.to.annotation.declared.correctly.error.value.is.invalid.for.mixin",
                        appliesToValueQualifiedName
                    );
                }
                else
                {
                    message = message(
                        "applies.to.annotation.declared.correctly.error.annotation.value.is.invalid.for.non.mixin",
                        appliesToValueQualifiedName
                    );
                }
            }

            if( message != null )
            {
                ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
                    appliesToAnnotationValue,
                    message,
                    new RemoveAnnotationValueFix( appliesToAnnotationValue, appliesToValueClassReference ),
                    GENERIC_ERROR_OR_WARNING );
                problems.add( problemDescriptor );
View Full Code Here

        if( fix == null )
        {
            fix = createRemoveAnnotationFix( serviceAnnotation );
        }

        ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
            serviceAnnotation, message, fix, GENERIC_ERROR_OR_WARNING );
        return new ProblemDescriptor[]{ problemDescriptor };
    }
View Full Code Here

        {
            if( modifierList.hasModifierProperty( com.intellij.psi.PsiModifier.STATIC ) )
            {
                String message = getInjectionAnnotationValidDeclarationMessage();
                AbstractFix removeAnnotationFix = createRemoveAnnotationFix( annotationToCheck );
                ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
                    annotationToCheck, message, removeAnnotationFix, com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING
                );

                return new ProblemDescriptor[]{ problemDescriptor };
            }
View Full Code Here

                PsiAnnotation annotationToCheck = getAnnotationToCheck( parameter );
                if( annotationToCheck != null )
                {
                    String message = getInjectionAnnotationValidDeclarationMessage();
                    AbstractFix removeAnnotationFix = createRemoveAnnotationFix( annotationToCheck );
                    ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
                        annotationToCheck, message, removeAnnotationFix, GENERIC_ERROR_OR_WARNING
                    );
                    problems.add( problemDescriptor );
                }
            }
View Full Code Here

        // If @SideEffects declared in class, suggest remove @SideEffects annotation
        if( !psiClass.isInterface() )
        {
            String message = message( "side.effects.annotation.declared.correctly.error.annotation.declared.in.class" );
            RemoveSideEffectsAnnotationFix fix = new RemoveSideEffectsAnnotationFix( sideEffectsAnnotation );
            ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( sideEffectsAnnotation, message, fix,
                                                                                   GENERIC_ERROR_OR_WARNING );
            return new ProblemDescriptor[]{ problemDescriptor };
        }

        // If @SideEffects annotation is empty, ignore
        List<PsiAnnotationMemberValue> sideEffectsAnnotationValue =
            getSideEffectsAnnotationValue( sideEffectsAnnotation );
        if( sideEffectsAnnotationValue.isEmpty() )
        {
            return null;
        }

        // If SideEffectOf is not resolved, ignore
        Project project = psiClass.getProject();
        GlobalSearchScope searchScope = determineSearchScope( psiClass );
        PsiClass sideEffectOfClass = Qi4jSideEffectUtil.getGenericSideEffectClass( project, searchScope );
        if( sideEffectOfClass == null )
        {
            return null;
        }

        List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
        for( PsiAnnotationMemberValue sideEffectClassReferenceWrapper : sideEffectsAnnotationValue )
        {
            PsiJavaCodeReferenceElement sideEffectClassReference =
                getSideEffectClassReference( sideEffectClassReferenceWrapper );

            // If it's not a class reference, ignore
            if( sideEffectClassReference == null )
            {
                continue;
            }

            // If class reference can't be resolved, ignore
            PsiClass sideEffectClass = (PsiClass) sideEffectClassReference.resolve();
            if( sideEffectClass == null )
            {
                continue;
            }

            // If side effect class does not inherit SideEffectOf class, suggest remove that reference.
            if( !sideEffectClass.isInheritor( sideEffectOfClass, true ) )
            {
                String message = Qi4jResourceBundle.message(
                    "side.effects.annotation.declared.correctly.error.side.effect.does.not.extend.side.effect.of",
                    sideEffectClass.getQualifiedName()
                );

                RemoveAnnotationValueFix fix = new RemoveAnnotationValueFix(
                    sideEffectClassReferenceWrapper, sideEffectClassReference
                );
                ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
                    sideEffectClassReferenceWrapper, message, fix, GENERIC_ERROR_OR_WARNING );
                problems.add( problemDescriptor );
            }
            else
            {
View Full Code Here

        if( fix == null )
        {
            fix = createRemoveAnnotationFix( invocationAnnotation );
        }

        ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
            invocationAnnotation, message, fix, GENERIC_ERROR_OR_WARNING );
        return new ProblemDescriptor[]{ problemDescriptor };
    }
View Full Code Here

TOP

Related Classes of com.intellij.codeInspection.ProblemDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.