本文整理汇总了Java中com.intellij.openapi.editor.markup.RangeHighlighter.setErrorStripeTooltip方法的典型用法代码示例。如果您正苦于以下问题:Java RangeHighlighter.setErrorStripeTooltip方法的具体用法?Java RangeHighlighter.setErrorStripeTooltip怎么用?Java RangeHighlighter.setErrorStripeTooltip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.markup.RangeHighlighter
的用法示例。
在下文中一共展示了RangeHighlighter.setErrorStripeTooltip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
public void apply(@Nullable Project project, @NotNull Document document) {
MarkupModel model = DocumentMarkupModel.forDocument(document, project, true);
for (Element piece : myPieces) {
RangeHighlighterEx delegate = piece.getDelegate();
if (!delegate.isValid()) continue;
RangeHighlighter highlighter = model
.addRangeHighlighter(piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getTextAttributes(), delegate.getTargetArea());
highlighter.setEditorFilter(delegate.getEditorFilter());
highlighter.setCustomRenderer(delegate.getCustomRenderer());
highlighter.setErrorStripeMarkColor(delegate.getErrorStripeMarkColor());
highlighter.setErrorStripeTooltip(delegate.getErrorStripeTooltip());
highlighter.setGutterIconRenderer(delegate.getGutterIconRenderer());
highlighter.setLineMarkerRenderer(delegate.getLineMarkerRenderer());
highlighter.setLineSeparatorColor(delegate.getLineSeparatorColor());
highlighter.setThinErrorStripeMark(delegate.isThinErrorStripeMark());
highlighter.setLineSeparatorPlacement(delegate.getLineSeparatorPlacement());
highlighter.setLineSeparatorRenderer(delegate.getLineSeparatorRenderer());
}
}
示例2: highlightRanges
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
public static void highlightRanges(HighlightManager highlightManager, Editor editor, TextAttributes attributes,
boolean clearHighlights,
List<TextRange> textRanges) {
if (clearHighlights) {
clearHighlights(editor, highlightManager, textRanges, attributes);
return;
}
ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
for (TextRange range : textRanges) {
highlightManager.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, false, highlighters);
}
for (RangeHighlighter highlighter : highlighters) {
String tooltip = getLineTextErrorStripeTooltip(editor.getDocument(), highlighter.getStartOffset(), true);
highlighter.setErrorStripeTooltip(tooltip);
}
}
示例3: highlightNode
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
/**
* Highlight a node in the editor.
* @param editor the editor
* @param node the node to be highlighted
* @param attrs the attributes for the highlighter
* @param cfg the plugin configuration
* @return The created highlighter object
*/
public static RangeHighlighter highlightNode(Editor editor, final PsiElement node, TextAttributes attrs, Config cfg) {
TextRange range;
final PsiElement realElement;
if ((node instanceof XmlTag) && cfg.isHighlightStartTagOnly()) {
XmlTag tag = (XmlTag)node;
realElement = MyPsiUtil.getNameElement(tag);
range = realElement.getTextRange();
} else {
range = node.getTextRange();
realElement = node;
}
// TODO: break at line boundaries
final ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>(1);
final HighlightManager mgr = HighlightManager.getInstance(editor.getProject());
mgr.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), attrs, false, highlighters);
final RangeHighlighter rangeHighlighter = highlighters.get(0);
if (cfg.isAddErrorStripe()) {
rangeHighlighter.setErrorStripeMarkColor(attrs.getBackgroundColor());
rangeHighlighter.setErrorStripeTooltip(formatTooltip(editor, realElement));
} else {
rangeHighlighter.setErrorStripeMarkColor(null);
}
return rangeHighlighter;
}
示例4: highlightPsiElement
import com.intellij.openapi.editor.markup.RangeHighlighter; //导入方法依赖的package包/类
private static void highlightPsiElement(@NotNull Project project,
@NotNull PsiElement psiElement, @NotNull Editor editor, @NotNull PsiFile file,
boolean shouldClear) {
final PsiElement target = SmartPointerManager.getInstance(psiElement.getProject())
.createSmartPsiElementPointer(psiElement)
.getElement();
if (target == null) {
return;
}
if (file instanceof PsiCompiledFile) {
file = ((PsiCompiledFile) file).getDecompiledPsiFile();
}
final Couple<List<TextRange>> usages = getUsages(target, file);
final List<TextRange> readRanges = usages.first;
final List<TextRange> writeRanges = usages.second;
final HighlightManager highlightManager = HighlightManager.getInstance(project);
if (shouldClear) {
clearHighlights(editor, highlightManager, readRanges);
clearHighlights(editor, highlightManager, writeRanges);
WindowManager.getInstance().getStatusBar(project).setInfo("");
return;
}
// TODO: 10/02/2017 pass target?
final TextAttributes ta = TextAttributesFactory.getInstance().get();
final Color scrollMarkColor;
if (ta.getErrorStripeColor() != null) {
scrollMarkColor = ta.getErrorStripeColor();
} else if (ta.getBackgroundColor() != null) {
scrollMarkColor = ta.getBackgroundColor().darker();
} else {
scrollMarkColor = null;
}
final String elementName = ElementDescriptionUtil.getElementDescription(target,
HighlightUsagesDescriptionLocation.INSTANCE);
// TODO: 06/02/2017 highlight write and read access
ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
highlight(highlightManager, readRanges, editor, ta, highlighters, scrollMarkColor);
highlight(highlightManager, writeRanges, editor, ta, highlighters, scrollMarkColor);
final Document doc = editor.getDocument();
for (RangeHighlighter highlighter : highlighters) {
highlighter.setErrorStripeTooltip(
HighlightHandlerBase.getLineTextErrorStripeTooltip(doc,
highlighter.getStartOffset(), true));
}
int refCount = readRanges.size() + writeRanges.size();
String msg;
if (refCount > 0) {
msg = MessageFormat.format("{0} {0, choice, 1#usage|2#usages} of {1} found", refCount,
elementName);
} else {
msg = MessageFormat.format("No usages of {0} found", elementName);
}
WindowManager.getInstance().getStatusBar(project).setInfo(msg);
}