|
38 | 38 | import consulo.project.DumbService; |
39 | 39 | import consulo.util.collection.ArrayUtil; |
40 | 40 | import consulo.util.lang.ref.Ref; |
41 | | -import org.jspecify.annotations.Nullable; |
42 | 41 | import jakarta.inject.Inject; |
| 42 | +import org.jspecify.annotations.Nullable; |
43 | 43 |
|
44 | 44 | import java.util.Collection; |
45 | 45 | import java.util.List; |
|
50 | 50 | * @since 29.12.13. |
51 | 51 | */ |
52 | 52 | @ExtensionImpl |
53 | | -public class CSharpLineMarkerProvider implements LineMarkerProvider, DumbAware |
54 | | -{ |
55 | | - private static final LineMarkerCollector[] ourSingleCollector = { |
56 | | - new LambdaLineMarkerCollector() |
57 | | - }; |
58 | | - |
59 | | - private static final LineMarkerCollector[] ourCollectors = { |
60 | | - new OverrideTypeCollector(), |
61 | | - new PartialTypeCollector(), |
62 | | - new HidingOrOverridingElementCollector(), |
63 | | - new HidedOrOverridedElementCollector(), |
64 | | - new RecursiveCallCollector() |
65 | | - }; |
66 | | - |
67 | | - protected final DaemonCodeAnalyzerSettings myDaemonCodeAnalyzerSettings; |
68 | | - protected final EditorColorsManager myEditorColorsManager; |
69 | | - |
70 | | - @Inject |
71 | | - public CSharpLineMarkerProvider(DaemonCodeAnalyzerSettings daemonSettings, EditorColorsManager colorsManager) |
72 | | - { |
73 | | - myDaemonCodeAnalyzerSettings = daemonSettings; |
74 | | - myEditorColorsManager = colorsManager; |
75 | | - } |
76 | | - |
77 | | - @RequiredReadAction |
78 | | - @Nullable |
79 | | - @Override |
80 | | - public LineMarkerInfo getLineMarkerInfo(PsiElement element) |
81 | | - { |
82 | | - if(myDaemonCodeAnalyzerSettings.SHOW_METHOD_SEPARATORS && (element instanceof DotNetQualifiedElement)) |
83 | | - { |
84 | | - if(element.getNode().getTreeParent() == null) |
85 | | - { |
86 | | - return null; |
87 | | - } |
88 | | - |
89 | | - final PsiElement parent = element.getParent(); |
90 | | - if(!(parent instanceof DotNetMemberOwner)) |
91 | | - { |
92 | | - return null; |
93 | | - } |
94 | | - |
95 | | - if(ArrayUtil.getFirstElement(((DotNetMemberOwner) parent).getMembers()) == element) |
96 | | - { |
97 | | - return null; |
98 | | - } |
99 | | - |
100 | | - LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, element1 -> null, null, |
101 | | - GutterIconRenderer.Alignment.RIGHT); |
102 | | - EditorColorsScheme scheme = myEditorColorsManager.getGlobalScheme(); |
103 | | - info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); |
104 | | - info.separatorPlacement = SeparatorPlacement.TOP; |
105 | | - return info; |
106 | | - } |
107 | | - |
108 | | - final Ref<LineMarkerInfo> ref = Ref.create(); |
109 | | - Consumer<LineMarkerInfo> consumer = markerInfo -> ref.set(markerInfo); |
110 | | - |
111 | | - //noinspection ForLoopReplaceableByForEach |
112 | | - for(int j = 0; j < ourSingleCollector.length; j++) |
113 | | - { |
114 | | - LineMarkerCollector ourCollector = ourSingleCollector[j]; |
115 | | - ourCollector.collect(element, consumer); |
116 | | - } |
117 | | - |
118 | | - return ref.get(); |
119 | | - } |
120 | | - |
121 | | - @RequiredReadAction |
122 | | - @Override |
123 | | - public void collectSlowLineMarkers(List<PsiElement> elements, final Collection<LineMarkerInfo> lineMarkerInfos) |
124 | | - { |
125 | | - ApplicationManager.getApplication().assertReadAccessAllowed(); |
126 | | - |
127 | | - if(elements.isEmpty() || DumbService.getInstance(elements.get(0).getProject()).isDumb()) |
128 | | - { |
129 | | - return; |
130 | | - } |
131 | | - |
132 | | - Consumer<LineMarkerInfo> consumer = lineMarkerInfos::add; |
133 | | - |
134 | | - //noinspection ForLoopReplaceableByForEach |
135 | | - for(int i = 0; i < elements.size(); i++) |
136 | | - { |
137 | | - PsiElement psiElement = elements.get(i); |
138 | | - |
139 | | - //noinspection ForLoopReplaceableByForEach |
140 | | - for(int j = 0; j < ourCollectors.length; j++) |
141 | | - { |
142 | | - LineMarkerCollector ourCollector = ourCollectors[j]; |
143 | | - ourCollector.collect(psiElement, consumer); |
144 | | - } |
145 | | - } |
146 | | - } |
147 | | - |
148 | | - @Override |
149 | | - public Language getLanguage() |
150 | | - { |
151 | | - return CSharpLanguage.INSTANCE; |
152 | | - } |
| 53 | +public class CSharpLineMarkerProvider implements LineMarkerProvider, DumbAware { |
| 54 | + private static final LineMarkerCollector[] ourSingleCollector = { |
| 55 | + new LambdaLineMarkerCollector() |
| 56 | + }; |
| 57 | + |
| 58 | + private static final LineMarkerCollector[] ourCollectors = { |
| 59 | + OverrideTypeCollector.INSTANCE, |
| 60 | + new PartialTypeCollector(), |
| 61 | + HidingOrOverridingElementCollector.INSTANCE, |
| 62 | + HidedOrOverridedElementCollector.INSTANCE, |
| 63 | + new RecursiveCallCollector() |
| 64 | + }; |
| 65 | + |
| 66 | + protected final DaemonCodeAnalyzerSettings myDaemonCodeAnalyzerSettings; |
| 67 | + protected final EditorColorsManager myEditorColorsManager; |
| 68 | + |
| 69 | + @Inject |
| 70 | + public CSharpLineMarkerProvider(DaemonCodeAnalyzerSettings daemonSettings, EditorColorsManager colorsManager) { |
| 71 | + myDaemonCodeAnalyzerSettings = daemonSettings; |
| 72 | + myEditorColorsManager = colorsManager; |
| 73 | + } |
| 74 | + |
| 75 | + @RequiredReadAction |
| 76 | + @Nullable |
| 77 | + @Override |
| 78 | + public LineMarkerInfo getLineMarkerInfo(PsiElement element) { |
| 79 | + if (myDaemonCodeAnalyzerSettings.SHOW_METHOD_SEPARATORS && (element instanceof DotNetQualifiedElement)) { |
| 80 | + if (element.getNode().getTreeParent() == null) { |
| 81 | + return null; |
| 82 | + } |
| 83 | + |
| 84 | + final PsiElement parent = element.getParent(); |
| 85 | + if (!(parent instanceof DotNetMemberOwner)) { |
| 86 | + return null; |
| 87 | + } |
| 88 | + |
| 89 | + if (ArrayUtil.getFirstElement(((DotNetMemberOwner) parent).getMembers()) == element) { |
| 90 | + return null; |
| 91 | + } |
| 92 | + |
| 93 | + LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, element1 -> null, null, |
| 94 | + GutterIconRenderer.Alignment.RIGHT); |
| 95 | + EditorColorsScheme scheme = myEditorColorsManager.getGlobalScheme(); |
| 96 | + info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR); |
| 97 | + info.separatorPlacement = SeparatorPlacement.TOP; |
| 98 | + return info; |
| 99 | + } |
| 100 | + |
| 101 | + final Ref<LineMarkerInfo> ref = Ref.create(); |
| 102 | + Consumer<LineMarkerInfo> consumer = markerInfo -> ref.set(markerInfo); |
| 103 | + |
| 104 | + //noinspection ForLoopReplaceableByForEach |
| 105 | + for (int j = 0; j < ourSingleCollector.length; j++) { |
| 106 | + LineMarkerCollector ourCollector = ourSingleCollector[j]; |
| 107 | + ourCollector.collect(element, consumer); |
| 108 | + } |
| 109 | + |
| 110 | + return ref.get(); |
| 111 | + } |
| 112 | + |
| 113 | + @RequiredReadAction |
| 114 | + @Override |
| 115 | + public void collectSlowLineMarkers(List<PsiElement> elements, final Collection<LineMarkerInfo> lineMarkerInfos) { |
| 116 | + ApplicationManager.getApplication().assertReadAccessAllowed(); |
| 117 | + |
| 118 | + if (elements.isEmpty() || DumbService.getInstance(elements.get(0).getProject()).isDumb()) { |
| 119 | + return; |
| 120 | + } |
| 121 | + |
| 122 | + Consumer<LineMarkerInfo> consumer = lineMarkerInfos::add; |
| 123 | + |
| 124 | + //noinspection ForLoopReplaceableByForEach |
| 125 | + for (int i = 0; i < elements.size(); i++) { |
| 126 | + PsiElement psiElement = elements.get(i); |
| 127 | + |
| 128 | + //noinspection ForLoopReplaceableByForEach |
| 129 | + for (int j = 0; j < ourCollectors.length; j++) { |
| 130 | + LineMarkerCollector ourCollector = ourCollectors[j]; |
| 131 | + ourCollector.collect(psiElement, consumer); |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + @Override |
| 137 | + public Language getLanguage() { |
| 138 | + return CSharpLanguage.INSTANCE; |
| 139 | + } |
153 | 140 | } |
0 commit comments