Skip to content

Commit b3c6198

Browse files
committed
code vision integration
1 parent a8b7ff6 commit b3c6198

11 files changed

Lines changed: 762 additions & 432 deletions

File tree

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,74 @@
11
action.CSharp.File.text:
2-
text: C# File
2+
text: C# File
33
action.CSharp.GenerateConstructor.text:
4-
text: Constructor
4+
text: Constructor
5+
action.CSharp.GenerateImplementMember.text:
6+
text: Implement Member
57
action.CSharp.GenerateProperty.text:
6-
text: Property
8+
text: Property
79
action.CSharp.GenerateReadOnlyProperty.text:
8-
text: Readonly Property
9-
action.CSharp.GenerateImplementMember.text:
10-
text: Implement Member
10+
text: Readonly Property
1111
action.CSharp.Internal.OpenTypeFromVariable.text:
12-
text: Open type from variable (C#)
12+
text: Open type from variable (C#)
13+
code.vision.implementations.hint:
14+
text: '{0, choice, 1#1 Implementation|2#{0,number} Implementations}'
15+
code.vision.inheritors.hint:
16+
text: '{0, choice, 1#1 Inheritor|2#{0,number} Inheritors}'
17+
code.vision.overrides.hint:
18+
text: '{0, choice, 1#1 Override|2#{0,number} Overrides}'
19+
csharp.preprocessor.language.display.name:
20+
text: C# Preprocessor
21+
csharp.version._10_0:
22+
text: ''
1323
csharp.version._1_0:
14-
text: ''
24+
text: ''
1525
csharp.version._2_0:
16-
text: generics, iterators, etc
26+
text: generics, iterators, etc
1727
csharp.version._3_0:
18-
text: '''var'', lambda, etc'
28+
text: '''var'', lambda, etc'
1929
csharp.version._4_0:
20-
text: named / optional arguments, etc
30+
text: named / optional arguments, etc
2131
csharp.version._5_0:
22-
text: '''async'', etc'
32+
text: '''async'', etc'
2333
csharp.version._6_0:
24-
text: property initializer, etc
34+
text: property initializer, etc
2535
csharp.version._7_0:
26-
text: tuples, local methods, ref return, etc
36+
text: tuples, local methods, ref return, etc
2737
csharp.version._7_1:
28-
text: default, etc
38+
text: default, etc
2939
csharp.version._7_2:
30-
text: ''
40+
text: ''
3141
csharp.version._7_3:
32-
text: ''
42+
text: ''
3343
csharp.version._8_0:
34-
text: ''
44+
text: ''
3545
csharp.version._9_0:
36-
text: ''
37-
csharp.version._10_0:
38-
text: ''
46+
text: ''
3947
livetemplates.cwl:
40-
text: Print object to console
48+
text: Print object to console
49+
livetemplates.fort:
50+
text: iter with foreach(... in ...)
51+
livetemplates.forv:
52+
text: iter with foreach(var in ...)
53+
livetemplates.prop:
54+
text: Auto-property
4155
livetemplates.psvm:
42-
text: Main() method
56+
text: Main() method
4357
livetemplates.psvms:
44-
text: Main(string[]) method
45-
livetemplates.prop:
46-
text: Auto-property
47-
livetemplates.forv:
48-
text: iter with foreach(var in ...)
49-
livetemplates.fort:
50-
text: iter with foreach(... in ...)
51-
nullable.option.unspecified:
52-
text: unspecified
58+
text: Main(string[]) method
59+
nullable.option.annotations:
60+
text: annotations
5361
nullable.option.disable:
54-
text: disable
62+
text: disable
5563
nullable.option.enable:
56-
text: enable
57-
nullable.option.annotations:
58-
text: annotations
64+
text: enable
65+
nullable.option.unspecified:
66+
text: unspecified
5967
nullable.option.warnings:
60-
text: warnings
61-
csharp.preprocessor.language.display.name:
62-
text: C# Preprocessor
68+
text: warnings
69+
settings.inlay.inheritors:
70+
text: Inheritors
71+
settings.inlay.usages:
72+
text: Usages
73+
usages.telescope:
74+
text: '{0, choice, 1#1 Usage|2#{0,number} Usages}'

csharp-impl/src/main/java/consulo/csharp/impl/ide/CSharpLineMarkerProvider.java

Lines changed: 88 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
import consulo.project.DumbService;
3939
import consulo.util.collection.ArrayUtil;
4040
import consulo.util.lang.ref.Ref;
41-
import org.jspecify.annotations.Nullable;
4241
import jakarta.inject.Inject;
42+
import org.jspecify.annotations.Nullable;
4343

4444
import java.util.Collection;
4545
import java.util.List;
@@ -50,104 +50,91 @@
5050
* @since 29.12.13.
5151
*/
5252
@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+
}
153140
}

0 commit comments

Comments
 (0)