Package com.intellij.lang.annotation

Examples of com.intellij.lang.annotation.Annotation$QuickFixInfo


                holder.createErrorAnnotation(namedPsiElement, "Invalid " + namedPsiElement.getElementType().getDescription());
            }
        }

        if (psiElement instanceof ChameleonPsiElement) {
            Annotation annotation = holder.createInfoAnnotation(psiElement, null);
            annotation.setTextAttributes(SQLTextAttributesKeys.CHAMELEON);
        }

        if (psiElement instanceof ExecutablePsiElementannotateExecutable(psiElement, holder);
    }
View Full Code Here


    }

    private void annotateToken(TokenPsiElement tokenPsiElement, AnnotationHolder holder) {
        TokenTypeCategory flavor = tokenPsiElement.getElementType().getFlavor();
        if (flavor != null) {
            Annotation annotation = holder.createInfoAnnotation(tokenPsiElement, null);
            switch (flavor) {
                case DATATYPE: annotation.setTextAttributes(SQLTextAttributesKeys.DATA_TYPE); break;
                case FUNCTION: annotation.setTextAttributes(SQLTextAttributesKeys.FUNCTION); break;
                case KEYWORD: annotation.setTextAttributes(SQLTextAttributesKeys.KEYWORD); break;
                case IDENTIFIER: annotation.setTextAttributes(SQLTextAttributesKeys.IDENTIFIER); break;
            }
        }
    }
View Full Code Here

        }*/
    }

    private void annotateAliasRef(IdentifierPsiElement aliasReference, AnnotationHolder holder) {
        if (aliasReference.resolve() == null) {
            Annotation annotation = holder.createWarningAnnotation(aliasReference, "Unknown identifier");
            annotation.setTextAttributes(PSQLTextAttributesKeys.UNKNOWN_IDENTIFIER);
        } else {
            Annotation annotation = holder.createInfoAnnotation(aliasReference, null);
            annotation.setTextAttributes(PSQLTextAttributesKeys.DATA_TYPE);
        }
    }
View Full Code Here

                            if (targetElement != null) {
                                NavigationAction navigationAction = targetContentType == DBContentType.CODE_BODY ?
                                        new NavigateToDefinitionAction(null, targetElement, objectType) :
                                        new NavigateToSpecificationAction(null, targetElement, objectType);
                                Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
                                NavigationGutterRenderer gutterIconRenderer = new NavigationGutterRenderer(navigationAction, GutterIconRenderer.Alignment.RIGHT);
                                annotation.setGutterIconRenderer(gutterIconRenderer);
                            }
                            NavigateToObjectAction navigateToObjectAction = new NavigateToObjectAction(identifierPsiElement.resolveUnderlyingObject(), objectType);
                            Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
                            annotation.setGutterIconRenderer(new NavigationGutterRenderer(navigateToObjectAction, GutterIconRenderer.Alignment.LEFT));


                        }
                    } else if (object.getContentType() == DBContentType.CODE_SPEC_AND_BODY) {
                        SourceCodeManager codeEditorManager = SourceCodeManager.getInstance(object.getProject());


                        BasePsiElement targetElement = codeEditorManager.getObjectNavigationElement(object, targetContentType, identifierPsiElement.getObjectType(), identifierPsiElement.getChars());
                        if (targetElement != null) {
                            NavigationAction navigationAction = targetContentType == DBContentType.CODE_BODY ?
                                    new NavigateToDefinitionAction(object, targetElement, objectType) :
                                    new NavigateToSpecificationAction(object, targetElement, objectType);
                            Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
                            annotation.setGutterIconRenderer(new NavigationGutterRenderer(navigationAction, GutterIconRenderer.Alignment.RIGHT));
                        }
                        NavigateToObjectAction navigateToObjectAction = new NavigateToObjectAction(identifierPsiElement.resolveUnderlyingObject(), objectType);
                        Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
                        annotation.setGutterIconRenderer(new NavigationGutterRenderer(navigateToObjectAction, GutterIconRenderer.Alignment.LEFT));
                    }
                }
            }
        }
    }
