use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class JavaGotoSuperTest method findMarkerWithElement.
private static LineMarkerInfo findMarkerWithElement(List<LineMarkerInfo> markers, PsiElement psiMethod) {
LineMarkerInfo marker = ContainerUtil.find(markers, info -> info.getElement().equals(psiMethod));
assertNotNull(markers.toString(), marker);
return marker;
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class GroovyLineMarkerProvider method collectOverridingMethods.
private static void collectOverridingMethods(@NotNull final Set<PsiMethod> methods, @NotNull Collection<LineMarkerInfo> result) {
final Set<PsiElement> overridden = new HashSet<>();
Set<PsiClass> classes = new THashSet<>();
for (PsiMethod method : methods) {
ProgressManager.checkCanceled();
final PsiClass parentClass = method.getContainingClass();
if (parentClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(parentClass.getQualifiedName())) {
classes.add(parentClass);
}
}
for (final PsiClass aClass : classes) {
AllOverridingMethodsSearch.search(aClass).forEach(pair -> {
ProgressManager.checkCanceled();
final PsiMethod superMethod = pair.getFirst();
if (isCorrectTarget(superMethod) && isCorrectTarget(pair.getSecond())) {
if (methods.remove(superMethod)) {
overridden.add(PsiImplUtil.handleMirror(superMethod));
}
}
return !methods.isEmpty();
});
}
for (PsiElement element : overridden) {
final Icon icon = AllIcons.Gutter.OverridenMethod;
element = PsiImplUtil.handleMirror(element);
PsiElement range = element instanceof GrNamedElement ? ((GrNamedElement) element).getNameIdentifierGroovy() : element;
final MarkerType type = element instanceof GrField ? GroovyMarkerTypes.OVERRIDEN_PROPERTY_TYPE : GroovyMarkerTypes.GR_OVERRIDEN_METHOD;
LineMarkerInfo info = new LineMarkerInfo<>(range, range.getTextRange(), icon, Pass.LINE_MARKERS, type.getTooltip(), type.getNavigationHandler(), GutterIconRenderer.Alignment.RIGHT);
result.add(info);
}
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class GroovyLineMarkerTest method doTest.
private void doTest(int count) {
final Editor editor = myFixture.getEditor();
final Project project = myFixture.getProject();
myFixture.doHighlighting();
final List<LineMarkerInfo> infoList = DaemonCodeAnalyzerImpl.getLineMarkers(editor.getDocument(), project);
assertEquals(count, infoList.size());
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class LineMarkersUtil method setLineMarkersToEditor.
static void setLineMarkersToEditor(@NotNull Project project, @NotNull Document document, @NotNull Segment bounds, @NotNull Collection<LineMarkerInfo> markers, int group) {
ApplicationManager.getApplication().assertIsDispatchThread();
MarkupModelEx markupModel = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
HighlightersRecycler toReuse = new HighlightersRecycler();
processLineMarkers(project, document, bounds, group, info -> {
toReuse.recycleHighlighter(info.highlighter);
return true;
});
if (LOG.isDebugEnabled()) {
List<LineMarkerInfo> oldMarkers = DaemonCodeAnalyzerImpl.getLineMarkers(document, project);
LOG.debug("LineMarkersUtil.setLineMarkersToEditor(markers: " + markers + ", group: " + group + "); oldMarkers: " + oldMarkers + "; reused: " + toReuse.forAllInGarbageBin().size());
}
for (final LineMarkerInfo info : markers) {
PsiElement element = info.getElement();
if (element == null) {
continue;
}
TextRange textRange = element.getTextRange();
if (textRange == null)
continue;
TextRange elementRange = InjectedLanguageManager.getInstance(project).injectedToHost(element, textRange);
if (!TextRange.containsRange(bounds, elementRange)) {
continue;
}
createOrReuseLineMarker(info, markupModel, toReuse);
}
for (RangeHighlighter highlighter : toReuse.forAllInGarbageBin()) {
highlighter.dispose();
}
}
use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.
the class LineMarkersUtil method addLineMarkerToEditorIncrementally.
static void addLineMarkerToEditorIncrementally(@NotNull Project project, @NotNull Document document, @NotNull LineMarkerInfo marker) {
ApplicationManager.getApplication().assertIsDispatchThread();
MarkupModelEx markupModel = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
LineMarkerInfo[] markerInTheWay = { null };
boolean allIsClear = markupModel.processRangeHighlightersOverlappingWith(marker.startOffset, marker.endOffset, highlighter -> (markerInTheWay[0] = getLineMarkerInfo(highlighter)) == null);
if (allIsClear) {
createOrReuseLineMarker(marker, markupModel, null);
}
if (LOG.isDebugEnabled()) {
LOG.debug("LineMarkersUtil.addLineMarkerToEditorIncrementally: " + marker + " " + (allIsClear ? "created" : " (was not added because " + markerInTheWay[0] + " was in the way)"));
}
}
Aggregations