Search in sources :

Example 46 with Nullable

use of org.jetbrains.annotations.Nullable in project scss-lint-plugin by idok.

the class ScssLintAnnotationResult method createAnnotation.

@Nullable
public static Annotation createAnnotation(@NotNull AnnotationHolder holder, @NotNull HighlightSeverity severity, @Nullable TextAttributes forcedTextAttributes, @NotNull TextRange range, @NotNull String message) {
    if (forcedTextAttributes != null) {
        Annotation annotation = createAnnotation(holder, severity, range, message);
        annotation.setEnforcedTextAttributes(forcedTextAttributes);
        return annotation;
    }
    return createAnnotation(holder, severity, range, message);
}
Also used : Annotation(com.intellij.lang.annotation.Annotation) Nullable(org.jetbrains.annotations.Nullable)

Example 47 with Nullable

use of org.jetbrains.annotations.Nullable in project qi4j-sdk by Qi4j.

the class InvocationAnnotationDeclaredCorrectlyInspection method verifyAnnotationDeclaredCorrectly.

@Nullable
protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly(@NotNull PsiVariable psiVariable, @NotNull PsiAnnotation invocationAnnotation, @NotNull InspectionManager manager) {
    LocalQuickFix fix = null;
    String message = null;
    String variableTypeQualifiedName = psiVariable.getType().getCanonicalText();
    InvocationAnnotationDeclarationValidationResult validationResult = isValidInvocationAnnotationDeclaration(psiVariable);
    switch(validationResult) {
        case invalidTypeIsInjectedViaStructureAnnotation:
            if (getStructureAnnotation(psiVariable) == null) {
                fix = new ReplaceWithStructureAnnotation(message("injections.invocation.annotation.declared.correctly.fix.replace.with.structure.annotation"), invocationAnnotation);
            }
            message = message("injections.invocation.annotation.declared.correctly.error.type.is.injected.by.structure", variableTypeQualifiedName);
            break;
        case invalidType:
            message = message("injections.invocation.annotation.declared.correctly.error.type.is.not.injectable", variableTypeQualifiedName);
            break;
    }
    // If it's not an error, return null
    if (message == null) {
        return null;
    }
    // If Fix not defined, by default we remove it.
    if (fix == null) {
        fix = createRemoveAnnotationFix(invocationAnnotation);
    }
    ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(invocationAnnotation, message, fix, GENERIC_ERROR_OR_WARNING);
    return new ProblemDescriptor[] { problemDescriptor };
}
Also used : InvocationAnnotationDeclarationValidationResult(org.qi4j.ide.plugin.idea.injections.invocation.common.Qi4jInvocationAnnotationUtil.InvocationAnnotationDeclarationValidationResult) ReplaceWithStructureAnnotation(org.qi4j.ide.plugin.idea.injections.structure.common.ReplaceWithStructureAnnotation) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) Nullable(org.jetbrains.annotations.Nullable)

Example 48 with Nullable

use of org.jetbrains.annotations.Nullable in project qi4j-sdk by Qi4j.

the class ServiceAnnotationDeclaredCorrectlyInspection method verifyAnnotationDeclaredCorrectly.

