27
27
import com .github ._1c_syntax .bsl .languageserver .context .FileType ;
28
28
import com .github ._1c_syntax .bsl .languageserver .context .symbol .RegionSymbol ;
29
29
import com .github ._1c_syntax .bsl .languageserver .utils .Regions ;
30
+ import com .github ._1c_syntax .bsl .languageserver .utils .Resources ;
30
31
import com .github ._1c_syntax .bsl .mdo .support .ScriptVariant ;
31
32
import com .github ._1c_syntax .bsl .types .ConfigurationSource ;
32
- import com .github ._1c_syntax .bsl .types .ModuleType ;
33
- import com .github ._1c_syntax .mdclasses .Configuration ;
34
33
import org .eclipse .lsp4j .CodeAction ;
35
34
import org .eclipse .lsp4j .CodeActionKind ;
36
35
import org .eclipse .lsp4j .CodeActionParams ;
@@ -73,8 +72,8 @@ public GenerateStandardRegionsSupplier(LanguageServerConfiguration languageServe
73
72
@ Override
74
73
public List <CodeAction > getCodeActions (CodeActionParams params , DocumentContext documentContext ) {
75
74
76
- ModuleType moduleType = documentContext .getModuleType ();
77
- FileType fileType = documentContext .getFileType ();
75
+ var moduleType = documentContext .getModuleType ();
76
+ var fileType = documentContext .getFileType ();
78
77
79
78
ScriptVariant regionsLanguage = getRegionsLanguage (documentContext , fileType );
80
79
Set <String > neededStandardRegions ;
@@ -100,14 +99,19 @@ public List<CodeAction> getCodeActions(CodeActionParams params, DocumentContext
100
99
String result = neededStandardRegions .stream ()
101
100
.map (s -> String .format (regionFormat , s ))
102
101
.collect (Collectors .joining ("\n " ));
103
- TextEdit textEdit = new TextEdit (calculateFixRange (params .getRange ()), result );
102
+ var textEdit = new TextEdit (calculateFixRange (params .getRange ()), result );
104
103
105
- WorkspaceEdit edit = new WorkspaceEdit ();
104
+ var edit = new WorkspaceEdit ();
106
105
Map <String , List <TextEdit >> changes = Map .of (documentContext .getUri ().toString (),
107
106
Collections .singletonList (textEdit ));
108
107
edit .setChanges (changes );
109
108
110
- CodeAction codeAction = new CodeAction ("Generate missing regions" );
109
+ var title = Resources .getResourceString (
110
+ languageServerConfiguration .getLanguage (),
111
+ getClass (),
112
+ "title"
113
+ );
114
+ var codeAction = new CodeAction (title );
111
115
codeAction .setDiagnostics (new ArrayList <>());
112
116
codeAction .setKind (CodeActionKind .Refactor );
113
117
codeAction .setEdit (edit );
@@ -117,7 +121,7 @@ public List<CodeAction> getCodeActions(CodeActionParams params, DocumentContext
117
121
private ScriptVariant getRegionsLanguage (DocumentContext documentContext , FileType fileType ) {
118
122
119
123
ScriptVariant regionsLanguage ;
120
- Configuration configuration = documentContext .getServerContext ().getConfiguration ();
124
+ var configuration = documentContext .getServerContext ().getConfiguration ();
121
125
if (configuration .getConfigurationSource () == ConfigurationSource .EMPTY || fileType == FileType .OS ) {
122
126
regionsLanguage = getScriptVariantFromConfigLanguage ();
123
127
} else {
@@ -137,7 +141,7 @@ private ScriptVariant getScriptVariantFromConfigLanguage() {
137
141
return regionsLanguage ;
138
142
}
139
143
140
- private Range calculateFixRange (Range range ) {
144
+ private static Range calculateFixRange (Range range ) {
141
145
142
146
Position start = range .getStart ();
143
147
if (start == null ) {
0 commit comments