Skip to content

Commit 288df9e

Browse files
authored
Merge pull request #2759 from EightM/feat/issue_439
2 parents d74603b + 52ae57f commit 288df9e

File tree

15 files changed

+668
-17
lines changed

15 files changed

+668
-17
lines changed

src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.github._1c_syntax.bsl.languageserver.configuration.codelens.CodeLensOptions;
3030
import com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions;
3131
import com.github._1c_syntax.bsl.languageserver.configuration.documentlink.DocumentLinkOptions;
32+
import com.github._1c_syntax.bsl.languageserver.configuration.formating.FormattingOptions;
3233
import com.github._1c_syntax.utils.Absolute;
3334
import lombok.AccessLevel;
3435
import lombok.AllArgsConstructor;
@@ -88,6 +89,10 @@ public class LanguageServerConfiguration {
8889
@JsonProperty("documentLink")
8990
@Setter(value = AccessLevel.NONE)
9091
private DocumentLinkOptions documentLinkOptions = new DocumentLinkOptions();
92+
93+
@JsonProperty("formatting")
94+
@Setter(value = AccessLevel.NONE)
95+
private FormattingOptions formattingOptions = new FormattingOptions();
9196

9297
private String siteRoot = "https://1c-syntax.github.io/bsl-language-server";
9398
private boolean useDevSite;
@@ -213,6 +218,7 @@ private void copyPropertiesFrom(LanguageServerConfiguration configuration) {
213218
PropertyUtils.copyProperties(this.codeLensOptions, configuration.codeLensOptions);
214219
PropertyUtils.copyProperties(this.diagnosticsOptions, configuration.diagnosticsOptions);
215220
PropertyUtils.copyProperties(this.documentLinkOptions, configuration.documentLinkOptions);
221+
PropertyUtils.copyProperties(this.formattingOptions, configuration.formattingOptions);
216222
}
217223

218224
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2022
5+
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
package com.github._1c_syntax.bsl.languageserver.configuration.formating;
23+
24+
import com.fasterxml.jackson.annotation.JsonCreator;
25+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
26+
import lombok.AllArgsConstructor;
27+
import lombok.Data;
28+
import lombok.NoArgsConstructor;
29+
30+
@Data
31+
@AllArgsConstructor(onConstructor = @__({@JsonCreator(mode = JsonCreator.Mode.DISABLED)}))
32+
@NoArgsConstructor
33+
@JsonIgnoreProperties(ignoreUnknown = true)
34+
public class FormattingOptions {
35+
private boolean useUpperCaseForOrNotAndKeywords = true;
36+
private boolean useKeywordsFormatting = true;
37+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2022
5+
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Fedkin <nixel2007@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
/**
23+
* Пакет содержит настройки {@link com.github._1c_syntax.bsl.languageserver.providers.FormatProvider}
24+
*/
25+
package com.github._1c_syntax.bsl.languageserver.configuration.formating;

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.github._1c_syntax.bsl.languageserver.utils.expressiontree.TransitiveOperationsIgnoringComparer;
4141
import com.github._1c_syntax.bsl.languageserver.utils.expressiontree.UnaryOperationNode;
4242
import com.github._1c_syntax.bsl.parser.BSLParser;
43+
import lombok.RequiredArgsConstructor;
4344
import org.antlr.v4.runtime.Token;
4445
import org.antlr.v4.runtime.tree.ParseTree;
4546
import org.eclipse.lsp4j.FormattingOptions;
@@ -60,6 +61,7 @@
6061
DiagnosticTag.SUSPICIOUS
6162
}
6263
)
64+
@RequiredArgsConstructor
6365
public class IdenticalExpressionsDiagnostic extends AbstractVisitorDiagnostic {
6466

6567
private static final int MIN_EXPRESSION_SIZE = 3;
@@ -70,7 +72,8 @@ public class IdenticalExpressionsDiagnostic extends AbstractVisitorDiagnostic {
7072
defaultValue = POPULAR_DIVISORS_DEFAULT_VALUE
7173
)
7274
private Set<String> popularDivisors = parseCommaSeparatedSet(POPULAR_DIVISORS_DEFAULT_VALUE);
73-
75+
private final FormatProvider formatProvider;
76+
7477
private static Set<String> parseCommaSeparatedSet(String values) {
7578
if (values.trim().isEmpty()) {
7679
return Collections.emptySet();
@@ -169,7 +172,7 @@ private boolean isPopularQuantification(BinaryOperationNode node) {
169172
return false;
170173
}
171174

172-
private static String getOperandText(BinaryOperationNode node) {
175+
private String getOperandText(BinaryOperationNode node) {
173176

174177
assert node.getRepresentingAst() != null;
175178

@@ -179,7 +182,8 @@ private static String getOperandText(BinaryOperationNode node) {
179182
fillTokens(pairedOperand, tokens);
180183

181184
// todo: очень плохое место для этого метода
182-
return FormatProvider.getNewText(tokens, Ranges.create(), 0, new FormattingOptions()).trim();
185+
return formatProvider.getNewText(
186+
tokens, documentContext.getScriptVariantLocale(), Ranges.create(), 0, new FormattingOptions()).trim();
183187

184188
}
185189

0 commit comments

Comments
 (0)