Skip to content

Commit 6bab456

Browse files
committed
Merge branch 'develop' into Null_for_join_2283_2
2 parents b6ececf + 288df9e commit 6bab456

22 files changed

+742
-21
lines changed

.github/workflows/rebase.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
token: ${{ secrets.GITHUB_TOKEN }}
1515
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
1616
- name: Automatic Rebase
17-
uses: cirrus-actions/rebase@1.6
17+
uses: cirrus-actions/rebase@1.7
1818
env:
1919
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
import com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol;
2525
import com.github._1c_syntax.bsl.languageserver.context.symbol.Symbol;
26+
import com.github._1c_syntax.bsl.languageserver.context.symbol.annotations.Annotation;
27+
import com.github._1c_syntax.bsl.languageserver.context.symbol.annotations.AnnotationKind;
2628
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata;
29+
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameter;
2730
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity;
2831
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag;
2932
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType;
@@ -48,10 +51,29 @@ public class NonExportMethodsInApiRegionDiagnostic extends AbstractVisitorDiagno
4851
"^(?:ПрограммныйИнтерфейс|СлужебныйПрограммныйИнтерфейс|Public|Internal)$"
4952
);
5053

54+
private static final boolean SKIP_ANNOTATED_METHODS = false;
55+
56+
@DiagnosticParameter(
57+
type = Boolean.class,
58+
defaultValue = "" + SKIP_ANNOTATED_METHODS
59+
)
60+
private boolean skipAnnotatedMethods = SKIP_ANNOTATED_METHODS;
61+
5162
@Override
5263
public ParseTree visitSub(BSLParser.SubContext ctx) {
5364

54-
documentContext.getSymbolTree().getMethodSymbol(ctx).ifPresent((MethodSymbol methodSymbol) -> {
65+
var optionalMethodSymbol = documentContext.getSymbolTree().getMethodSymbol(ctx);
66+
67+
if (skipAnnotatedMethods
68+
&& optionalMethodSymbol
69+
.stream()
70+
.flatMap(methodSymbol -> methodSymbol.getAnnotations().stream())
71+
.map(Annotation::getKind)
72+
.anyMatch((AnnotationKind kind) -> kind != AnnotationKind.CUSTOM)) {
73+
return ctx;
74+
}
75+
76+
optionalMethodSymbol.ifPresent((MethodSymbol methodSymbol) -> {
5577
if (methodSymbol.isExport()) {
5678
return;
5779
}

0 commit comments

Comments
 (0)