View Full Code Here

    private void annotateExecutable(PsiElement psiElement, AnnotationHolder holder) {
        ExecutablePsiElement executable = (ExecutablePsiElement) psiElement;
        if (!executable.isNestedExecutable()) {
            StatementExecutionProcessor executionProcessor = executable.getExecutionProcessor();
            if (executionProcessor != null) {
                Annotation annotation = holder.createInfoAnnotation(psiElement, null);
                annotation.setGutterIconRenderer(new StatementGutterRenderer(executionProcessor));
            }
        }
    }
View Full Code Here


  private static void addAnnotation(final ExtendedProblemDescriptor problemDescriptor, final List<ExtendedProblemDescriptor> matchingDescriptors, final PsiElement psiElement, @NotNull final AnnotationHolder annotationHolder) {
    final BugInstance bugInstance = problemDescriptor.getBugInstance();
    final int priority = bugInstance.getPriority();
    final Annotation annotation;
    final PsiElement problemElement = problemDescriptor.getPsiElement();
    final TextRange textRange = problemElement.getTextRange();


    switch (priority) {
      case Detector.HIGH_PRIORITY:

        if (psiElement instanceof PsiAnonymousClass) {
          final PsiElement firstChild = psiElement.getFirstChild();
          annotation = annotationHolder.createWarningAnnotation(firstChild == null ? psiElement : firstChild, getAnnotationText(matchingDescriptors));
          // todo: use color from annotation configuration
          annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.RED.brighter(), EffectType.BOXED, Font.PLAIN));
        } else {
          annotation = annotationHolder.createWarningAnnotation(textRange, getAnnotationText(matchingDescriptors));
          // todo: use color from annotation configuration
          annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.RED, EffectType.WAVE_UNDERSCORE, Font.PLAIN));
        }

        annotation.registerFix(new SuppressReportBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new SuppressReportBugForClassIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearAndSuppressBugIntentionAction(problemDescriptor), textRange);

        break;

      case Detector.NORMAL_PRIORITY:

        if (psiElement instanceof PsiAnonymousClass) {
          final PsiElement firstChild = psiElement.getFirstChild();
          annotation = annotationHolder.createWarningAnnotation(firstChild == null ? psiElement : firstChild, getAnnotationText(matchingDescriptors));
        } else {
          annotation = annotationHolder.createWarningAnnotation(textRange, getAnnotationText(matchingDescriptors));
        }

        // todo: use color from annotation configuration
        annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.YELLOW.darker(), EffectType.WAVE_UNDERSCORE, Font.PLAIN));

        annotation.registerFix(new SuppressReportBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new SuppressReportBugForClassIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearAndSuppressBugIntentionAction(problemDescriptor), textRange);

        break;

      case Detector.EXP_PRIORITY:

        if (problemElement instanceof PsiAnonymousClass) {
          final PsiElement firstChild = psiElement.getFirstChild();
          annotation = annotationHolder.createWarningAnnotation(firstChild == null ? psiElement : firstChild, getAnnotationText(matchingDescriptors));
        } else {
          annotation = annotationHolder.createWarningAnnotation(textRange, getAnnotationText(matchingDescriptors));
        }

        // todo: use color from annotation configuration
        annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.GRAY, EffectType.WAVE_UNDERSCORE, Font.PLAIN));

        annotation.registerFix(new SuppressReportBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new SuppressReportBugForClassIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearAndSuppressBugIntentionAction(problemDescriptor), textRange);

        break;
      case Detector.LOW_PRIORITY:

        if (psiElement instanceof PsiAnonymousClass) {
          final PsiElement firstChild = psiElement.getFirstChild();
          annotation = annotationHolder.createInfoAnnotation(firstChild == null ? psiElement : firstChild, getAnnotationText(matchingDescriptors));
        } else {
          annotation = annotationHolder.createInfoAnnotation(textRange, getAnnotationText(matchingDescriptors));
        }

        // todo: use color from annotation configuration
        annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.GREEN, EffectType.WAVE_UNDERSCORE, Font.PLAIN));

        annotation.registerFix(new SuppressReportBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new SuppressReportBugForClassIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearAndSuppressBugIntentionAction(problemDescriptor), textRange);

        break;
      case Detector.IGNORE_PRIORITY:
        if (problemElement instanceof PsiAnonymousClass) {
          final PsiElement firstChild = psiElement.getFirstChild();
          annotation = annotationHolder.createWarningAnnotation(firstChild == null ? psiElement : firstChild, getAnnotationText(matchingDescriptors));
          annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.MAGENTA.brighter(), EffectType.WAVE_UNDERSCORE, Font.PLAIN));
        } else {
          annotation = annotationHolder.createWarningAnnotation(textRange, getAnnotationText(matchingDescriptors));
        }

        // todo: use color from annotation configuration
        annotation.setEnforcedTextAttributes(new TextAttributes(null, null, JBColor.MAGENTA, EffectType.WAVE_UNDERSCORE, Font.PLAIN));

        annotation.registerFix(new SuppressReportBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new SuppressReportBugForClassIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearBugIntentionAction(problemDescriptor), textRange);
        annotation.registerFix(new ClearAndSuppressBugIntentionAction(problemDescriptor), textRange);

        break;
      default:
        throw new IllegalArgumentException("Unknown bugInstance.getPriority() == " + priority);
    }
