public void execute(final String line, final int textEndOffset) { myResult = null; myInfo = parseExceptionLine(line); if (myInfo == null) { return; } myMethod = myInfo.getSecond().substring(line); final int lparenthIndex = myInfo.third.getStartOffset(); final int rparenthIndex = myInfo.third.getEndOffset(); final String fileAndLine = line.substring(lparenthIndex + 1, rparenthIndex).trim(); final int colonIndex = fileAndLine.lastIndexOf(':'); if (colonIndex < 0) return; final String lineString = fileAndLine.substring(colonIndex + 1); try { final int lineNumber = Integer.parseInt(lineString); myClass = findPositionClass(line); myFile = myClass == null ? null : (PsiFile) myClass.getContainingFile().getNavigationElement(); if (myFile == null) { // try find the file with the required name PsiFile[] files = PsiShortNamesCache.getInstance(myProject) .getFilesByName(fileAndLine.substring(0, colonIndex).trim()); if (files.length > 0) { myFile = files[0]; } } if (myFile == null) return; /* IDEADEV-4976: Some scramblers put something like SourceFile mock instead of real class name. final String filePath = fileAndLine.substring(0, colonIndex).replace('/', File.separatorChar); final int slashIndex = filePath.lastIndexOf(File.separatorChar); final String shortFileName = slashIndex < 0 ? filePath : filePath.substring(slashIndex + 1); if (!file.getName().equalsIgnoreCase(shortFileName)) return null; */ final int textStartOffset = textEndOffset - line.length(); final int highlightStartOffset = textStartOffset + lparenthIndex + 1; final int highlightEndOffset = textStartOffset + rparenthIndex; final VirtualFile virtualFile = myFile.getVirtualFile(); HyperlinkInfo linkInfo = new MyHyperlinkInfo(myProject, virtualFile, lineNumber); TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone(); if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(virtualFile)) { Color color = UIUtil.getInactiveTextColor(); attributes.setForegroundColor(color); attributes.setEffectColor(color); } myResult = new Filter.Result(highlightStartOffset, highlightEndOffset, linkInfo, attributes); } catch (NumberFormatException e) { // } }
/** Patches attributes to be visible under debugger active line */ @SuppressWarnings("UseJBColor") private static TextAttributes patchAttributesColor( TextAttributes attributes, TextRange range, Editor editor) { int line = editor.offsetToLogicalPosition(range.getStartOffset()).line; for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) { if (!highlighter.isValid()) continue; if (highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE && editor.offsetToLogicalPosition(highlighter.getStartOffset()).line == line) { TextAttributes textAttributes = highlighter.getTextAttributes(); if (textAttributes != null) { Color color = textAttributes.getBackgroundColor(); if (color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128) { TextAttributes clone = attributes.clone(); clone.setForegroundColor(Color.orange); clone.setEffectColor(Color.orange); return clone; } } } } return attributes; }
/** Patches attributes to be visible under debugger active line */ @SuppressWarnings("UseJBColor") public static TextAttributes patchAttributesColor( TextAttributes attributes, @NotNull TextRange range, @NotNull Editor editor) { if (attributes.getForegroundColor() == null && attributes.getEffectColor() == null) return attributes; MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false); if (model != null) { if (!((MarkupModelEx) model) .processRangeHighlightersOverlappingWith( range.getStartOffset(), range.getEndOffset(), highlighter -> { if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) { TextAttributes textAttributes = highlighter.getTextAttributes(); if (textAttributes != null) { Color color = textAttributes.getBackgroundColor(); return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128); } } return true; })) { TextAttributes clone = attributes.clone(); clone.setForegroundColor(Color.orange); clone.setEffectColor(Color.orange); return clone; } } return attributes; }
static { DEFINED_CONSTANTS_ATTR.setForegroundColor(Color.MAGENTA); UPVAL_ATTR.setFontType(SimpleTextAttributes.STYLE_ITALIC); LONGSTRING_ATTR.setBackgroundColor(new Color(0xD0, 0xD0, 0xD0)); GLOBAL_VAR_ATTR.setForegroundColor(new Color(128, 0, 0)); LOCAL_VAR_ATTR.setForegroundColor(new Color(0, 153, 153)); PARAMETER_ATTR.setForegroundColor(new Color(153, 102, 255)); LUADOC_ATTR.setForegroundColor(new Color(64, 95, 189)); LUADOC_TAG_ATTR.setForegroundColor(new Color(64, 95, 189)); LUADOC_VALUE_ATTR.setForegroundColor(new Color(64, 95, 189)); }
private void merge(TextAttributes attributes) { Color myBackground = myMergedAttributes.getBackgroundColor(); if (myBackground == null || myDefaultBackground.equals(myBackground)) { myMergedAttributes.setBackgroundColor(attributes.getBackgroundColor()); } Color myForeground = myMergedAttributes.getForegroundColor(); if (myForeground == null || myDefaultForeground.equals(myForeground)) { myMergedAttributes.setForegroundColor(attributes.getForegroundColor()); } if (myMergedAttributes.getFontType() == Font.PLAIN) { myMergedAttributes.setFontType(attributes.getFontType()); } }
protected void updateImpl(PresentationData data) { super.updateImpl(data); String newName; if (myBuilder.getTodoTreeStructure().isPackagesShown()) { newName = getValue().getName(); } else { newName = mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl(); } int nameEndOffset = newName.length(); int todoItemCount; try { todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue()); } catch (IndexNotReadyException e) { return; } if (mySingleFileMode) { if (todoItemCount == 0) { newName = IdeBundle.message("node.todo.no.items.found", newName); } else { newName = IdeBundle.message("node.todo.found.items", newName, todoItemCount); } } else { newName = IdeBundle.message("node.todo.items", newName, todoItemCount); } myHighlightedRegions.clear(); TextAttributes textAttributes = new TextAttributes(); textAttributes.setForegroundColor(myColor); myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes)); EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme(); myHighlightedRegions.add( new HighlightedRegion( nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES))); }
static { MAP_KEY_ATTRIBUTES.setForegroundColor(MAP_KEY_COLOR); }
static { LITERAL_CONVERSION_ATTRIBUTES.setForegroundColor(PlatformColors.BLUE); LITERAL_CONVERSION_ATTRIBUTES.setFontType(Font.BOLD); }
static { UNRESOLVED_ACCESS_ATTRIBUTES.setForegroundColor(Color.BLACK); UNRESOLVED_ACCESS_ATTRIBUTES.setEffectColor(Color.GRAY); UNRESOLVED_ACCESS_ATTRIBUTES.setEffectType(EffectType.LINE_UNDERSCORE); }
static { KEYWORD_ATTRIBUTES.setForegroundColor(new Color(0, 0, 67)); KEYWORD_ATTRIBUTES.setFontType(Font.BOLD); }
@NotNull public static TextAttributes createRainbowAttribute(@Nullable Color color) { TextAttributes ret = new TextAttributes(); ret.setForegroundColor(color); return ret; }