com.intellij.openapi.editor.LineExtensionInfo Java Examples
The following examples show how to use
com.intellij.openapi.editor.LineExtensionInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LineState.java From GitToolBox with Apache License 2.0 | 6 votes |
@Nullable List<LineExtensionInfo> getOrClearCachedLineInfo(Function<RevisionInfo, List<LineExtensionInfo>> lineInfoMaker) { BlameEditorData editorData = BlameEditorData.get(lineInfo.getEditor()); if (editorData != null) { if (isSameEditorData(editorData)) { return getLineInfo(editorData, lineInfoMaker); } else { clear(); if (LOG.isTraceEnabled()) { LOG.trace("BlameEditorData cleared: " + editorData); } } } else { if (LOG.isTraceEnabled()) { LOG.trace("BlameEditorData: null"); } } return null; }
Example #2
Source File: LineState.java From GitToolBox with Apache License 2.0 | 6 votes |
@Nullable private List<LineExtensionInfo> getLineInfo(@NotNull BlameEditorData editorData, @NotNull Function<RevisionInfo, List<LineExtensionInfo>> lineInfoMaker) { final boolean trace = LOG.isTraceEnabled(); if (trace) { LOG.trace("BlameEditorData is same: " + editorData); } RevisionInfo revisionInfo = editorData.getRevisionInfo(); BlameEditorLineData lineData = BlameEditorLineData.get(lineInfo.getEditor()); if (lineData != null && lineData.isSameRevision(revisionInfo)) { if (trace) { LOG.trace("Same revision: " + revisionInfo + " == " + lineData); } return lineData.getLineInfo(); } else { List<LineExtensionInfo> lineExtensions = lineInfoMaker.apply(revisionInfo); BlameEditorLineData newLineData = new BlameEditorLineData(revisionInfo, lineExtensions); BlameEditorLineData.set(lineInfo.getEditor(), newLineData); if (trace) { LOG.trace("New BlameEditorLineData: " + newLineData); } return lineExtensions; } }
Example #3
Source File: XDebuggerEditorLinePainter.java From consulo with Apache License 2.0 | 6 votes |
public void produceChangedParts(List<LineExtensionInfo> result) { if (isArray(actual) && isArray(old)) { List<String> actualParts = getArrayParts(actual); List<String> oldParts = getArrayParts(old); result.add(new LineExtensionInfo("{", getNormalAttributes())); for (int i = 0; i < actualParts.size(); i++) { if (i < oldParts.size() && StringUtil.equals(actualParts.get(i), oldParts.get(i))) { result.add(new LineExtensionInfo(actualParts.get(i), getNormalAttributes())); } else { result.add(new LineExtensionInfo(actualParts.get(i), getChangedAttributes())); } if (i != actualParts.size() - 1) { result.add(new LineExtensionInfo(", ", getNormalAttributes())); } } result.add(new LineExtensionInfo("}", getNormalAttributes())); return; } result.add(new LineExtensionInfo(actual, getChangedAttributes())); }
Example #4
Source File: OREditorLinePainter.java From reasonml-idea-plugin with MIT License | 5 votes |
@Nullable @Override public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) { //long start = System.currentTimeMillis(); CodeLensView.CodeLensInfo data = project.getUserData(CodeLensView.CODE_LENS); if (data == null) { return null; } if (ServiceManager.getService(project, ErrorsManager.class).hasErrors(file.getName(), lineNumber + 1)) { return null; } Collection<LineExtensionInfo> info = null; String signature = data.get(file, lineNumber); if (signature != null) { EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); TextAttributes codeLens = globalScheme.getAttributes(ORSyntaxHighlighter.CODE_LENS_); info = Collections.singletonList(new LineExtensionInfo(" " + signature, codeLens)); } //long end = System.currentTimeMillis(); //System.out.println("line extensions in " + (end - start) + "ms"); return info; }
Example #5
Source File: BlameUiServiceImpl.java From GitToolBox with Apache License 2.0 | 5 votes |
@Nullable private List<LineExtensionInfo> getLineExtensionsInternal(@NotNull VirtualFile file, int editorLineIndex) { LineInfo lineInfo = createLineInfo(file, editorLineIndex); if (lineInfo != null && isLineWithCaret(lineInfo.getEditor(), lineInfo.getIndex())) { return gateway.getEditorInfoTimer().timeSupplier(() -> getLineInfosWithCaching(lineInfo)); } return null; }
Example #6
Source File: BlameUiServiceImpl.java From GitToolBox with Apache License 2.0 | 5 votes |
@Nullable private List<LineExtensionInfo> getLineInfosWithCaching(@NotNull LineInfo lineInfo) { LineState lineState = new LineState(lineInfo); List<LineExtensionInfo> cachedInfo = lineState.getOrClearCachedLineInfo(this::getLineInfoDecoration); if (cachedInfo != null) { return cachedInfo; } else { RevisionInfo lineRevisionInfo = gateway.getLineBlame(lineInfo); if (lineRevisionInfo.isNotEmpty()) { lineState.setRevisionInfo(lineRevisionInfo); } return lineState.getOrClearCachedLineInfo(this::getLineInfoDecoration); } }
Example #7
Source File: BlameUiServiceImpl.java From GitToolBox with Apache License 2.0 | 4 votes |
@Nullable @Override public Collection<LineExtensionInfo> getLineExtensions(@NotNull VirtualFile file, int editorLineIndex) { return gateway.getEditorTimer().timeSupplier(() -> getLineExtensionsInternal(file, editorLineIndex)); }
Example #8
Source File: BlameUiServiceImpl.java From GitToolBox with Apache License 2.0 | 4 votes |
@NotNull private List<LineExtensionInfo> getLineInfoDecoration(RevisionInfo revisionInfo) { String text = formatBlameText(revisionInfo); return Collections.singletonList(new LineExtensionInfo(text, getBlameTextAttributes())); }
Example #9
Source File: BlameUiService.java From GitToolBox with Apache License 2.0 | 4 votes |
@Nullable Collection<LineExtensionInfo> getLineExtensions(@NotNull VirtualFile file, int editorLineIndex);
Example #10
Source File: XDebuggerEditorLinePainter.java From consulo with Apache License 2.0 | 4 votes |
void add(LineExtensionInfo info) { infos.add(info); length += info.getText().length(); }
Example #11
Source File: ConsolePromptDecorator.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Override public Collection<LineExtensionInfo> getLineExtensions(@Nonnull Project project, @Nonnull VirtualFile file, int lineNumber) { return null; }
Example #12
Source File: EditorEx.java From consulo with Apache License 2.0 | 2 votes |
/** * Registers a function which will be applied to a line number to obtain additional text fragments. The fragments returned by the * function will be drawn in the editor after end of the line (together with fragments returned by {@link com.intellij.openapi.editor.EditorLinePainter} extensions). */ void registerLineExtensionPainter(IntFunction<Collection<LineExtensionInfo>> lineExtensionPainter);