View Full Code Here

    for (Pair<String, Integer> pair : HaxeStringUtil.getWordsWithOffset(nodeText)) {
      final String word = pair.getFirst();
      final int offset = pair.getSecond();
      final int absoluteOffset = node.getTextOffset() + offset;
      final TextRange range = new TextRange(absoluteOffset, absoluteOffset + word.length());
      final Annotation annotation = holder.createInfoAnnotation(range, null);
      final String attributeName = definitions.contains(word) ? HaxeSyntaxHighlighterColors.HAXE_DEFINED_VAR
                                                              : HaxeSyntaxHighlighterColors.HAXE_UNDEFINED_VAR;
      annotation.setTextAttributes(TextAttributesKey.find(attributeName));
      annotation.registerFix(new HaxeDefineIntention(word, definitions.contains(word)), range);
    }
  }
View Full Code Here

    }
  }

  public static Optional<Annotation> createAnnotation(AnnotationHolder holder, PsiFile psiFile, SonarIssue issue) {
    HighlightSeverity severity = SonarToIjSeverityMapping.toHighlightSeverity(issue.getSeverity());
    Annotation annotation;
    if (issue.getLine() == null) {
      annotation = createAnnotation(holder, issue.formattedMessage(), psiFile, severity);
      annotation.setFileLevelAnnotation(true);
    } else {
      Optional<PsiElement> startElement = Finders.findFirstElementAtLine(psiFile, issue.getLine());
      if (!startElement.isPresent()) {
        // There is no AST element on this line. Maybe a tabulation issue on a blank line?
        annotation = createAnnotation(holder, issue.formattedMessage(), Finders.getLineRange(psiFile, issue.getLine()), severity);
View Full Code Here

         /* @TODO: not working  firstChild.getNode().getElementType() == PhpDocElementTypes.DOC_TAG_NAME */
        if(firstChild == null) {
            return;
        }

        Annotation annotationHolder = parameter.getHolder().createWarningAnnotation(firstChild, "Import class");

        // clean warning; we dont want tooltip, but popover menu entry; @TODO: direct call possible?
        annotationHolder.setHighlightType(ProblemHighlightType.INFORMATION);
        annotationHolder.setTooltip(null);

        for(PhpClass phpClass: phpClasses) {
            annotationHolder.registerFix(new CreatePropertyQuickFix(phpDocTag, "\\" + phpClass.getPresentableFQN()));
        }

    }
View Full Code Here

      if (source != message.getSource()) {
        LOG.warn("Unexpected Source: " + message.getSource() + ",\nfile: " + annotatedFile.getPath());
        continue;
      }

      final Annotation annotation = annotate(holder, message, fileTextLength);
      if (annotation != null) {
        registerFixes(psiFile, annotation, message);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.intellij.lang.annotation.Annotation$QuickFixInfo

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.