@Override public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) { if (SmcTypes.ACTION_NAME.equals(element.getNode().getElementType())) { PsiElement parent = element.getParent(); if (parent == null || !(parent instanceof SmcAction)) { return; } SmcAction action = (SmcAction) parent; SmcFile containingFile = (SmcFile)action.getContainingFile(); String contextClassName = containingFile.getContextClassQName(); if (!SmcPsiUtil.isMethodInClass(contextClassName, action.getName(), action.getArgumentCount(), element.getProject())) { Annotation errorAnnotation = holder.createErrorAnnotation(element, getNotResolvedMessage(action.getFullName(), contextClassName)); errorAnnotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); errorAnnotation.registerFix(new CreateMethodInContextClassFix(action.getName(), action.getArgumentCount())); } else if (SmcPsiUtil.isMethodInClassNotUnique(contextClassName, action.getName(), action.getArgumentCount(), element.getProject())) { holder.createWarningAnnotation(element, getAmbiguityMessage(action.getFullName(),contextClassName)); } } }
@Override public void update(PresentationData data) { final PsiElement value = getPsiElement(); if (value == null || !value.isValid()) { setValue(null); } if (getPsiElement() == null) return; int flags = Iconable.ICON_FLAG_VISIBILITY; if (isMarkReadOnly()) { flags |= Iconable.ICON_FLAG_READ_STATUS; } LOG.assertTrue(value.isValid()); Icon icon = value.getIcon(flags); data.setIcon(icon); data.setPresentableText(myName); if (isDeprecated()) { data.setAttributesKey(CodeInsightColors.DEPRECATED_ATTRIBUTES); } updateImpl(data); for(ProjectViewNodeDecorator decorator: Extensions.getExtensions(ProjectViewNodeDecorator.EP_NAME, myProject)) { decorator.decorate(this, data); } }
/** * Returns the text attribute key used for highlighting the annotation. If not specified * explicitly, the key is determined automatically based on the problem highlight type and * the annotation severity. * * @return the text attribute key used for highlighting */ @NotNull public TextAttributesKey getTextAttributes() { if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey; if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) { if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) { return CodeInsightColors.ERRORS_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) { return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) { return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES; } return HighlighterColors.NO_HIGHLIGHTING; }
private static void flashUsageScriptaculously(@NotNull final Usage usage) { if (!(usage instanceof UsageInfo2UsageAdapter)) { return; } UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage; Editor editor = usageInfo.openTextEditor(true); if (editor == null) return; TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES); RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6); List<Segment> segments = new ArrayList<Segment>(); CommonProcessors.CollectProcessor<Segment> processor = new CommonProcessors.CollectProcessor<Segment>(segments); usageInfo.processRangeMarkers(processor); rangeBlinker.resetMarkers(segments); rangeBlinker.startBlinking(); }
@NotNull public static LineMarkerInfo createMethodSeparatorLineMarker(@NotNull PsiElement startFrom, @NotNull EditorColorsManager colorsManager) { LineMarkerInfo info = new LineMarkerInfo<PsiElement>( startFrom, startFrom.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT ); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; }
private static void addInspectionSeverityAttributes(List<AttributesDescriptor> descriptors) { descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unknown.symbol"), CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.deprecated.symbol"), CodeInsightColors.DEPRECATED_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unused.symbol"), CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.error"), CodeInsightColors.ERRORS_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.warning"), CodeInsightColors.WARNINGS_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.weak.warning"), CodeInsightColors.WEAK_WARNING_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.problems"), CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.duplicate"), CodeInsightColors.DUPLICATE_FROM_SERVER)); for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) { for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) { final TextAttributesKey attributesKey = highlightInfoType.getAttributesKey(); descriptors.add(new AttributesDescriptor(toDisplayName(attributesKey), attributesKey)); } } }
@Override protected void updateImpl(PresentationData data) { PsiFile value = getValue(); data.setPresentableText(value.getName()); data.setIcon(value.getIcon(Iconable.ICON_FLAG_READ_STATUS)); VirtualFile file = getVirtualFile(); if (file != null && file.is(VFileProperty.SYMLINK)) { String target = file.getCanonicalPath(); if (target == null) { data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); data.setTooltip(CommonBundle.message("vfs.broken.link")); } else { data.setTooltip(FileUtil.toSystemDependentName(target)); } } }
@Override public void doApplyInformationToEditor() { HighlightInfo info = null; if (myRange != null) { TextAttributes attributes = new TextAttributes(null, null, myEditor.getColorsScheme().getAttributes(CodeInsightColors.WEAK_WARNING_ATTRIBUTES) .getEffectColor(), null, Font.PLAIN); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(myRange); builder.textAttributes(attributes); builder.descriptionAndTooltip(SIGNATURE_SHOULD_BE_POSSIBLY_CHANGED); info = builder.createUnconditionally(); final ArrayList<IntentionAction> options = new ArrayList<IntentionAction>(); options.add(new DismissNewSignatureIntentionAction()); QuickFixAction.registerQuickFixAction(info, new ChangeSignatureDetectorAction(), options, null); } Collection<HighlightInfo> infos = info != null ? Collections.singletonList(info) : Collections.<HighlightInfo>emptyList(); UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId()); }
@Nullable public static Annotation createAnnotation(final DomElementProblemDescriptor problemDescriptor) { return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, Annotation>() { @Override public Annotation fun(final Pair<TextRange, PsiElement> s) { String text = problemDescriptor.getDescriptionTemplate(); if (StringUtil.isEmpty(text)) text = null; final HighlightSeverity severity = problemDescriptor.getHighlightSeverity(); TextRange range = s.first; if (text == null) range = TextRange.from(range.getStartOffset(), 0); range = range.shiftRight(s.second.getTextRange().getStartOffset()); final Annotation annotation = createAnnotation(severity, range, text); if (problemDescriptor instanceof DomElementResolveProblemDescriptor) { annotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); } for(LocalQuickFix fix:problemDescriptor.getFixes()) { if (fix instanceof IntentionAction) annotation.registerFix((IntentionAction)fix); } return annotation; } }); }
public static ItemPresentation getFieldPresentation(final PsiField psiField) { return new ColoredItemPresentation() { @Override public String getPresentableText() { return psiField.getName(); } @Override public TextAttributesKey getTextAttributesKey() { if (psiField.isDeprecated()) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } return null; } @Override public String getLocationString() { return getJavaSymbolContainerText(psiField); } @Override public Icon getIcon(boolean open) { return psiField.getIcon(Iconable.ICON_FLAG_VISIBILITY); } }; }
/** * Returns the text attribute key used for highlighting the annotation. If not specified * explicitly, the key is determined automatically based on the problem highlight type and * the annotation severity. * * @return the text attribute key used for highlighting */ public TextAttributesKey getTextAttributes() { if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey; if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) { if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) { return CodeInsightColors.ERRORS_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) { return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) { return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES; } return HighlighterColors.TEXT; }
private static void addInspectionSeverityAttributes(List<AttributesDescriptor> descriptors) { descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unknown.symbol"), CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.deprecated.symbol"), CodeInsightColors.DEPRECATED_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unused.symbol"), CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.error"), CodeInsightColors.ERRORS_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.warning"), CodeInsightColors.WARNINGS_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.weak.warning"), CodeInsightColors.WEAK_WARNING_ATTRIBUTES)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.problems"), CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.duplicate"), CodeInsightColors.DUPLICATE_FROM_SERVER)); for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) { for (HighlightInfoType highlightInfoType : provider.getSeveritiesHighlightInfoTypes()) { final TextAttributesKey attributesKey = highlightInfoType.getAttributesKey(); descriptors.add(new AttributesDescriptor(attributesKey.myExternalName, attributesKey)); } } }
@Nullable public static Annotation createAnnotation(final DomElementProblemDescriptor problemDescriptor) { return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, Annotation>() { public Annotation fun(final Pair<TextRange, PsiElement> s) { String text = problemDescriptor.getDescriptionTemplate(); if (StringUtil.isEmpty(text)) text = null; final HighlightSeverity severity = problemDescriptor.getHighlightSeverity(); TextRange range = s.first; if (text == null) range = TextRange.from(range.getStartOffset(), 0); range = range.shiftRight(s.second.getTextRange().getStartOffset()); final Annotation annotation = createAnnotation(severity, range, text); if (problemDescriptor instanceof DomElementResolveProblemDescriptor) { annotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); } for(LocalQuickFix fix:problemDescriptor.getFixes()) { if (fix instanceof IntentionAction) annotation.registerFix((IntentionAction)fix); } return annotation; } }); }
@RequiredReadAction @Nullable @Override public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { if(myDaemonSettings.SHOW_METHOD_SEPARATORS) { if(element instanceof LuaDocComment) { LuaDocCommentOwner owner = ((LuaDocComment) element).getOwner(); if(owner instanceof LuaFunctionDefinition) { TextRange range = new TextRange(element.getTextOffset(), owner.getTextRange().getEndOffset()); LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(element, range, null, Pass.UPDATE_ALL, NullableFunction.NULL, null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; } } } return null; }
@Override @Nullable public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { if (myDaemonSettings.SHOW_METHOD_SEPARATORS) { if (element instanceof DylanDefinition) { LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.BOTTOM; return info; } } return null; }
/** * Returns the text attribute key used for highlighting the annotation. If not specified * explicitly, the key is determined automatically based on the problem highlight type and * the annotation severity. * * @return the text attribute key used for highlighting */ @Nonnull public TextAttributesKey getTextAttributes() { if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey; if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) { if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) { return CodeInsightColors.ERRORS_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) { return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) { return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES; } return HighlighterColors.NO_HIGHLIGHTING; }
private static void flashUsageScriptaculously(@Nonnull final Usage usage) { if (!(usage instanceof UsageInfo2UsageAdapter)) { return; } UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage; Editor editor = usageInfo.openTextEditor(true); if (editor == null) return; TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES); RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6); List<Segment> segments = new ArrayList<>(); Processor<Segment> processor = Processors.cancelableCollectProcessor(segments); usageInfo.processRangeMarkers(processor); rangeBlinker.resetMarkers(segments); rangeBlinker.startBlinking(); }
@Nonnull public static LineMarkerInfo createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) { LineMarkerInfo info = new LineMarkerInfo<>( startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT ); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; }
@Override protected void updateImpl(PresentationData data) { PsiFile value = getValue(); data.setPresentableText(value.getName()); data.setIcon(IconDescriptorUpdaters.getIcon(value, Iconable.ICON_FLAG_READ_STATUS)); VirtualFile file = getVirtualFile(); if (file != null && file.is(VFileProperty.SYMLINK)) { String target = file.getCanonicalPath(); if (target == null) { data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); data.setTooltip(CommonBundle.message("vfs.broken.link")); } else { data.setTooltip(FileUtil.toSystemDependentName(target)); } } }
@Override public void doApplyInformationToEditor() { HighlightInfo info = null; final InplaceChangeSignature currentRefactoring = InplaceChangeSignature.getCurrentRefactoring(myEditor); if (currentRefactoring != null) { final ChangeInfo changeInfo = currentRefactoring.getStableChange(); final PsiElement element = changeInfo.getMethod(); int offset = myEditor.getCaretModel().getOffset(); if (element == null || !element.isValid()) return; final TextRange elementTextRange = element.getTextRange(); if (elementTextRange == null || !elementTextRange.contains(offset)) return; final LanguageChangeSignatureDetector<ChangeInfo> detector = LanguageChangeSignatureDetectors.INSTANCE.forLanguage(changeInfo.getLanguage()); TextRange range = detector.getHighlightingRange(changeInfo); TextAttributes attributes = new TextAttributes(null, null, myEditor.getColorsScheme().getAttributes(CodeInsightColors.WEAK_WARNING_ATTRIBUTES) .getEffectColor(), null, Font.PLAIN); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(range); builder.textAttributes(attributes); builder.descriptionAndTooltip(SIGNATURE_SHOULD_BE_POSSIBLY_CHANGED); info = builder.createUnconditionally(); QuickFixAction.registerQuickFixAction(info, new ApplyChangeSignatureAction(currentRefactoring.getInitialName())); } Collection<HighlightInfo> infos = info != null ? Collections.singletonList(info) : Collections.emptyList(); UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId()); }
public static ItemPresentation getFieldPresentation(final PsiField psiField) { return new ColoredItemPresentation() { @Override public String getPresentableText() { return psiField.getName(); } @Override public TextAttributesKey getTextAttributesKey() { if (psiField.isDeprecated()) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } return null; } @Override public String getLocationString() { return getJavaSymbolContainerText(psiField); } @Override public Icon getIcon(boolean open) { return IconDescriptorUpdaters.getIcon(psiField, Iconable.ICON_FLAG_VISIBILITY); } }; }
@Override public void update(PresentationData data) { final PsiElement value = getPsiElement(); if (value == null || !value.isValid()) { setValue(null); } if (getPsiElement() == null) return; int flags = Iconable.ICON_FLAG_VISIBILITY; if (isMarkReadOnly()) { flags |= Iconable.ICON_FLAG_READ_STATUS; } LOG.assertTrue(value.isValid()); Icon icon = IconDescriptorUpdaters.getIcon(value, flags); data.setIcon(icon); data.setPresentableText(myName); if (isDeprecated()) { data.setAttributesKey(CodeInsightColors.DEPRECATED_ATTRIBUTES); } updateImpl(data); for(ProjectViewNodeDecorator decorator: Extensions.getExtensions(ProjectViewNodeDecorator.EP_NAME, myProject)) { decorator.decorate(this, data); } }
@Override public LineMarkerInfo getLineMarkerInfo(final PsiElement element) { if (element instanceof LuaReturnStatement && LuaApplicationSettings.getInstance().SHOW_TAIL_CALLS_IN_GUTTER) { LuaReturnStatement e = (LuaReturnStatement) element; if (e.isTailCall()) return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), LuaIcons.TAIL_RECURSION, Pass.UPDATE_ALL, tailCallTooltip, null, GutterIconRenderer.Alignment.LEFT); } if (myDaemonSettings.SHOW_METHOD_SEPARATORS) { if (element instanceof LuaDocComment) { LuaDocCommentOwner owner = ((LuaDocComment) element).getOwner(); if (owner instanceof LuaFunctionDefinition) { TextRange range = new TextRange(element.getTextOffset(), owner.getTextRange().getEndOffset()); LineMarkerInfo<PsiElement> info = new LineMarkerInfo<PsiElement>(element, range, null, Pass.UPDATE_ALL, NullableFunction.NULL, null, GutterIconRenderer.Alignment.RIGHT); EditorColorsScheme scheme = myColorsManager.getGlobalScheme(); info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); info.separatorPlacement = SeparatorPlacement.TOP; return info; } } } return null; }
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (element instanceof SmcParameterType) { SmcParameterType type = (SmcParameterType) element; String name = type.getName(); PsiElement nameIdentifier = type.getNameIdentifier(); if (name == null || nameIdentifier == null) return; if (!SmcPsiUtil.isTypeAvailableFromSmc(type)) { Annotation errorAnnotation = holder.createErrorAnnotation(nameIdentifier, getMessage(name)); errorAnnotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); } } }
public static Color errorColor() { TextAttributes attribute = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.ERRORS_ATTRIBUTES); Color color = JBColor.RED; if (attribute != null) { if (attribute.getForegroundColor() != null) { color = attribute.getForegroundColor(); } else if (attribute.getEffectColor() != null) { color = attribute.getEffectColor(); } else if (attribute.getErrorStripeColor() != null) { color = attribute.getErrorStripeColor(); } } return color; }
public static Color warningColor() { TextAttributes attribute = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.WARNINGS_ATTRIBUTES); Color color = JBColor.ORANGE; if (attribute != null) { if (attribute.getForegroundColor() != null) { color = attribute.getForegroundColor(); } else if (attribute.getEffectColor() != null) { color = attribute.getEffectColor(); } else if (attribute.getErrorStripeColor() != null) { color = attribute.getErrorStripeColor(); } } return color; }
@Override public ItemPresentation getPresentation(@NotNull final PsiClass psiClass) { return new ColoredItemPresentation() { @Override public String getPresentableText() { return ClassPresentationUtil.getNameForClass(psiClass, false); } @Override public String getLocationString() { PsiFile file = psiClass.getContainingFile(); if (file instanceof PsiClassOwner) { PsiClassOwner classOwner = (PsiClassOwner)file; String packageName = classOwner.getPackageName(); if (packageName.isEmpty()) return null; return "(" + packageName + ")"; } return null; } @Override public TextAttributesKey getTextAttributesKey() { try { if (psiClass.isDeprecated()) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } } catch (IndexNotReadyException ignore) { } return null; } @Override public Icon getIcon(boolean open) { return psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS); } }; }
@NotNull public static ColoredItemPresentation getMethodPresentation(@NotNull final PsiMethod psiMethod) { return new ColoredItemPresentation() { @Override public String getPresentableText() { return PsiFormatUtil.formatMethod( psiMethod, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE ); } @Override public TextAttributesKey getTextAttributesKey() { if (psiMethod.isDeprecated()) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } return null; } @Override public String getLocationString() { return getJavaSymbolContainerText(psiMethod); } @Override public Icon getIcon(boolean open) { return psiMethod.getIcon(Iconable.ICON_FLAG_VISIBILITY); } }; }
@NotNull public static ItemPresentation getFieldPresentation(@NotNull final PsiField psiField) { return new ColoredItemPresentation() { @Override public String getPresentableText() { return psiField.getName(); } @Override public TextAttributesKey getTextAttributesKey() { if (psiField.isDeprecated()) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } return null; } @Override public String getLocationString() { return getJavaSymbolContainerText(psiField); } @Override public Icon getIcon(boolean open) { return psiField.getIcon(Iconable.ICON_FLAG_VISIBILITY); } }; }
@NotNull private static Icon createErrorIcon() { return new SingleColorIcon(CodeInsightColors.ERRORS_ATTRIBUTES) { @Override public void paintIcon(Component c, Graphics g, int x, int y) { IconUtil.colorize(AllIcons.General.InspectionsError, getColor()).paintIcon(c, g, x, y); } }; }
@NotNull public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor, @NotNull HighlightSeverity severity, @NotNull SeverityRegistrar severityRegistrar) { final ProblemHighlightType highlightType = problemDescriptor.getHighlightType(); switch (highlightType) { case GENERIC_ERROR_OR_WARNING: return severityRegistrar.getHighlightInfoTypeBySeverity(severity); case LIKE_DEPRECATED: return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.DEPRECATED.getAttributesKey()); case LIKE_UNKNOWN_SYMBOL: if (severity == HighlightSeverity.ERROR) { return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.WRONG_REF.getAttributesKey()); } if (severity == HighlightSeverity.WARNING) { return new HighlightInfoType.HighlightInfoTypeImpl(severity, CodeInsightColors.WEAK_WARNING_ATTRIBUTES); } return severityRegistrar.getHighlightInfoTypeBySeverity(severity); case LIKE_UNUSED_SYMBOL: return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.UNUSED_SYMBOL.getAttributesKey()); case INFO: return HighlightInfoType.INFO; case WEAK_WARNING: return HighlightInfoType.WEAK_WARNING; case ERROR: return HighlightInfoType.WRONG_REF; case GENERIC_ERROR: return HighlightInfoType.ERROR; case INFORMATION: final TextAttributesKey attributes = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes(); if (attributes != null) { return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, attributes); } return HighlightInfoType.INFORMATION; } throw new RuntimeException("Cannot map " + highlightType); }
@NotNull private static TextAttributes getFollowedHyperlinkAttributes(@NotNull RangeHighlighter range) { HyperlinkInfoTextAttributes attrs = HYPERLINK.get(range); TextAttributes result = attrs != null ? attrs.getFollowedHyperlinkAttributes() : null; if (result == null) { result = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.FOLLOWED_HYPERLINK_ATTRIBUTES); } return result; }
@Override protected void postprocess(@NotNull PresentationData presentation) { if (hasProblemFileBeneath() ) { presentation.setAttributesKey(CodeInsightColors.ERRORS_ATTRIBUTES); } setForcedForeground(presentation); if (hasProblemFileBeneath() ) { presentation.setAttributesKey(CodeInsightColors.ERRORS_ATTRIBUTES); } }