@Nullable
protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly(@NotNull PsiVariable psiVariable, @NotNull PsiAnnotation serviceAnnotation, @NotNull InspectionManager manager) {
    ServiceAnnotationDeclarationValidationResult annotationCheck = isValidServiceAnnotationDeclaration(psiVariable);
    String message = null;
    LocalQuickFix fix = null;
    switch(annotationCheck) {
        case invalidTypeIsInjectedViaStructureAnnotation:
            if (getStructureAnnotation(psiVariable) == null) {
                fix = new ReplaceWithStructureAnnotation(message("injections.service.annotation.declared.correctly.fix.replace.with.structure.annotation"), serviceAnnotation);
            }
            message = message("injections.service.annotation.declared.correctly.error.type.is.injected.by.structure", psiVariable.getType().getCanonicalText());
            break;
    }
    // If it's not an error, return null
    if (message == null) {
        return null;
    }
    // Default behavior to remove @Service annotation
    if (fix == null) {
        fix = createRemoveAnnotationFix(serviceAnnotation);
    }
    ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(serviceAnnotation, message, fix, GENERIC_ERROR_OR_WARNING);
    return new ProblemDescriptor[] { problemDescriptor };
}
Also used : ReplaceWithStructureAnnotation(org.qi4j.ide.plugin.idea.injections.structure.common.ReplaceWithStructureAnnotation) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) ServiceAnnotationDeclarationValidationResult(org.qi4j.ide.plugin.idea.injections.service.common.Qi4jServiceAnnotationUtil.ServiceAnnotationDeclarationValidationResult) Nullable(org.jetbrains.annotations.Nullable)

Example 49 with Nullable

use of org.jetbrains.annotations.Nullable in project qi4j-sdk by Qi4j.

the class StructureAnnotationDeclaredCorrectlyInspection method verifyAnnotationDeclaredCorrectly.

@Nullable
protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly(@NotNull PsiVariable psiVariable, @NotNull PsiAnnotation structureAnnotation, @NotNull InspectionManager manager) {
    StructureAnnotationDeclarationValidationResult annotationCheck = validateStructureAnnotationDeclaration(psiVariable);
    switch(annotationCheck) {
        case invalidInjectionType:
            String message = message("injections.structure.annotation.declared.correctly.error.invalid.injection.type", psiVariable.getType().getCanonicalText());
            AbstractFix removeStructureAnnotationFix = createRemoveAnnotationFix(structureAnnotation);
            ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(structureAnnotation, message, removeStructureAnnotationFix, GENERIC_ERROR_OR_WARNING);
            return new ProblemDescriptor[] { problemDescriptor };
    }
    return null;
}
Also used : StructureAnnotationDeclarationValidationResult(org.qi4j.ide.plugin.idea.injections.structure.common.Qi4jStructureAnnotationUtil.StructureAnnotationDeclarationValidationResult) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) AbstractFix(org.qi4j.ide.plugin.idea.common.inspections.AbstractFix) Nullable(org.jetbrains.annotations.Nullable)

Example 50 with Nullable

use of org.jetbrains.annotations.Nullable in project qi4j-sdk by Qi4j.

the class Qi4jSideEffectUtil method getSideEffectOfClass.

/**
     * @param searchContext Search context.
     * @return {@code SideEffectOf} class given the search context. {@code null} if not found.
     * @since 0.1
     */
@Nullable
public static PsiClass getSideEffectOfClass(@NotNull PsiElement searchContext) {
    Project project = searchContext.getProject();
    GlobalSearchScope searchScope = determineSearchScope(searchContext);
    return getSideEffectOfClass(project, searchScope);
}
Also used : Project(com.intellij.openapi.project.Project) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)4694 VirtualFile (com.intellij.openapi.vfs.VirtualFile)812 PsiElement (com.intellij.psi.PsiElement)485 File (java.io.File)405 Project (com.intellij.openapi.project.Project)396 PsiFile (com.intellij.psi.PsiFile)320 NotNull (org.jetbrains.annotations.NotNull)259 IOException (java.io.IOException)247 Module (com.intellij.openapi.module.Module)227 ArrayList (java.util.ArrayList)178 TextRange (com.intellij.openapi.util.TextRange)156 Document (com.intellij.openapi.editor.Document)124 List (java.util.List)116 ASTNode (com.intellij.lang.ASTNode)105 IElementType (com.intellij.psi.tree.IElementType)103 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)102 XmlTag (com.intellij.psi.xml.XmlTag)96 Editor (com.intellij.openapi.editor.Editor)94 Element (org.jdom.Element)93 XmlFile (com.intellij.psi.xml.XmlFile)78