Skip to content

Commit fd1e842

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/updateMDClasses_0_10
# Conflicts: # src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java
2 parents 143f945 + 9425319 commit fd1e842

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ plugins {
1010
id("org.cadixdev.licenser") version "0.6.1"
1111
id("org.sonarqube") version "3.4.0.2513"
1212
id("io.freefair.lombok") version "6.5.0.2"
13-
id("io.freefair.javadoc-links") version "6.5.0.2"
14-
id("io.freefair.javadoc-utf-8") version "6.5.0.2"
15-
id("io.freefair.aspectj.post-compile-weaving") version "6.5.0.2"
16-
id("io.freefair.maven-central.validate-poms") version "6.5.0.2"
13+
id("io.freefair.javadoc-links") version "6.5.0.3"
14+
id("io.freefair.javadoc-utf-8") version "6.5.0.3"
15+
id("io.freefair.aspectj.post-compile-weaving") version "6.5.0.3"
16+
id("io.freefair.maven-central.validate-poms") version "6.5.0.3"
1717
id("me.qoomon.git-versioning") version "6.1.6"
1818
id("com.github.ben-manes.versions") version "0.42.0"
1919
id("org.springframework.boot") version "2.6.7"

src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
import com.github._1c_syntax.bsl.languageserver.context.FileType;
2828
import com.github._1c_syntax.bsl.languageserver.context.symbol.RegionSymbol;
2929
import com.github._1c_syntax.bsl.languageserver.utils.Regions;
30+
import com.github._1c_syntax.bsl.languageserver.utils.Resources;
3031
import com.github._1c_syntax.bsl.mdo.support.ScriptVariant;
3132
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;
3433
import org.eclipse.lsp4j.CodeAction;
3534
import org.eclipse.lsp4j.CodeActionKind;
3635
import org.eclipse.lsp4j.CodeActionParams;
@@ -73,8 +72,8 @@ public GenerateStandardRegionsSupplier(LanguageServerConfiguration languageServe
7372
@Override
7473
public List<CodeAction> getCodeActions(CodeActionParams params, DocumentContext documentContext) {
7574

76-
ModuleType moduleType = documentContext.getModuleType();
77-
FileType fileType = documentContext.getFileType();
75+
var moduleType = documentContext.getModuleType();
76+
var fileType = documentContext.getFileType();
7877

7978
ScriptVariant regionsLanguage = getRegionsLanguage(documentContext, fileType);
8079
Set<String> neededStandardRegions;
@@ -100,14 +99,19 @@ public List<CodeAction> getCodeActions(CodeActionParams params, DocumentContext
10099
String result = neededStandardRegions.stream()
101100
.map(s -> String.format(regionFormat, s))
102101
.collect(Collectors.joining("\n"));
103-
TextEdit textEdit = new TextEdit(calculateFixRange(params.getRange()), result);
102+
var textEdit = new TextEdit(calculateFixRange(params.getRange()), result);
104103

105-
WorkspaceEdit edit = new WorkspaceEdit();
104+
var edit = new WorkspaceEdit();
106105
Map<String, List<TextEdit>> changes = Map.of(documentContext.getUri().toString(),
107106
Collections.singletonList(textEdit));
108107
edit.setChanges(changes);
109108

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);
111115
codeAction.setDiagnostics(new ArrayList<>());
112116
codeAction.setKind(CodeActionKind.Refactor);
113117
codeAction.setEdit(edit);
@@ -117,7 +121,7 @@ public List<CodeAction> getCodeActions(CodeActionParams params, DocumentContext
117121
private ScriptVariant getRegionsLanguage(DocumentContext documentContext, FileType fileType) {
118122

119123
ScriptVariant regionsLanguage;
120-
Configuration configuration = documentContext.getServerContext().getConfiguration();
124+
var configuration = documentContext.getServerContext().getConfiguration();
121125
if (configuration.getConfigurationSource() == ConfigurationSource.EMPTY || fileType == FileType.OS) {
122126
regionsLanguage = getScriptVariantFromConfigLanguage();
123127
} else {
@@ -137,7 +141,7 @@ private ScriptVariant getScriptVariantFromConfigLanguage() {
137141
return regionsLanguage;
138142
}
139143

140-
private Range calculateFixRange(Range range) {
144+
private static Range calculateFixRange(Range range) {
141145

142146
Position start = range.getStart();
143147
if (start == null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title=Generate missing regions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title=Сгенерировать пропущенные области

src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplierTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
*/
2222
package com.github._1c_syntax.bsl.languageserver.codeactions;
2323

24-
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
24+
import com.github._1c_syntax.bsl.languageserver.configuration.Language;
25+
import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration;
26+
import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterClass;
2527
import com.github._1c_syntax.bsl.languageserver.util.TestUtils;
2628
import org.eclipse.lsp4j.CodeAction;
2729
import org.eclipse.lsp4j.CodeActionContext;
@@ -39,15 +41,21 @@
3941
import static org.assertj.core.api.Assertions.assertThat;
4042

4143
@SpringBootTest
44+
@CleanupContextBeforeClassAndAfterClass
4245
class GenerateStandardRegionsSupplierTest {
4346

47+
@Autowired
48+
private LanguageServerConfiguration configuration;
49+
4450
@Autowired
4551
private GenerateStandardRegionsSupplier codeActionSupplier;
4652

4753
@Test
4854
void testGetCodeActions() {
4955

5056
// given
57+
configuration.setLanguage(Language.EN);
58+
5159
String filePath = "./src/test/resources/suppliers/generateRegion.bsl";
5260
var documentContext = TestUtils.getDocumentContextFromFile(filePath);
5361

0 commit comments

Comments
 (0)